arm/ftrace: fix building on BE32
PATCH 1/1 arm/ftrace: fix building on BE32
Compiling patch.c on BE32 fails because there is no definition of __opcode_to_mem_thumb32()
arch/arm/kernel/patch.c: In function '__patch_text_real':arch/arm/kernel/patch.c:94:11: error: implicit declaration of function '__opcode_to_mem_thumb32' [-Werror=implicit-function-declaration]
Since we don't actually call it, only a declaration is required here, add one without a definition that fixes the build here but will cause a link failure if someone actually relies on the result.
---
Not sure if this version is any less ugly than the first approach of adding an #ifdef in patch.c
--- arch/arm/include/asm/opcodes.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)
arch/arm/include/asm/opcodes.h +7 -2
@@ -110,14 +110,19 @@ extern asmlinkage unsigned int arm_check_condition(u32 opcode, u32 psr);#define __opcode_to_mem_thumb16 (x) ___opcode_identity16(x)#define ___asm_opcode_to_mem_arm (x) ___asm_opcode_identity32(x)#define ___asm_opcode_to_mem_thumb16 (x) ___asm_opcode_identity16(x) -#ifndef CONFIG_CPU_ENDIAN_BE32 /* * On BE32 systems, using 32-bit accesses to store Thumb instructions will not * work in all cases, due to alignment constraints. For now, a correct -* version is not provided for BE32. +* version is not provided for BE32, only an extern declaration to allow +* compiling patch.c */ +#ifndef CONFIG_CPU_ENDIAN_BE32 #define __opcode_to_mem_thumb32 (x) ___opcode_swahw32(x)#define ___asm_opcode_to_mem_thumb32 (x) ___asm_opcode_swahw32(x) +#else +#ifndef __ASSEMBLY__ +extern unsigned __opcode_to_mem_thumb32 (unsigned ); +#endif #endif #endif /* ! CONFIG_CPU_ENDIAN_BE8 */
Signature · 1 line
2.20.0
Quoted 11 lines · On Wed, 8 Jan 2020 15:36:30 +0100 Arnd Bergmann <[email protected]> wrote:
Compiling
patch.con BE32 fails because there is no definition of__opcode_to_mem_thumb32()
arch/arm/kernel/patch.c: In function '__patch_text_real':arch/arm/kernel/patch.c:94:11: error: implicit declaration of function '__opcode_to_mem_thumb32' [-Werror=implicit-function-declaration]Since we don't actually call it, only a declaration is required here, add one without a definition that fixes the build here but will cause a link failure if someone actually relies on the result.
Quoted 5 lines
Fixes 5a735583b764 ("arm/ftrace: Use __patch_text()")Signed-off-by Arnd Bergmann <[email protected]>---
Not sure if this version is any less ugly than the first approach of adding an #ifdef inpatch.c
Adding #ifdef in headers is always better than adding it in C code.
-- Steve
Quoted 30 lines
--- arch/arm/include/asm/opcodes.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-)arch/arm/include/asm/opcodes.h +7
-2@@ -110,14 +110,19 @@ extern asmlinkage unsigned int arm_check_condition(u32 opcode, u32 psr);#define __opcode_to_mem_thumb16 (x) ___opcode_identity16(x)#define ___asm_opcode_to_mem_arm (x) ___asm_opcode_identity32(x)#define ___asm_opcode_to_mem_thumb16 (x) ___asm_opcode_identity16(x) -#ifndef CONFIG_CPU_ENDIAN_BE32 /* * On BE32 systems, using 32-bit accesses to store Thumb instructions will not * work in all cases, due to alignment constraints. For now, a correct -* version is not provided for BE32. +* version is not provided for BE32, only an extern declaration to allow +* compiling patch.c */ +#ifndef CONFIG_CPU_ENDIAN_BE32 #define __opcode_to_mem_thumb32 (x) ___opcode_swahw32(x)#define ___asm_opcode_to_mem_thumb32 (x) ___asm_opcode_swahw32(x) +#else +#ifndef __ASSEMBLY__ +extern unsigned __opcode_to_mem_thumb32 (unsigned ); +#endif #endif #endif /* ! CONFIG_CPU_ENDIAN_BE8 */