[llvm] [llvm-objcopy][ELF] Add an option to remove notes (PR #118739)
Igor Kudrin via llvm-commits
llvm-commits at lists.llvm.org
Fri Dec 13 21:21:36 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);
----------------
igorkudrin wrote:
Since most parts of the argument are designed to be optional (see [RFC](https://discourse.llvm.org/t/rfc-llvm-objcopy-feature-for-editing-notes/83491)), the separators should be unique, otherwise, we would end up guessing whether a given token means the section or the originator's name. `:` is often used for sections, so I chose `/` for the note name. I don't have any strict preferences for the delimiters, though.
https://github.com/llvm/llvm-project/pull/118739
More information about the llvm-commits
mailing list