diff mbox series

[v2,13/16] objtool: Use macros to define arch specific reloc types

Message ID 20220829055223.24767-14-sv@linux.ibm.com (mailing list archive)
State Superseded
Headers show
Series objtool: Enable and implement --mcount option on powerpc | expand

Commit Message

Sathvika Vasireddy Aug. 29, 2022, 5:52 a.m. UTC
Make relocation types architecture specific.

Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>
---
 tools/objtool/arch/x86/include/arch/elf.h | 2 ++
 tools/objtool/check.c                     | 2 +-
 2 files changed, 3 insertions(+), 1 deletion(-)

Comments

Christophe Leroy Aug. 30, 2022, 6:33 a.m. UTC | #1
Le 29/08/2022 à 07:52, Sathvika Vasireddy a écrit :
> Make relocation types architecture specific.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>

> ---
>   tools/objtool/arch/x86/include/arch/elf.h | 2 ++
>   tools/objtool/check.c                     | 2 +-
>   2 files changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/objtool/arch/x86/include/arch/elf.h b/tools/objtool/arch/x86/include/arch/elf.h
> index 69cc4264b28a..ac14987cf687 100644
> --- a/tools/objtool/arch/x86/include/arch/elf.h
> +++ b/tools/objtool/arch/x86/include/arch/elf.h
> @@ -2,5 +2,7 @@
>   #define _OBJTOOL_ARCH_ELF
>   
>   #define R_NONE R_X86_64_NONE
> +#define R_ABS64 R_X86_64_64
> +#define R_ABS32 R_X86_64_32
>   
>   #endif /* _OBJTOOL_ARCH_ELF */
> diff --git a/tools/objtool/check.c b/tools/objtool/check.c
> index 5298a143ceac..f1d055467926 100644
> --- a/tools/objtool/check.c
> +++ b/tools/objtool/check.c
> @@ -883,7 +883,7 @@ static int create_mcount_loc_sections(struct objtool_file *file)
>   		memset(loc, 0, addrsize);
>   
>   		if (elf_add_reloc_to_insn(file->elf, sec, idx,
> -					  R_X86_64_64,
> +					  addrsize == sizeof(u64) ? R_ABS64 : R_ABS32,
>   					  insn->sec, insn->offset))
>   			return -1;
>
Peter Zijlstra Sept. 1, 2022, 7:28 p.m. UTC | #2
On Mon, Aug 29, 2022 at 11:22:20AM +0530, Sathvika Vasireddy wrote:
> Make relocation types architecture specific.
> 
> Signed-off-by: Sathvika Vasireddy <sv@linux.ibm.com>

Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
diff mbox series

Patch

diff --git a/tools/objtool/arch/x86/include/arch/elf.h b/tools/objtool/arch/x86/include/arch/elf.h
index 69cc4264b28a..ac14987cf687 100644
--- a/tools/objtool/arch/x86/include/arch/elf.h
+++ b/tools/objtool/arch/x86/include/arch/elf.h
@@ -2,5 +2,7 @@ 
 #define _OBJTOOL_ARCH_ELF
 
 #define R_NONE R_X86_64_NONE
+#define R_ABS64 R_X86_64_64
+#define R_ABS32 R_X86_64_32
 
 #endif /* _OBJTOOL_ARCH_ELF */
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index 5298a143ceac..f1d055467926 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -883,7 +883,7 @@  static int create_mcount_loc_sections(struct objtool_file *file)
 		memset(loc, 0, addrsize);
 
 		if (elf_add_reloc_to_insn(file->elf, sec, idx,
-					  R_X86_64_64,
+					  addrsize == sizeof(u64) ? R_ABS64 : R_ABS32,
 					  insn->sec, insn->offset))
 			return -1;