From: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
To: xen-devel@lists.xenproject.org, ross.lagerwall@citrix.com
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Subject: [PATCH LIVEPATCH-BUILD-TOOLS] EFI build with -ffunction-sections fails.
Date: Wed, 13 Jul 2016 16:14:12 -0400 [thread overview]
Message-ID: <1468440852-7568-1-git-send-email-konrad.wilk@oracle.com> (raw)
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>
---
livepatch-build | 2 ++
1 file changed, 2 insertions(+)
diff --git a/livepatch-build b/livepatch-build
index 8dc8889..6ccadd6 100755
--- a/livepatch-build
+++ b/livepatch-build
@@ -86,8 +86,10 @@ function build_special()
# Build with special GCC flags
cd "${SRCDIR}/xen" || die
sed -i 's/CFLAGS += -nostdinc/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/' Rules.mk
+ sed -i 's/--section-alignment=0x200000/--section-alignment=0x1000/' arch/x86/Makefile
make "-j$CPUS" debug="$XEN_DEBUG" &> "${OUTPUT}/build_${name}_compile.log" || die
sed -i 's/CFLAGS += -nostdinc -ffunction-sections -fdata-sections/CFLAGS += -nostdinc/' Rules.mk
+ sed -i 's/--section-alignment=0x1000/--section-alignment=0x200000/' arch/x86/Makefile
unset LIVEPATCH_BUILD_DIR
unset LIVEPATCH_CAPTURE_DIR
--
2.5.5
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next reply other threads:[~2016-07-13 20:14 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-07-13 20:14 Konrad Rzeszutek Wilk [this message]
2016-07-14 7:22 ` [PATCH LIVEPATCH-BUILD-TOOLS] EFI build with -ffunction-sections fails Ross Lagerwall
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1468440852-7568-1-git-send-email-konrad.wilk@oracle.com \
--to=konrad.wilk@oracle.com \
--cc=ross.lagerwall@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).