This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


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

Re: Code Bloat g++


> Can you give me a pointer as to how I could test this ? I.e. solaris
> ld doesnt remove duplicate instantiations ??
> 
> I tried compiling a simple program and then tried to link it using
> solaris ld and gnu ld, but got lot of errors..

Please try the attached tar file; the Makefile in it assumes that the
default installation uses GNU binutils.

You'll get a number of binary files, including a.o, a, and
a.gnu. Inspect them all with 'objdump --headers'. a.o results from
a.cc, and has a section

  1 .gnu.linkonce.t.f__H1Zi_v_v 0000001c  00000000  00000000  000000c0  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE, LINK_ONCE_DISCARD

b.o has a similar section. Unfortunately, /usr/ccs/bin/ld does not
support the LINK_ONCE_DISCARD flag (at least not on 2.5.1), so the
resulting binary has

 10 .gnu.linkonce.t.f__H1Zi_v_v 00000038  0001091c  0001091c  0000091c  2**2
                  CONTENTS, ALLOC, LOAD, READONLY, CODE, LINK_ONCE_DISCARD

which is twice the size of the original section, since ld was
concatenating both template instantiations.

The binary produced by GNU ld does not have such a section; GNU ld
merges the gnu.linkonce sections into the .text section.

Regards,
Martin

dupsection.tgz


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