Open serge-sans-paille opened 2 weeks ago
:white_check_mark: With the latest revision this PR passed the C/C++ code formatter.
the buildkite failure seems unrelated
I am on the fence whether there should be an error (which will set the exit code to 1 and suppress the output).
One use case for --add-section
is to create intentionally invalid object files to test consumers.
While we can check SHT_NOTE, it's not practical to check other section types.
In addition, GNU objcopy doesn't verify the added .note
.
Thanks for the early comments. My use case was very pragamatic: trying to add a note, forgetting about the required padding and then wondering how to improve the situation. I like the idea of the very explicit --add-note-section
that would quite naturally imply a check. @nickclifton do you think we could see that in binutils' objcopy
too? That way we would avoid having (too much) diverging CLI.
@llvm/pr-subscribers-llvm-binary-utilities
Author: None (serge-sans-paille)
Changes
--- Full diff: https://github.com/llvm/llvm-project/pull/90458.diff 2 Files Affected: - (modified) llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp (+64-6) - (added) llvm/test/tools/llvm-objcopy/ELF/add-invalid-note.test (+35) ``````````diff diff --git a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp index f343d1447e0554..90e59a5228d6fe 100644 --- a/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp +++ b/llvm/lib/ObjCopy/ELF/ELFObjcopy.cpp @@ -623,6 +623,58 @@ handleUserSection(const NewSectionInfo &NewSection, return F(NewSection.SectionName, Data); } +static Error verifyNoteSection(StringRef Name, llvm::endianness E, + ArrayRef