symbols: check table sizes don't change between linking passes 2 and 3
PATCH v2 1/1 symbols: check table sizes don't change between linking passes 2 and 3
While sizes (and possibly positions) of the symbol table related symbols (and as a result other ones) are expected to change from linking pass 1 to pass 2, no such change should happen anymore from pass 2 to pass 3, or else the internally recorded symbol table wouldn't represent the ELF or PE/COFF ones.
For comparing to be actually useful, i.e. most notably also covering the last of the arrays emitted, symbol sizes need establishing. Make use of the xen/linkage.h machinery to achieve that.
---
Likely other ports also want to add such checking. Really it would be nice if we could properly abstract out shared parts of the linking steps.
RFC: I'm all ears towards improvement suggestions in the temporary helper
file handling of compare-symbol-tables. Or ideally some approach to avoid the use of a helper file altogether.
---
v2: Actually compare the two files passed into compare-symbol-tables,
rather than the 1st one with itself.
v1': Re-base over the re-numbering of intermediate files. Integrate into
series.
xen/arch/x86/Makefile +3 -0
@@ -148,6 +148,7 @@ $(TARGET)-syms: $(objtree)/prelink.o $(o | $(objtree)/tools/symbols $(all_symbols) --sysv --sort $(syms-warn-dup-y) \ > $(dot-target).2.S $(MAKE) $(build)=$(@D) $(dot-target).2.o + $(call compare-symbol-tables, $(dot-target).1.o, $(dot-target).2.o) $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \ $(orphan-handling-y) $(dot-target).2.o -o $@ $(NM) -pa --format=sysv $@ \
@@ -230,6 +231,8 @@ endif | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \ > $(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) + $(call compare-symbol-tables, $(dot-target).1s.o, $(dot-target).2s.o) $(LD) $(call EFI_LDFLAGS,$(VIRT_BASE)) -T $(obj)/efi.lds $< \ $(dot-target).2r.o $(dot-target).2s.o $(orphan-handling-y) \ $(note_file_option) -o $@
xen/scripts/Kbuild.include +13 -0
@@ -56,6 +56,19 @@ define filechk fi endef +### +# Compare the symbol tables of two object files. As diff's -I option isn't +# standardized, the name difference of the two object files needs abstracting +# out. +define compare-symbol-tables + ln -f $(1) $(@D)/.cst.$$$$; \ + $(OBJDUMP) -t $(@D)/.cst.$$$$ > $(1).sym; \ + ln -f $(2) $(@D)/.cst.$$$$; \ + $(OBJDUMP) -t $(@D)/.cst.$$$$ > $(2).sym; \ + rm -f $(@D)/.cst.$$$$ + diff -u $(1).sym $(2).sym +endef + # as-insn: Check whether assembler supports an instruction. # Usage: cflags-y += $(call as-insn,CC FLAGS,"insn",option-yes,option-no) as-insn = $(if $(shell echo 'void _(void) { asm volatile ( $(2) ); }' \
xen/tools/symbols.c +43 -46
148 lines not on this page · raw message
Quoted 6 lines · Jan Beulich
While sizes (and possibly positions) of the symbol table related symbols (and as a result other ones) are expected to change from linking pass 1 to pass 2, no such change should happen anymore from pass 2 to pass 3, or else the internally recorded symbol table wouldn't represent the ELF or PE/COFF ones.
Quoted 6 lines
For comparing to be actually useful, i.e. most notably also covering the last of the arrays emitted, symbol sizes need establishing. Make use of the
xen/linkage.hmachinery to achieve that.Suggested-by Roger Pau Monné <[email protected]>Signed-off-by Jan Beulich <[email protected]>
Thanks, Roger.
Quoted 7 lines · Roger Pau Monné
Quoted 6 lines · Jan Beulich
While sizes (and possibly positions) of the symbol table related symbols (and as a result other ones) are expected to change from linking pass 1 to pass 2, no such change should happen anymore from pass 2 to pass 3, or else the internally recorded symbol table wouldn't represent the ELF or PE/COFF ones.
Quoted 8 lines
Quoted 6 lines
For comparing to be actually useful, i.e. most notably also covering the last of the arrays emitted, symbol sizes need establishing. Make use of the
xen/linkage.hmachinery to achieve that.Suggested-by Roger Pau Monné <[email protected]>Signed-off-by Jan Beulich <[email protected]>Acked-by Roger Pau Monné <[email protected]>
Hmm, the Ubuntu builds (up to 20.04) still say no for xen.efi. One example:
.xen.efi.2s.o.sym renamed from .xen.efi.1s.o.sym +8 -8
@@ -7,13 +7,13 @@ 0000000000000000 l d .bss 0000000000000000 .bss 0000000000000000 l d .rodata 0000000000000000 .rodata 0000000000000000 l d .note.GNU-stack 0000000000000000 .note.GNU-stack -0000000000000000 g O .rodata 000000000000743c .hidden symbols_offsets -000000000000743c g O .rodata 0000000000000004 .hidden symbols_num_addrs -0000000000007440 g O .rodata 0000000000017f1e .hidden symbols_names -000000000001f360 g O .rodata 0000000000000078 .hidden symbols_markers -000000000001f3d8 g O .rodata 0000000000000443 .hidden symbols_token_table -000000000001f81c g O .rodata 0000000000000200 .hidden symbols_token_index -000000000001fa1c g O .rodata 0000000000000004 .hidden symbols_num_names -000000000001fa20 g O .rodata 000000000000e878 .hidden symbols_sorted_offsets +0000000000000000 g O .rodata 0000000000007438 .hidden symbols_offsets +0000000000007438 g O .rodata 0000000000000004 .hidden symbols_num_addrs +000000000000743c g O .rodata 0000000000017f13 .hidden symbols_names +000000000001f350 g O .rodata 0000000000000078 .hidden symbols_markers +000000000001f3c8 g O .rodata 0000000000000443 .hidden symbols_token_table +000000000001f80c g O .rodata 0000000000000200 .hidden symbols_token_index +000000000001fa0c g O .rodata 0000000000000004 .hidden symbols_num_names +000000000001fa10 g O .rodata 000000000000e870 .hidden symbols_sorted_offsets
i.e. there looks to be a (proper) symbol disappearing in this case.
Oh, wait - this is because "x86/EFI: correct symbol table generation with older GNU ld" still hasn't gone in (and can't without having an ack).
Jan