public inbox for binutils@sourceware.org
 help / color / mirror / Atom feed
* Optimised output from ld
@ 2003-05-09  8:51 Dan Hovang
  2003-05-09  8:58 ` Ian Lance Taylor
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Hovang @ 2003-05-09  8:51 UTC (permalink / raw)
  To: binutils

Hi,

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?

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.

Any help would be appreciated! I'm using arm-elf-binutils.

Thanks,
  Dan

-- 
Dan Hovang   dan at wespot dot com    +46 733 451 427
WeSpot AB    Scheleevägen 19c  223 70 Lund, Sweden

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Optimised output from ld
  2003-05-09  8:51 Optimised output from ld Dan Hovang
@ 2003-05-09  8:58 ` Ian Lance Taylor
  2003-05-09 22:12   ` Richard Henderson
  0 siblings, 1 reply; 5+ messages in thread
From: Ian Lance Taylor @ 2003-05-09  8:58 UTC (permalink / raw)
  To: Dan Hovang; +Cc: binutils

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Optimised output from ld
  2003-05-09  8:58 ` Ian Lance Taylor
@ 2003-05-09 22:12   ` Richard Henderson
  2003-05-09 22:15     ` Ian Lance Taylor
  0 siblings, 1 reply; 5+ messages in thread
From: Richard Henderson @ 2003-05-09 22:12 UTC (permalink / raw)
  To: binutils, dan

On Fri, May 09, 2003 at 01:58:06AM -0700, Ian Lance Taylor wrote:
> --gc-sections is not supported in conjunction with -r.  I'm not sure
> why, myself.

(1) There is no entry point to begin keeping sections.
(2) It is not known what symbols the runtime will refer to.


r~

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Optimised output from ld
  2003-05-09 22:12   ` Richard Henderson
@ 2003-05-09 22:15     ` Ian Lance Taylor
  2003-05-09 22:23       ` Ian Lance Taylor
  0 siblings, 1 reply; 5+ messages in thread
From: Ian Lance Taylor @ 2003-05-09 22:15 UTC (permalink / raw)
  To: Richard Henderson; +Cc: binutils, dan

Richard Henderson <rth@redhat.com> writes:

> On Fri, May 09, 2003 at 01:58:06AM -0700, Ian Lance Taylor wrote:
> > --gc-sections is not supported in conjunction with -r.  I'm not sure
> > why, myself.
> 
> (1) There is no entry point to begin keeping sections.
> (2) It is not known what symbols the runtime will refer to.

I suppose it would be possible to require explicit -U options when
using --gc-sections with -r, and use that set of symbols as the root.
That might be useful for embedded systems which work with relocateable
object files.  If anybody cares enough to implement it.

Ian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: Optimised output from ld
  2003-05-09 22:15     ` Ian Lance Taylor
@ 2003-05-09 22:23       ` Ian Lance Taylor
  0 siblings, 0 replies; 5+ messages in thread
From: Ian Lance Taylor @ 2003-05-09 22:23 UTC (permalink / raw)
  To: Richard Henderson; +Cc: binutils, dan

Ian Lance Taylor <ian@airs.com> writes:

> Richard Henderson <rth@redhat.com> writes:
> 
> > On Fri, May 09, 2003 at 01:58:06AM -0700, Ian Lance Taylor wrote:
> > > --gc-sections is not supported in conjunction with -r.  I'm not sure
> > > why, myself.
> > 
> > (1) There is no entry point to begin keeping sections.
> > (2) It is not known what symbols the runtime will refer to.
> 
> I suppose it would be possible to require explicit -U options when
> using --gc-sections with -r, and use that set of symbols as the root.
> That might be useful for embedded systems which work with relocateable
> object files.  If anybody cares enough to implement it.

Sorry, of course I mean -u (--undefined) options.

Ian

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2003-05-09 22:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-09  8:51 Optimised output from ld Dan Hovang
2003-05-09  8:58 ` Ian Lance Taylor
2003-05-09 22:12   ` Richard Henderson
2003-05-09 22:15     ` Ian Lance Taylor
2003-05-09 22:23       ` Ian Lance Taylor

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).