Skip to content

Commit 5c12c8f

Browse files
compnerdbnbarham
authored andcommitted
Target: explicitly handle .swift1_autolink_entries
This is being applied downstream as the section is not a standard section and this is Swift centric. The longer term solution here is to drop support for gold as a linker as we have done for the BFD linker. With the use of LLD, we can use a LLVM extension to inject linker options into ELF. This has a corresponding change to Swift to remove the previous ELF specific gadget to discard the metadata. rdar://82640394
1 parent 3d87d8a commit 5c12c8f

File tree

2 files changed

+5
-0
lines changed

2 files changed

+5
-0
lines changed

llvm/lib/CodeGen/TargetLoweringObjectFileImpl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -763,6 +763,8 @@ static MCSection *selectExplicitSectionGlobal(
763763
StringRef Group = "";
764764
bool IsComdat = false;
765765
unsigned Flags = getELFSectionFlags(Kind);
766+
if (SectionName == ".swift1_autolink_entries")
767+
Flags |= ELF::SHF_EXCLUDE;
766768
if (const Comdat *C = getELFComdat(GO)) {
767769
Group = C->getName();
768770
IsComdat = C->getSelectionKind() == Comdat::Any;

llvm/lib/Target/TargetLoweringObjectFile.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -215,6 +215,9 @@ SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalObject *GO,
215215
// Global variables require more detailed analysis.
216216
const auto *GVar = cast<GlobalVariable>(GO);
217217

218+
if (GVar->getSection() == ".swift1_autolink_entries")
219+
return SectionKind::getMetadata();
220+
218221
// Handle thread-local data first.
219222
if (GVar->isThreadLocal()) {
220223
if (isSuitableForBSS(GVar) && !TM.Options.NoZerosInBSS) {

0 commit comments

Comments
 (0)