This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: Global symbol prefixes
- From: Jan Tlatlik <jtlatlik at techfak dot uni-bielefeld dot de>
- To: binutils at sourceware dot org
- Cc: Mike Frysinger <vapier at gentoo dot org>
- Date: Fri, 29 Mar 2013 02:30:04 +0100
- Subject: Re: Global symbol prefixes
- References: <515471A0 dot 5030908 at techfak dot uni-bielefeld dot de> <201303281429 dot 28549 dot vapier at gentoo dot org> <51548D2E dot 1060006 at techfak dot uni-bielefeld dot de>
On 03/28/2013 07:34 PM, Jan Tlatlik wrote:
> On 03/28/2013 07:29 PM, Mike Frysinger wrote:
>> 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?
>> [...]
>>
>> alternatively, change the assembly syntax to disambiguate the register names
>> (and use $r23 instead of r23).
>> -mike
> I suppose this would be way with the least effort to solve the problem.
>
> Thanks.
Well, I supposed wrong. It is much easier to do it the way I wanted to
do it initially.
FYI:
/* symbols may begin with an % to prevent name collisions with register
operands*/
#define LEX_PCT LEX_BEGIN_NAME
/* % prefixes will be trimmed */
#define tc_canonicalize_symbol_name(s) ( *(s) == '%' ? (s)+1 : (s))
That's all!
Jan Tlatlik