This is the mail archive of the gcc-bugs@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]
Other format: [Raw text]

[Bug c++/33871] [4.3 Regression] typeinfo name referenced in ... defined in discarded section



------- Comment #26 from amodra at bigpond dot net dot au  2007-10-31 04:03 -------
I believe the linker is correct to reject relocations against local symbols in
discarded sections.  The reason being that the linker allows linkonce (and
comdat group) section contents to differ between two files, so that for
example, two files may be compiled with different optimisations yet still link
correctly.  Since the contents may differ, the location of symbols within the
section may also differ between files.  Using the value of "local_sym + offset"
in one file (in the discarded section) may point to an entirely wrong location
in the other file (in the kept section).

You could argue that the linker ought to look up the value of "local_sym" in
the file with the kept section, but relocations against local symbols are often
reduced to relocations against section symbols, so the original "local_sym" is
lost.

The situation is different with global symbols because globals are merged.  The
definition in the kept section will be used for all relocations.

I hope this answers Geoff's remark "ld refuses to link your program for no good
reason".


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=33871


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