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: Robert Dewar <dewar at adacore dot com>
- To: Wolfgang Roemer <w dot r dot a dot roemer at t-online dot de>
- Cc: binutils at sources dot redhat dot com, Michael Veksler <VEKSLER at il dot ibm dot com>, gcc at gnu dot org
- Date: Thu, 06 Oct 2005 08:50:51 -0400
- Subject: Re: Bug or feature: symbol names of global/extern variables
- References: <200510061444.59094.w.r.a.roemer@t-online.de>
Wolfgang Roemer wrote:
The main.o will perfectly link with the library although main.o needs a double
variable named maximum and the lib only offers an int variable named maximum.
Because the symbol name does in no way reflect the variable type, everything
links fine but in fact the variable named "minimum" gets scrambled in this
example because "maximum" is accessed as if it is a double variable thus
overwriting 4 additional bytes (in this case the 4 bytes of the variable
minimum). The assertion will show that.
I tested that on Windows with Visual C++ as well and there main.obj doesn't
link because the variable type is part of the symbol name and everthing is
fine.
I think it would be very very important for the binary interface to have that
feature as well.
I actually disagree with this, I think attempting to make the link fail
here would be a mistake.
What is more interesting is a proposal to have the linker give warnings
if the debug descriptions of symbols do not match. That can even work
across languages.