Skip to content

Commit b75dcd9

Browse files
committed
ARC: module: print pretty section names
Now that we have referece to section name string table in apply_relocate_add(), use it to - print the name of section being relocated - print symbol with NULL name (since it refers to a section) before | Section to fixup 7000a060 | ========================================================= | rela->r_off | rela->addend | sym->st_value | ADDR | VALUE | ========================================================= | 1c 0 7000e000 7000a07c 7000e000 [] | 40 0 7000a000 7000a0a0 7000a000 [] after | Section to fixup .eh_frame @7000a060 | ========================================================= | r_off r_add st_value ADDRESS VALUE | ========================================================= | 1c 0 7000e000 7000a07c 7000e000 [.init.text] | 40 0 7000a000 7000a0a0 7000a000 [.exit.text] Signed-off-by: Vineet Gupta <[email protected]>
1 parent d65283f commit b75dcd9

File tree

1 file changed

+21
-14
lines changed

1 file changed

+21
-14
lines changed

arch/arc/kernel/module.c

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -51,42 +51,49 @@ int apply_relocate_add(Elf32_Shdr *sechdrs,
5151
unsigned int relsec, /* sec index for relo sec */
5252
struct module *module)
5353
{
54-
int i, n;
54+
int i, n, relo_type;
5555
Elf32_Rela *rel_entry = (void *)sechdrs[relsec].sh_addr;
5656
Elf32_Sym *sym_entry, *sym_sec;
57-
Elf32_Addr relocation;
58-
Elf32_Addr location;
59-
Elf32_Addr sec_to_patch;
60-
int relo_type;
57+
Elf32_Addr relocation, location, tgt_addr;
6158
unsigned int tgtsec;
6259

60+
/*
61+
* @relsec has relocations e.g. .rela.init.text
62+
* @tgtsec is section to patch e.g. .init.text
63+
*/
6364
tgtsec = sechdrs[relsec].sh_info;
64-
sec_to_patch = sechdrs[tgtsec].sh_addr;
65+
tgt_addr = sechdrs[tgtsec].sh_addr;
6566
sym_sec = (Elf32_Sym *) sechdrs[symindex].sh_addr;
6667
n = sechdrs[relsec].sh_size / sizeof(*rel_entry);
6768

68-
pr_debug("\n========== Module Sym reloc ===========================\n");
69-
pr_debug("Section to fixup %x\n", sec_to_patch);
69+
pr_debug("\nSection to fixup %s @%x\n",
70+
module->arch.secstr + sechdrs[tgtsec].sh_name, tgt_addr);
7071
pr_debug("=========================================================\n");
71-
pr_debug("rela->r_off | rela->addend | sym->st_value | ADDR | VALUE\n");
72+
pr_debug("r_off\tr_add\tst_value ADDRESS VALUE\n");
7273
pr_debug("=========================================================\n");
7374

7475
/* Loop thru entries in relocation section */
7576
for (i = 0; i < n; i++) {
77+
const char *s;
7678

7779
/* This is where to make the change */
78-
location = sec_to_patch + rel_entry[i].r_offset;
80+
location = tgt_addr + rel_entry[i].r_offset;
7981

8082
/* This is the symbol it is referring to. Note that all
8183
undefined symbols have been resolved. */
8284
sym_entry = sym_sec + ELF32_R_SYM(rel_entry[i].r_info);
8385

8486
relocation = sym_entry->st_value + rel_entry[i].r_addend;
8587

86-
pr_debug("\t%x\t\t%x\t\t%x %x %x [%s]\n",
87-
rel_entry[i].r_offset, rel_entry[i].r_addend,
88-
sym_entry->st_value, location, relocation,
89-
strtab + sym_entry->st_name);
88+
if (sym_entry->st_name == 0 && ELF_ST_TYPE (sym_entry->st_info) == STT_SECTION) {
89+
s = module->arch.secstr + sechdrs[sym_entry->st_shndx].sh_name;
90+
} else {
91+
s = strtab + sym_entry->st_name;
92+
}
93+
94+
pr_debug(" %x\t%x\t%x %x %x [%s]\n",
95+
rel_entry[i].r_offset, rel_entry[i].r_addend,
96+
sym_entry->st_value, location, relocation, s);
9097

9198
/* This assumes modules are built with -mlong-calls
9299
* so any branches/jumps are absolute 32 bit jmps

0 commit comments

Comments
 (0)