Martin Storsjo | e84a0b5 | 2018-12-19 07:24:38 +0000 | [diff] [blame] | 1 | Test plain passthrough copying with llvm-objcopy, by checking that obj2yaml |
| 2 | produces identical output for both input and output object files/executables. |
| 3 | (Intentionally not comparing to the original input yaml, in case there are |
| 4 | superficial differences like line endings.) In order to have a check of the |
| 5 | whole file and not just individual fields with FileCheck, checking with |
| 6 | obj2yaml+cmp instead of llvm-readobj+cmp, as llvm-readobj also prints file |
| 7 | details that can differ between otherwise equal files (such as file offsets). |
| 8 | |
| 9 | Actual copied object files/executables can differ in, among others, the |
| 10 | following aspects: |
| 11 | - The padding of executable sections (lld uses 0xcc, which is int3 on x86) |
| 12 | - The actual layout of the string table (it can be filled linearly, |
| 13 | strings can be dedupliated, the table can be optimized by sharing tails |
| 14 | of longer strings; different parts in llvm do each of these three options) |
| 15 | - The size indication for an empty/missing string table can either be 4 |
| 16 | or left out altogether |
| 17 | - Alignment of section data |
| 18 | - Checksums |
| 19 | |
| 20 | RUN: yaml2obj %p/Inputs/i386-obj.yaml > %t.i386.o |
| 21 | RUN: llvm-objcopy %t.i386.o %t.i386-copy.o |
| 22 | RUN: obj2yaml %t.i386.o > %t.i386.o.yaml |
| 23 | RUN: obj2yaml %t.i386-copy.o > %t.i386-copy.o.yaml |
| 24 | RUN: cmp %t.i386.o.yaml %t.i386-copy.o.yaml |
| 25 | |
| 26 | RUN: yaml2obj %p/Inputs/x86_64-obj.yaml > %t.x86_64.o |
| 27 | RUN: llvm-objcopy %t.x86_64.o %t.x86_64-copy.o |
| 28 | RUN: obj2yaml %t.x86_64.o > %t.x86_64.o.yaml |
| 29 | RUN: obj2yaml %t.x86_64-copy.o > %t.x86_64-copy.o.yaml |
| 30 | RUN: cmp %t.x86_64.o.yaml %t.x86_64-copy.o.yaml |
| 31 | |
| 32 | RUN: yaml2obj %p/Inputs/i386-exe.yaml > %t.i386.exe |
| 33 | RUN: llvm-objcopy %t.i386.exe %t.i386-copy.exe |
| 34 | RUN: obj2yaml %t.i386.exe > %t.i386.exe.yaml |
| 35 | RUN: obj2yaml %t.i386-copy.exe > %t.i386-copy.exe.yaml |
| 36 | RUN: cmp %t.i386.exe.yaml %t.i386-copy.exe.yaml |
| 37 | |
| 38 | RUN: yaml2obj %p/Inputs/x86_64-exe.yaml > %t.x86_64.exe |
| 39 | RUN: llvm-objcopy %t.x86_64.exe %t.x86_64-copy.exe |
| 40 | RUN: obj2yaml %t.x86_64.exe > %t.x86_64.exe.yaml |
| 41 | RUN: obj2yaml %t.x86_64-copy.exe > %t.x86_64-copy.exe.yaml |
| 42 | RUN: cmp %t.x86_64.exe.yaml %t.x86_64-copy.exe.yaml |
Martin Storsjo | d1cc64f | 2019-01-11 13:47:37 +0000 | [diff] [blame] | 43 | |
| 44 | RUN: yaml2obj %p/Inputs/no-symbols.yaml > %t.no-symbols.o |
| 45 | RUN: llvm-objcopy %t.no-symbols.o %t.no-symbols-copy.o |
| 46 | RUN: obj2yaml %t.no-symbols.o > %t.no-symbols.o.yaml |
| 47 | RUN: obj2yaml %t.no-symbols-copy.o > %t.no-symbols-copy.o.yaml |
| 48 | RUN: cmp %t.no-symbols.o.yaml %t.no-symbols-copy.o.yaml |