Bug or feature: symbol names of global/extern variables

Jan Beulich JBeulich@novell.com
Thu Oct 6 14:46:00 GMT 2005


Using debug info wouldn't help much, because there's no guarantee it'll
ever be available. And in my opinion debug info free builds are
generally more important, because those normally are where production
code gets generated. Of course, if it's available, the linker might want
to consider it, but I'd say this isn't worth a lot of to-be-added code
(not knowing the linker internals, and thus how far it is from having
the information at hand). Jan

>>> Michael Veksler <VEKSLER@il.ibm.com> 06.10.05 16:11:38 >>>

[removed gcc@gcc.gnu.org, it is offtopic there].

"Jan Beulich" <JBeulich@novell.com> wrote on 06/10/2005 16:38:57:

> I don't think this has anything to do with binutils; whether linking
> succeeds exclusively depends on the mangling method used (VC does
mangle
> data object names, while g++ doesn't). AFAIK the standard only talks
> about function signatures, meaning mangling data object names is
neither
> prohibited nor required (i.e. implementation defined) [7.5 clause 9
> deals with that].
>

You missed the previous comments in the original thread.
I'll cut-and-paste parts of what I wrote on gcc@gnu.org: 

] It sounds as if the symbol is still "maximum" and it is annotated
with
] its type (something like debug information). I should be possible to
] hack the linker to emit a warning for symbols with conflicting debug
] information.

So the basic idea is to look at debug info (if available). The debug
info as follows:
$ echo "int common;" > t1.cpp
$ cat > t2.cpp
extern double common;
int main() { return common; }
$ gcc -c -g t[12].cpp
$ readelf --debug-dump t2.o
[...]
     DW_AT_name        : common
[...]
     DW_AT_type        : <9b>
[...]
 <1><9b>: Abbrev Number: 3 (DW_TAG_base_type)
!!!!!   DW_AT_name        : double   !!!!!!!
[...]
$ readelf --debug-dump t1.o
[...]
     DW_AT_name        : common
[...]
     DW_AT_type        : <82>
[...]
 <1><82>: Abbrev Number: 3 (DW_TAG_base_type)
!!!!!     DW_AT_name        : int   !!!!!

---------------
As you can see, the information is there. It clearly states that in
one
object file 'common' is int while in the other it is 'double'.

This will work for all languages - be it C++, C, or even Ada.


  Michael



More information about the Binutils mailing list