This is the mail archive of the binutils@sourceware.org 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]

Re: Re[2]: Help needed - defining the output section order


SB> It might be enough if you prevent ld from creating the magic stack
SB> segment behind its own back, e.g., I have this in my Makefiles:

SB> %.o: %.c
SB> $(CC) $(CFLAGS) -c $< -o $@ && $(OBJCOPY) -R .note.GNU-stack $@


SB> (using /DISCARD/ in your linker script is _not_ enough).

This sounds very interesting - however, I have to admit I don't know
much about makefile syntax and/or gcc options - I'm a pascal guy,
after all ;). To which ld options would this translate to?

Not an ld option; instead, you run an objcopy command on every object file, before you link them together. An example is

objcopy -R .note.GNU-stack example.o

Do this on _every_ object file that is used in the link.

Some background: if ld sees a .note.GNU-stack note section in
all of the input files, it puts a GNU_STACK segment into the
output file automagically.  Linux uses this information to make
the stack non-executable.  But this automatic generation of a
PHDR seems to screw up the precomputed count of PHDRS.  Maybe
we can call this a bug, even?


Segher



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