aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorNate Begeman <natebegeman@mac.com>2006-09-10 23:03:44 +0000
committerNate Begeman <natebegeman@mac.com>2006-09-10 23:03:44 +0000
commit019f851ab26511c089e41b61901f743e75f90714 (patch)
treeea2bc98cabda82ffcb48ff1d0772920df577b1bc /include
parentf369dd26fbc8e3e174be0773fec6bffa80fb6cd4 (diff)
downloadexternal_llvm-019f851ab26511c089e41b61901f743e75f90714.zip
external_llvm-019f851ab26511c089e41b61901f743e75f90714.tar.gz
external_llvm-019f851ab26511c089e41b61901f743e75f90714.tar.bz2
Behold, more work on relocations. Things are looking pretty good now.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@30240 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include')
-rw-r--r--include/llvm/CodeGen/MachOWriter.h47
1 files changed, 36 insertions, 11 deletions
diff --git a/include/llvm/CodeGen/MachOWriter.h b/include/llvm/CodeGen/MachOWriter.h
index bb20f7b..a5e3520 100644
--- a/include/llvm/CodeGen/MachOWriter.h
+++ b/include/llvm/CodeGen/MachOWriter.h
@@ -344,6 +344,10 @@ namespace llvm {
/// SectionData - The actual data for this section which we are building
/// up for emission to the file.
DataBuffer SectionData;
+
+ /// RelocBuffer - A buffer to hold the mach-o relocations before we write
+ /// them out at the appropriate location in the file.
+ DataBuffer RelocBuffer;
/// Relocations - The relocations that we have encountered so far in this
/// section that we will need to convert to MachORelocation entries when
@@ -421,7 +425,7 @@ namespace llvm {
}
MachOSection(const std::string &seg, const std::string &sect)
- : sectname(sect), segname(seg), addr(0), size(0), offset(0), align(0),
+ : sectname(sect), segname(seg), addr(0), size(0), offset(0), align(2),
reloff(0), nreloc(0), flags(0), reserved1(0), reserved2(0),
reserved3(0) { }
};
@@ -449,10 +453,13 @@ namespace llvm {
SN->flags = MachOSection::S_REGULAR | Flags;
return *SN;
}
- MachOSection &getTextSection() {
- return getSection("__TEXT", "__text",
- MachOSection::S_ATTR_PURE_INSTRUCTIONS |
- MachOSection::S_ATTR_SOME_INSTRUCTIONS);
+ MachOSection &getTextSection(bool isCode = true) {
+ if (isCode)
+ return getSection("__TEXT", "__text",
+ MachOSection::S_ATTR_PURE_INSTRUCTIONS |
+ MachOSection::S_ATTR_SOME_INSTRUCTIONS);
+ else
+ return getSection("__TEXT", "__text");
}
MachOSection &getBSSSection() {
return getSection("__DATA", "__bss", MachOSection::S_ZEROFILL);
@@ -479,6 +486,12 @@ namespace llvm {
}
return getSection("__TEXT", "__const");
}
+ MachOSection &getJumpTableSection() {
+ if (TM.getRelocationModel() == Reloc::PIC_)
+ return getTextSection(false);
+ else
+ return getSection("__TEXT", "__const");
+ }
/// MachOSymTab - This struct contains information about the offsets and
/// size of symbol table information.
@@ -563,10 +576,6 @@ namespace llvm {
/// local symbols first in the list).
std::vector<MachOSym> SymbolTable;
- /// RelocBuffer - A buffer to hold the mach-o relocations before we write
- /// them out at the appropriate location in the file.
- DataBuffer RelocBuffer;
-
/// SymT - A buffer to hold the symbol table before we write it out at the
/// appropriate location in the file.
DataBuffer SymT;
@@ -666,15 +675,31 @@ namespace llvm {
outbyte(Output, 0);
}
+ void fixhalf(DataBuffer &Output, unsigned short X, unsigned Offset) {
+ unsigned char *P = &Output[Offset];
+ P[0] = (X >> (isLittleEndian ? 0 : 8)) & 255;
+ P[1] = (X >> (isLittleEndian ? 8 : 0)) & 255;
+ }
+ void fixword(DataBuffer &Output, unsigned X, unsigned Offset) {
+ unsigned char *P = &Output[Offset];
+ P[0] = (X >> (isLittleEndian ? 0 : 24)) & 255;
+ P[1] = (X >> (isLittleEndian ? 8 : 16)) & 255;
+ P[2] = (X >> (isLittleEndian ? 16 : 8)) & 255;
+ P[3] = (X >> (isLittleEndian ? 24 : 0)) & 255;
+ }
+
private:
void AddSymbolToSection(MachOSection &MOS, GlobalVariable *GV);
void EmitGlobal(GlobalVariable *GV);
void EmitHeaderAndLoadCommands();
void EmitSections();
void BufferSymbolAndStringTable();
+ void CalculateRelocations(MachOSection &MOS, unsigned RelOffset);
- virtual void GetTargetRelocation(MachOSection &MOS, MachineRelocation &MR,
- uint64_t Addr) = 0;
+ virtual MachineRelocation GetJTRelocation(unsigned Offset,
+ MachineBasicBlock *MBB) = 0;
+ virtual void GetTargetRelocation(MachineRelocation &MR, MachOSection &MOS,
+ unsigned ToIndex) = 0;
};
}