llvm-project/llvm/test/tools
Jake Ehrlich 76e9110f3d [llvm-objcopy] Refactor llvm-objcopy to use reader and writer objects
While writing code for input and output formats in llvm-objcopy it became
apparent that there was a code health problem. This change attempts to solve
that problem by refactoring the code to use Reader and Writer objects that can
read in different objects in different formats, convert them to a single shared
internal representation, and then write them to any other representation.

New classes:
Reader: the base class used to construct instances of the internal
representation
Writer: the base class used to write out instances of the internal
representation
ELFBuilder: a helper class for ELFWriter that takes an ELFFile and converts it
to a Object
SectionVisitor: it became necessary to remove writeSection from SectionBase
because, under the new Reader/Writer scheme, it's possible to convert between
ELF Types such as ELF32LE and ELF32BE. This isn't possible with writeSection
because it (dynamically) depends on the underlying section type *and*
(statically) depends on the ELF type. Bad things would happen if the underlying
sections for ELF32LE were used for writing to ELF64BE. To avoid this code smell
(which would have compiled, run, and output some nonsesnse) I decoupled writing
of sections from a class.
SectionWriter: This is just the ELFT templated implementation of
SectionVisitor. Many classes now have this class as a friend so that the
writing methods in this class can write out private data.
ELFWriter: This is the Writer that outputs to ELF
BinaryWriter: This is the Writer that outputs to Binary
ElfType: Because the ELF Type is not a part of the Object anymore we need a way
to construct the correct default Writer based on properties of the Reader. This
enum just keeps track of the ELF type of the input so it can be used as the
default output type as well.

Object has correspondingly undergone some serious changes as well. It now has
more generic methods for building and manipulating ELF binaries. This interface
makes ELFBuilder easy enough to use and will make the BinaryReader/Builder easy
to create as well. Most changes in this diff are cosmetic and deal with the
fact that a method has been moved from one class to another or a change from a
pointer to a reference. Almost no changes should result in a functional
difference (this is after all a refactor). One minor functional change was made
and the result can be seen in remove-shstrtab-error.test. The fact that it
fails hasn't changed but the error message has changed because that failure is
detected at a later point in the code now (because WriteSectionHeaders is a
property of the ElfWriter *not* a property of the Object). I'd say roughly
80-90% of this code is cosmetically different, 10-19% is different but
functionally the same, and 1-5% is functionally different despite not causing a
change in tests.

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

llvm-svn: 323480
2018-01-25 22:46:17 +00:00
..
dsymutil [DebugInfo] Unify dumping of address ranges 2018-01-16 11:17:57 +00:00
gold Make GlobalValues with non-default visibilility dso_local. 2018-01-18 02:08:23 +00:00
llvm-ar [llvm-ar] Support an options string that start with a dash 2017-11-03 20:09:10 +00:00
llvm-cfi-verify/X86 [CodeGen] Unify MBB reference format in both MIR and debug output 2017-12-04 17:18:51 +00:00
llvm-config [llvm-config] Fix cflags test looking for "warning" 2017-05-30 20:21:47 +00:00
llvm-cov Profiling tests: Endianess XFAIL for powerpc- (32-bit) 2018-01-09 20:09:23 +00:00
llvm-cvtres Fix buffer overrun in WindowsResourceCOFFWriter::writeSymbolTable() 2017-12-18 22:10:14 +00:00
llvm-cxxdump
llvm-cxxfilt c++filt: support COFF import thunks 2017-03-22 21:15:19 +00:00
llvm-dlltool [COFF] Ignore semicolons in module definition identifiers 2017-12-06 19:18:24 +00:00
llvm-dwarfdump [DebugInfo] Unify dumping of address ranges 2018-01-16 11:17:57 +00:00
llvm-dwp llvm-dwarfdump: automatically dump both regular and .dwo variant of sections 2017-09-13 22:09:01 +00:00
llvm-extract [llvm-extract] Support extracting basic blocks 2018-01-23 21:51:34 +00:00
llvm-isel-fuzzer [llvm-isel-fuzzer] Use "--" as separator rather than '='. 2017-10-13 00:18:32 +00:00
llvm-lib [test] Move llvm-lib tests into tools/llvm-lib. NFC. 2017-11-02 20:05:20 +00:00
llvm-lit
llvm-lto Object: Remove ModuleSummaryIndexObjectFile class. 2017-05-01 20:42:32 +00:00
llvm-lto2 Fix the bug that parseAAPipeline is not invoked in runNewPMPasses in release compiler. 2017-08-02 03:03:19 +00:00
llvm-mc
llvm-modextract
llvm-mt [llvm-mt] Remove platform-specific path in test 2018-01-05 18:23:22 +00:00
llvm-nm [WebAssembly] Remove debug names from symbol table 2018-01-17 19:28:43 +00:00
llvm-objcopy [llvm-objcopy] Refactor llvm-objcopy to use reader and writer objects 2018-01-25 22:46:17 +00:00
llvm-objdump [WebAssembly] Remove debug names from symbol table 2018-01-17 19:28:43 +00:00
llvm-opt-fuzzer [llvm-opt-fuzzer] Only run tests for the x86 target. 2017-11-15 13:35:42 +00:00
llvm-opt-report [llvm-opt-report] Fix context-sensitive lines where nothing happened 2017-01-07 20:21:17 +00:00
llvm-pdbdump [pdbutil] Replace 0 byte PDB input with correct version to fix failing unit test 2018-01-17 03:48:07 +00:00
llvm-profdata Profiling tests: Endianess XFAIL for powerpc- (32-bit) 2018-01-09 20:09:23 +00:00
llvm-rc Really fix llvm-rc include-paths.test 2017-10-11 21:27:54 +00:00
llvm-readobj [WebAssembly] Remove debug names from symbol table 2018-01-17 19:28:43 +00:00
llvm-size
llvm-split Make GlobalValues with non-default visibilility dso_local. 2018-01-18 02:08:23 +00:00
llvm-strings [llvm-strings] Add support for the -a/--all options 2017-11-14 19:58:36 +00:00
llvm-symbolizer [llvm-symbolizer] Fix coff-dwarf.test 2017-09-16 19:01:04 +00:00
llvm-xray/X86 [XRay][tools] Support arg1 logging entries in the basic logging mode 2017-10-05 05:18:17 +00:00
lto LTOModule::isBitcodeFile() shouldn't assert when returning false. 2017-10-31 16:39:47 +00:00
obj2yaml [obj2yaml] Don't crash for input files without symbol table 2017-09-22 09:30:40 +00:00
opt-viewer Fix some opt-viewer test issues and disable on Windows. 2018-01-05 22:05:13 +00:00
sancov [sancov] better input parameters validation 2017-03-03 18:22:20 +00:00
sanstats [sanstats] Remove a flaky test. 2017-07-13 01:36:12 +00:00
yaml2obj Add ELF dynamic symbol support to yaml2obj/obj2yaml 2017-11-16 18:10:15 +00:00