55 lines · plain
1## Verify that --add-section warns on invalid note sections.2 3## Add [namesz, descsz, type, name, desc] for a build id.4 5## Notes should be padded to 8 bytes.6# RUN: printf "\004\000\000\000" > %t-miss-padding-note.bin7# RUN: printf "\007\000\000\000" >> %t-miss-padding-note.bin8# RUN: printf "\003\000\000\000" >> %t-miss-padding-note.bin9# RUN: printf "GNU\000" >> %t-miss-padding-note.bin10# RUN: printf "\014\015\016" >> %t-miss-padding-note.bin11 12## The namesz field bit is incorrect.13# RUN: printf "\010\000\000\000" > %t-invalid-size-note.bin14# RUN: printf "\007\000\000\000" >> %t-invalid-size-note.bin15# RUN: printf "\003\000\000\000" >> %t-invalid-size-note.bin16# RUN: printf "GNU\000" >> %t-invalid-size-note.bin17# RUN: printf "\014\015\016\000" >> %t-invalid-size-note.bin18 19## Missing type field.20# RUN: printf "\010\000\000\000" > %t-short-note.bin21# RUN: printf "\007\000\000\000" >> %t-short-note.bin22 23# RUN: yaml2obj %s -o %t.o24 25## Test each invalid note.26# 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 %s27# CHECK-MISS-PADDING: .note.miss.padding data size must be a multiple of 4 bytes28 29# RUN: not llvm-objcopy --add-section=.note.invalid.size=%t-invalid-size-note.bin %t.o %t-with-note.o 2>&1 | FileCheck --check-prefix=CHECK-INVALID-SIZE %s30# CHECK-INVALID-SIZE: .note.invalid.size data size is incompatible with the content of the name and description size fields: expecting 28, found 2031 32# 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 %s33# CHECK-SHORT: .note.short data must be either empty or at least 12 bytes long34 35## Test compatibility with .note.gnu.property, which has 8-byte alignment.36# RUN: printf "\004\000\000\000\100\000\000\000\005\000\000\000\107\116\125\000" > %t-note-gnu-property.bin37# RUN: printf "\002\000\000\300\004\000\000\000\003\000\000\000\000\000\000\000" >> %t-note-gnu-property.bin38# RUN: printf "\001\200\001\300\004\000\000\000\001\000\000\000\000\000\000\000" >> %t-note-gnu-property.bin39# RUN: printf "\001\000\001\300\004\000\000\000\013\000\000\000\000\000\000\000" >> %t-note-gnu-property.bin40# RUN: printf "\002\000\001\300\004\000\000\000\001\000\000\000\000\000\000\000" >> %t-note-gnu-property.bin41# RUN: llvm-objcopy --add-section=.note.gnu.property=%t-note-gnu-property.bin %t.o %t-with-note-gnu-property.o42 43## Test that verification can be disabled.44# RUN: llvm-objcopy --add-section=.note.short=%t-short-note.bin --no-verify-note-sections %t.o %t-with-note.o45 46## Test that last argument has precedence.47# RUN: llvm-objcopy --add-section=.note.short=%t-short-note.bin --verify-note-sections --no-verify-note-sections %t.o %t-with-note.o48# RUN: not llvm-objcopy --add-section=.note.short=%t-short-note.bin --no-verify-note-sections --verify-note-sections %t.o %t-with-note.o 2>&1 | FileCheck --check-prefix=CHECK-SHORT %s49 50!ELF51FileHeader:52 Class: ELFCLASS6453 Data: ELFDATA2LSB54 Type: ET_REL55