Skip to content

Commit c4afad6

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

File tree

3 files changed

+23
-21
lines changed

3 files changed

+23
-21
lines changed

llvm/docs/CommandGuide/llvm-objcopy.rst

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,10 @@ them.
422422

423423
The default is `default`.
424424

425+
.. option:: --no-verify-note-sections
426+
427+
When adding note sections, do not verify if the section format is valid.
428+
425429
.. option:: --output-target <format>, -O
426430

427431
Write the output as the specified format. See `SUPPORTED FORMATS`_ for a list
@@ -514,12 +518,8 @@ them.
514518

515519
.. option:: --verify-note-sections
516520

517-
When adding note sections, verify if the section format is valid. This flag is
518-
turned on by default for ELF files.
519-
520-
.. option:: --no-verify-note-sections
521-
522-
When adding note sections, do not verify if the section format is valid.
521+
When adding note sections, verify if the section format is valid. On by default
522+
for ELF files.
523523

524524
.. option:: --weaken-symbol <symbol>, -W
525525

llvm/docs/ReleaseNotes.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,9 @@ Changes to the LLVM tools
285285
now has a map for the mapped files. (`#92835
286286
<https://github.com/llvm/llvm-project/pull/92835>`).
287287

288+
* llvm-objcopy now verifies format of ``.note`` sections for ELF input. This can
289+
be disabled by ``--no-verify-note-sections``.
290+
288291
Changes to LLDB
289292
---------------------------------
290293

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

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,22 @@
33
## Add [namesz, descsz, type, name, desc] for a build id.
44

55
## Notes should be padded on 8 bytes.
6-
# RUN: echo -e -n "\x04\x00\x00\x00" > %t-miss-padding-note.bin
7-
# RUN: echo -e -n "\x07\x00\x00\x00" >> %t-miss-padding-note.bin
8-
# RUN: echo -e -n "\x03\x00\x00\x00" >> %t-miss-padding-note.bin
9-
# RUN: echo -e -n "GNU\x00" >> %t-miss-padding-note.bin
10-
# RUN: echo -e -n "\x0c\x0d\x0e" >> %t-miss-padding-note.bin
6+
# RUN: printf "\x04\x00\x00\x00" > %t-miss-padding-note.bin
7+
# RUN: printf "\x07\x00\x00\x00" >> %t-miss-padding-note.bin
8+
# RUN: printf "\x03\x00\x00\x00" >> %t-miss-padding-note.bin
9+
# RUN: printf "GNU\x00" >> %t-miss-padding-note.bin
10+
# RUN: printf "\x0c\x0d\x0e" >> %t-miss-padding-note.bin
1111

1212
## The namesz field bit is incorrect.
13-
# RUN: echo -e -n "\x08\x00\x00\x00" > %t-invalid-size-note.bin
14-
# RUN: echo -e -n "\x07\x00\x00\x00" >> %t-invalid-size-note.bin
15-
# RUN: echo -e -n "\x03\x00\x00\x00" >> %t-invalid-size-note.bin
16-
# RUN: echo -e -n "GNU\x00" >> %t-invalid-size-note.bin
17-
# RUN: echo -e -n "\x0c\x0d\x0e\x00" >> %t-invalid-size-note.bin
13+
# RUN: printf "\x08\x00\x00\x00" > %t-invalid-size-note.bin
14+
# RUN: printf "\x07\x00\x00\x00" >> %t-invalid-size-note.bin
15+
# RUN: printf "\x03\x00\x00\x00" >> %t-invalid-size-note.bin
16+
# RUN: printf "GNU\x00" >> %t-invalid-size-note.bin
17+
# RUN: printf "\x0c\x0d\x0e\x00" >> %t-invalid-size-note.bin
1818

1919
## Missing type field.
20-
# RUN: echo -e -n "\x08\x00\x00\x00" > %t-short-note.bin
21-
# RUN: echo -e -n "\x07\x00\x00\x00" >> %t-short-note.bin
20+
# RUN: printf "\x08\x00\x00\x00" > %t-short-note.bin
21+
# RUN: printf "\x07\x00\x00\x00" >> %t-short-note.bin
2222

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

@@ -32,15 +32,14 @@
3232
# RUN: not llvm-objcopy --add-section=.note.short=%t-short-note.bin %t.o %t-with-note.o 2>&1 | FileCheck --check-prefix=CHECK-SHORT %s
3333
# CHECK-SHORT: .note.short data must be either empty or at least 12 bytes long
3434

35-
## test that verification can be disabled
35+
## Test that verification can be disabled.
3636
# RUN: llvm-objcopy --add-section=.note.short=%t-short-note.bin --no-verify-note-sections %t.o %t-with-note.o
3737

38-
## test that last argument has precedence
38+
## Test that last argument has precedence.
3939
# RUN: llvm-objcopy --add-section=.note.short=%t-short-note.bin --verify-note-sections --no-verify-note-sections %t.o %t-with-note.o
4040

4141
!ELF
4242
FileHeader:
4343
Class: ELFCLASS64
4444
Data: ELFDATA2LSB
4545
Type: ET_REL
46-

0 commit comments

Comments
 (0)