when is ld appending .number to end of section names?

Mike Frysinger vapier@gentoo.org
Tue Jan 22 15:42:00 GMT 2008


On Saturday 19 January 2008, Sam Ravnborg wrote:
> On Sat, Jan 19, 2008 at 11:20:26AM +1030, Alan Modra wrote:
> > On Fri, Jan 18, 2008 at 10:42:28PM +0100, Sam Ravnborg wrote:
> > > The expected section name was: ".init.text".
> > > But the actual section name was ".init.text.1"
> >
> > Quoting from ld/emultemp/elf32.em
> >
> >   /* Choose a unique name for the section.  This will be needed if the
> >      same section name appears in the input file with different
> >      loadable or allocatable characteristics.  */
> >
> > Most likely someone forgot to flag .init.text with "ax" in one of the
> > input object files.  Another possiblility is that ld --unique was
> > used.
>
> Thanks Alan - it was a case of missing "ax" as you expected.
>
> See: http://lkml.org/lkml/2008/1/19/51

seems to me the code should be using the already existing macros ...

> Having started to look into this I tried to dig a bit more into the
> subject of sections and assembler code.
>
> In the kernel we have following ways to specify the .init.text section:
> a) .section .init.text, "ax"
> b) .section ".init.text", "ax"
> c) .section ".init.text", #alloc, #execinstr
> d) .section .init.text, "ax", @progbits

e) use the macros in linux/init.h:
__INIT
<stuff>
__FINIT

> It is my understanding that a) b) and c) are equal.
> And the preferred syntax is a) (I would prefer c) as it is more
> descriptive)

yes

> The syntax in d) is used in some places.
> What is the significance of specifying @progbits?

sets the proper TYPE on the ELF section so that when things get merged, only 
alike things get merged.  also used by debuggers/ldso/elf parsers as a hint 
at how to treat the data in the section (or whether to just completely ignore 
the section)

> The main reason I bring up this question is that I cannot create
> a macro like this:
> #define __INIT .section .init.text, "ax", @progbits
>
> as it would fail on ARM where '@' is used to specify a comment.

use %progbits in include/linux/init.h then

> So the simplest solution would be to just drop "@progbits",
> but before that I would like to understand the usage.
>
> An explanation of the use of "@progbits" would be good - but
> a pointer to some documentation would be preferred as I then can
> read up on this instead of asking.
>
> info gas told me this:
>
> `@progbits'
>      section contains data
>
> `@nobits'
>      section does not contain data (i.e., section only occupies space)
>
> But that did not convince me that the use of "@progbits" was optional and
> could be dropped.

i think gas is smart enough to guess the proper section type, but if you want 
to be explicit/correct, then you should specify it
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 827 bytes
Desc: This is a digitally signed message part.
URL: <https://sourceware.org/pipermail/binutils/attachments/20080122/63bccf80/attachment.sig>


More information about the Binutils mailing list