Skip to content

Commit 555eaef

Browse files
committed
[target] .swift_ast section is a metadata section
This change ensures that this section is not marked as loadable, which makes it possible for it to be stripped. The swift_ast section holds the raw Swift module bytes that are needed by LLDB, but that are not required at runtime.
1 parent 6025d02 commit 555eaef

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

llvm/lib/Target/TargetLoweringObjectFile.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -213,7 +213,8 @@ SectionKind TargetLoweringObjectFile::getKindForGlobal(const GlobalObject *GO,
213213
// Global variables require more detailed analysis.
214214
const auto *GVar = cast<GlobalVariable>(GO);
215215

216-
if (GVar->getSection() == ".swift1_autolink_entries")
216+
if (GVar->getSection() == ".swift1_autolink_entries" ||
217+
GVar->getSection() == ".swift_ast")
217218
return SectionKind::getMetadata();
218219

219220
// Handle thread-local data first.
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
; RUN: llc -mtriple x86_64-unknown-linux-gnu -filetype asm -o - %s | FileCheck %s
2+
; REQUIRES: x86-registered-target
3+
4+
@__Swift_AST = internal constant [8 x i8] c"test.ast", section ".swift_ast", align 4
5+
@_swift1_autolink_entries = private constant [0 x i8] zeroinitializer, section ".swift1_autolink_entries", no_sanitize_address, align 8
6+
@llvm.used = appending global [2 x ptr] [ptr @__Swift_AST, ptr @_swift1_autolink_entries], section "llvm.metadata"
7+
8+
; CHECK: .section .swift_ast,"R"
9+
; CHECK: .section .swift1_autolink_entries,"eR"

0 commit comments

Comments
 (0)