This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: target-specific way to make ld -N the default
I wrote:
> In embedded systems work one generally doesn't want the program headers
> being part of the first (or any) segment and thus shouldn't have to deal
> with "Not enough room for program headers" at all.
I found this in scripttempl/elf.sc
# if this is for an embedded system, don't add SIZEOF_HEADERS.
if [ -z "$EMBEDDED" ]; then
test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR} + SIZEOF_HEADERS"
else
test -z "${TEXT_BASE_ADDRESS}" && TEXT_BASE_ADDRESS="${TEXT_START_ADDR}"
fi
Clearly the linker is already _trying_ to DTRT for embedded targets
w.r.t. program headers. It's just not going far enough.
Doing a blanket default of -N for all targets that set EMBEDDED to be
non-empty in their emulparams/foo.sh script is far too risky though
I _think_ it is the correct solution. Maybe the powers that be
can add a new keyword REALLY_EMBEDDED :-).
In the meantime there is LDEMUL_BEFORE_PARSE.
I see the mmix port is already making an attempt at this:
static void
elfmmix_before_parse ()
{
gld${EMULATION_NAME}_before_parse ();
/* Make sure we don't create a demand-paged executable. Unfortunately
this isn't changeable with a command-line option. It makes no
difference to mmo, but the sections in elf64mmix will be aligned to a
page in the linked file, which is non-intuitive. If there's ever a
full system with shared libraries and demand paging, you will want to
exclude this file. */
config.magic_demand_paged = false;
}