This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Bug or feature: symbol names of global/extern variables
- From: Michael Veksler <VEKSLER at il dot ibm dot com>
- To: "Jan Beulich" <JBeulich at novell dot com>
- Cc: binutils at sourceware dot org, "Robert Dewar" <dewar at adacore dot com>, "Wolfgang Roemer" <w dot r dot a dot roemer at t-online dot de>
- Date: Thu, 6 Oct 2005 17:11:38 +0300
- Subject: Re: Bug or feature: symbol names of global/extern variables
[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