[llvm-bugs] [Bug 37473] New: objcopy and strip get rid of the GNU_RELRO program header for binaries produced by lld
via llvm-bugs
llvm-bugs at lists.llvm.org
Tue May 15 11:00:16 PDT 2018
https://bugs.llvm.org/show_bug.cgi?id=37473
Bug ID: 37473
Summary: objcopy and strip get rid of the GNU_RELRO program
header for binaries produced by lld
Product: lld
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: ELF
Assignee: unassignedbugs at nondot.org
Reporter: ppadevski at gmail.com
CC: llvm-bugs at lists.llvm.org
Suppose I have 3 files - f.h, f.cpp and main.cpp. I can add the contents if
necessary. I want to use full RELRO. checkrelro.sh comes from here
http://www.trapkit.de/tools/checkrelro.sh
>mkdir -p build
>
>./c++ -o build/main.o -c -g -fPIC main.cpp
>./c++ -o build/foo.o -c -g -fPIC foo.cpp
>./c++ -o build/libfoo.so -Wl,--hash-style=gnu -Wl,-O2 -Wl,-z,relro -Wl,-z,now -shared build/foo.o
>./c++ -o build/a.out -pie -Wl,--hash-style=gnu -Wl,-O2 -Wl,-z,relro -Wl,-z,now build/main.o -Lbuild -lfoo
>
>
>./checkrelro.sh --file build/libfoo.so
>
>echo 'objcopy --only-keep-debug'
>objcopy --only-keep-debug build/libfoo.so build/libfoo.so.debug
>./checkrelro.sh --file build/libfoo.so
>
>echo 'objcopy -R .gnu_debuglink'
>objcopy -R .gnu_debuglink --add-gnu-debuglink=build/libfoo.so.debug build/libfoo.so
>./checkrelro.sh --file build/libfoo.so
>
>echo 'strip'
>strip build/libfoo.so -o build/libfoo.so.stripped
>./checkrelro.sh --file build/libfoo.so
>./checkrelro.sh --file build/libfoo.so.stripped
>
>
>./checkrelro.sh --file build/a.out
>
>echo 'objcopy --only-keep-debug'
>objcopy --only-keep-debug build/a.out build/a.out.debug
>./checkrelro.sh --file build/a.out
>
>echo 'objcopy -R .gnu_debuglink'
>objcopy -R .gnu_debuglink --add-gnu-debuglink=build/a.out.debug build/a.out
>./checkrelro.sh --file build/a.out
>
>echo 'strip'
>strip build/a.out -o build/a.out.stripped
>./checkrelro.sh --file build/a.out
>./checkrelro.sh --file build/a.out.stripped
With gcc 6.4 and ld.bfd I get
> build/libfoo.so - full RELRO
> objcopy --only-keep-debug
> build/libfoo.so - full RELRO
> objcopy -R .gnu_debuglink
> build/libfoo.so - full RELRO
> strip
> build/libfoo.so - full RELRO
> build/libfoo.so.stripped - full RELRO
> build/a.out - full RELRO
> objcopy --only-keep-debug
> build/a.out - full RELRO
> objcopy -R .gnu_debuglink
> build/a.out - full RELRO
> strip
> build/a.out - full RELRO
> build/a.out.stripped - full RELRO
With gcc 6.4 and ld.lld I get
> build/libfoo.so - full RELRO
> objcopy --only-keep-debug
> build/libfoo.so - full RELRO
> objcopy -R .gnu_debuglink
> build/libfoo.so - no RELRO
> strip
> build/libfoo.so - no RELRO
> build/libfoo.so.stripped - no RELRO
> build/a.out - full RELRO
> objcopy --only-keep-debug
> build/a.out - full RELRO
> objcopy -R .gnu_debuglink
> build/a.out - no RELRO
> strip
> build/a.out - no RELRO
> build/a.out.stripped - no RELRO
It seems that both objcopy and strip get rid of the GNU_RELRO program header
which is very very unfortunate. Is there a remedy for that?
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20180515/4101c92b/attachment-0001.html>
More information about the llvm-bugs
mailing list