84a1b114cd
This CL pulls out the refactorings used to support the new MachOWriter in a followup CL to allow them to be reviewed separately. Rename Elf -> ElfWriter. Also rename model classes used by ElfWriter for concepts that exist both in ELF and Mach-O to ElfX. For example, the old ELF-specific SymbolTable is renamed to ElfSymbolTable. Adds SharedObjectWriter to serve as a base class for both ElfWriter and the upcoming MachOWriter. Adds a new AbstractWriteStream that serves as a common superclass of both BaseWriteStream and SharedObjectWriter::WriteStream and allows the creation of fully delegating WriteStreams that do not maintain a local buffer. Abstract the old Elf::SymbolData class into SharedObjectWriter::SymbolData, which stores an enum value as the type of the symbol instead of storing the ELF encoding of the type. Rename the DwarfElfStream (which actually wasn't ELF specific, as all the ELF-specific DWARF information is handled by ElfWriter) to DwarfSharedObjectStream and put it in a separate header file. Rename Image::compiled_to_elf() to Image::compiled_to_shared_object() and add a separate Image::compiled_to_elf() that checks for the ELF magic value at the DSO base. Also add Image::shared_object_start() and Image::build_id_start() to return pointers to the DSO base and the build ID note, respectively. Refactor Image::build_id() and Image::build_id_length() to check compiled_for_elf() prior to decoding the data pointed to by build_id_start() as an ELF note section. Create an AOTSnapshotType enum to specific the snapshot writer to use in CreateAppAOTSnapshot instead of using an as_elf boolean. TEST=refactorings, so existing tests on ci Change-Id: Ia3ab37a4dff93b6e00390b123753be5a51fbdaaa Cq-Include-Trybots: luci.dart.try:vm-aot-linux-debug-x64-try,vm-aot-mac-release-arm64-try,vm-aot-dwarf-linux-product-x64-try,vm-linux-debug-x64-try,vm-mac-debug-arm64-try Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/421301 Reviewed-by: Ryan Macnak <rmacnak@google.com> Commit-Queue: Tess Strickland <sstrickl@google.com>