xref: /llvm-project/llvm/test/tools/llvm-objcopy/ELF/binary-output-empty.test (revision b2702d6a45016b24bed936901c183a5b1851858a)
1*b2702d6aSJordan Rupprecht# RUN: yaml2obj %s -o %t.o
2*b2702d6aSJordan Rupprecht
3*b2702d6aSJordan Rupprecht# Writing an empty output to a non-existent file will still create it.
4*b2702d6aSJordan Rupprecht# RUN: rm -f %t-new.txt
5*b2702d6aSJordan Rupprecht# RUN: llvm-objcopy -R .text -O binary %t.o %t-new.txt
6*b2702d6aSJordan Rupprecht# RUN: wc -c %t-new.txt | FileCheck %s
7*b2702d6aSJordan Rupprecht
8*b2702d6aSJordan Rupprecht# Writing an empty output to an existing file will truncate it.
9*b2702d6aSJordan Rupprecht# RUN: echo abcd > %t-existing.txt
10*b2702d6aSJordan Rupprecht# RUN: llvm-objcopy -R .text -O binary %t.o %t-existing.txt
11*b2702d6aSJordan Rupprecht# RUN: wc -c %t-existing.txt | FileCheck %s
12*b2702d6aSJordan Rupprecht
13*b2702d6aSJordan Rupprecht# In both cases, the file should be empty.
14*b2702d6aSJordan Rupprecht# CHECK: 0
15*b2702d6aSJordan Rupprecht
16*b2702d6aSJordan Rupprecht!ELF
17*b2702d6aSJordan RupprechtFileHeader:
18*b2702d6aSJordan Rupprecht  Class:           ELFCLASS64
19*b2702d6aSJordan Rupprecht  Data:            ELFDATA2LSB
20*b2702d6aSJordan Rupprecht  Type:            ET_EXEC
21*b2702d6aSJordan Rupprecht  Machine:         EM_X86_64
22*b2702d6aSJordan RupprechtSections:
23*b2702d6aSJordan Rupprecht  - Name:            .text
24*b2702d6aSJordan Rupprecht    Type:            SHT_PROGBITS
25*b2702d6aSJordan Rupprecht    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ]
26*b2702d6aSJordan Rupprecht    Content:         "c3c3c3c3"
27*b2702d6aSJordan Rupprecht    Size:            0x1000
28