Global symbol prefixes

Mike Frysinger vapier@gentoo.org
Thu Mar 28 18:24:00 GMT 2013


On Thursday 28 March 2013 12:36:48 Jan Tlatlik wrote:
> Hey there,
> 
> I need a few directions:
> 
> I'm porting GAS to my architecture and I'm stuck with global symbol
> prefixes.
> Since my register operands are not prefixed (e.g. r23 instead of  %r23),
> I need to prefix global symbols to avoid name collisions.
> How do I tell GAS to recognize this prefix?
> 
> If I try to assemble
> 
>     .global %main
> %main:
>     [...]
> 
> I am getting errors like
> > example.s:1: Error: expected symbol name
> > example.s:2: Error: junk at end of line, first unrecognized character
> is `%'
> 
> The symbol names in the object file though must not have the prefix. It
> is only needed at assembly time to solve the name collision problem.
> 
> I looked through a few existing ports, but none of them seem to do it
> this way. Could anyone give me some advice how to do that?

this is the reason (or at least one of them) why the Blackfin ABI has an 
underscore prefix.  gcc takes care of generating "_main" from the "main" symbol 
so the assembly code only ever sees the prefixed symbols.

in hand written assembly, you still have the problem, but the answer then is 
"don't do that".

alternatively, change the assembly syntax to disambiguate the register names 
(and use $r23 instead of r23).
-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/20130328/16f8d1cd/attachment.sig>


More information about the Binutils mailing list