[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] [PATCH v10 1/5] gcov: Call constructors during initialization



On Fri, 2013-02-22 at 09:40 +0000, Frediano Ziglio wrote:
> On Fri, 2013-02-22 at 08:50 +0000, Ian Campbell wrote:
> > On Thu, 2013-02-21 at 16:13 +0000, Frediano Ziglio wrote:
> > > diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
> > > index 410d7db..50e0c4b 100644
> > > --- a/xen/arch/arm/xen.lds.S
> > > +++ b/xen/arch/arm/xen.lds.S
> > > @@ -84,6 +84,13 @@ SECTIONS
> > >         *(.init.data)
> > >         *(.init.data.rel)
> > >         *(.init.data.rel.*)
> > > +
> > > +       . = ALIGN(4);
> > > +       __CTOR_LIST__ = .;
> > > +       LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
> > > +       *(.ctors)
> > > +       LONG(0)
> > > +       __CTOR_END__ = .;
> > >    } :text
> > >    . = ALIGN(32);
> > >    .init.setup : { 
> > 
> > 
> > This broke my 64-bit branch (not your fault, it's not merged yet, but I
> > was planning to commit it shortly):
> >         prelink.o: In function `init_constructors':
> >         
> > /local/scratch/ianc/devel/arm/xen.git/xen/common/lib.c:491:(.init.text+0xc44):
> >  relocation truncated to fit: R_AARCH64_LDST64_ABS_LO12_NC against symbol 
> > `__CTOR_LIST__' defined in .init.data section in 
> > /local/scratch/ianc/devel/arm/xen.git/xen/.xen-arm64-syms.0
> >         
> > To fixup I intend to add the following to my "xen: arm64: initial build
> > + config changes, start of day code".
> > 
> > Xen doesn't have a xen/xen.lds.h header, but perhaps adding that and
> > using it to define common things like this as macros might be an
> > interesting future cleanup.
> > 
> > 8<--------------------------------------
> > 
> > diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
> > index 9043994..5136b79 100644
> > --- a/xen/arch/arm/xen.lds.S
> > +++ b/xen/arch/arm/xen.lds.S
> > @@ -91,9 +91,9 @@ SECTIONS
> >         *(.init.data.rel)
> >         *(.init.data.rel.*)
> >  
> > -       . = ALIGN(4);
> > +       . = ALIGN(BYTES_PER_LONG);
> >         __CTOR_LIST__ = .;
> > -       LONG((__CTOR_END__ - __CTOR_LIST__) / 4 - 2)
> > +       LONG((__CTOR_END__ - __CTOR_LIST__) / BYTES_PER_LONG - 2)
> >         *(.ctors)
> >         LONG(0)
> >         __CTOR_END__ = .;
> > 
> > 
> > 
> > 
> 
> Hi,
>   this does not work, LONG is always 32 bit

Yes, I'm just discovering that ;-)

> but if you use pointers should be QUAD. Or I can change structure to be just 
> a range of pointers
> addressed by start and end, so in ld script
> 
>        . = ALIGN(8);
>        __CTOR_LIST__ = .;
>        *(.ctors)
>        __CTOR_END__ = .;
> 
> In code:
> 
> typedef void (*ctor_func_t)(void);
> extern const ctor_func_t __CTOR_LIST__[1], __CTOR_END__[1];
> 
> void __init init_constructors(void)
> {
>     const ctor_func_t pf = __CTOR_LIST__;
>     for ( ; pf < __CTOR_END__; ++pf )
>         pf();
> }
> 
> This will work for both 32 and 64 bit. At this point I would rename 
> __CTOR_LIST__ with a more "Xen" name.

Let me play with something along these lines. I'll send out a patch.

Ian.



_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxx
http://lists.xen.org/xen-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.