Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'objtool_urgent_for_v5.15_rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull objtool fixes from Borislav Petkov:

- Remove an extra section.len member in favour of section.sh_size

- Align .altinstructions section creation with the kernel's by creating
them with entry size of 0

- Fix objtool to convert a reloc symbol to a section offset and not to
not warn about not knowing how

* tag 'objtool_urgent_for_v5.15_rc5' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
objtool: Remove redundant 'len' field from struct section
objtool: Make .altinstructions section entry size consistent
objtool: Remove reloc symbol type checks in get_alt_entry()

+25 -50
+1 -1
tools/objtool/arch/x86/decode.c
··· 684 684 sec = find_section_by_name(elf, ".altinstructions"); 685 685 if (!sec) { 686 686 sec = elf_create_section(elf, ".altinstructions", 687 - SHF_ALLOC, size, 0); 687 + SHF_ALLOC, 0, 0); 688 688 689 689 if (!sec) { 690 690 WARN_ELF("elf_create_section");
+8 -8
tools/objtool/check.c
··· 292 292 !strcmp(sec->name, ".entry.text")) 293 293 sec->noinstr = true; 294 294 295 - for (offset = 0; offset < sec->len; offset += insn->len) { 295 + for (offset = 0; offset < sec->sh.sh_size; offset += insn->len) { 296 296 insn = malloc(sizeof(*insn)); 297 297 if (!insn) { 298 298 WARN("malloc failed"); ··· 307 307 insn->offset = offset; 308 308 309 309 ret = arch_decode_instruction(file->elf, sec, offset, 310 - sec->len - offset, 310 + sec->sh.sh_size - offset, 311 311 &insn->len, &insn->type, 312 312 &insn->immediate, 313 313 &insn->stack_ops); ··· 349 349 { 350 350 struct instruction *insn = NULL; 351 351 unsigned int offset; 352 - unsigned int end = (sec->len > 10) ? sec->len - 10 : 0; 352 + unsigned int end = (sec->sh.sh_size > 10) ? sec->sh.sh_size - 10 : 0; 353 353 354 - for (offset = sec->len - 1; offset >= end && !insn; offset--) 354 + for (offset = sec->sh.sh_size - 1; offset >= end && !insn; offset--) 355 355 insn = find_insn(file, sec, offset); 356 356 357 357 return insn; ··· 389 389 insn = find_insn(file, reloc->sym->sec, reloc->addend); 390 390 if (insn) 391 391 insn = list_prev_entry(insn, list); 392 - else if (reloc->addend == reloc->sym->sec->len) { 392 + else if (reloc->addend == reloc->sym->sec->sh.sh_size) { 393 393 insn = find_last_insn(file, reloc->sym->sec); 394 394 if (!insn) { 395 395 WARN("can't find unreachable insn at %s+0x%x", ··· 424 424 insn = find_insn(file, reloc->sym->sec, reloc->addend); 425 425 if (insn) 426 426 insn = list_prev_entry(insn, list); 427 - else if (reloc->addend == reloc->sym->sec->len) { 427 + else if (reloc->addend == reloc->sym->sec->sh.sh_size) { 428 428 insn = find_last_insn(file, reloc->sym->sec); 429 429 if (!insn) { 430 430 WARN("can't find reachable insn at %s+0x%x", ··· 1561 1561 return -1; 1562 1562 } 1563 1563 1564 - if (sec->len % sizeof(struct unwind_hint)) { 1564 + if (sec->sh.sh_size % sizeof(struct unwind_hint)) { 1565 1565 WARN("struct unwind_hint size mismatch"); 1566 1566 return -1; 1567 1567 } 1568 1568 1569 1569 file->hints = true; 1570 1570 1571 - for (i = 0; i < sec->len / sizeof(struct unwind_hint); i++) { 1571 + for (i = 0; i < sec->sh.sh_size / sizeof(struct unwind_hint); i++) { 1572 1572 hint = (struct unwind_hint *)sec->data->d_buf + i; 1573 1573 1574 1574 reloc = find_reloc_by_dest(file->elf, sec, i * sizeof(*hint));
+6 -8
tools/objtool/elf.c
··· 286 286 return -1; 287 287 } 288 288 } 289 - sec->len = sec->sh.sh_size; 290 289 291 290 if (sec->sh.sh_flags & SHF_EXECINSTR) 292 - elf->text_size += sec->len; 291 + elf->text_size += sec->sh.sh_size; 293 292 294 293 list_add_tail(&sec->list, &elf->sections); 295 294 elf_hash_add(section, &sec->hash, sec->idx); ··· 733 734 data->d_size = strlen(str) + 1; 734 735 data->d_align = 1; 735 736 736 - len = strtab->len; 737 - strtab->len += data->d_size; 737 + len = strtab->sh.sh_size; 738 + strtab->sh.sh_size += data->d_size; 738 739 strtab->changed = true; 739 740 740 741 return len; ··· 789 790 data->d_align = 1; 790 791 data->d_type = ELF_T_SYM; 791 792 792 - sym->idx = symtab->len / sizeof(sym->sym); 793 + sym->idx = symtab->sh.sh_size / sizeof(sym->sym); 793 794 794 - symtab->len += data->d_size; 795 + symtab->sh.sh_size += data->d_size; 795 796 symtab->changed = true; 796 797 797 798 symtab_shndx = find_section_by_name(elf, ".symtab_shndx"); ··· 813 814 data->d_align = 4; 814 815 data->d_type = ELF_T_WORD; 815 816 816 - symtab_shndx->len += 4; 817 + symtab_shndx->sh.sh_size += 4; 817 818 symtab_shndx->changed = true; 818 819 } 819 820 ··· 854 855 } 855 856 856 857 sec->idx = elf_ndxscn(s); 857 - sec->len = size; 858 858 sec->changed = true; 859 859 860 860 sec->data = elf_newdata(s);
-1
tools/objtool/include/objtool/elf.h
··· 38 38 Elf_Data *data; 39 39 char *name; 40 40 int idx; 41 - unsigned int len; 42 41 bool changed, text, rodata, noinstr; 43 42 }; 44 43
+1 -1
tools/objtool/orc_gen.c
··· 204 204 205 205 /* Add a section terminator */ 206 206 if (!empty) { 207 - orc_list_add(&orc_list, &null, sec, sec->len); 207 + orc_list_add(&orc_list, &null, sec, sec->sh.sh_size); 208 208 nr++; 209 209 } 210 210 }
+9 -31
tools/objtool/special.c
··· 58 58 { 59 59 } 60 60 61 - static bool reloc2sec_off(struct reloc *reloc, struct section **sec, unsigned long *off) 61 + static void reloc_to_sec_off(struct reloc *reloc, struct section **sec, 62 + unsigned long *off) 62 63 { 63 - switch (reloc->sym->type) { 64 - case STT_FUNC: 65 - *sec = reloc->sym->sec; 66 - *off = reloc->sym->offset + reloc->addend; 67 - return true; 68 - 69 - case STT_SECTION: 70 - *sec = reloc->sym->sec; 71 - *off = reloc->addend; 72 - return true; 73 - 74 - default: 75 - return false; 76 - } 64 + *sec = reloc->sym->sec; 65 + *off = reloc->sym->offset + reloc->addend; 77 66 } 78 67 79 68 static int get_alt_entry(struct elf *elf, struct special_entry *entry, ··· 98 109 WARN_FUNC("can't find orig reloc", sec, offset + entry->orig); 99 110 return -1; 100 111 } 101 - if (!reloc2sec_off(orig_reloc, &alt->orig_sec, &alt->orig_off)) { 102 - WARN_FUNC("don't know how to handle reloc symbol type %d: %s", 103 - sec, offset + entry->orig, 104 - orig_reloc->sym->type, 105 - orig_reloc->sym->name); 106 - return -1; 107 - } 112 + 113 + reloc_to_sec_off(orig_reloc, &alt->orig_sec, &alt->orig_off); 108 114 109 115 if (!entry->group || alt->new_len) { 110 116 new_reloc = find_reloc_by_dest(elf, sec, offset + entry->new); ··· 117 133 if (arch_is_retpoline(new_reloc->sym)) 118 134 return 1; 119 135 120 - if (!reloc2sec_off(new_reloc, &alt->new_sec, &alt->new_off)) { 121 - WARN_FUNC("don't know how to handle reloc symbol type %d: %s", 122 - sec, offset + entry->new, 123 - new_reloc->sym->type, 124 - new_reloc->sym->name); 125 - return -1; 126 - } 136 + reloc_to_sec_off(new_reloc, &alt->new_sec, &alt->new_off); 127 137 128 138 /* _ASM_EXTABLE_EX hack */ 129 139 if (alt->new_off >= 0x7ffffff0) ··· 159 181 if (!sec) 160 182 continue; 161 183 162 - if (sec->len % entry->size != 0) { 184 + if (sec->sh.sh_size % entry->size != 0) { 163 185 WARN("%s size not a multiple of %d", 164 186 sec->name, entry->size); 165 187 return -1; 166 188 } 167 189 168 - nr_entries = sec->len / entry->size; 190 + nr_entries = sec->sh.sh_size / entry->size; 169 191 170 192 for (idx = 0; idx < nr_entries; idx++) { 171 193 alt = malloc(sizeof(*alt));