[lld] [lld][MachO] Support for -interposable (PR #131813)
John Holdsworth via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 18 09:02:59 PDT 2025
https://github.com/johnno1962 updated https://github.com/llvm/llvm-project/pull/131813
>From a4ca70fe98ed96344aad8b1ff3208a04f0d5fd1b Mon Sep 17 00:00:00 2001
From: John Holdsworth <1786033+johnno1962 at users.noreply.github.com>
Date: Tue, 18 Mar 2025 15:41:17 +0100
Subject: [PATCH] [lld][MachO] Support for -interposable
---
lld/MachO/Config.h | 1 +
lld/MachO/Driver.cpp | 1 +
lld/MachO/Options.td | 1 -
lld/MachO/SymbolTable.cpp | 6 +++---
4 files changed, 5 insertions(+), 4 deletions(-)
diff --git a/lld/MachO/Config.h b/lld/MachO/Config.h
index f8dcc84e4ee1b..629fa2bfd0cb3 100644
--- a/lld/MachO/Config.h
+++ b/lld/MachO/Config.h
@@ -183,6 +183,7 @@ struct Configuration {
bool deadStripDylibs = false;
bool demangle = false;
bool deadStrip = false;
+ bool interposable = false;
bool errorForArchMismatch = false;
bool ignoreAutoLink = false;
// ld64 allows invalid auto link options as long as the link succeeds. LLD
diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index 4f6c9b4ddc798..a335b5750b3de 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -1676,6 +1676,7 @@ bool link(ArrayRef<const char *> argsArr, llvm::raw_ostream &stdoutOS,
// Must be set before any InputSections and Symbols are created.
config->deadStrip = args.hasArg(OPT_dead_strip);
+ config->interposable = args.hasArg(OPT_interposable);
config->systemLibraryRoots = getSystemLibraryRoots(args);
if (const char *path = getReproduceOption(args)) {
diff --git a/lld/MachO/Options.td b/lld/MachO/Options.td
index 9001e85582c12..abc7697fde873 100644
--- a/lld/MachO/Options.td
+++ b/lld/MachO/Options.td
@@ -875,7 +875,6 @@ def setuid_safe : Flag<["-"], "setuid_safe">,
Group<grp_rare>;
def interposable : Flag<["-"], "interposable">,
HelpText<"Indirects access to all to exported symbols in a dylib">,
- Flags<[HelpHidden]>,
Group<grp_rare>;
def multi_module : Flag<["-"], "multi_module">,
Alias<interposable>,
diff --git a/lld/MachO/SymbolTable.cpp b/lld/MachO/SymbolTable.cpp
index a61e60a944fb4..ad48e909903b5 100644
--- a/lld/MachO/SymbolTable.cpp
+++ b/lld/MachO/SymbolTable.cpp
@@ -203,9 +203,9 @@ Defined *SymbolTable::addDefined(StringRef name, InputFile *file,
}
// With -flat_namespace, all extern symbols in dylibs are interposable.
- // FIXME: Add support for `-interposable` (PR53680).
- bool interposable = config->namespaceKind == NamespaceKind::flat &&
- config->outputType != MachO::MH_EXECUTE &&
+ bool interposable = ((config->namespaceKind == NamespaceKind::flat &&
+ config->outputType != MachO::MH_EXECUTE) ||
+ config->interposable) &&
!isPrivateExtern;
Defined *defined = replaceSymbol<Defined>(
s, name, file, isec, value, size, isWeakDef, /*isExternal=*/true,
More information about the llvm-commits
mailing list