Incremental linking, ELF, & templates => REDUNDANT CODE
Joe Buck
jbuck@synopsys.com
Fri Apr 10 12:35:00 GMT 1998
> 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.
More information about the Gcc
mailing list