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]

Re: Optimised output from ld


Dan Hovang <dan@wespot.com> writes:

> I want ld to produce a minimum size relocatable ELF for use in an
> embedded system with our own run-time ELF loader. So after compiling
> all source (C and C++) files with -ffunction-sections and
> -fdata-sections I tried:
> 
> ld -r *.o -o myapp.o
> 
> After disassembly I noticed that alot of relative jumps within the
> same section were not resolved which increased the size of the ELF
> with reloc info. Is there some way to tell ld to try and resolv
> as many relocs as possible?

ld -r doesn't remove any relocs.  It would probably be possible to
change the linker to support this, but it wouldn't be completely
trivial.

> I would also like to use --gc-sections still producing relocatable
> output. Like ld -r -e main --gc-sections *.o myapp.o, discarding
> sections not referenced to (direct/indirect) by main. ld tells me
> that I cannot do that, but I don't understand why.

--gc-sections is not supported in conjunction with -r.  I'm not sure
why, myself.  Again, I assume it would be possible to change this, but
I don't know how much work it would be.

Ian


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