[llvm] [llvm-objdump] Error with relevant message when adding invalid notes (PR #90458)

James Henderson via llvm-commits llvm-commits at lists.llvm.org
Wed May 22 00:38:07 PDT 2024


================
@@ -0,0 +1,34 @@
+## Verify that --add-section warns on invalid note sections.
+
+# Add [namesz, descsz, type, name, desc] for a build id.
+#
+# RUN: echo -e -n "\x04\x00\x00\x00" >  %t-miss-padding-note.bin
+# RUN: echo -e -n "\x07\x00\x00\x00" >> %t-miss-padding-note.bin
+# RUN: echo -e -n "\x03\x00\x00\x00" >> %t-miss-padding-note.bin
+# RUN: echo -e -n "GNU\x00"          >> %t-miss-padding-note.bin
+# RUN: echo -e -n "\x0c\x0d\x0e"     >> %t-miss-padding-note.bin
+#
+# RUN: echo -e -n "\x08\x00\x00\x00" >  %t-invalid-size-note.bin
+# RUN: echo -e -n "\x07\x00\x00\x00" >> %t-invalid-size-note.bin
+# RUN: echo -e -n "\x03\x00\x00\x00" >> %t-invalid-size-note.bin
+# RUN: echo -e -n "GNU\x00"          >> %t-invalid-size-note.bin
+# RUN: echo -e -n "\x0c\x0d\x0e\x00" >> %t-invalid-size-note.bin
+
+# RUN: echo -e -n "\x08\x00\x00\x00" >  %t-short-note.bin
+# RUN: echo -e -n "\x07\x00\x00\x00" >> %t-short-note.bin
+
+# RUN: yaml2obj %s -o %t.o
+# 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
----------------
jh7370 wrote:

A more readable order, in my opinion, is:
```
# RUN: yaml2obj ...
# RUN: ... | FileCheck --check-prefix=PREFIX1
# PREFIX1: ...

# RUN: ... | FileCheck --check-prefix=PREFIX2
# PREFIX2: ...

# RUN: ... | FileCheck --check-prefix=PREFIX3
# PREFIX3: ...

!ELF
...
```

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


More information about the llvm-commits mailing list