diff options
author | Nuri Amari <nuri.amari99@gmail.com> | 2024-05-15 09:21:02 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-05-15 09:21:02 -0700 |
commit | 141391ad2f22885342935442642c6c892f43e1ed (patch) | |
tree | 37336c583627103c0fdb9cdc418a95d87117f6dd /llvm/lib/Bitcode/Reader/BitcodeReader.cpp | |
parent | 03c53c69a367008da689f0d2940e2197eb4a955c (diff) | |
download | llvm-141391ad2f22885342935442642c6c892f43e1ed.zip llvm-141391ad2f22885342935442642c6c892f43e1ed.tar.gz llvm-141391ad2f22885342935442642c6c892f43e1ed.tar.bz2 |
[lld] Fix -ObjC load behavior with LTO (#92162)
When -ObjC is passed, the linker must force load any object files that
contain special sections that store Objective-C / Swift information that
is used at runtime.
This should work regadless if input files are bitcode or native, but it
was not working with bitcode. This is because the sections that identify
an object file that should be loaded were inconsistent when dealing with
a native file vs bitcode file. In particular, bitcode files were not
searched for `__TEXT,__swift` prefixed sections, while native files
were.
This means LLD wasn't loading certain bitcode files and forcing the user
to introduce --force-load to their linker invocation for that archive.
Co-authored-by: Nuri Amari <nuriamari@fb.com>
Diffstat (limited to 'llvm/lib/Bitcode/Reader/BitcodeReader.cpp')
-rw-r--r-- | llvm/lib/Bitcode/Reader/BitcodeReader.cpp | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp index 19a1520..e64051c 100644 --- a/llvm/lib/Bitcode/Reader/BitcodeReader.cpp +++ b/llvm/lib/Bitcode/Reader/BitcodeReader.cpp @@ -306,7 +306,8 @@ static Expected<bool> hasObjCCategoryInModule(BitstreamCursor &Stream) { return error("Invalid section name record"); // Check for the i386 and other (x86_64, ARM) conventions if (S.find("__DATA,__objc_catlist") != std::string::npos || - S.find("__OBJC,__category") != std::string::npos) + S.find("__OBJC,__category") != std::string::npos || + S.find("__TEXT,__swift") != std::string::npos) return true; break; } |