llvm/test/tools/llvm-objcopy/binary-input-and-output.test
Jordan Rupprecht cd514b66e8 [llvm-objcopy] Add support for -I binary -B <arch>.
Summary:
The -I (--input-target) and -B (--binary-architecture) flags exist but are currently silently ignored. This adds support for -I binary for architectures i386, x86-64 (and alias i386:x86-64), arm, aarch64, sparc, and ppc (powerpc:common64). This is largely based on D41687.

This is done by implementing an additional subclass of Reader, BinaryReader, which works by interpreting the input file as contents for .data field, sets up a synthetic header, and adds additional sections/symbols (e.g. _binary__tmp_data_txt_start).

Reviewers: jakehehrlich, alexshap, jhenderson, javed.absar

Reviewed By: jhenderson

Subscribers: jyknight, nemanjai, kbarton, fedor.sergeev, jrtc27, kristof.beyls, paulsemel, llvm-commits

Differential Revision: https://reviews.llvm.org/D50343

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@340070 91177308-0d34-0410-b5e6-96231b3b80d8
2018-08-17 18:51:11 +00:00

16 lines
539 B
Plaintext

# RUN: echo abcd > %t.txt
# Preserve input to verify it is not modified
# RUN: cp %t.txt %t-copy.txt
# -I binary -O binary preserves payload through in-memory representation
# RUN: llvm-objcopy -I binary -B i386:x86-64 -O binary %t.txt %t.2.txt
# RUN: cmp %t.txt %t.2.txt
# RUN: cmp %t.txt %t-copy.txt
# -I binary -O binary preserves payload through an intermediate object file
# RUN: llvm-objcopy -I binary -B i386:x86-64 %t.txt %t.o
# RUN: llvm-objcopy -O binary %t.o %t.3.txt
# RUN: cmp %t.txt %t.3.txt
# RUN: cmp %t.txt %t-copy.txt