strip removes the section name GNU_RELRO from binaries linked with LLD. |
||||
Issue description
When link with LLD, I have a binary with following sections,
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
PHDR 0x0000000000000040 0x0000000000000040 0x0000000000000040
0x00000000000002a0 0x00000000000002a0 R 8
INTERP 0x00000000000002e0 0x00000000000002e0 0x00000000000002e0
0x000000000000001c 0x000000000000001c R 1
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x00000000019e3ed0 0x00000000019e3ed0 R 1000
LOAD 0x00000000019e4000 0x00000000019e4000 0x00000000019e4000
0x0000000006a84f60 0x0000000006a84f60 R E 1000
LOAD 0x0000000008469000 0x0000000008469000 0x0000000008469000
0x00000000006b8138 0x0000000000910964 RW 1000
TLS 0x00000000084f0000 0x00000000084f0000 0x00000000084f0000
0x0000000000000010 0x0000000000000020 R 8
DYNAMIC 0x0000000008af4a58 0x0000000008af4a58 0x0000000008af4a58
0x0000000000000350 0x0000000000000350 RW 8
GNU_RELRO 0x00000000084f0000 0x00000000084f0000 0x00000000084f0000
0x0000000000631138 0x0000000000632000 R 1
GNU_EH_FRAME 0x00000000019e38a8 0x00000000019e38a8 0x00000000019e38a8
0x00000000000000dc 0x00000000000000dc R 1
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 0
NOTE 0x00000000000002fc 0x00000000000002fc 0x00000000000002fc
0x0000000000000020 0x0000000000000020 R 4
NOTE 0x0000000000b04ef8 0x0000000000b04ef8 0x0000000000b04ef8
0x0000000000000024 0x0000000000000024 R 4
After striping it out, it turns
Program Headers:
Type Offset VirtAddr PhysAddr
FileSiz MemSiz Flags Align
PHDR 0x0000000000000040 0x0000000000000040 0x0000000000000040
0x00000000000002a0 0x00000000000002a0 R 8
INTERP 0x00000000000002e0 0x00000000000002e0 0x00000000000002e0
0x000000000000001c 0x000000000000001c R 1
[Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
LOAD 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x00000000019e3ed0 0x00000000019e3ed0 R 1000
LOAD 0x00000000019e4000 0x00000000019e4000 0x00000000019e4000
0x0000000006a84f60 0x0000000006a84f60 R E 1000
LOAD 0x0000000008469000 0x0000000008469000 0x0000000008469000
0x00000000006b8138 0x0000000000910964 RW 1000
TLS 0x00000000084f0000 0x00000000084f0000 0x00000000084f0000
0x0000000000000010 0x000000000000001c R 8
DYNAMIC 0x0000000008af4a58 0x0000000008af4a58 0x0000000008af4a58
0x0000000000000350 0x0000000000000350 RW 8
NULL 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 0
GNU_EH_FRAME 0x00000000019e38a8 0x00000000019e38a8 0x00000000019e38a8
0x00000000000000dc 0x00000000000000dc R 1
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
0x0000000000000000 0x0000000000000000 RW 0
NOTE 0x00000000000002fc 0x00000000000002fc 0x00000000000002fc
0x0000000000000020 0x0000000000000020 R 4
NOTE 0x0000000000b04ef8 0x0000000000b04ef8 0x0000000000b04ef8
0x0000000000000024 0x0000000000000024 R 4
Not that the GNU_RELRO becomes NULL, this makes the platform_ToolchainOptions test fail.
,
Feb 5 2018
I tried to debug it last Friday but have not ping point the real problem. From https://bugs.chromium.org/p/chromium/issues/detail?id=742655#c4, Android has made this switch. Currently we only want to use eu-strip for chrome linked with lld. We may switch to llvm-strip in the future if it is ready.
,
Feb 5 2018
if we're only changing the chrome ebuild to use eu-strip, that'd be fine from a reliability aspect, especially since it's the only thing currently using lld are there plans to change CrOS in general to use lld by default ? i.e. is there an open bug we can make this a blocker of so we don't forget ?
,
Feb 5 2018
Currently we do not have plan to use lld by default. This is a bug entry about using lld to link chrome for linux in crbug.com/607968 and it seems the migration for linux is completed.
,
Feb 5 2018
migrating to LLD for everything is a long term goal. So, yes, we should file a bug with P=3. For now, we only care about Chrome.
,
Feb 5 2018
Just filed a bug and used our new component for bugs in crbug.com/809268
,
Feb 7 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/3fc71d6766e169da97ec345059e273aca8d94af8 commit 3fc71d6766e169da97ec345059e273aca8d94af8 Author: Yunlian Jiang <yunlian@chromium.org> Date: Wed Feb 07 02:18:57 2018 re-enable USE=utils for elfutils on host This reverts commit ee1c59430d09cc7d98475ab411800d94928f8edb. Reason for revert: We want to use eu-strip because strip from binutils has a bug to strip binaries linked with lld. crbug.com/808262 Original change's description: > profile: set USE=-utils for elfutils on host. > > We want to get rid of elfutils because it cannot be built with > clang. Removing the utils provided by it is the first step. > > BUG=chromium:217722 > TEST=cbuildbot chromiumos-sdk > > Change-Id: I18e126fe0ab82dc77509c107d700ef185b79f49d > Reviewed-on: https://chromium-review.googlesource.com/609403 > Commit-Ready: Yunlian Jiang <yunlian@chromium.org> > Tested-by: Yunlian Jiang <yunlian@chromium.org> > Reviewed-by: Mike Frysinger <vapier@chromium.org> BUG= chromium:808262 TEST=sudo emerge elfutils eu-strip works on binaries linked with lld. Change-Id: I0d3c9b1c45283c0ecaec25018ec3f43745c7341e Reviewed-on: https://chromium-review.googlesource.com/901923 Commit-Ready: Yunlian Jiang <yunlian@chromium.org> Tested-by: Yunlian Jiang <yunlian@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org> [modify] https://crrev.com/3fc71d6766e169da97ec345059e273aca8d94af8/profiles/targets/sdk/package.use
,
Feb 9 2018
,
Mar 8 2018
,
Mar 9 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/dfe6945d9426165a53a45534341f35391af6e652 commit dfe6945d9426165a53a45534341f35391af6e652 Author: Yunlian Jiang <yunlian@chromium.org> Date: Fri Mar 09 01:01:09 2018 chromeos-chrome: use eu-strip when USE="lld" is set. 'strip' from binutils has a bug and it messed up the elf program header when a binary is linked with LLD. As a workaround, use eu-strip instead. BUG= chromium:808262 TEST=USE="-gold lld" emerge-samus chromeos-chrome Change-Id: Ie8a7c6ca0198716ba9e69be58dde4478c63f66d9 Reviewed-on: https://chromium-review.googlesource.com/956009 Commit-Ready: Yunlian Jiang <yunlian@chromium.org> Tested-by: Yunlian Jiang <yunlian@chromium.org> Reviewed-by: Manoj Gupta <manojgupta@chromium.org> [modify] https://crrev.com/dfe6945d9426165a53a45534341f35391af6e652/chromeos-base/chromeos-chrome/chromeos-chrome-9999.ebuild
,
Mar 10 2018
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/chromite/+/2cb91dc6dfcb35c330f909c8be2f7d46333362ac commit 2cb91dc6dfcb35c330f909c8be2f7d46333362ac Author: Yunlian Jiang <yunlian@chromium.org> Date: Sat Mar 10 01:39:25 2018 cros_setup_toolchain: add elfutils to sdk. We want to use eu-strip to strip chrome binary, so we need to add elfutils to chrome_sdk to make simple chrome work. BUG= chromium:808262 TEST=cbuildbot chromiumos-sdk Change-Id: I66f36fd057861ba56199d6bbb39d9566b978be69 Reviewed-on: https://chromium-review.googlesource.com/955887 Commit-Ready: Yunlian Jiang <yunlian@chromium.org> Tested-by: Yunlian Jiang <yunlian@chromium.org> Reviewed-by: Caroline Tice <cmtice@chromium.org> [modify] https://crrev.com/2cb91dc6dfcb35c330f909c8be2f7d46333362ac/scripts/cros_setup_toolchains.py
,
Mar 20 2018
can this be closed now?
,
Mar 20 2018
,
Sep 2
The following revision refers to this bug: https://chromium.googlesource.com/chromiumos/overlays/chromiumos-overlay/+/bcbd65eae99e526d842b6629146b3d9f35d7d497 commit bcbd65eae99e526d842b6629146b3d9f35d7d497 Author: Yunlian Jiang <yunlian@google.com> Date: Sun Sep 02 01:33:46 2018 chromeos-chrome: use 'strip' instead of 'eu-strip' with LLD. Previously we changed to use eu-strip when using LLD to link chrome. This is because using 'strip' corrupts the GNU_RELRO part of program header. However, using eu-strip makes the dump_syms crash and we could not get the valid breakpad symbol files. Using 'strip' from binutils works fine in this case. I verified that the error reported in the bug was gone, probably it is becaues we upgraded LLD after the bug was reported. We also remove the link flag -Wl,--no-rosegment because we added that in the LLD wrapper already. BUG= chromium:808262 TEST=USE="-gold lld" emerge-samus chromeos-chrome checked the output of readelf -l on stripped chrome binary, the GNU_RELRO part is still there. cros_generate_breakpad_symbols --board samus /build/samus/opt/google/chrome/chrome it generates valid symbol files. Change-Id: I54f604d5e3b3be2a92335c8f8a83931ff997f465 Reviewed-on: https://chromium-review.googlesource.com/1200323 Commit-Ready: Yunlian Jiang <yunlian@chromium.org> Tested-by: Yunlian Jiang <yunlian@chromium.org> Reviewed-by: Manoj Gupta <manojgupta@chromium.org> [modify] https://crrev.com/bcbd65eae99e526d842b6629146b3d9f35d7d497/chromeos-base/chromeos-chrome/chromeos-chrome-9999.ebuild |
||||
►
Sign in to add a comment |
||||
Comment 1 by vapier@chromium.org
, Feb 5 2018