This is the mail archive of the 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]

Re: How to save and restore a symbol value in Aarch64?

On Thu, Apr 20, 2017 at 5:16 AM, Jeffrey Walton <> wrote:
> I'm trying to save (and restore) the original value of a symbol under
> Aarch64. The code runs on a variety of machines, and it looks like I
> need a solution for Binutils 2.24 and above.
> I know .set allows me to set the symbol value:
>     asm(".set .cpu, generic+crc \n" ... );
> I need the method to get the previous .cpu value and save it for the
> restore. About all I have been able to do is cause assembler errors.
> For example:
>     __inline unsigned int GCC_INLINE_ATTRIB
>     CRC32B(unsigned int crc, unsigned char v)
>     {
>           unsigned int r;
>           asm (".set old_cpu, .cpu  \n"
>                ".cpu generic+crc  \n"
>                "crc32w %w2, %w1, %w0  \n"
>                ".set .cpu, old_cpu   \n"
>                : "=r"(r) : "r"(crc), "r"((unsigned int)v)
>               );
>           return r;
>       }
> It results in:
> Adding a leading dot results in:
> My question is, how do I save and restore a symbol value for Binutils
> 2.2.4 and above on Aarch64?

Sorry about the truncated message. Here are the error messages.

For ".set old_cpu, .cpu  \n" (no leading dot):

/tmp/ccbAvT3u.s: Assembler messages:
/tmp/ccbAvT3u.s:32: Error: unknown mnemonic `old_cpu' -- `old_cpu .equ .cpu'
/tmp/ccbAvT3u.s:35: Error: unknown mnemonic `set' -- `set .cpu,old_cpu'

For ".set .old_cpu, .cpu  \n" (leading dot):

/tmp/cc0r6bvh.s: Assembler messages:
/tmp/cc0r6bvh.s:32: Error: unknown pseudo-op: `.old_cpu'

Here's the relevant AS manual section that discusses symbols:


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