This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
Re: Optimised output from ld
- From: Ian Lance Taylor <ian at airs dot com>
- To: Dan Hovang <dan at wespot dot com>
- Cc: binutils at sources dot redhat dot com
- Date: 09 May 2003 01:58:06 -0700
- Subject: Re: Optimised output from ld
- References: <3EBB6D01.2050401@wespot.com>
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