Skip to content

Commit 3ba121c

Browse files
committed
Merge tag 'objtool-core-2025-05-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip
Pull objtool updates from Ingo Molnar: - Speed up SHT_GROUP reindexing (Josh Poimboeuf) - Fix up st_info in COMDAT group section (Rong Xu) * tag 'objtool-core-2025-05-25' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip: objtool: Speed up SHT_GROUP reindexing objtool: Fix up st_info in COMDAT group section
2 parents b3570b0 + 4ed9d82 commit 3ba121c

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

tools/objtool/elf.c

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,34 @@ static int read_symbols(struct elf *elf)
572572
return -1;
573573
}
574574

575+
static int mark_group_syms(struct elf *elf)
576+
{
577+
struct section *symtab, *sec;
578+
struct symbol *sym;
579+
580+
symtab = find_section_by_name(elf, ".symtab");
581+
if (!symtab) {
582+
ERROR("no .symtab");
583+
return -1;
584+
}
585+
586+
list_for_each_entry(sec, &elf->sections, list) {
587+
if (sec->sh.sh_type == SHT_GROUP &&
588+
sec->sh.sh_link == symtab->idx) {
589+
sym = find_symbol_by_index(elf, sec->sh.sh_info);
590+
if (!sym) {
591+
ERROR("%s: can't find SHT_GROUP signature symbol",
592+
sec->name);
593+
return -1;
594+
}
595+
596+
sym->group_sec = sec;
597+
}
598+
}
599+
600+
return 0;
601+
}
602+
575603
/*
576604
* @sym's idx has changed. Update the relocs which reference it.
577605
*/
@@ -745,7 +773,7 @@ __elf_create_symbol(struct elf *elf, struct symbol *sym)
745773

746774
/*
747775
* Move the first global symbol, as per sh_info, into a new, higher
748-
* symbol index. This fees up a spot for a new local symbol.
776+
* symbol index. This frees up a spot for a new local symbol.
749777
*/
750778
first_non_local = symtab->sh.sh_info;
751779
old = find_symbol_by_index(elf, first_non_local);
@@ -763,6 +791,11 @@ __elf_create_symbol(struct elf *elf, struct symbol *sym)
763791
if (elf_update_sym_relocs(elf, old))
764792
return NULL;
765793

794+
if (old->group_sec) {
795+
old->group_sec->sh.sh_info = new_idx;
796+
mark_sec_changed(elf, old->group_sec, true);
797+
}
798+
766799
new_idx = first_non_local;
767800
}
768801

@@ -1035,6 +1068,9 @@ struct elf *elf_open_read(const char *name, int flags)
10351068
if (read_symbols(elf))
10361069
goto err;
10371070

1071+
if (mark_group_syms(elf))
1072+
goto err;
1073+
10381074
if (read_relocs(elf))
10391075
goto err;
10401076

tools/objtool/include/objtool/elf.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ struct symbol {
7272
u8 ignore : 1;
7373
struct list_head pv_target;
7474
struct reloc *relocs;
75+
struct section *group_sec;
7576
};
7677

7778
struct reloc {

0 commit comments

Comments
 (0)