Subzero: Add basic ELFObjectWriter (text section, symtab, strtab, headers).
Able to write out the ELF file header w/ a text section,
a symbol table, and string table. Write text buffer
directly to file after translating each CFG.
This means that the header is written out early w/ fake
data and then we seek back and write the real header
at the very end.
Does not yet handle relocations, data, rodata, constant
pools, bss, or -ffunction-sections, more than 64K sections
or more than 2^24 symbols.
Numbers w/ current NOASSERT=1 build on 176.gcc:
w/out -elf-writer:
0.233771 (21.1%): [ 1287] emit
28MB .s file
w/ -elf-writer:
0.051056 ( 5.6%): [ 1287] emit
2.4MB .o file
BUG=none
R=stichnot@chromium.org
Review URL: https://codereview.chromium.org/678533005
diff --git a/src/assembler.cpp b/src/assembler.cpp
index b0bd297..a9516e8 100644
--- a/src/assembler.cpp
+++ b/src/assembler.cpp
@@ -20,7 +20,6 @@
#include "assembler.h"
#include "IceGlobalContext.h"
-#include "IceMemoryRegion.h"
#include "IceOperand.h"
namespace Ice {
@@ -76,25 +75,6 @@
AssemblerBuffer::~AssemblerBuffer() {}
-void AssemblerBuffer::ProcessFixups(const MemoryRegion ®ion) {
- for (SizeT I = 0; I < fixups_.size(); ++I) {
- AssemblerFixup *fixup = fixups_[I];
- fixup->Process(region, fixup->position());
- }
-}
-
-void AssemblerBuffer::FinalizeInstructions(const MemoryRegion &instructions) {
- // Copy the instructions from the buffer.
- MemoryRegion from(reinterpret_cast<void *>(contents()), Size());
- instructions.CopyFrom(0, from);
-
- // Process fixups in the instructions.
- ProcessFixups(instructions);
-#ifndef NDEBUG
- fixups_processed_ = true;
-#endif // !NDEBUG
-}
-
void AssemblerBuffer::ExtendCapacity() {
intptr_t old_size = Size();
intptr_t old_capacity = Capacity();
@@ -123,6 +103,11 @@
assert(Size() == old_size);
}
+llvm::StringRef Assembler::getBufferView() const {
+ return llvm::StringRef(reinterpret_cast<const char *>(buffer_.contents()),
+ buffer_.Size());
+}
+
void Assembler::emitIASBytes(GlobalContext *Ctx) const {
Ostream &Str = Ctx->getStrEmit();
intptr_t EndPosition = buffer_.Size();