[ELF] Change sh_link of .rel{,a}.plt to make GNU strip happy
authorFangrui Song <maskray@google.com>
Thu, 1 Nov 2018 22:28:58 +0000 (22:28 +0000)
committerFangrui Song <maskray@google.com>
Thu, 1 Nov 2018 22:28:58 +0000 (22:28 +0000)
commit27d036e9952387dff6eafe009f1769b575148454
tree31400cb0954f4c24159090a2cf78a2f9e73e2f42
parenta1f048d2abe3ee56d5b310b7eb8f038038df802f
[ELF] Change sh_link of .rel{,a}.plt to make GNU strip happy

Summary:
D52830 sets sh_link to .symtab in static link, which breaks executable stripped by GNU strip.
It may also be odd that .rela.plt (SHF_ALLOC) points to .symtab (non-SHF_ALLOC).

Change the logic on pcc's suggestion.

Before:

% clang -fuse-ld=lld -static -xc =(printf 'int main(){}') # or gcc
% strip a.out; ./a.out
unexpected reloc type in static binary[1]    61634 segmentation fault  ./a.out

Reviewers: ruiu, grimar, emaste, espindola

Reviewed By: ruiu

Subscribers: pcc, arichardson, llvm-commits

Differential Revision: https://reviews.llvm.org/D53993

llvm-svn: 345899
lld/ELF/SyntheticSections.cpp
lld/test/ELF/aarch64-gnu-ifunc.s
lld/test/ELF/gnu-ifunc-i386.s
lld/test/ELF/gnu-ifunc.s