This is the mail archive of the binutils@sources.redhat.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

target-specific way to make ld -N the default


Is there already an approved way for making ld -N the default
for a particular target?
The default behaviour for the linker is to create demand paged
executables.  This has subtle hits to embedded toolchains (which
was a constant source of customer problem reports at Cygnus IIRC).

I don't recall seeing an option that is the opposite of -N
so in a multi-targeted ld changing the default would be problematic
when using it for other targets (should such a day come).
But for embedded systems, the current behaviour is more than
a little annoying!  Am I missing something?

---
btw, this seems to be a bug.  It sure gave me some grief while
trying to understand "Not enough room for program headers".
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.  [Really.  News at 11. :-)]

sources = current cvs
target = i386-linux, but any elf toolchain will do (especially embedded)

--- foo.S: ---
	.section ".sec1", "ax"
foo1:
	.space 4096

	.section ".sec2", "aw"
foo2:
	.space 4096


--- foo.ld ---
start = 30;

SECTIONS
{
   .sec1 : AT (start + 0) { *(.sec1) }
   .sec2 : AT (start + 4096) { *(.sec1) }
}

--- bar.ld ---
start = 40;

SECTIONS
{
   .sec1 : AT (start + 0) { *(.sec1) }
   .sec2 : AT (start + 4096) { *(.sec1) }
}

bash$ gcc -c foo.S
bash$ gcc -nostdlib -Tfoo.ld foo.o
bash$ gcc -nostdlib -Tbar.ld foo.o
/usr/bin/ld: a.out: Not enough room for program headers, try linking with -N
/usr/bin/ld: final link failed: Bad value
collect2: ld returned 1 exit status

I understand why there's difference.  It's this line in
elf.c:map_sections_to_segments:

	  || sections[0]->lma < phdr_size

phdr_size = 32

But methinks this test is either a hack (which therefore needs an explanation)
or needs to be rewritten/removed.  Why is it there?
Am I missing something?


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]