diff options
author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2009-06-07 21:22:38 +0000 |
---|---|---|
committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2009-06-07 21:22:38 +0000 |
commit | a029a27fae25628fa7805aba6d7ae3216a4e026b (patch) | |
tree | 5f353df4c5e7e55748682c997d11b1e0e014f36c /lib/CodeGen/ELFCodeEmitter.h | |
parent | faeedf1254a4f79004cb94c3d2b738f138af450e (diff) | |
download | external_llvm-a029a27fae25628fa7805aba6d7ae3216a4e026b.tar.gz external_llvm-a029a27fae25628fa7805aba6d7ae3216a4e026b.tar.bz2 external_llvm-a029a27fae25628fa7805aba6d7ae3216a4e026b.zip |
Simple ELF32/64 binary files can now be emitted for x86 and x86_64 without
relocation sections.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73038 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/ELFCodeEmitter.h')
-rw-r--r-- | lib/CodeGen/ELFCodeEmitter.h | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/lib/CodeGen/ELFCodeEmitter.h b/lib/CodeGen/ELFCodeEmitter.h index e9ee936a48..c0289daf3e 100644 --- a/lib/CodeGen/ELFCodeEmitter.h +++ b/lib/CodeGen/ELFCodeEmitter.h @@ -20,8 +20,24 @@ namespace llvm { /// emit the code for functions to the ELF file. class ELFCodeEmitter : public MachineCodeEmitter { ELFWriter &EW; + + /// Target machine description TargetMachine &TM; - ELFSection *ES; // Section to write to. + + /// Section containing code for functions + ELFSection *ES; + + /// Relocations - These are the relocations that the function needs, as + /// emitted. + std::vector<MachineRelocation> Relocations; + + /// MBBLocations - This vector is a mapping from MBB ID's to their address. + /// It is filled in by the StartMachineBasicBlock callback and queried by + /// the getMachineBasicBlockAddress callback. + std::vector<uintptr_t> MBBLocations; + + /// FnStartPtr - Pointer to the start location of the current function + /// in the buffer uint8_t *FnStartPtr; public: explicit ELFCodeEmitter(ELFWriter &ew) : EW(ew), TM(EW.TM) {} @@ -30,10 +46,19 @@ namespace llvm { bool finishFunction(MachineFunction &F); void addRelocation(const MachineRelocation &MR) { - assert(0 && "relo not handled yet!"); + Relocations.push_back(MR); } virtual void StartMachineBasicBlock(MachineBasicBlock *MBB) { + if (MBBLocations.size() <= (unsigned)MBB->getNumber()) + MBBLocations.resize((MBB->getNumber()+1)*2); + MBBLocations[MBB->getNumber()] = getCurrentPCOffset(); + } + + virtual uintptr_t getMachineBasicBlockAddress(MachineBasicBlock *MBB) { + assert(MBBLocations.size() > (unsigned)MBB->getNumber() && + MBBLocations[MBB->getNumber()] && "MBB not emitted!"); + return MBBLocations[MBB->getNumber()]; } virtual uintptr_t getConstantPoolEntryAddress(unsigned Index) const { |