[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <d848189dac6c41193a6c55c3588b78114bbcb0f8.1590597288.git.mhelsley@vmware.com>
Date: Wed, 27 May 2020 09:42:32 -0700
From: Matt Helsley <mhelsley@...are.com>
To: <linux-kernel@...r.kernel.org>
CC: Josh Poimboeuf <jpoimboe@...hat.com>,
Peter Zijlstra <peterz@...radead.org>,
Steven Rostedt <rostedt@...dmis.org>,
Matt Helsley <mhelsley@...are.com>
Subject: [RFC][PATCH 2/3] objtool: Find relocation base section using sh_info
Currently objtool uses a naming heuristic to find the "base"
section to apply the relocation(s) to. The standard defines
the SHF_INFO_LINK flag (SHF => in the section header flags)
which indicates when the section header's sh_info field can
be used to find the necessary section.
Warns when the heuristic is used as a fallback and changes
the name heuristic calculation to handle rela (explicit
addend) and now rel (implicit addend) relocations.
Signed-off-by: Matt Helsley <mhelsley@...are.com>
---
tools/objtool/elf.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/tools/objtool/elf.c b/tools/objtool/elf.c
index 6fb9f83f7f66..a162bc383945 100644
--- a/tools/objtool/elf.c
+++ b/tools/objtool/elf.c
@@ -502,7 +502,13 @@ static int read_relocs(struct elf *elf)
if (sec->sh.sh_type != SHT_RELA)
continue;
- sec->base = find_section_by_name(elf, sec->name + 5);
+ if (sec->sh.sh_flags & SHF_INFO_LINK) {
+ sec->base = find_section_by_index(elf, sec->sh.sh_info);
+ } else if (strncmp(sec->name, ".rel", 4) == 0) {
+ WARN("Using naming heuristic to find base of reloc section %s",
+ sec->name);
+ sec->base = find_section_by_name(elf, sec->name + 5);
+ }
if (!sec->base) {
WARN("can't find base section for reloc section %s",
sec->name);
--
2.20.1
Powered by blists - more mailing lists