version scripts and default/C language mangling
Mike Frysinger
vapier@gentoo.org
Tue Jul 6 20:03:00 GMT 2010
the current version script page does not define a default language:
http://sourceware.org/binutils/docs/ld/VERSION.html
presumably it works with linker-visible symbols by default which means targets
that have an ABI prefix (like the Blackfin port) wont usually match.
to speak in exact terms, if i compile the code on my x86_64 system:
extern "C" int foo(void) {}
extern "C" int var(void) {}
int f(int x, double d) {}
i get an object with the linker visible symbols:
foo
bar
_Z1fid
if i compile it with my Blackfin toolchain, i get:
_foo
_bar
__Z1fid
using a version script of:
{
global:
foo;
extern "C" { bar; };
extern "C++" { "f(int, double)"; };
local: *;
};
on x86_64, all the symbols will be GLOBAL. on Blackfin, all will be LOCAL.
i'm ok with "foo" being LOCAL, but it seems like the other two should be
exported per the declared language.
at the moment, ldlang.c:lang_vers_match() doesnt do demangling for C symbols,
and the cplus_demangle() doesnt account for the ABI prefix. that is only
declared via USER_LABEL_PREFIX in the emulparams subfolder, but it isnt
exported to any C code that i can see. not that we'd really want to since
this is a bfd target specific issue. any tips on how best to proceed here to
fix things ?
also, i noticed the example script in the referenced URL above seems to have
some errors in it. it suggests:
extern "C++" { "int f(int, double)"; }
but a C++ function like that doesnt encode the return type into the mangled
name, so when the linker demangles things, it ends up with "f(int, double)"
and so it never matches. the example also lacks a trailing semicolon after
the brace, so the linker complains about a syntax error in the file.
-mike
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: This is a digitally signed message part.
URL: <https://sourceware.org/pipermail/binutils/attachments/20100706/b770212b/attachment.sig>
More information about the Binutils
mailing list