public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Omit output section from executable
@ 2006-08-02 20:43 Udo A. Steinberg
  2006-08-02 20:50 ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Udo A. Steinberg @ 2006-08-02 20:43 UTC (permalink / raw)
  To: binutils


Hi all,

For an OS kernel I have put all CPU-local data in a specific ELF section named
".cpulocal". During bootstrap the kernel allocates a memory page for each CPU
and maps it to the VMA of the ".cpulocal" section.

I would like the linker to omit the (useless) contents of that section from the
executable while still maintaining references into the section. I can achieve
the desired effect by doing an objcopy -R .cpulocal after the final link.

Any way I could do the same with only a linker script and without the objcopy?

Thanks

	- Udo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Omit output section from executable
  2006-08-02 20:43 Omit output section from executable Udo A. Steinberg
@ 2006-08-02 20:50 ` Daniel Jacobowitz
  2006-08-02 21:20   ` Udo A. Steinberg
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2006-08-02 20:50 UTC (permalink / raw)
  To: Udo A. Steinberg; +Cc: binutils

On Wed, Aug 02, 2006 at 10:43:24PM +0200, Udo A. Steinberg wrote:
> 
> Hi all,
> 
> For an OS kernel I have put all CPU-local data in a specific ELF section named
> ".cpulocal". During bootstrap the kernel allocates a memory page for each CPU
> and maps it to the VMA of the ".cpulocal" section.
> 
> I would like the linker to omit the (useless) contents of that section from the
> executable while still maintaining references into the section. I can achieve
> the desired effect by doing an objcopy -R .cpulocal after the final link.
> 
> Any way I could do the same with only a linker script and without the objcopy?

I'm not sure exactly what you want, but if the data is useless, try
making the .cpulocal section "nobits".

-- 
Daniel Jacobowitz
CodeSourcery

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Omit output section from executable
  2006-08-02 20:50 ` Daniel Jacobowitz
@ 2006-08-02 21:20   ` Udo A. Steinberg
  2006-08-02 21:29     ` Daniel Jacobowitz
  0 siblings, 1 reply; 6+ messages in thread
From: Udo A. Steinberg @ 2006-08-02 21:20 UTC (permalink / raw)
  To: binutils

On Wed, 2 Aug 2006 16:50:19 -0400 Daniel Jacobowitz (DJ) wrote:

DJ> I'm not sure exactly what you want, but if the data is useless, try
DJ> making the .cpulocal section "nobits".

Nobits is what I want indeed. In assembler sources I can do:

        .section .cpulocal, "aw", @nobits
        foo: .long

and I get
        .cpulocal     00000004  00000000  00000000  000000ba  2**0
                      ALLOC

But how can I achieve the same for C sources? When I write:

        unsigned foo __attribute__((section (".cpulocal")));

I get
        .cpulocal     00000004  00000000  00000000  00000034  2**2
                      CONTENTS, ALLOC, LOAD, DATA

Thanks,

	- Udo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Omit output section from executable
  2006-08-02 21:20   ` Udo A. Steinberg
@ 2006-08-02 21:29     ` Daniel Jacobowitz
  2006-08-03  0:44       ` Alan Modra
  0 siblings, 1 reply; 6+ messages in thread
From: Daniel Jacobowitz @ 2006-08-02 21:29 UTC (permalink / raw)
  To: binutils

On Wed, Aug 02, 2006 at 11:20:18PM +0200, Udo A. Steinberg wrote:
> But how can I achieve the same for C sources? When I write:
> 
>         unsigned foo __attribute__((section (".cpulocal")));
> 
> I get
>         .cpulocal     00000004  00000000  00000000  00000034  2**2
>                       CONTENTS, ALLOC, LOAD, DATA

I don't think you can do this from GCC.

-- 
Daniel Jacobowitz
CodeSourcery

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Omit output section from executable
  2006-08-02 21:29     ` Daniel Jacobowitz
@ 2006-08-03  0:44       ` Alan Modra
  2006-08-03  1:02         ` Udo A. Steinberg
  0 siblings, 1 reply; 6+ messages in thread
From: Alan Modra @ 2006-08-03  0:44 UTC (permalink / raw)
  Cc: binutils

On Wed, Aug 02, 2006 at 05:29:07PM -0400, Daniel Jacobowitz wrote:
> On Wed, Aug 02, 2006 at 11:20:18PM +0200, Udo A. Steinberg wrote:
> > But how can I achieve the same for C sources? When I write:
> > 
> >         unsigned foo __attribute__((section (".cpulocal")));
> > 
> > I get
> >         .cpulocal     00000004  00000000  00000000  00000034  2**2
> >                       CONTENTS, ALLOC, LOAD, DATA
> 
> I don't think you can do this from GCC.

Try this evil hack.

unsigned foo __attribute__((section (".cpulocal,\"aw\",@nobits#")));

The '#' might need to be different for targets that start gas comments
with another character.

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: Omit output section from executable
  2006-08-03  0:44       ` Alan Modra
@ 2006-08-03  1:02         ` Udo A. Steinberg
  0 siblings, 0 replies; 6+ messages in thread
From: Udo A. Steinberg @ 2006-08-03  1:02 UTC (permalink / raw)
  To: binutils

On Thu, 3 Aug 2006 10:13:55 +0930 Alan Modra (AM) wrote:

AM> Try this evil hack.
AM> 
AM> unsigned foo __attribute__((section (".cpulocal,\"aw\",@nobits#")));
AM> 
AM> The '#' might need to be different for targets that start gas comments
AM> with another character.

Excellent. I had tried this but without the # at the end. Doh!

Thanks,

	- Udo

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-08-03  1:02 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-08-02 20:43 Omit output section from executable Udo A. Steinberg
2006-08-02 20:50 ` Daniel Jacobowitz
2006-08-02 21:20   ` Udo A. Steinberg
2006-08-02 21:29     ` Daniel Jacobowitz
2006-08-03  0:44       ` Alan Modra
2006-08-03  1:02         ` Udo A. Steinberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).