Skip to content

Commit 22682a0

Browse files
Mikulas Patockasuryasaimadhu
authored andcommitted
objtool: Fix objtool regression on x32 systems
Commit c087c6e ("objtool: Fix type of reloc::addend") failed to appreciate cross building from ILP32 hosts, where 'int' == 'long' and the issue persists. As such, use s64/int64_t/Elf64_Sxword for this field and suffer the pain that is ISO C99 printf formats for it. Fixes: c087c6e ("objtool: Fix type of reloc::addend") Signed-off-by: Mikulas Patocka <mpatocka@redhat.com> [peterz: reword changelog, s/long long/s64/] Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Signed-off-by: Borislav Petkov <bp@suse.de> Cc: <stable@vger.kernel.org> Link: https://lkml.kernel.org/r/alpine.LRH.2.02.2205161041260.11556@file01.intranet.prod.int.rdu2.redhat.com
1 parent ead165f commit 22682a0

File tree

3 files changed

+8
-7
lines changed

3 files changed

+8
-7
lines changed

tools/objtool/check.c

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
#include <string.h>
77
#include <stdlib.h>
8+
#include <inttypes.h>
89
#include <sys/mman.h>
910

1011
#include <arch/elf.h>
@@ -561,12 +562,12 @@ static int add_dead_ends(struct objtool_file *file)
561562
else if (reloc->addend == reloc->sym->sec->sh.sh_size) {
562563
insn = find_last_insn(file, reloc->sym->sec);
563564
if (!insn) {
564-
WARN("can't find unreachable insn at %s+0x%lx",
565+
WARN("can't find unreachable insn at %s+0x%" PRIx64,
565566
reloc->sym->sec->name, reloc->addend);
566567
return -1;
567568
}
568569
} else {
569-
WARN("can't find unreachable insn at %s+0x%lx",
570+
WARN("can't find unreachable insn at %s+0x%" PRIx64,
570571
reloc->sym->sec->name, reloc->addend);
571572
return -1;
572573
}
@@ -596,12 +597,12 @@ static int add_dead_ends(struct objtool_file *file)
596597
else if (reloc->addend == reloc->sym->sec->sh.sh_size) {
597598
insn = find_last_insn(file, reloc->sym->sec);
598599
if (!insn) {
599-
WARN("can't find reachable insn at %s+0x%lx",
600+
WARN("can't find reachable insn at %s+0x%" PRIx64,
600601
reloc->sym->sec->name, reloc->addend);
601602
return -1;
602603
}
603604
} else {
604-
WARN("can't find reachable insn at %s+0x%lx",
605+
WARN("can't find reachable insn at %s+0x%" PRIx64,
605606
reloc->sym->sec->name, reloc->addend);
606607
return -1;
607608
}

tools/objtool/elf.c

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

552552
int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset,
553-
unsigned int type, struct symbol *sym, long addend)
553+
unsigned int type, struct symbol *sym, s64 addend)
554554
{
555555
struct reloc *reloc;
556556

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-
long addend;
76+
s64 addend;
7777
int idx;
7878
bool jump_table_start;
7979
};
@@ -145,7 +145,7 @@ struct elf *elf_open_read(const char *name, int flags);
145145
struct section *elf_create_section(struct elf *elf, const char *name, unsigned int sh_flags, size_t entsize, int nr);
146146

147147
int elf_add_reloc(struct elf *elf, struct section *sec, unsigned long offset,
148-
unsigned int type, struct symbol *sym, long addend);
148+
unsigned int type, struct symbol *sym, s64 addend);
149149
int elf_add_reloc_to_insn(struct elf *elf, struct section *sec,
150150
unsigned long offset, unsigned int type,
151151
struct section *insn_sec, unsigned long insn_off);

0 commit comments

Comments
 (0)