symbols: explicitly specify source file name for symtab

If there are any local symbols in an object file, GNU ld will create an
STT_FILE symbol derived from the object file name if there is none in the
incoming symbol table. The object file name, however, varies between
linking passes. As a result, symbol name compression can yield different
results if any of those local symbols need retaining (Arm [and RISC-V]
mapping symbols are omitted, for example). If that difference in
compression would yield a difference in the sizes of symbol_names[] or
symbols_token_table[], the compare-symbol-tables sanity check will fail.

Fixes: d37d63d4b5 ("symbols: prefix static symbols with their source file names")
Reported-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Tested-by: Oleksii Kurochko <oleksii.kurochko@gmail.com>
Acked-by: Roger Pau Monné <roger.pau@citrix.com>
This commit is contained in:
Jan Beulich committed 2026-05-13 10:00:52 +02:00
1 parent 1044a59e8e
commit c5d554edff
2 files changed
+8 -1

No files matched your search

+4 -1
View File
@@ -200,7 +200,8 @@ $(TARGET).efi: $(objtree)/prelink.o $(note_file) $(obj)/efi.lds $(obj)/efi/reloc
ifeq ($(CONFIG_DEBUG_INFO),y)
$(if $(filter --strip-debug,$(EFI_LDFLAGS)),echo,:) "Will strip debug info from $(@F)"
endif
$(objtree)/tools/symbols $(all_symbols) --empty > $(dot-target).0s.S
$(objtree)/tools/symbols $(all_symbols) --source-name=$(@F).S --empty \
> $(dot-target).0s.S
$(MAKE) $(build)=$(@D) .$(@F).0s.o
$(foreach base, $(VIRT_BASE) $(ALT_BASE), \
$(LD) $(call EFI_LDFLAGS,$(base)) -T $(obj)/efi.lds $< $(relocs-dummy) \
@@ -210,6 +211,7 @@ endif
> $(dot-target).1r.S
$(NM) -pa --format=sysv $(dot-target).$(VIRT_BASE).0 \
| $(objtree)/tools/symbols $(all_symbols) --sysv --sort \
--source-name=$(@F).S \
> $(dot-target).1s.S
$(MAKE) $(build)=$(@D) .$(@F).1r.o .$(@F).1s.o
$(foreach base, $(VIRT_BASE) $(ALT_BASE), \
@@ -220,6 +222,7 @@ endif
> $(dot-target).2r.S
$(NM) -pa --format=sysv $(dot-target).$(VIRT_BASE).1 \
| $(objtree)/tools/symbols $(all_symbols) --sysv --sort \
--source-name=$(@F).S \
> $(dot-target).2s.S
$(MAKE) $(build)=$(@D) .$(@F).2r.o .$(@F).2s.o
$(call compare-symbol-tables, $(dot-target).1r.o, $(dot-target).2r.o)
+4
View File
@@ -66,6 +66,7 @@ int token_profit[0x10000];
unsigned char best_table[256][2];
unsigned char best_table_len[256];
static const char *srcname = "xen-syms.S";
static void usage(void)
{
@@ -356,6 +357,7 @@ static void write_src(void)
printf("#define ALGN 4\n");
printf("#endif\n");
printf("\t.file \"%s\"\n", srcname);
printf("\t.section .rodata, \"a\"\n");
printf("#ifndef SYMBOLS_ORIGIN\n");
@@ -679,6 +681,8 @@ int main(int argc, char **argv)
unsorted = true;
else if (strcmp(argv[i], "--sort-by-name") == 0)
sort_by_name = 1;
else if (strncmp(argv[i], "--source-name=", 14) == 0)
srcname = argv[i] + 14;
else if (strcmp(argv[i], "--warn-dup") == 0)
warn_dup = true;
else if (strcmp(argv[i], "--error-dup") == 0)
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.