This is the mail archive of the binutils@sourceware.org mailing list for the binutils 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]

version scripts and default/C language mangling


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

Attachment: signature.asc
Description: This is a digitally signed message part.


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