]>
xenbits.xensource.com Git - people/wipawel/livepatch-build-tools/commit
EFI build with -ffunction-sections fails.
When we build Xen with the Rules.mk modified we end up:
ld -mi386pep --subsystem=10 --image-base=0xffff82d080000000 --stack=0,0 --heap=0,0 --strip-debug --section-alignment=0x200000 --file-alignment=0x20 --major-image-version=4 --minor-image-version=8 --major-os-version=2 --minor-os-version=0 --major-subsystem-version=2 --minor-subsystem-version=0 -T efi.lds -N prelink-efi.o efi/relocs-dummy.o /home/konrad/xen/xen/common/symbols-dummy.o -o /home/konrad/xen/xen/.xen.efi.0xffff82d080000000.0 && ld -mi386pep --subsystem=10 --image-base=0xffff82d0c0000000 --stack=0,0 --heap=0,0 --strip-debug --section-alignment=0x200000 --file-alignment=0x20 --major-image-version=4 --minor-image-version=8 --major-os-version=2 --minor-os-version=0 --major-subsystem-version=2 --minor-subsystem-version=0 -T efi.lds -N prelink-efi.o efi/relocs-dummy.o /home/konrad/xen/xen/common/symbols-dummy.o -o /home/konrad/xen/xen/.xen.efi.0xffff82d0c0000000.0 && :
ld: Xen image overlaps stubs area
prelink-efi.o: In function `__high_start':
/home/konrad/xen/xen/arch/x86/boot/x86_64.S:6:(.text+0x23): relocation truncated to fit: R_X86_64_PC32 against `gdt_descr'
/home/konrad/xen/xen/arch/x86/boot/x86_64.S:18:(.text+0x43): relocation truncated to fit: R_X86_64_PC32 against `stack_start'
/home/konrad/xen/xen/arch/x86/boot/x86_64.S:35:(.text+0x6a): relocation truncated to fit: R_X86_64_PC32 against `.data'
/home/konrad/xen/xen/arch/x86/boot/x86_64.S:36:(.text+0x6f): relocation truncated to fit: R_X86_64_PC32 against `__start_xen'
.. and more.
Re-running it with -M on a build (the giant ld -mi386pep..) with the -ffunction-sections and without it
makes it obvious what the problem is:
With: -ffunction-sections -fdata-sections:
.data 0xffff82d291e18000 0xf8 prelink-efi.o
0xffff82d291e18006 gdt_descr
*(.text)
.text 0xffff82d0c0100000 0x27e4 prelink-efi.o
0xffff82d0c0100000 start
0xffff82d0c0100020 __high_start
distance is 0x1D1D18000
Normal build:
.data 0xffff82d0c0818000 0x12e8 prelink-efi.o
0xffff82d0c0818006 gdt_descr
.text 0xffff82d0c0100000 0x14b000
0xffff82d0c0100000 _stext = .
*(.text)
.text 0xffff82d0c0100000 0x149243 prelink-efi.o
0xffff82d0c0100000 start
0xffff82d0c0100020 __high_start
where the distance is 0x718000
The 0x1D1D18000 is most certainly over the 32-bit limit and leads to the truncation.
Now if we look more closely at the map we can see that each
.text section is:
.text.domain_kill
0xffff82d0cd200000 0x140
.text.domain_kill
0xffff82d0cd200000 0x139 prelink-efi.o
0xffff82d0cd200000 domain_kill
.text.domain_create
0xffff82d0cd400000 0x520
.text.domain_create
0xffff82d0cd400000 0x502 prelink-efi.o
0xffff82d0cd400000 domain_create
.. seperated by 2MB!
A bit of grepping showed that the issue is with:
--section-alignment=0x200000
which is used on the linker command line and this fix
replaces the --section-alignment to be 4KB which allows the build
to complete.
Signed-off-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>