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.

objtool: Use section/symbol type helpers

Commit 25eac74b6bdb ("objtool: Add section/symbol type helpers")
introduced several helper macros to improve code readability.

Update the remaining open-coded checks in check.c, disas.c, elf.c,
and klp-diff.c to use these new helpers.

Signed-off-by: Wentong Tian <tianwentong2000@gmail.com>
Link: https://patch.msgid.link/20260122144404.40602-1-tianwentong2000@gmail.com
Signed-off-by: Josh Poimboeuf <jpoimboe@kernel.org>

authored by

Wentong Tian and committed by
Josh Poimboeuf
c19c854b 11439c46

+12 -12
+2 -2
tools/objtool/check.c
··· 4293 4293 list_for_each_entry(insn, &file->retpoline_call_list, call_node) { 4294 4294 struct symbol *sym = insn->sym; 4295 4295 4296 - if (sym && (sym->type == STT_NOTYPE || 4297 - sym->type == STT_FUNC) && !sym->nocfi) { 4296 + if (sym && (is_notype_sym(sym) || 4297 + is_func_sym(sym)) && !sym->nocfi) { 4298 4298 struct instruction *prev = 4299 4299 prev_insn_same_sym(file, insn); 4300 4300
+3 -3
tools/objtool/disas.c
··· 264 264 * If the relocation symbol is a section name (for example ".bss") 265 265 * then we try to further resolve the name. 266 266 */ 267 - if (reloc->sym->type == STT_SECTION) { 267 + if (is_sec_sym(reloc->sym)) { 268 268 str = offstr(reloc->sym->sec, reloc->sym->offset + offset); 269 269 DINFO_FPRINTF(dinfo, bfd_vma_fmt, addr, str); 270 270 free(str); ··· 580 580 */ 581 581 dinfo->buffer = insn->sec->data->d_buf; 582 582 dinfo->buffer_vma = 0; 583 - dinfo->buffer_length = insn->sec->sh.sh_size; 583 + dinfo->buffer_length = sec_size(insn->sec); 584 584 585 585 return disasm(insn->offset, &dctx->info); 586 586 } ··· 1231 1231 1232 1232 for_each_sec(dctx->file->elf, sec) { 1233 1233 1234 - if (!(sec->sh.sh_flags & SHF_EXECINSTR)) 1234 + if (!is_text_sec(sec)) 1235 1235 continue; 1236 1236 1237 1237 sec_for_each_sym(sec, sym) {
+3 -3
tools/objtool/elf.c
··· 614 614 if (elf_add_symbol(elf, sym)) 615 615 return -1; 616 616 617 - if (sym->type == STT_FILE) 617 + if (is_file_sym(sym)) 618 618 file = sym; 619 619 else if (sym->bind == STB_LOCAL) 620 620 sym->file = file; ··· 1335 1335 return -1; 1336 1336 } 1337 1337 1338 - offset = ALIGN(strtab->sh.sh_size, strtab->sh.sh_addralign); 1338 + offset = ALIGN(sec_size(strtab), strtab->sh.sh_addralign); 1339 1339 1340 1340 if (!elf_add_data(elf, strtab, str, strlen(str) + 1)) 1341 1341 return -1; ··· 1377 1377 sec->data->d_size = size; 1378 1378 sec->data->d_align = 1; 1379 1379 1380 - offset = ALIGN(sec->sh.sh_size, sec->sh.sh_addralign); 1380 + offset = ALIGN(sec_size(sec), sec->sh.sh_addralign); 1381 1381 sec->sh.sh_size = offset + size; 1382 1382 1383 1383 mark_sec_changed(elf, sec, true);
+4 -4
tools/objtool/klp-diff.c
··· 271 271 */ 272 272 static bool is_clang_tmp_label(struct symbol *sym) 273 273 { 274 - return sym->type == STT_NOTYPE && 274 + return is_notype_sym(sym) && 275 275 is_text_sec(sym->sec) && 276 276 strstarts(sym->name, ".Ltmp") && 277 277 isdigit(sym->name[5]); ··· 480 480 if (sym->bind != STB_LOCAL) 481 481 return 0; 482 482 483 - if (vmlinux && sym->type == STT_FUNC) { 483 + if (vmlinux && is_func_sym(sym)) { 484 484 /* 485 485 * HACK: Unfortunately, symbol ordering can differ between 486 486 * vmlinux.o and vmlinux due to the linker script emitting ··· 1046 1046 sec->name, offset, patched_sym->name, \ 1047 1047 addend >= 0 ? "+" : "-", labs(addend), \ 1048 1048 sym_type(patched_sym), \ 1049 - patched_sym->type == STT_SECTION ? "" : " ", \ 1050 - patched_sym->type == STT_SECTION ? "" : sym_bind(patched_sym), \ 1049 + is_sec_sym(patched_sym) ? "" : " ", \ 1050 + is_sec_sym(patched_sym) ? "" : sym_bind(patched_sym), \ 1051 1051 is_undef_sym(patched_sym) ? " UNDEF" : "", \ 1052 1052 export ? " EXPORTED" : "", \ 1053 1053 klp ? " KLP" : "")