Test plain passthrough copying with llvm-objcopy, by checking that obj2yaml
produces identical output for both input and output object files/executables.
(Intentionally not comparing to the original input yaml, in case there are
superficial differences like line endings.) In order to have a check of the
whole file and not just individual fields with FileCheck, checking with
obj2yaml+cmp instead of llvm-readobj+cmp, as llvm-readobj also prints file
details that can differ between otherwise equal files (such as file offsets).
Actual copied object files/executables can differ in, among others, the
following aspects:
- The padding of executable sections (lld uses 0xcc, which is int3 on x86)
- The actual layout of the string table (it can be filled linearly,
strings can be dedupliated, the table can be optimized by sharing tails
of longer strings; different parts in llvm do each of these three options)
- The size indication for an empty/missing string table can either be 4
or left out altogether
- Alignment of section data
- Checksums
RUN: yaml2obj %p/Inputs/i386-obj.yaml -o %t.i386.o
RUN: llvm-objcopy %t.i386.o %t.i386-copy.o
RUN: obj2yaml %t.i386.o > %t.i386.o.yaml
RUN: obj2yaml %t.i386-copy.o > %t.i386-copy.o.yaml
RUN: cmp %t.i386.o.yaml %t.i386-copy.o.yaml
RUN: yaml2obj %p/Inputs/x86_64-obj.yaml -o %t.x86_64.o
RUN: llvm-objcopy %t.x86_64.o %t.x86_64-copy.o
RUN: obj2yaml %t.x86_64.o > %t.x86_64.o.yaml
RUN: obj2yaml %t.x86_64-copy.o > %t.x86_64-copy.o.yaml
RUN: cmp %t.x86_64.o.yaml %t.x86_64-copy.o.yaml
RUN: yaml2obj %p/Inputs/i386-exe.yaml -o %t.i386.exe
RUN: llvm-objcopy %t.i386.exe %t.i386-copy.exe
RUN: obj2yaml %t.i386.exe > %t.i386.exe.yaml
RUN: obj2yaml %t.i386-copy.exe > %t.i386-copy.exe.yaml
RUN: cmp %t.i386.exe.yaml %t.i386-copy.exe.yaml
RUN: yaml2obj %p/Inputs/x86_64-exe.yaml -o %t.x86_64.exe
RUN: llvm-objcopy %t.x86_64.exe %t.x86_64-copy.exe
RUN: obj2yaml %t.x86_64.exe > %t.x86_64.exe.yaml
RUN: obj2yaml %t.x86_64-copy.exe > %t.x86_64-copy.exe.yaml
RUN: cmp %t.x86_64.exe.yaml %t.x86_64-copy.exe.yaml
RUN: yaml2obj %p/Inputs/no-symbols.yaml -o %t.no-symbols.o
RUN: llvm-objcopy %t.no-symbols.o %t.no-symbols-copy.o
RUN: obj2yaml %t.no-symbols.o > %t.no-symbols.o.yaml
RUN: obj2yaml %t.no-symbols-copy.o > %t.no-symbols-copy.o.yaml
RUN: cmp %t.no-symbols.o.yaml %t.no-symbols-copy.o.yaml