This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
Re: How to save and restore a symbol value in Aarch64?
- From: Jeffrey Walton <noloader at gmail dot com>
- To: Jiong Wang <jiong dot wang at foss dot arm dot com>
- Cc: Binutils <binutils at sourceware dot org>
- Date: Thu, 20 Apr 2017 15:01:24 -0400
- Subject: Re: How to save and restore a symbol value in Aarch64?
- Authentication-results: sourceware.org; auth=none
- References: <CAH8yC8m4ReBF_eY5B_Xs28G0-XYey0dBMssBo+X0pzi-3=OYeg@mail.gmail.com> <87tw5je6r1.fsf@linux-m68k.org> <CAH8yC8=0pov5WiPwk2nMFB94e-Tgg8_LX-02_uP5GbEa9SBYCQ@mail.gmail.com> <e77e6166-8281-ba9b-2451-724ec0d8aecc@foss.arm.com>
- Reply-to: noloader at gmail dot com
On Thu, Apr 20, 2017 at 8:35 AM, Jiong Wang <jiong.wang@foss.arm.com> wrote:
> On 20/04/17 11:54, Jeffrey Walton wrote:
>>
>> ...
>
> It will not work as you expected.
> They are simply treating "push/pop" as symbols, and their value will be the
> string ".cpu".
>
>
> Below is a purely work around for your reference that you can escape
> assembler's architecture requirement check.
>
> __inline unsigned int GCC_INLINE_ATTRIB
> CRC32B(unsigned int crc, unsigned char v)
> {
> unsigned int r;
> asm (
> "\t.set raw_x0, 0\n"
> "\t.set raw_x1, 1\n"
> "\t.set raw_x2, 2\n"
> "\t.set raw_x3, 3\n"
> "\t.set raw_x4, 4\n"
> "\t.set raw_x5, 5\n"
> "\t.set raw_x6, 6\n"
> "\t.set raw_x7, 7\n"
> "\t#crc32w %w2, %w1, %w0\n"
> "\t.inst\t0x1ac04800 | (raw_%2) | (raw_%1 << 5) |
> (raw_%0 << 16)\n"
> : "=r"(r) : "r"(crc), "r"((unsigned int)v)
> );
> return r;
> }
Thanks again Jiong. I needed one small change to make things work. I'm
posting it back to the list in case someone copies/pastes. The
operands needed to be reversed:
__inline unsigned int GCC_INLINE_ATTRIB
CRC32B(unsigned int crc, unsigned char v)
{
volatile unsigned int res;
asm (
"\t" ".set reg_x0, 0\n"
"\t" ".set reg_x1, 1\n"
"\t" ".set reg_x2, 2\n"
"\t" ".set reg_x3, 3\n"
"\t" ".set reg_x4, 4\n"
"\t" ".set reg_x5, 5\n"
"\t" ".set reg_x6, 6\n"
"\t" ".set reg_x7, 7\n"
"\t" "#crc32w %w0, %w1, %w2\n"
"\t" ".inst 0x1ac04800 | (reg_%2 << 16) | (reg_%1 << 5) | (reg_%0)\n"
: "=r"(res) : "r"(crc), "r"(val)
);
return res;
}
Thanks again.
Jeff