linux-mips
[Top] [All Lists]

Re: [RFC] Add __initbss section

To: Franck Bui-Huu <vagabon.xyz@gmail.com>
Subject: Re: [RFC] Add __initbss section
From: "Maciej W. Rozycki" <macro@linux-mips.org>
Date: Fri, 19 Oct 2007 12:59:25 +0100 (BST)
Cc: Ralf Baechle <ralf@linux-mips.org>, Geert Uytterhoeven <geert@linux-m68k.org>, linux-mips <linux-mips@linux-mips.org>
In-reply-to: <4717C1FB.4030602@gmail.com>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <470DF25E.60009@gmail.com> <Pine.LNX.4.64N.0710111307180.16370@blysk.ds.pg.gda.pl> <4712738A.5000703@gmail.com> <Pine.LNX.4.64N.0710151311350.16262@blysk.ds.pg.gda.pl> <4713C840.8080206@gmail.com> <Pine.LNX.4.64N.0710161123110.22596@blysk.ds.pg.gda.pl> <4717C1FB.4030602@gmail.com>
Sender: linux-mips-bounce@linux-mips.org
On Thu, 18 Oct 2007, Franck Bui-Huu wrote:

> So it seems there is no way from a linker script to specify that a
> section has the nobits type, is it ?

 Well, you cannot switch section types in a linker script at all in 
general.  The place to do it is always in the assembler, which is the tool 
which actually emits this data.

> After spending some fun time trying several different configurations
> with gcc and ld, I noticed that gcc makes a section with @nobits
> attribute if the section name starts with .bss.*

 Exactly how GCC sets section flags is mostly determined by 
default_section_type_flags() in gcc/varasm.c; some flags are set elsewhere 
too.  This is with HEAD of GCC.

> Another test I did is to put .init.bss (not .bss.init) section right
> before .bss section in order to have only one segment to load. And it
> makes magically ld do the right thing. I must admit that I don't
> understand why, and the lack of documentation doesn't help...

 Hmm, isn't what `info ld' says enough?  I think a look at what the SysV 
ABI documents say about ELF could clarify some matters too.  Also have a 
look at how sections are mapped to segments as after the final link it is 
segments that matter -- `readelf -l' will do.

> Unfortunately I don't know if we can rely on one of these
> behaviours. IOW if they're going to work with all supported versions
> of gcc/ld.

 Probably -- I guess you only need to check what GCC 3.2 did.  Or you 
could use a hack with __attribute__((section())) like one I did for 
merging strings -- unlike with SECTION_BSS I think there is no way to 
request (SECTION_MERGE | SECTION_STRINGS) in an implicit way anyhow.

  Maciej

<Prev in Thread] Current Thread [Next in Thread>