public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* Incremental linking, ELF, & templates => REDUNDANT CODE
@ 1998-04-10  7:27 Brad M. Garcia
  1998-04-10 12:23 ` H.J. Lu
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Brad M. Garcia @ 1998-04-10  7:27 UTC (permalink / raw)
  To: egcs

I've been under the impression for some time now that when a platform
uses the ELF object format, that all redundant template code (weak
symbols) will cancel out.

This is not (necessarily) true!

It appears that when you do an incremental link (ld -r), this
cancellation will occur during that link, but subsequent links will
fail to cancel redundant code.

When a *.o file is created from a C++ source file, it has a number of
sections called .gnu.linkonce.*.  When the incremental link is attempted,
it appears that redundant copies of these sections are removed, but then
these sections are simply rolled into the .text section of the resulting
*.o file.  Once in the .text section, weak symbols cannot be removed.

This seems like a bug in the linker.  Has anyone heard of a fix?
Am I wrong in my analysis?  I'm using binutils 2.8.1.

Brad Garcia
   ___/  __ /  __ /  ___/ "Being the Linux of digital media
  __/   /  /  / _/  __/    would be a very good life."
_/    ____/ _/ _| ____/      - Jean-Louis Gassee, CEO of Be, Inc.


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

* Re: Incremental linking, ELF, & templates => REDUNDANT CODE
  1998-04-10  7:27 Incremental linking, ELF, & templates => REDUNDANT CODE Brad M. Garcia
@ 1998-04-10 12:23 ` H.J. Lu
  1998-04-10 12:23 ` Ian Lance Taylor
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: H.J. Lu @ 1998-04-10 12:23 UTC (permalink / raw)
  To: Brad M. Garcia; +Cc: egcs

> This seems like a bug in the linker.  Has anyone heard of a fix?
> Am I wrong in my analysis?  I'm using binutils 2.8.1.
> 

So many bugs have been fixed since 2.8.1. Please try either binutils 2.9
beta or my binutils 2.8.1.0.30. My binutils 2.8.1.0.30 is binutils 2.9
beta plus ARM/ELF and x86 changes.


-- 
H.J. Lu (hjl@gnu.org)

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

* Re: Incremental linking, ELF, & templates => REDUNDANT CODE
  1998-04-10  7:27 Incremental linking, ELF, & templates => REDUNDANT CODE Brad M. Garcia
  1998-04-10 12:23 ` H.J. Lu
@ 1998-04-10 12:23 ` Ian Lance Taylor
  1998-04-10 12:35 ` Joe Buck
  1998-04-13 12:29 ` Martin von Loewis
  3 siblings, 0 replies; 5+ messages in thread
From: Ian Lance Taylor @ 1998-04-10 12:23 UTC (permalink / raw)
  To: bgarcia; +Cc: egcs

   Date: Fri, 10 Apr 1998 06:56:17 -0400 (EDT)
   From: "Brad M. Garcia" <bgarcia@fore.com>

   It appears that when you do an incremental link (ld -r), this
   cancellation will occur during that link, but subsequent links will
   fail to cancel redundant code.

   When a *.o file is created from a C++ source file, it has a number of
   sections called .gnu.linkonce.*.  When the incremental link is attempted,
   it appears that redundant copies of these sections are removed, but then
   these sections are simply rolled into the .text section of the resulting
   *.o file.  Once in the .text section, weak symbols cannot be removed.

   This seems like a bug in the linker.  Has anyone heard of a fix?
   Am I wrong in my analysis?  I'm using binutils 2.8.1.

This is a bug in the binutils 2.8.1 release.  I believe that it will
be fixed in the upcoming binutils 2.9 release.

Linker bug reports should really go to bug-gnu-utils@gnu.org rather
than egcs@cygnus.com.

Ian

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

* Re: Incremental linking, ELF, & templates => REDUNDANT CODE
  1998-04-10  7:27 Incremental linking, ELF, & templates => REDUNDANT CODE Brad M. Garcia
  1998-04-10 12:23 ` H.J. Lu
  1998-04-10 12:23 ` Ian Lance Taylor
@ 1998-04-10 12:35 ` Joe Buck
  1998-04-13 12:29 ` Martin von Loewis
  3 siblings, 0 replies; 5+ messages in thread
From: Joe Buck @ 1998-04-10 12:35 UTC (permalink / raw)
  To: Brad M. Garcia; +Cc: egcs

> I've been under the impression for some time now that when a platform
> uses the ELF object format, that all redundant template code (weak
> symbols) will cancel out.
> 
> This is not (necessarily) true!
> 
> It appears that when you do an incremental link (ld -r), this
> cancellation will occur during that link, but subsequent links will
> fail to cancel redundant code.

As others have said, the term "incremental link" is usually used in
a different way (when you have an executable and you link in new code
to that executable).  ld -r is usually called "partial linking".
Nevertheless, I think you have a case.

> When a *.o file is created from a C++ source file, it has a number of
> sections called .gnu.linkonce.*.  When the incremental link is attempted,
> it appears that redundant copies of these sections are removed, but then
> these sections are simply rolled into the .text section of the resulting
> *.o file.  Once in the .text section, weak symbols cannot be removed.

It seems that ld -r should work in a different way, choosing one
.gnu.linkonce.* section of each type to copy to the output file
but otherwise leaving them the same.

> This seems like a bug in the linker.  Has anyone heard of a fix?

Well, "bug" is perhaps too strong, but it seems like a misfeature.

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

* Re: Incremental linking, ELF, & templates => REDUNDANT CODE
  1998-04-10  7:27 Incremental linking, ELF, & templates => REDUNDANT CODE Brad M. Garcia
                   ` (2 preceding siblings ...)
  1998-04-10 12:35 ` Joe Buck
@ 1998-04-13 12:29 ` Martin von Loewis
  3 siblings, 0 replies; 5+ messages in thread
From: Martin von Loewis @ 1998-04-13 12:29 UTC (permalink / raw)
  To: bgarcia; +Cc: egcs

> I've been under the impression for some time now that when a platform
> uses the ELF object format, that all redundant template code (weak
> symbols) will cancel out.
> 
> This is not (necessarily) true!

Indeed. It only works with GNU binutils. As you find, it doesn't
even work always, then.

.gnu.linkonce is a GNU binutils extension to ELF, as the name
suggests.

> This seems like a bug in the linker.  Has anyone heard of a fix?
> Am I wrong in my analysis?  I'm using binutils 2.8.1.

I use 'GNU ld version 2.8.2 (with BFD 980130)', and I can't confirm
your observation. linkonce is processed using the linker script
(e.g. elf_i386.xs):

  .text      :
  {
    *(.text)
    *(.stub)
    /* .gnu.warning sections are handled specially by elf32.em.  */
    *(.gnu.warning)
    *(.gnu.linkonce.t*)
  } =0x9090

In the linker script for relative linking (elf_i386.xr), I find
no special processing for linkonce sections. objdump know another
section flag, LINK_ONCE_DISCARD. Apparently, my ld does the right
thing when relative loading such sections.

Regards,
Martin

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

end of thread, other threads:[~1998-04-13 12:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1998-04-10  7:27 Incremental linking, ELF, & templates => REDUNDANT CODE Brad M. Garcia
1998-04-10 12:23 ` H.J. Lu
1998-04-10 12:23 ` Ian Lance Taylor
1998-04-10 12:35 ` Joe Buck
1998-04-13 12:29 ` Martin von Loewis

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).