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
This commit is contained in:
Bruno Cardoso Lopes
2009-06-07 21:22:38 +00:00
parent faeedf1254
commit a029a27fae
6 changed files with 174 additions and 60 deletions
+11 -17
View File
@@ -14,6 +14,7 @@
#ifndef ELFWRITER_H
#define ELFWRITER_H
#include "llvm/ADT/SetVector.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "ELF.h"
#include <list>
@@ -46,35 +47,21 @@ namespace llvm {
protected:
/// Output stream to send the resultant object file to.
///
raw_ostream &O;
/// Target machine description.
///
TargetMachine &TM;
/// Mang - The object used to perform name mangling for this module.
///
Mangler *Mang;
/// MCE - The MachineCodeEmitter object that we are exposing to emit machine
/// code for functions to the .o file.
ELFCodeEmitter *MCE;
//===------------------------------------------------------------------===//
// Properties to be set by the derived class ctor, used to configure the
// ELFWriter.
// e_machine - This field is the target specific value to emit as the
// e_machine member of the ELF header.
unsigned short e_machine;
// e_flags - The machine flags for the target. This defaults to zero.
unsigned e_flags;
//===------------------------------------------------------------------===//
// Properties inferred automatically from the target machine.
//
//===------------------------------------------------------------------===//
/// is64Bit/isLittleEndian - This information is inferred from the target
/// machine directly, indicating whether to emit a 32- or 64-bit ELF file.
@@ -95,6 +82,9 @@ namespace llvm {
// as well!).
DataBuffer FileHeader;
/// ElfHdr - Hold information about the ELF Header
ELFHeader *ElfHdr;
/// SectionList - This is the list of sections that we have emitted to the
/// file. Once the file has been completely built, the section header table
/// is constructed from this info.
@@ -140,6 +130,11 @@ namespace llvm {
/// local symbols first in the list).
std::vector<ELFSym> SymbolTable;
/// PendingSyms - This is a list of externally defined symbols that we have
/// been asked to emit, but have not seen a reference to. When a reference
/// is seen, the symbol will move from this list to the SymbolTable.
SetVector<GlobalValue*> PendingGlobals;
// As we complete the ELF file, we need to update fields in the ELF header
// (e.g. the location of the section table). These members keep track of
// the offset in ELFHeader of these various pieces to update and other
@@ -149,9 +144,8 @@ namespace llvm {
unsigned ELFHdr_e_shnum_Offset; // e_shnum in ELF header.
private:
void EmitGlobal(GlobalVariable *GV);
void EmitSymbolTable();
void EmitRelocations();
void EmitSectionTableStringTable();
void OutputSectionsAndSectionTable();
};