提交 173fb54b 编写于 作者: P Peter Zijlstra 提交者: Zheng Zengkai

objtool: Fix type of reloc::addend

stable inclusion
from stable-v5.10.133
commit 3e8afd072d098958a507fb10251a201c9899150c
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I5YVKO

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=3e8afd072d098958a507fb10251a201c9899150c

--------------------------------

commit c087c6e7 upstream.

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: 627fce14 ("objtool: Add ORC unwind table generation")
Signed-off-by: NPeter Zijlstra (Intel) <peterz@infradead.org>
Acked-by: NJosh Poimboeuf <jpoimboe@redhat.com>
Link: https://lkml.kernel.org/r/20220419203807.596871927@infradead.orgSigned-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NBen Hutchings <ben@decadent.org.uk>
Signed-off-by: NGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
Acked-by: NXie XiuQi <xiexiuqi@huawei.com>
上级 98ec1668
...@@ -468,12 +468,12 @@ static int add_dead_ends(struct objtool_file *file) ...@@ -468,12 +468,12 @@ static int add_dead_ends(struct objtool_file *file)
else if (reloc->addend == reloc->sym->sec->len) { else if (reloc->addend == reloc->sym->sec->len) {
insn = find_last_insn(file, reloc->sym->sec); insn = find_last_insn(file, reloc->sym->sec);
if (!insn) { if (!insn) {
WARN("can't find unreachable insn at %s+0x%x", WARN("can't find unreachable insn at %s+0x%lx",
reloc->sym->sec->name, reloc->addend); reloc->sym->sec->name, reloc->addend);
return -1; return -1;
} }
} else { } else {
WARN("can't find unreachable insn at %s+0x%x", WARN("can't find unreachable insn at %s+0x%lx",
reloc->sym->sec->name, reloc->addend); reloc->sym->sec->name, reloc->addend);
return -1; return -1;
} }
...@@ -503,12 +503,12 @@ static int add_dead_ends(struct objtool_file *file) ...@@ -503,12 +503,12 @@ static int add_dead_ends(struct objtool_file *file)
else if (reloc->addend == reloc->sym->sec->len) { else if (reloc->addend == reloc->sym->sec->len) {
insn = find_last_insn(file, reloc->sym->sec); insn = find_last_insn(file, reloc->sym->sec);
if (!insn) { if (!insn) {
WARN("can't find reachable insn at %s+0x%x", WARN("can't find reachable insn at %s+0x%lx",
reloc->sym->sec->name, reloc->addend); reloc->sym->sec->name, reloc->addend);
return -1; return -1;
} }
} else { } else {
WARN("can't find reachable insn at %s+0x%x", WARN("can't find reachable insn at %s+0x%lx",
reloc->sym->sec->name, reloc->addend); reloc->sym->sec->name, reloc->addend);
return -1; return -1;
} }
......
...@@ -509,7 +509,7 @@ static struct section *elf_create_reloc_section(struct elf *elf, ...@@ -509,7 +509,7 @@ static struct section *elf_create_reloc_section(struct elf *elf,
int reltype); int reltype);
int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset, int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset,
unsigned int type, struct symbol *sym, int addend) unsigned int type, struct symbol *sym, long addend)
{ {
struct reloc *reloc; struct reloc *reloc;
......
...@@ -74,7 +74,7 @@ struct reloc { ...@@ -74,7 +74,7 @@ struct reloc {
struct symbol *sym; struct symbol *sym;
unsigned long offset; unsigned long offset;
unsigned int type; unsigned int type;
int addend; long addend;
int idx; int idx;
bool jump_table_start; bool jump_table_start;
}; };
...@@ -128,7 +128,7 @@ struct elf *elf_open_read(const char *name, int flags); ...@@ -128,7 +128,7 @@ struct elf *elf_open_read(const char *name, int flags);
struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr); struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr);
int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset, int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset,
unsigned int type, struct symbol *sym, int addend); unsigned int type, struct symbol *sym, long addend);
int elf_add_reloc_to_insn(struct elf *elf, struct section *sec, int elf_add_reloc_to_insn(struct elf *elf, struct section *sec,
unsigned long offset, unsigned int type, unsigned long offset, unsigned int type,
struct section *insn_sec, unsigned long insn_off); struct section *insn_sec, unsigned long insn_off);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册