properly and seems to get stuck while trying to generate and load the
ACPI tables. This is caused by the layout of the binary when linked
with LLVM LD.
LLVM LD has a different default linker script that GNU LD, and the
resulting hvmloader binary is slightly different:
LLVM LD:
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
PHDR 0x000034 0x000ff034 0x000ff034 0x00060 0x00060 R 0x4
LOAD 0x000000 0x000ff000 0x000ff000 0x38000 0x38000 RWE 0x1000
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0
GNU LD:
Program Headers:
Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
LOAD 0x000080 0x00100000 0x00100000 0x36308 0x3fd74 RWE 0x10
GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x4
Note that in the LLVM LD case (as with GNU LD) the .text section does
indeed have the address set to 0x100000 as requested on the command
line:
[ 1] .text PROGBITS
00100000 001000 00dd10 00 AX 0 0 16
There's however the PHDR which is not present when using GNU LD.
Fix this by using a very simple linker script that generates the same
binary regardless of whether LLVM or GNU LD is used. By using a linker
script the usage of -Ttext can also be avoided by placing the desired
.text load address directly in the linker script.
Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Wei Liu <wei.liu2@citrix.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
XEN_ROOT = $(CURDIR)/../../..
include $(XEN_ROOT)/tools/firmware/Rules.mk
-
-LOADADDR = 0x100000
-
# SMBIOS spec requires format mm/dd/yyyy
SMBIOS_REL_DATE ?= $(shell date +%m/%d/%Y)
vpath static_tables.c $(ACPI_PATH)
OBJS += $(ACPI_OBJS)
-hvmloader: $(OBJS)
- $(LD) $(LDFLAGS_DIRECT) -N -Ttext $(LOADADDR) -o $@ $^
+hvmloader: $(OBJS) hvmloader.lds
+ $(LD) $(LDFLAGS_DIRECT) -N -T hvmloader.lds -o $@ $(OBJS)
roms.inc: $(ROMS)
echo "/* Autogenerated file. DO NOT EDIT */" > $@.new
--- /dev/null
+SECTIONS
+{
+ . = 0x100000;
+ /*
+ * NB: there's no need to use the AT keyword in order to set the LMA, by
+ * default the linker will use VMA = LMA unless specified otherwise.
+ */
+ .text : { *(.text) *(.text.*) }
+ .rodata : { *(.rodata) *(.rodata.*) }
+ .data : { *(.data) *(.data.*) }
+ .bss : { *(.bss) *(.bss.*) }
+ _end = .;
+}