[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] xen/riscv: do a 4th linking pass if necessary



commit 1bca40c1896235e3bdda79746887a957aefd2b55
Author:     Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
AuthorDate: Tue Jul 21 09:48:37 2026 +0200
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Jul 21 09:48:37 2026 +0200

    xen/riscv: do a 4th linking pass if necessary
    
    Embedding the symbol table can shift sections and flip relaxation
    decisions, changing code size and thus the set of emitted tools/symbols
    (e.g. gap end markers).  Re-link with a regenerated table when its
    size differs from the previous pass.
    
    This takes the same remedy as commit 35de7285d508 ("Arm: do a 4th
    linking pass if necessary"), though the underlying cause differs:
    here no symbol (dis)appears from the ELF symbol table; instead the
    set of end markers emitted by tools/symbols legitimately changes,
    because want_symbol_end() depends on code layout, and layout differs
    between passes due to linker relaxation.
    
    Signed-off-by: Oleksii Kurochko <oleksii.kurochko@xxxxxxxxx>
    Acked-by: Jan Beulich <jbeulich@xxxxxxxx>
---
 xen/arch/riscv/Makefile | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)

diff --git a/xen/arch/riscv/Makefile b/xen/arch/riscv/Makefile
index 8f7fd625dd..4c7d4e5af5 100644
--- a/xen/arch/riscv/Makefile
+++ b/xen/arch/riscv/Makefile
@@ -46,9 +46,21 @@ $(TARGET)-syms: $(objtree)/prelink.o $(obj)/xen.lds
                | $(objtree)/tools/symbols $(all_symbols) --sysv --sort \
                > $(dot-target).2.S
        $(MAKE) $(build)=$(@D) $(dot-target).2.o
-       $(call compare-symbol-tables, $(dot-target).1.o, $(dot-target).2.o)
+       if ! { $(call compare-symbol-tables, $(dot-target).1.o, 
$(dot-target).2.o) >/dev/null; }; \
+       then \
+               set -e; \
+               $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \
+                   $(dot-target).2.o -o $(dot-target).2; \
+               $(NM) -pa --format=sysv $(dot-target).2 \
+                       | $(objtree)/tools/symbols $(all_symbols) --sysv --sort 
\
+                       > $(dot-target).3.S; \
+               $(MAKE) $(build)=$(@D) $(dot-target).3.o; \
+               $(call compare-symbol-tables, $(dot-target).2.o, 
$(dot-target).3.o); \
+       else \
+               ln -sf $(dot-target).2.o $(dot-target).3.o; \
+       fi
        $(LD) $(XEN_LDFLAGS) -T $(obj)/xen.lds $< $(build_id_linker) \
-           $(dot-target).2.o -o $@
+           $(dot-target).3.o -o $@
        $(NM) -pa --format=sysv $@ \
                | $(objtree)/tools/symbols --all-symbols --xensyms --sysv 
--sort \
                > $@.map
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.