Skip to content

Commit

Permalink
Mark start/stop sections as SHF_GNU_RETAIN
Browse files Browse the repository at this point in the history
  • Loading branch information
keith authored and kateinoigakukun committed Feb 6, 2024
1 parent 9ce1baf commit 0e410da
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 14 deletions.
11 changes: 0 additions & 11 deletions lib/Driver/UnixToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -214,17 +214,6 @@ toolchains::GenericUnix::constructInvocation(const DynamicLinkJobAction &job,
#else
Arguments.push_back(context.Args.MakeArgString("-fuse-ld=" + Linker));
#endif
// Starting with lld 13, Swift stopped working with the lld --gc-sections
// implementation for ELF, unless -z nostart-stop-gc is also passed to lld:
//
// https://reviews.llvm.org/D96914
if (Linker == "lld" || (Linker.length() > 5 &&
Linker.substr(Linker.length() - 6) == "ld.lld")) {
Arguments.push_back("-Xlinker");
Arguments.push_back("-z");
Arguments.push_back("-Xlinker");
Arguments.push_back("nostart-stop-gc");
}
}

// Configure the toolchain.
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/runtime/SwiftRT-ELF-WASM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ static const void *__backtraceRef __attribute__((used))
// by the linker. Otherwise, we may end up with undefined symbol references as
// the linker table section was never constructed.
#if defined(__ELF__)
# define DECLARE_EMPTY_METADATA_SECTION(name) __asm__("\t.section " #name ",\"a\"\n");
# define DECLARE_EMPTY_METADATA_SECTION(name) __asm__("\t.section " #name ",\"aR\"\n");
#elif defined(__wasm__)
# define DECLARE_EMPTY_METADATA_SECTION(name) __asm__("\t.section " #name ",\"\",@\n");
#endif
Expand Down
2 changes: 0 additions & 2 deletions test/Driver/link-time-opt.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
// CHECK-SIMPLE-THIN-linux-gnu: clang
// CHECK-SIMPLE-THIN-linux-gnu-DAG: -flto=thin
// CHECK-SIMPLE-THIN-linux-gnu-DAG: -fuse-ld=lld
// CHECK-SIMPLE-THIN-linux-gnu-DAG: -Xlinker -z -Xlinker nostart-stop-gc
// CHECK-SIMPLE-THIN-linux-gnu-DAG: [[BITCODEFILE]]
// CHECK-SIMPLE-THIN-linux-gnu-NOT: swift-autolink-extract

Expand All @@ -36,7 +35,6 @@
// CHECK-SIMPLE-FULL-linux-gnu: clang
// CHECK-SIMPLE-FULL-linux-gnu-DAG: -flto=full
// CHECK-SIMPLE-FULL-linux-gnu-DAG: -fuse-ld=lld
// CHECK-SIMPLE-FULL-linux-gnu-DAG: -Xlinker -z -Xlinker nostart-stop-gc
// CHECK-SIMPLE-FULL-linux-gnu-DAG: [[BITCODEFILE]]
// CHECK-SIMPLE-FULL-linux-gnu-NOT: swift-autolink-extract

Expand Down

0 comments on commit 0e410da

Please sign in to comment.