[llvm] [llvm-objcopy] Add support of symbol modification flags for MachO (PR #120895)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Mon Dec 23 00:15:41 PST 2024


================
@@ -93,19 +93,38 @@ static void markSymbols(const CommonConfig &, Object &Obj) {
 static void updateAndRemoveSymbols(const CommonConfig &Config,
                                    const MachOConfig &MachOConfig,
                                    Object &Obj) {
-  for (SymbolEntry &Sym : Obj.SymTable) {
-    // Weaken symbols first to match ELFObjcopy behavior.
-    bool IsExportedAndDefined =
-        (Sym.n_type & llvm::MachO::N_EXT) &&
-        (Sym.n_type & llvm::MachO::N_TYPE) != llvm::MachO::N_UNDF;
-    if (IsExportedAndDefined &&
+  Obj.SymTable.updateSymbols([&](SymbolEntry &Sym) {
+    if (Config.SymbolsToSkip.matches(Sym.Name))
+      return;
+
+    if (!Sym.isUndefinedSymbol() && Config.SymbolsToLocalize.matches(Sym.Name))
+      Sym.n_type &= ~llvm::MachO::N_EXT;
----------------
jh7370 wrote:

Nit: is the `llvm::` prefix here and in various other places needed? This code is already inside the `llvm` namespace.

https://github.com/llvm/llvm-project/pull/120895


More information about the llvm-commits mailing list