summaryrefslogtreecommitdiffstats
path: root/tools/objtool/check.c
diff options
context:
space:
mode:
authorJosh Poimboeuf <jpoimboe@kernel.org>2023-05-30 19:20:56 +0200
committerJosh Poimboeuf <jpoimboe@kernel.org>2023-06-07 19:03:15 +0200
commit53257a977a69b5eabbaafb64dcd767d2a4fef2b3 (patch)
tree330e0fa0f2417613b8199d23c5853dbd53654864 /tools/objtool/check.c
parentobjtool: Improve reloc naming (diff)
downloadlinux-53257a977a69b5eabbaafb64dcd767d2a4fef2b3.tar.xz
linux-53257a977a69b5eabbaafb64dcd767d2a4fef2b3.zip
objtool: Consolidate rel/rela handling
The GElf_Rel[a] structs have more similarities than differences. It's safe to hard-code the assumptions about their shared fields as they will never change. Consolidate their handling where possible, getting rid of duplicated code. Also, at least for now we only ever create rela sections, so simplify the relocation creation code to be rela-only. Link: https://lore.kernel.org/r/dcabf6df400ca500ea929f1e4284f5e5ec0b27c8.1685464332.git.jpoimboe@kernel.org Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>
Diffstat (limited to 'tools/objtool/check.c')
-rw-r--r--tools/objtool/check.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/tools/objtool/check.c b/tools/objtool/check.c
index f4c52a2c8d5b..2ab8699bbd76 100644
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -952,7 +952,7 @@ static int create_cfi_sections(struct objtool_file *file)
static int create_mcount_loc_sections(struct objtool_file *file)
{
- int addrsize = elf_class_addrsize(file->elf);
+ size_t addr_size = elf_addr_size(file->elf);
struct instruction *insn;
struct section *sec;
int idx;
@@ -971,25 +971,25 @@ static int create_mcount_loc_sections(struct objtool_file *file)
list_for_each_entry(insn, &file->mcount_loc_list, call_node)
idx++;
- sec = elf_create_section(file->elf, "__mcount_loc", addrsize, idx);
+ sec = elf_create_section(file->elf, "__mcount_loc", addr_size, idx);
if (!sec)
return -1;
- sec->sh.sh_addralign = addrsize;
+ sec->sh.sh_addralign = addr_size;
idx = 0;
list_for_each_entry(insn, &file->mcount_loc_list, call_node) {
void *loc;
loc = sec->data->d_buf + idx;
- memset(loc, 0, addrsize);
+ memset(loc, 0, addr_size);
if (elf_add_reloc_to_insn(file->elf, sec, idx,
- addrsize == sizeof(u64) ? R_ABS64 : R_ABS32,
+ addr_size == sizeof(u64) ? R_ABS64 : R_ABS32,
insn->sec, insn->offset))
return -1;
- idx += addrsize;
+ idx += addr_size;
}
return 0;