[llvm] Add functionality to llvm-objcopy to remove prefixes (PR #79415)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 26 00:14:07 PST 2024


================
@@ -731,7 +731,15 @@ objcopy::parseObjcopyOptions(ArrayRef<const char *> RawArgsArr,
         llvm::crc32(arrayRefFromStringRef(Debug->getBuffer()));
   }
   Config.SplitDWO = InputArgs.getLastArgValue(OBJCOPY_split_dwo);
+
   Config.SymbolsPrefix = InputArgs.getLastArgValue(OBJCOPY_prefix_symbols);
+  Config.SymbolsPrefixRemove =
+      InputArgs.getLastArgValue(OBJCOPY_prefix_symbols_remove);
+  if (!Config.SymbolsPrefix.empty() && !Config.SymbolsPrefixRemove.empty())
+    return createStringError(
+        errc::invalid_argument,
+        "--prefix-symbols and --prefix-symbols-remove are mutualy exclusive");
----------------
jh7370 wrote:

Sorry, I disagree. There is a standard model for handling multiple options in llvm-objcopy (e.g. `--remove-section` and then `--add-section`) which is to perform the subtractive option first and then do the additive one, regardless of the order in which they appear on the command-line, and this isn't significantly different to that style. In other words, in this case you'd apply the (either last value or all, I'd actually consider doing all, in order) prefix remove option before doing the prefix add option. You can mention this in the documentation and enforce the ordering by tests. Honestly, I don't think there's any risk of confusion either, since it's fairly obvious what has happened by simply looking at the names.

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


More information about the llvm-commits mailing list