From c00d2078651e27f45aec03f1f55e364a09325d8b Mon Sep 17 00:00:00 2001 From: Surya Kumari Jangala Date: Tue, 10 Sep 2024 14:01:50 +0530 Subject: [PATCH] Change code from non-PIC to PIC for ppc64 Signed-off-by: SURYA KUMARI JANGALA --- src/common/CMakeLists.txt | 1 + src/common/crc32c_ppc_fast_zero_asm.S | 25 +++++++++++++++++++++---- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index c3fd51d26468..8b9f3339e388 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -225,6 +225,7 @@ elseif(HAVE_POWER8) list(APPEND crc32_srcs crc32c_ppc_asm.S crc32c_ppc_fast_zero_asm.S) + set_source_files_properties(crc32c_ppc_asm.S PROPERTIES COMPILE_FLAGS -D__ASSEMBLY__) endif(HAVE_PPC64LE) elseif(HAVE_ARMV8_CRC) list(APPEND crc32_srcs diff --git a/src/common/crc32c_ppc_fast_zero_asm.S b/src/common/crc32c_ppc_fast_zero_asm.S index cff9cce7fd40..3defa6deca68 100644 --- a/src/common/crc32c_ppc_fast_zero_asm.S +++ b/src/common/crc32c_ppc_fast_zero_asm.S @@ -25,6 +25,23 @@ #endif #include "ppc-opcode.h" +/* + * The following line is required because toc is defined as 2 in + * ppc-asm.h. This definition will break @toc in the assembly code, + * hence toc should be undefined. + */ +#undef toc + +/* If we do not define r2 as 2, the assembler throws errors. + * This is because the assembler has no builtin support for + * registers, and we should either define them ourselves or + * use their indexes explicitly like: + * addis 4,2,.bit_reflected_constants@toc@ha + */ +#ifndef r2 +#define r2 2 +#endif + .section .data .balign 16 .constants: @@ -45,8 +62,8 @@ /* unsigned int barrett_reduction(unsigned long val) */ FUNC_START(barrett_reduction) - lis r4,.constants@ha - la r4,.constants@l(r4) + addis r4,r2,.constants@toc@ha + addi r4,r4,.constants@toc@l li r5,16 vxor v1,v1,v1 /* zero v1 */ @@ -83,8 +100,8 @@ FUNC_END(barrett_reduction) /* unsigned int barrett_reduction_reflected(unsigned long val) */ FUNC_START(barrett_reduction_reflected) - lis r4,.bit_reflected_constants@ha - la r4,.bit_reflected_constants@l(r4) + addis r4,r2,.bit_reflected_constants@toc@ha + addi r4,r4,.bit_reflected_constants@toc@l li r5,16 vxor v1,v1,v1 /* zero v1 */ -- 2.47.3