Skip to content

Commit 98d9838

Browse files
fixup! [llvm-objcopy] Error with relevant message when adding invalid notes
1 parent b110703 commit 98d9838

File tree

4 files changed

+12
-12
lines changed

4 files changed

+12
-12
lines changed

llvm/docs/CommandGuide/llvm-objcopy.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -512,11 +512,14 @@ them.
512512
specified format. See `SUPPORTED FORMATS`_ for a list of valid ``<format>``
513513
values.
514514

515-
.. option:: --verify-note-sections, --no-verify-note-sections
515+
.. option:: --verify-note-sections
516516

517-
When adding note sections, verify if the section format is valid. Defaults to
518-
``--verify-note-sections``
517+
When adding note sections, verify if the section format is valid. This flag is
518+
turned on by default for ELF files.
519519

520+
.. option:: --no-verify-note-sections
521+
522+
When adding note sections, do not verify if the section format is valid.
520523

521524
.. option:: --weaken-symbol <symbol>, -W
522525

llvm/test/tools/llvm-objcopy/ELF/add-invalid-note.test

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
## Verify that --add-section warns on invalid note sections.
22

3-
# Add [namesz, descsz, type, name, desc] for a build id.
3+
## Add [namesz, descsz, type, name, desc] for a build id.
44

5-
## Notes should be padded on 8 bits
5+
## Notes should be padded on 8 bytes.
66
# RUN: echo -e -n "\x04\x00\x00\x00" > %t-miss-padding-note.bin
77
# RUN: echo -e -n "\x07\x00\x00\x00" >> %t-miss-padding-note.bin
88
# RUN: echo -e -n "\x03\x00\x00\x00" >> %t-miss-padding-note.bin
99
# RUN: echo -e -n "GNU\x00" >> %t-miss-padding-note.bin
1010
# RUN: echo -e -n "\x0c\x0d\x0e" >> %t-miss-padding-note.bin
1111

12-
## The namesz field bit is incorrect
12+
## The namesz field bit is incorrect.
1313
# RUN: echo -e -n "\x08\x00\x00\x00" > %t-invalid-size-note.bin
1414
# RUN: echo -e -n "\x07\x00\x00\x00" >> %t-invalid-size-note.bin
1515
# RUN: echo -e -n "\x03\x00\x00\x00" >> %t-invalid-size-note.bin
1616
# RUN: echo -e -n "GNU\x00" >> %t-invalid-size-note.bin
1717
# RUN: echo -e -n "\x0c\x0d\x0e\x00" >> %t-invalid-size-note.bin
1818

19-
## Missing type field
19+
## Missing type field.
2020
# RUN: echo -e -n "\x08\x00\x00\x00" > %t-short-note.bin
2121
# RUN: echo -e -n "\x07\x00\x00\x00" >> %t-short-note.bin
2222

2323
# RUN: yaml2obj %s -o %t.o
2424

25-
## test each invalid note
25+
## Test each invalid note.
2626
# RUN: not llvm-objcopy --add-section=.note.miss.padding=%t-miss-padding-note.bin %t.o %t-with-note.o 2>&1 | FileCheck --check-prefix=CHECK-MISS-PADDING %s
2727
# CHECK-MISS-PADDING: .note.miss.padding data size must be a multiple of 4 bytes
2828

llvm/tools/llvm-objcopy/ObjcopyOptions.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -950,10 +950,8 @@ objcopy::parseObjcopyOptions(ArrayRef<const char *> RawArgsArr,
950950
: DiscardType::Locals;
951951
}
952952

953-
const bool ShouldVerifyNoteSectionsByDefault = true;
954953
ELFConfig.VerifyNoteSections = InputArgs.hasFlag(
955-
OBJCOPY_verify_note_sections, OBJCOPY_no_verify_note_sections,
956-
ShouldVerifyNoteSectionsByDefault);
954+
OBJCOPY_verify_note_sections, OBJCOPY_no_verify_note_sections, true);
957955

958956
Config.OnlyKeepDebug = InputArgs.hasArg(OBJCOPY_only_keep_debug);
959957
ELFConfig.KeepFileSymbols = InputArgs.hasArg(OBJCOPY_keep_file_symbols);

llvm/tools/llvm-objcopy/ObjcopyOpts.td

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ multiclass B<string name, string help1, string help2> {
55
def no_ # NAME: Flag<["--"], "no-" # name>, HelpText<help2>;
66
}
77

8-
98
defm binary_architecture
109
: Eq<"binary-architecture", "Ignored for compatibility">;
1110
def B : JoinedOrSeparate<["-"], "B">,

0 commit comments

Comments
 (0)