[PATCH] Fix the error of GET_DATA_POINTER for aarch64 on linux
Tianjia Zhang
tianjia.zhang at linux.alibaba.com
Thu May 12 16:06:08 CEST 2022
Hi Jussi,
On 5/12/22 1:14 AM, Jussi Kivilinna wrote:
> Hello,
>
> On 10.5.2022 15.49, Tianjia Zhang via Gcrypt-devel wrote:
>> * cipher/asm-common-aarch64.h: Use same macro GET_DATA_POINTER() for
>> linux and windows.
>> --
>>
>> For multiple labels defined in the same consts object on Linux,
>> except the first label, an error result will be obtained when taking
>> the addresss of other labels through GET_DATA_POINTER(). The error
>> address is the same as the first label. An error fragment code after
>> compilation is as follows:
>>
>> 0x0000fffff7f18be4 <+12>: adrp x6, 0xfffff7fb8000
>> 0x0000fffff7f18be8 <+16>: ldr x6, [x6, #3216]
>> 0x0000fffff7f18bec <+20>: ld1b {z24.b}, p0/z, [x6]
>> 0x0000fffff7f18bf0 <+24>: adrp x6, 0xfffff7fb8000
>> 0x0000fffff7f18bf4 <+28>: ldr x6, [x6, #3216]
>> 0x0000fffff7f18bf8 <+32>: ldr p1, [x6]
>>
>> This patch fixes this problem by using the ADRP/ADD instruction.
>>
>> Signed-off-by: Tianjia Zhang <tianjia.zhang at linux.alibaba.com>
>> ---
>> cipher/asm-common-aarch64.h | 2 +-
>> 1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/cipher/asm-common-aarch64.h b/cipher/asm-common-aarch64.h
>> index d3f7801c7661..b29479a32157 100644
>> --- a/cipher/asm-common-aarch64.h
>> +++ b/cipher/asm-common-aarch64.h
>> @@ -33,7 +33,7 @@
>> #define GET_DATA_POINTER(reg, name) \
>> adrp reg, name at GOTPAGE ; \
>> add reg, reg, name at GOTPAGEOFF ;
>> -#elif defined(_WIN32)
>> +#elif defined(__linux__) || defined(_WIN32)
>> #define GET_DATA_POINTER(reg, name) \
>> adrp reg, name ; \
>> add reg, reg, #:lo12:name ;
>
> It might be better to rename GET_DATA_POINTER to GET_LOCAL_POINTER,
> remove the ifdefs and just use:
> #define GET_LOCAL_POINTER(reg, name) \
> adrp reg, name ; \
> add reg, reg, #:lo12:name ;
>
> The Apple variant is likely to be broken in the same way as the
> Linux variant. If we later need support for external objects,
> we can add GET_EXTERN_POINTER macro.
>
> -Jussi
I agree. It's a good idea. I've tested the latest patch.
Best regards,
Tianjia
More information about the Gcrypt-devel
mailing list