Issue metadata
Sign in to add a comment
|
X86_64 4.4 kernel fails to build with llvm-next |
||||||||||||||||||||||||
Issue descriptionhttps://uberchromegw.corp.google.com/i/chromiumos.tryserver/builders/release/builds/20856 chromeos-kernel-4_4-4.4.120-r1398: RELOCS arch/x86/realmode/rm/realmode.relocs chromeos-kernel-4_4-4.4.120-r1398: Unsupported relocation type: R_386_PLT32 (4) chromeos-kernel-4_4-4.4.120-r1398: make[4]: *** [/build/squawks/tmp/portage/sys-kernel/chromeos-kernel-4_4-4.4.120-r1398/work/chromeos-kernel-4_4-4.4.120/arch/x86/realmode/rm/Makefile:68: arch/x86/realmode/rm/realmode.relocs] Error 1 chromeos-kernel-4_4-4.4.120-r1398: make[4]: Target 'arch/x86/realmode/rm/realmode.bin' not remade because of errors. To repro: Build llvm as: USE="llvm-next" emerge-squawks chromeos-kernel-4_4
,
Mar 8 2018
My limited understanding is that PLT is used for dynamic linking, which isn't supported in the kernel. This ancient thread involving a kernel maintainer is very clear about not supporting it: http://linux-arm-kernel.infradead.narkive.com/QRUkU1L9/r-arm-plt32-relocation Do we know what changed in LLVM that it wants to use dynamic linking?
,
Mar 8 2018
Thanks, let me investigate.
,
Mar 9 2018
arch/x86/realmode/rm/video-vesa.c has a PLT relocation on memset. The issue is present on ToT clang as well. Doing a bisection to find the CL causing this issue.
,
Mar 9 2018
Opened https://bugs.llvm.org/show_bug.cgi?id=36674 (The original CL was reverted initially because of a different bug so I should be able to cherry-pick the revert to make the kernel builds work for now) https://reviews.llvm.org/rL323297 https://reviews.llvm.org/rL325514
,
Mar 9 2018
A comment on the LLVM bug (https://bugs.llvm.org/show_bug.cgi?id=36674#c3) mentions a kernel patch, which actually has already been merged to the upstream kernel: commit b21ebf2fb4cde1618915a97cc773e287ff49173e Author: H.J. Lu <hjl.tools@gmail.com> Date: Wed Feb 7 14:20:09 2018 -0800 x86: Treat R_X86_64_PLT32 as R_X86_64_PC32 We can cherry pick this patch to v4.4 and v4.14 instead of reverting the LLVM change. This kind of change still sucks, since it breaks builds of 'older' kernels (including v4.14 LTS) not only for us but for everybody using a ToTish LLVM :/
,
Mar 9 2018
Thanks Matthias, I was just going to ask you. Maybe you (or ask HJL) can cherry-pick it to 4.4/4.14 kernel LTS trees ?
,
Mar 9 2018
Support for R_386_PLT32 is still missing.
mka@ can you send this patch Linux kernel upstream?
diff --git a/arch/x86/kernel/module.c b/arch/x86/kernel/module.c
index 005c03e93fc5..b88bfaf4e991 100644
--- a/arch/x86/kernel/module.c
+++ b/arch/x86/kernel/module.c
@@ -124,6 +124,7 @@ int apply_relocate(Elf32_Shdr *sechdrs,
*location += sym->st_value;
break;
case R_386_PC32:
+ case R_386_PLT32:
/* Add the value, subtract its position */
*location += sym->st_value - (uint32_t)location;
break;
diff --git a/arch/x86/tools/relocs.c b/arch/x86/tools/relocs.c
index 73eb7fd4aec4..fb4382a7f949 100644
--- a/arch/x86/tools/relocs.c
+++ b/arch/x86/tools/relocs.c
@@ -834,6 +835,7 @@ static int do_reloc32(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
switch (r_type) {
case R_386_NONE:
case R_386_PC32:
+ case R_386_PLT32:
case R_386_PC16:
case R_386_PC8:
/*
@@ -877,6 +879,7 @@ static int do_reloc_real(struct section *sec, Elf_Rel *rel, Elf_Sym *sym,
switch (r_type) {
case R_386_NONE:
case R_386_PC32:
+ case R_386_PLT32:
case R_386_PC16:
case R_386_PC8:
/*
,
Mar 9 2018
At first sight a port of the x86_64 patch to i386 seems trivial, however I am not sure if that trivial port is correct. From the commit message of the x86_64 patch: "On i386, there are 2 types of PLTs, PIC and non-PIC. PIE and shared objects must use PIC PLT. To use PIC PLT, you need to load _GLOBAL_OFFSET_TABLE_ into EBX first. There is no need for that on x86-64 since x86-64 uses PC-relative PLT." manoj, could you reply to the LLVM bug (where the author of the patch posted) that the kernel patch doesn't fix the reported problem with R_386_PLT32 and try to get some more information on what would be the correct solution?
,
Mar 9 2018
HJL just replied on the bug. So I hope Rafael will take care of fixing it. Meanwhile, I can fix our builds by cherry-picking the revert if the fix takes some time.
,
Mar 10 2018
Rafael send he fix for R_386_PLT32 at https://reviews.llvm.org/D44334
,
Mar 10 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/20d214bc1b568d202de358041734f83ab3eb6bf0 commit 20d214bc1b568d202de358041734f83ab3eb6bf0 Author: Manoj Gupta <manojgupta@google.com> Date: Sat Mar 10 06:59:17 2018 llvm-next: Cherry-pick 4 upstream CLs. Cherry-pick 4 CLs to fix various issues. These are cherry-picked to Chrome OS's llvm-next only. Does not impact the current llvm version used. CL descriptions: commit 284236c047631c8b0eabac3ddd3d0c95253f4361 Author: Manoj Gupta <manojgupta@google.com> Date: Fri Mar 2 23:52:44 2018 +0000 Do not generate calls to fentry with __attribute__((no_instrument_function)) commit 30f9051d7d8b6f56c8149fd1bdcc714285f77527 Author: Dan Albert <danalbert@google.com> Date: Wed Feb 21 22:36:51 2018 +0000 [Driver] Generate .eh_frame_hdr for static executables too. commit 98079e294f718c14d25ccf30ab2b1938780ffe4d Author: Florian Hahn <florian.hahn@arm.com> Date: Fri Mar 2 13:02:55 2018 +0000 [ARM] Fix codegen for VLD3/VLD4/VST3/VST4 with WB commit ffaaef68dbab0e872c0e6013836170bb78705a81 Author: Reid Kleckner <rnk@google.com> Date: Tue Feb 6 00:47:14 2018 +0000 Revert "Don't assume a null GV is local for ELF and MachO." BUG= chromium:820140 BUG= chromium:815357 BUG=b:74090329 TEST="USE=llvm-next" sudo emerge llvm works. Change-Id: I67d2215dd47dc9ada2381b8817b485c9f8a0d107 Reviewed-on: https://chromium-review.googlesource.com/957474 Commit-Ready: Manoj Gupta <manojgupta@chromium.org> Tested-by: Manoj Gupta <manojgupta@chromium.org> Reviewed-by: Yunlian Jiang <yunlian@chromium.org> [add] https://crrev.com/20d214bc1b568d202de358041734f83ab3eb6bf0/sys-devel/llvm/files/cherry/30f9051d7d8b6f56c8149fd1bdcc714285f77527.patch [add] https://crrev.com/20d214bc1b568d202de358041734f83ab3eb6bf0/sys-devel/llvm/files/cherry/98079e294f718c14d25ccf30ab2b1938780ffe4d.patch [add] https://crrev.com/20d214bc1b568d202de358041734f83ab3eb6bf0/sys-devel/llvm/files/cherry/284236c047631c8b0eabac3ddd3d0c95253f4361.patch [rename] https://crrev.com/20d214bc1b568d202de358041734f83ab3eb6bf0/sys-devel/llvm/llvm-6.0_pre321490_p20180131-r7.ebuild [add] https://crrev.com/20d214bc1b568d202de358041734f83ab3eb6bf0/sys-devel/llvm/files/cherry/ffaaef68dbab0e872c0e6013836170bb78705a81.patch
,
Mar 13 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/655a49d1a7385c14f9822a39673970a05b41a00c commit 655a49d1a7385c14f9822a39673970a05b41a00c Author: Manoj Gupta <manojgupta@google.com> Date: Tue Mar 13 04:03:06 2018 llvm-next Update to r326829. Update llvm-next to current crosstool version. In addition, add a few cherry picks to fix issues related to Linxu kernel: 1. PLT relocations: r327198. 2. Increased stack usage: r327192 and r327229. Note: Does not affect the current llvm used in Chrome OS. BUG= chromium:817628 BUG= chromium:820140 BUG=chromium:815537 TEST=USE="llvm-next" sudo emerge llvm lld works. Change-Id: I436d578030775b3ffbccb246dbd43394452e67a3 Reviewed-on: https://chromium-review.googlesource.com/957790 Trybot-Ready: Manoj Gupta <manojgupta@chromium.org> Commit-Queue: Manoj Gupta <manojgupta@chromium.org> Tested-by: Manoj Gupta <manojgupta@chromium.org> Reviewed-by: Luis Lozano <llozano@chromium.org> [add] https://crrev.com/655a49d1a7385c14f9822a39673970a05b41a00c/sys-devel/llvm/files/cherry/8fdc88794b44e70bdb93c6cf04baf3c1e3251d8b.patch [delete] https://crrev.com/bd99bff64464733038e8b5cdc488fd9f4941aea6/sys-devel/llvm/files/cherry/98079e294f718c14d25ccf30ab2b1938780ffe4d.patch [rename] https://crrev.com/655a49d1a7385c14f9822a39673970a05b41a00c/sys-devel/lld/lld-6.0_pre321490-r3.ebuild [delete] https://crrev.com/bd99bff64464733038e8b5cdc488fd9f4941aea6/sys-devel/llvm/files/cherry/30f9051d7d8b6f56c8149fd1bdcc714285f77527.patch [delete] https://crrev.com/bd99bff64464733038e8b5cdc488fd9f4941aea6/sys-devel/llvm/files/cherry/16748767563bb9bcb1e1c3e42c35d44924d464d0.patch [rename] https://crrev.com/655a49d1a7385c14f9822a39673970a05b41a00c/sys-devel/llvm/llvm-6.0_pre321490_p20180131-r9.ebuild [add] https://crrev.com/655a49d1a7385c14f9822a39673970a05b41a00c/sys-devel/llvm/files/cherry/824eedb9eb4888575924b1ed80c4250dddd5b59b.patch [delete] https://crrev.com/bd99bff64464733038e8b5cdc488fd9f4941aea6/sys-devel/llvm/files/cherry/284236c047631c8b0eabac3ddd3d0c95253f4361.patch [rename] https://crrev.com/655a49d1a7385c14f9822a39673970a05b41a00c/sys-libs/compiler-rt/compiler-rt-6.0_pre321490-r5.ebuild [delete] https://crrev.com/bd99bff64464733038e8b5cdc488fd9f4941aea6/sys-devel/llvm/files/cherry/ffaaef68dbab0e872c0e6013836170bb78705a81.patch [add] https://crrev.com/655a49d1a7385c14f9822a39673970a05b41a00c/sys-devel/llvm/files/cherry/c28eb6d02c5cedd40b02aa7c496f13a71763312e.patch
,
Mar 17 2018
|
|||||||||||||||||||||||||
►
Sign in to add a comment |
|||||||||||||||||||||||||
Comment 1 by manojgupta@chromium.org
, Mar 8 2018Labels: OS-Chrome