From: kettenis Date: Sun, 23 Apr 2023 21:08:26 +0000 (+0000) Subject: Don't create IBT .plt if there are no PLT entries. Cherry picked from X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=a3cd701e6e5f3719a4f464aecc0f437a5f4de7af;p=openbsd Don't create IBT .plt if there are no PLT entries. Cherry picked from upstream. Fixes several issues including problems with ld.bfd when it sees such a .plt in an object file that is getting linked into a binary. ok deraadt@ --- diff --git a/gnu/llvm/lld/ELF/SyntheticSections.cpp b/gnu/llvm/lld/ELF/SyntheticSections.cpp index 187b2ac90c2..32248aac70d 100644 --- a/gnu/llvm/lld/ELF/SyntheticSections.cpp +++ b/gnu/llvm/lld/ELF/SyntheticSections.cpp @@ -2729,6 +2729,8 @@ size_t IBTPltSection::getSize() const { return 16 + in.plt->getNumEntries() * target->pltEntrySize; } +bool IBTPltSection::isNeeded() const { return in.plt->getNumEntries() > 0; } + // The string hash function for .gdb_index. static uint32_t computeGdbHash(StringRef s) { uint32_t h = 0; diff --git a/gnu/llvm/lld/ELF/SyntheticSections.h b/gnu/llvm/lld/ELF/SyntheticSections.h index bc24922598f..bc79fcdd49f 100644 --- a/gnu/llvm/lld/ELF/SyntheticSections.h +++ b/gnu/llvm/lld/ELF/SyntheticSections.h @@ -769,6 +769,7 @@ class IBTPltSection : public SyntheticSection { public: IBTPltSection(); void writeTo(uint8_t *Buf) override; + bool isNeeded() const override; size_t getSize() const override; };