[llvm] [llvm-objcopy][ELF] Add an option to remove notes (PR #118739)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Thu Dec 12 01:32:15 PST 2024


================
@@ -527,6 +527,37 @@ static Expected<NewSymbolInfo> parseNewSymbolInfo(StringRef FlagValue) {
   return SI;
 }
 
+static Expected<RemoveNoteInfo> parseRemoveNoteInfo(StringRef FlagValue) {
+  // Parse value given with --remove-note option. The format is:
+  //
+  // [name/]type_id
+  //
+  // where:
+  // <name>    - optional note name. If not given, all notes with the specified
+  //             <type_id> are removed.
+  // <type_id> - note type value, can be decimal or hexadecimal number prefixed
+  //             with 0x.
+  RemoveNoteInfo NI;
+  if (FlagValue.empty())
+    return createStringError(errc::invalid_argument,
+                             "bad format for --remove-note, missing type_id");
+  SmallVector<StringRef, 2> Tokens;
+  FlagValue.split(Tokens, '/', /*MaxSplit=*/1);
----------------
jh7370 wrote:

I feel like `/` is quite an unusual character to split on. `:` or `,` seem to be more commonly used in llvm-objcopy (e.g. `,` is used for Mach-O segment/section splitting).

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


More information about the llvm-commits mailing list