diff options
| -rw-r--r-- | arch/arc/kernel/module.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/arch/arc/kernel/module.c b/arch/arc/kernel/module.c index 24bd2ffb90b7..42e964db2967 100644 --- a/arch/arc/kernel/module.c +++ b/arch/arc/kernel/module.c | |||
| @@ -51,31 +51,33 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, | |||
| 51 | unsigned int relsec, /* sec index for relo sec */ | 51 | unsigned int relsec, /* sec index for relo sec */ |
| 52 | struct module *module) | 52 | struct module *module) |
| 53 | { | 53 | { |
| 54 | int i, n; | 54 | int i, n, relo_type; |
| 55 | Elf32_Rela *rel_entry = (void *)sechdrs[relsec].sh_addr; | 55 | Elf32_Rela *rel_entry = (void *)sechdrs[relsec].sh_addr; |
| 56 | Elf32_Sym *sym_entry, *sym_sec; | 56 | Elf32_Sym *sym_entry, *sym_sec; |
| 57 | Elf32_Addr relocation; | 57 | Elf32_Addr relocation, location, tgt_addr; |
| 58 | Elf32_Addr location; | ||
| 59 | Elf32_Addr sec_to_patch; | ||
| 60 | int relo_type; | ||
| 61 | unsigned int tgtsec; | 58 | unsigned int tgtsec; |
| 62 | 59 | ||
| 60 | /* | ||
| 61 | * @relsec has relocations e.g. .rela.init.text | ||
| 62 | * @tgtsec is section to patch e.g. .init.text | ||
| 63 | */ | ||
| 63 | tgtsec = sechdrs[relsec].sh_info; | 64 | tgtsec = sechdrs[relsec].sh_info; |
| 64 | sec_to_patch = sechdrs[tgtsec].sh_addr; | 65 | tgt_addr = sechdrs[tgtsec].sh_addr; |
| 65 | sym_sec = (Elf32_Sym *) sechdrs[symindex].sh_addr; | 66 | sym_sec = (Elf32_Sym *) sechdrs[symindex].sh_addr; |
| 66 | n = sechdrs[relsec].sh_size / sizeof(*rel_entry); | 67 | n = sechdrs[relsec].sh_size / sizeof(*rel_entry); |
| 67 | 68 | ||
| 68 | pr_debug("\n========== Module Sym reloc ===========================\n"); | 69 | pr_debug("\nSection to fixup %s @%x\n", |
| 69 | pr_debug("Section to fixup %x\n", sec_to_patch); | 70 | module->arch.secstr + sechdrs[tgtsec].sh_name, tgt_addr); |
| 70 | pr_debug("=========================================================\n"); | 71 | 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"); |
| 72 | pr_debug("=========================================================\n"); | 73 | pr_debug("=========================================================\n"); |
| 73 | 74 | ||
| 74 | /* Loop thru entries in relocation section */ | 75 | /* Loop thru entries in relocation section */ |
| 75 | for (i = 0; i < n; i++) { | 76 | for (i = 0; i < n; i++) { |
| 77 | const char *s; | ||
| 76 | 78 | ||
| 77 | /* This is where to make the change */ | 79 | /* 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; |
| 79 | 81 | ||
| 80 | /* This is the symbol it is referring to. Note that all | 82 | /* This is the symbol it is referring to. Note that all |
| 81 | undefined symbols have been resolved. */ | 83 | undefined symbols have been resolved. */ |
| @@ -83,10 +85,15 @@ int apply_relocate_add(Elf32_Shdr *sechdrs, | |||
| 83 | 85 | ||
| 84 | relocation = sym_entry->st_value + rel_entry[i].r_addend; | 86 | relocation = sym_entry->st_value + rel_entry[i].r_addend; |
| 85 | 87 | ||
| 86 | pr_debug("\t%x\t\t%x\t\t%x %x %x [%s]\n", | 88 | if (sym_entry->st_name == 0 && ELF_ST_TYPE (sym_entry->st_info) == STT_SECTION) { |
| 87 | rel_entry[i].r_offset, rel_entry[i].r_addend, | 89 | s = module->arch.secstr + sechdrs[sym_entry->st_shndx].sh_name; |
| 88 | sym_entry->st_value, location, relocation, | 90 | } else { |
| 89 | strtab + sym_entry->st_name); | 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); | ||
| 90 | 97 | ||
| 91 | /* This assumes modules are built with -mlong-calls | 98 | /* This assumes modules are built with -mlong-calls |
| 92 | * so any branches/jumps are absolute 32 bit jmps | 99 | * so any branches/jumps are absolute 32 bit jmps |
