This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: looking for non-loaded, non-writable, non-allocated elf segment
- From: Ian Lance Taylor <ian at airs dot com>
- To: Andrew Brown <atatat at atatdot dot net>
- Cc: binutils at sources dot redhat dot com
- Date: 01 Jan 2002 10:03:21 -0800
- Subject: Re: looking for non-loaded, non-writable, non-allocated elf segment
- References: <20020101045940.A29286@noc.untraceable.net>
Andrew Brown <atatat@atatdot.net> writes:
> what i'm trying to do is embed some configuration data that describes
> my program in the actual binary itself so that i have less "things" i
> need to keep track of. what seemed best to me was to stuff the data
> into a non-loadable, non-allocated, and also read-only (although i
> supposed that's moot if it's not loaded or allocated) elf segment via,
> eg:
>
> static const char config[]
> #ifdef __ELF__
> __attribute__((section(".netbsd.config")))
> #endif /* __ELF__ */
> __attribute__((__unused__)) = "...";
>
> running objdump on my binary shows at this point shows me this:
>
> % objdump -h netbsd
> ...
> Sections:
> Idx Name Size VMA LMA File off Algn
> ...
> 6 .netbsd.config 0000b140 00000000 00000000 002bca40 2**5
> CONTENTS, ALLOC, LOAD, READONLY, DATA
>
> which isn't exactly what i was looking for.
I would say that you are looking for a new gcc feature: if a variable
marked unused is placed in a special section, gcc should not request
that the section be allocatable. This is not a binutils issue.
Your workaround depends upon the particular implementation used by
both gcc and gas. It may continue to work in future releases, but you
should not expect it. It may work for other targets, but you should
not expect that either.
Ian