From: Peter Zijlstra <peterz@infradead.org>
To: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: Nick Desaulniers <ndesaulniers@google.com>,
x86@kernel.org, hjl.tools@gmail.com, mbenes@suse.cz,
rostedt@goodmis.org, linux-toolchains@vger.kernel.org,
clang-built-linux <llvm@lists.linux.dev>
Subject: Re: The trouble with __weak and objtool got worse
Date: Sun, 17 Apr 2022 17:46:09 +0200 [thread overview]
Message-ID: <20220417154609.GD2762@worktop.programming.kicks-ass.net> (raw)
In-Reply-To: <20220417154422.GH2731@worktop.programming.kicks-ass.net>
On Sun, Apr 17, 2022 at 05:44:22PM +0200, Peter Zijlstra wrote:
> On Sat, Apr 16, 2022 at 09:07:42AM -0700, Josh Poimboeuf wrote:
>
> > I guess objtool will need to bite the bullet and create section symbols.
>
Which then led to..
I'll properly post the patches on Tue, once this easter thing has run
it's course and we're actually working again, ha!
---
Subject: objtool: Fix type of reloc::addend
From: Peter Zijlstra <peterz@infradead.org>
Date: Sun Apr 17 17:03:40 CEST 2022
Elf{32,64}_Rela::r_addend is of type: Elf{32,64}_Sword, that means
that out reloc::addend needs to be long or face tuncation issues when
we do elf_rebuild_rel_reloc_sections():
- 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
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
---
tools/objtool/check.c | 8 ++++----
tools/objtool/elf.c | 2 +-
tools/objtool/include/objtool/elf.h | 4 ++--
3 files changed, 7 insertions(+), 7 deletions(-)
--- a/tools/objtool/check.c
+++ b/tools/objtool/check.c
@@ -560,12 +560,12 @@ static int add_dead_ends(struct objtool_
else if (reloc->addend == reloc->sym->sec->sh.sh_size) {
insn = find_last_insn(file, reloc->sym->sec);
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);
return -1;
}
} 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);
return -1;
}
@@ -595,12 +595,12 @@ static int add_dead_ends(struct objtool_
else if (reloc->addend == reloc->sym->sec->sh.sh_size) {
insn = find_last_insn(file, reloc->sym->sec);
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);
return -1;
}
} 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);
return -1;
}
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -546,7 +546,7 @@ static struct section *elf_create_reloc_
int reltype);
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;
--- a/tools/objtool/include/objtool/elf.h
+++ b/tools/objtool/include/objtool/elf.h
@@ -73,7 +73,7 @@ struct reloc {
struct symbol *sym;
unsigned long offset;
unsigned int type;
- int addend;
+ long addend;
int idx;
bool jump_table_start;
};
@@ -135,7 +135,7 @@ struct elf *elf_open_read(const char *na
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,
- 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,
unsigned long offset, unsigned int type,
struct section *insn_sec, unsigned long insn_off);
next prev parent reply other threads:[~2022-04-17 15:46 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-15 11:19 The trouble with __weak and objtool got worse Peter Zijlstra
2022-04-15 14:12 ` Steven Rostedt
2022-04-15 15:31 ` Peter Zijlstra
2022-04-15 15:10 ` Josh Poimboeuf
2022-04-15 15:15 ` Josh Poimboeuf
2022-04-15 15:26 ` Peter Zijlstra
2022-04-15 17:40 ` Nick Desaulniers
2022-04-15 18:21 ` Josh Poimboeuf
2022-04-15 18:23 ` Josh Poimboeuf
2022-04-15 20:36 ` Nick Desaulniers
2022-04-16 10:49 ` Peter Zijlstra
2022-04-16 10:48 ` Peter Zijlstra
2022-04-16 16:07 ` Josh Poimboeuf
2022-04-16 16:32 ` H.J. Lu
2022-04-17 15:44 ` Peter Zijlstra
2022-04-17 15:46 ` Peter Zijlstra [this message]
2022-04-15 18:22 ` Segher Boessenkool
2022-04-15 18:36 ` Nick Desaulniers
2022-04-15 20:07 ` Segher Boessenkool
2022-04-15 20:31 ` Nick Desaulniers
2022-04-15 21:17 ` Fangrui Song
2022-04-15 21:41 ` Segher Boessenkool
2022-04-16 11:09 ` Peter Zijlstra
2022-04-16 10:59 ` Peter Zijlstra
2022-04-16 13:20 ` Segher Boessenkool
2022-04-16 17:59 ` Segher Boessenkool
2022-04-15 21:04 ` H.J. Lu
2022-04-16 11:25 ` Peter Zijlstra
2022-04-16 16:27 ` H.J. Lu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20220417154609.GD2762@worktop.programming.kicks-ass.net \
--to=peterz@infradead.org \
--cc=hjl.tools@gmail.com \
--cc=jpoimboe@redhat.com \
--cc=linux-toolchains@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=mbenes@suse.cz \
--cc=ndesaulniers@google.com \
--cc=rostedt@goodmis.org \
--cc=x86@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.