Skip to content

Commit c087c6e

Browse files
author
Peter Zijlstra
committed
objtool: Fix type of reloc::addend
Elf{32,64}_Rela::r_addend is of type: Elf{32,64}_Sword, that means that our reloc::addend needs to be long or face tuncation issues when we do elf_rebuild_reloc_section(): - 107: 48 b8 00 00 00 00 00 00 00 00 movabs $0x0,%rax 109: R_X86_64_64 level4_kernel_pgt+0x80000067 + 107: 48 b8 00 00 00 00 00 00 00 00 movabs $0x0,%rax 109: R_X86_64_64 level4_kernel_pgt-0x7fffff99 Fixes: 627fce1 ("objtool: Add ORC unwind table generation") Signed-off-by: Peter Zijlstra (Intel) <[email protected]> Acked-by: Josh Poimboeuf <[email protected]> Link: https://lkml.kernel.org/r/[email protected]
1 parent 08feafe commit c087c6e

File tree

3 files changed

+7
-7
lines changed

3 files changed

+7
-7
lines changed

tools/objtool/check.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -559,12 +559,12 @@ static int add_dead_ends(struct objtool_file *file)
559559
else if (reloc->addend == reloc->sym->sec->sh.sh_size) {
560560
insn = find_last_insn(file, reloc->sym->sec);
561561
if (!insn) {
562-
WARN("can't find unreachable insn at %s+0x%x",
562+
WARN("can't find unreachable insn at %s+0x%lx",
563563
reloc->sym->sec->name, reloc->addend);
564564
return -1;
565565
}
566566
} else {
567-
WARN("can't find unreachable insn at %s+0x%x",
567+
WARN("can't find unreachable insn at %s+0x%lx",
568568
reloc->sym->sec->name, reloc->addend);
569569
return -1;
570570
}
@@ -594,12 +594,12 @@ static int add_dead_ends(struct objtool_file *file)
594594
else if (reloc->addend == reloc->sym->sec->sh.sh_size) {
595595
insn = find_last_insn(file, reloc->sym->sec);
596596
if (!insn) {
597-
WARN("can't find reachable insn at %s+0x%x",
597+
WARN("can't find reachable insn at %s+0x%lx",
598598
reloc->sym->sec->name, reloc->addend);
599599
return -1;
600600
}
601601
} else {
602-
WARN("can't find reachable insn at %s+0x%x",
602+
WARN("can't find reachable insn at %s+0x%lx",
603603
reloc->sym->sec->name, reloc->addend);
604604
return -1;
605605
}

tools/objtool/elf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ static struct section *elf_create_reloc_section(struct elf *elf,
546546
int reltype);
547547

548548
int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset,
549-
unsigned int type, struct symbol *sym, int addend)
549+
unsigned int type, struct symbol *sym, long addend)
550550
{
551551
struct reloc *reloc;
552552

tools/objtool/include/objtool/elf.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ struct reloc {
7373
struct symbol *sym;
7474
unsigned long offset;
7575
unsigned int type;
76-
int addend;
76+
long addend;
7777
int idx;
7878
bool jump_table_start;
7979
};
@@ -135,7 +135,7 @@ struct elf *elf_open_read(const char *name, int flags);
135135
struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr);
136136

137137
int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset,
138-
unsigned int type, struct symbol *sym, int addend);
138+
unsigned int type, struct symbol *sym, long addend);
139139
int elf_add_reloc_to_insn(struct elf *elf, struct section *sec,
140140
unsigned long offset, unsigned int type,
141141
struct section *insn_sec, unsigned long insn_off);

0 commit comments

Comments
 (0)