[ELF][X86] Don't create IBT .plt if there is no PLT entry
authorJoao Moreira <joao.moreira@intel.com>
Sat, 26 Feb 2022 03:55:39 +0000 (03:55 +0000)
committerFangrui Song <i@maskray.me>
Sat, 26 Feb 2022 03:55:40 +0000 (03:55 +0000)
commit9d7001eba9c4cb311e03cd8cdc231f9e579f2d0f
tree9b75870e1e083d977d930fb1c34abffcb0815754
parent2dc6e906b09deb092c15a726c06d0ecbeec1eb18
[ELF][X86] Don't create IBT .plt if there is no PLT entry

https://github.com/ClangBuiltLinux/linux/issues/1606
When GNU_PROPERTY_X86_FEATURE_1_IBT is enabled, ld.lld will create .plt output
section even if there is no PLT entry. Fix this by implementing
IBTPltSection::isNeeded instead of using the default code path (which always
returns true).

Reviewed By: MaskRay

Differential Revision: https://reviews.llvm.org/D120600
lld/ELF/SyntheticSections.cpp
lld/ELF/SyntheticSections.h
lld/test/ELF/format-binary.test
lld/test/ELF/x86-64-feature-cet.s