Skip to content

Commit 8782e7c

Browse files
jpoimboesuryasaimadhu
authored andcommitted
objtool: Support Clang non-section symbols in ORC dump
Historically, the relocation symbols for ORC entries have only been section symbols: .text+0: sp:sp+8 bp:(und) type:call end:0 However, the Clang assembler is aggressive about stripping section symbols. In that case we will need to use function symbols: freezing_slow_path+0: sp:sp+8 bp:(und) type:call end:0 In preparation for the generation of such entries in "objtool orc generate", add support for reading them in "objtool orc dump". Signed-off-by: Josh Poimboeuf <[email protected]> Signed-off-by: Borislav Petkov <[email protected]> Reviewed-by: Miroslav Benes <[email protected]> Acked-by: Peter Zijlstra (Intel) <[email protected]> Link: https://lkml.kernel.org/r/b811b5eb1a42602c3b523576dc5efab9ad1c174d.1585761021.git.jpoimboe@redhat.com
1 parent bd841d6 commit 8782e7c

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

tools/objtool/orc_dump.c

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ int orc_dump(const char *_objname)
6666
char *name;
6767
size_t nr_sections;
6868
Elf64_Addr orc_ip_addr = 0;
69-
size_t shstrtab_idx;
69+
size_t shstrtab_idx, strtab_idx = 0;
7070
Elf *elf;
7171
Elf_Scn *scn;
7272
GElf_Shdr sh;
@@ -127,6 +127,8 @@ int orc_dump(const char *_objname)
127127

128128
if (!strcmp(name, ".symtab")) {
129129
symtab = data;
130+
} else if (!strcmp(name, ".strtab")) {
131+
strtab_idx = i;
130132
} else if (!strcmp(name, ".orc_unwind")) {
131133
orc = data->d_buf;
132134
orc_size = sh.sh_size;
@@ -138,7 +140,7 @@ int orc_dump(const char *_objname)
138140
}
139141
}
140142

141-
if (!symtab || !orc || !orc_ip)
143+
if (!symtab || !strtab_idx || !orc || !orc_ip)
142144
return 0;
143145

144146
if (orc_size % sizeof(*orc) != 0) {
@@ -159,21 +161,29 @@ int orc_dump(const char *_objname)
159161
return -1;
160162
}
161163

162-
scn = elf_getscn(elf, sym.st_shndx);
163-
if (!scn) {
164-
WARN_ELF("elf_getscn");
165-
return -1;
166-
}
167-
168-
if (!gelf_getshdr(scn, &sh)) {
169-
WARN_ELF("gelf_getshdr");
170-
return -1;
171-
}
172-
173-
name = elf_strptr(elf, shstrtab_idx, sh.sh_name);
174-
if (!name || !*name) {
175-
WARN_ELF("elf_strptr");
176-
return -1;
164+
if (GELF_ST_TYPE(sym.st_info) == STT_SECTION) {
165+
scn = elf_getscn(elf, sym.st_shndx);
166+
if (!scn) {
167+
WARN_ELF("elf_getscn");
168+
return -1;
169+
}
170+
171+
if (!gelf_getshdr(scn, &sh)) {
172+
WARN_ELF("gelf_getshdr");
173+
return -1;
174+
}
175+
176+
name = elf_strptr(elf, shstrtab_idx, sh.sh_name);
177+
if (!name) {
178+
WARN_ELF("elf_strptr");
179+
return -1;
180+
}
181+
} else {
182+
name = elf_strptr(elf, strtab_idx, sym.st_name);
183+
if (!name) {
184+
WARN_ELF("elf_strptr");
185+
return -1;
186+
}
177187
}
178188

179189
printf("%s+%llx:", name, (unsigned long long)rela.r_addend);

0 commit comments

Comments
 (0)