[llvm-objcopy][ELF] Preserve sh_link to .symtab when applicable
authorAndrew Ng <andrew.ng@sony.com>
Wed, 17 May 2023 18:20:59 +0000 (19:20 +0100)
committerAndrew Ng <andrew.ng@sony.com>
Tue, 6 Jun 2023 13:35:04 +0000 (14:35 +0100)
commit744e589caa20f214c586bb70ed53769f93c9cb27
tree66311eb400ab0d6734a58cd8f50426dab2eabf94
parente4a589ba5dbd426d30d945ebf8210c8d5114f5b9
[llvm-objcopy][ELF] Preserve sh_link to .symtab when applicable

This change to llvm-objcopy preserves the ELF section sh_link to .symtab
so long as none of the symbol table indices have been changed.
Previously, any invocation of llvm-objcopy including a "no-op" would
clear any section sh_link to .symtab.

Differential Revision: https://reviews.llvm.org/D150859
lld/test/ELF/icf-safe.s
llvm/lib/ObjCopy/ELF/ELFObject.cpp
llvm/lib/ObjCopy/ELF/ELFObject.h
llvm/test/tools/llvm-objcopy/ELF/symtab-link.test