Skip to content

Commit 907d19d

Browse files
committed
---
yaml --- r: 349350 b: refs/heads/master-next c: 266f22f h: refs/heads/master
1 parent 2fe49cc commit 907d19d

File tree

5 files changed

+43
-2
lines changed

5 files changed

+43
-2
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
refs/heads/master: 3574c513bbc5578dd9346b4ea9ab5995c5927bb5
3-
refs/heads/master-next: 4b43e8c60819d0fc1b06a7f21bc79af7c309f656
3+
refs/heads/master-next: 266f22fef107904568f18462caa29148596bbcab
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea
66
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-b: 66d897bfcf64a82cb9a87f5e663d889189d06d07

branches/master-next/lib/IRGen/IRGenModule.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1168,7 +1168,13 @@ void IRGenModule::emitAutolinkInfo() {
11681168
}
11691169
auto EntriesConstant = llvm::ConstantDataArray::getString(
11701170
LLVMContext, EntriesString, /*AddNull=*/false);
1171-
1171+
// Mark the swift1_autolink_entries section with the SHF_EXCLUDE attribute
1172+
// to get the linker to drop it in the final linked binary.
1173+
// LLVM doesn't provide an interface to specify section attributs in the IR
1174+
// so we pass the attribute with inline assembly.
1175+
if (TargetInfo.OutputObjectFormat == llvm::Triple::ELF)
1176+
Module.appendModuleInlineAsm(".section .swift1_autolink_entries,"
1177+
"\"0x80000000\"");
11721178
auto var =
11731179
new llvm::GlobalVariable(*getModule(), EntriesConstant->getType(), true,
11741180
llvm::GlobalValue::PrivateLinkage,

branches/master-next/stdlib/public/runtime/ImageInspectionELF.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
#ifndef SWIFT_RUNTIME_IMAGEINSPECTIONELF_H
2020
#define SWIFT_RUNTIME_IMAGEINSPECTIONELF_H
2121

22+
#define SWIFT_REFLECTION_METADATA_ELF_NOTE_MAGIC_STRING "swift_reflection_metadata_magic_string"
23+
2224
#if defined(__ELF__)
2325

2426
#include "../SwiftShims/Visibility.h"
@@ -54,6 +56,8 @@ struct MetadataSections {
5456
Range swift5_assocty;
5557
Range swift5_replace;
5658
Range swift5_replac2;
59+
Range swift5_builtin;
60+
Range swift5_capture;
5761
};
5862
} // namespace swift
5963

branches/master-next/stdlib/public/runtime/SwiftRT-ELF.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ DECLARE_SWIFT_SECTION(swift5_fieldmd)
3434
DECLARE_SWIFT_SECTION(swift5_assocty)
3535
DECLARE_SWIFT_SECTION(swift5_replace)
3636
DECLARE_SWIFT_SECTION(swift5_replac2)
37+
DECLARE_SWIFT_SECTION(swift5_builtin)
38+
DECLARE_SWIFT_SECTION(swift5_capture)
3739
}
3840

3941
#undef DECLARE_SWIFT_SECTION
@@ -65,10 +67,22 @@ static void swift_image_constructor() {
6567
SWIFT_SECTION_RANGE(swift5_assocty),
6668
SWIFT_SECTION_RANGE(swift5_replace),
6769
SWIFT_SECTION_RANGE(swift5_replac2),
70+
SWIFT_SECTION_RANGE(swift5_builtin),
71+
SWIFT_SECTION_RANGE(swift5_capture),
6872
};
6973

7074
#undef SWIFT_SECTION_RANGE
7175

7276
swift_addNewDSOImage(&sections);
7377
}
7478

79+
__asm__(".section \".note.swift_reflection_metadata\", \"aw\"");
80+
81+
static __attribute__((__used__))
82+
__attribute__((__section__(".note.swift_reflection_metadata")))
83+
__attribute__((__aligned__(1)))
84+
struct {
85+
const char MagicString[sizeof(SWIFT_REFLECTION_METADATA_ELF_NOTE_MAGIC_STRING)];
86+
const swift::MetadataSections *Sections;
87+
} __attribute__((__packed__))
88+
Note = {SWIFT_REFLECTION_METADATA_ELF_NOTE_MAGIC_STRING, &sections};
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %swiftc_driver -emit-ir %s -o - | %FileCheck %s -check-prefix ELF
2+
3+
// Check that the swift auto link section is available in the object file.
4+
// RUN: %swiftc_driver -c %s -o %t
5+
// RUN: llvm-readelf %t -S | %FileCheck %s -check-prefix SECTION
6+
7+
// Checks that the swift auto link section is removed from the final binary.
8+
// RUN: %swiftc_driver -emit-executable %s -o %t
9+
// RUN: llvm-readelf %t -S | %FileCheck %s -check-prefix NOSECTION
10+
11+
// REQUIRES: OS=linux-gnu
12+
13+
print("Hi from Swift!")
14+
15+
// ELF: module asm ".section .swift1_autolink_entries,\220x80000000\22"
16+
// SECTION: .swift1_autolink_entries
17+
// NOSECTION-NOT: .swift1_autolink_entries

0 commit comments

Comments
 (0)