From 0bd3ff852d66745aa5e32da760169c56cffaed68 Mon Sep 17 00:00:00 2001 From: Jan Beulich Date: Tue, 19 May 2026 13:40:23 +0200 Subject: [PATCH] symbols: explicitly specify source file name for symtab MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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: d37d63d4b548 ("symbols: prefix static symbols with their source file names") Reported-by: Oleksii Kurochko Signed-off-by: Jan Beulich Tested-by: Oleksii Kurochko Acked-by: Roger Pau Monné master commit: c5d554edff679302b94aecb67bfe9792a2c33aa6 master date: 2026-05-13 10:00:52 +0200 --- xen/arch/x86/Makefile | 2 ++ xen/tools/symbols.c | 4 ++++ 2 files changed, 6 insertions(+) diff --git a/xen/arch/x86/Makefile b/xen/arch/x86/Makefile index 95b30a888f..a21151b56d 100644 --- a/xen/arch/x86/Makefile +++ b/xen/arch/x86/Makefile @@ -216,6 +216,7 @@ endif > $(dot-target).0r.S $(NM) -pa --format=sysv $(dot-target).$(VIRT_BASE).0 \ | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ + --source-name=$(@F).S \ > $(dot-target).0s.S $(MAKE) $(build)=$(@D) .$(@F).0r.o .$(@F).0s.o $(foreach base, $(VIRT_BASE) $(ALT_BASE), \ @@ -226,6 +227,7 @@ endif > $(dot-target).1r.S $(NM) -pa --format=sysv $(dot-target).$(VIRT_BASE).1 \ | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ + --source-name=$(@F).S \ > $(dot-target).1s.S $(MAKE) $(build)=$(@D) .$(@F).1r.o .$(@F).1s.o $(LD) $(call EFI_LDFLAGS,$(VIRT_BASE)) -T $(obj)/efi.lds $< \ diff --git a/xen/tools/symbols.c b/xen/tools/symbols.c index e532709ba7..b597fa8918 100644 --- a/xen/tools/symbols.c +++ b/xen/tools/symbols.c @@ -63,6 +63,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) { @@ -320,6 +321,7 @@ static void write_src(void) printf("#define ALGN .align 4\n"); printf("#endif\n"); + printf("\t.file \"%s\"\n", srcname); printf("\t.section .rodata, \"a\"\n"); printf("#ifndef SYMBOLS_ORIGIN\n"); @@ -612,6 +614,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)