Message ID | 20200108143640.1034808-1-arnd@arndb.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | arm/ftrace: fix building on BE32 | expand |
On Wed, 8 Jan 2020 15:36:30 +0100 Arnd Bergmann <arnd@arndb.de> wrote: > 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. > > Fixes: 5a735583b764 ("arm/ftrace: Use __patch_text()") > Signed-off-by: Arnd Bergmann <arnd@arndb.de> > --- > Not sure if this version is any less ugly than the first > approach of adding an #ifdef in patch.c Adding #ifdef in headers is always better than adding it in C code. Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org> -- Steve > --- > arch/arm/include/asm/opcodes.h | 9 +++++++-- > 1 file changed, 7 insertions(+), 2 deletions(-) > > diff --git a/arch/arm/include/asm/opcodes.h b/arch/arm/include/asm/opcodes.h > index 6bff94b2372b..f75f59c1257a 100644 > --- a/arch/arm/include/asm/opcodes.h > +++ b/arch/arm/include/asm/opcodes.h > @@ -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 */
diff --git a/arch/arm/include/asm/opcodes.h b/arch/arm/include/asm/opcodes.h index 6bff94b2372b..f75f59c1257a 100644 --- a/arch/arm/include/asm/opcodes.h +++ b/arch/arm/include/asm/opcodes.h @@ -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 */
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. Fixes: 5a735583b764 ("arm/ftrace: Use __patch_text()") Signed-off-by: Arnd Bergmann <arnd@arndb.de> --- 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(-)