aboutsummaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/ELFCodeEmitter.cpp
diff options
context:
space:
mode:
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>2009-06-22 19:16:16 +0000
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>2009-06-22 19:16:16 +0000
commit0d3193ef3ce7377eeaa1d38ca08f8a62ebcd5f63 (patch)
treea7128bd8b2f69fc709ff68afc5ad43904421822e /lib/CodeGen/ELFCodeEmitter.cpp
parent8dcbbdd00ebb4beb8eeb822791df326eee5de827 (diff)
downloadexternal_llvm-0d3193ef3ce7377eeaa1d38ca08f8a62ebcd5f63.zip
external_llvm-0d3193ef3ce7377eeaa1d38ca08f8a62ebcd5f63.tar.gz
external_llvm-0d3193ef3ce7377eeaa1d38ca08f8a62ebcd5f63.tar.bz2
Add more methods to gather target specific elf stuff
Support for .text relocations, implementing TargetELFWriter overloaded methods for x86/x86_64. Use a map to track global values to their symbol table indexes Code cleanup and small fixes git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73894 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/ELFCodeEmitter.cpp')
-rw-r--r--lib/CodeGen/ELFCodeEmitter.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/lib/CodeGen/ELFCodeEmitter.cpp b/lib/CodeGen/ELFCodeEmitter.cpp
index ca68396..8cb7c94 100644
--- a/lib/CodeGen/ELFCodeEmitter.cpp
+++ b/lib/CodeGen/ELFCodeEmitter.cpp
@@ -71,39 +71,38 @@ bool ELFCodeEmitter::finishFunction(MachineFunction &MF) {
// Update Section Size
ES->Size = CurBufferPtr - BufferBegin;
+ // Set the symbol type as a function
+ FnSym.setType(ELFSym::STT_FUNC);
+ FnSym.SectionIdx = ES->SectionIdx;
+ FnSym.Size = CurBufferPtr-FnStartPtr;
+
+ // Offset from start of Section
+ FnSym.Value = FnStartPtr-BufferBegin;
+
// Figure out the binding (linkage) of the symbol.
switch (MF.getFunction()->getLinkage()) {
default:
// appending linkage is illegal for functions.
assert(0 && "Unknown linkage type!");
case GlobalValue::ExternalLinkage:
- FnSym.SetBind(ELFSym::STB_GLOBAL);
+ FnSym.setBind(ELFSym::STB_GLOBAL);
+ EW.SymbolList.push_back(FnSym);
break;
case GlobalValue::LinkOnceAnyLinkage:
case GlobalValue::LinkOnceODRLinkage:
case GlobalValue::WeakAnyLinkage:
case GlobalValue::WeakODRLinkage:
- FnSym.SetBind(ELFSym::STB_WEAK);
+ FnSym.setBind(ELFSym::STB_WEAK);
+ EW.SymbolList.push_back(FnSym);
break;
case GlobalValue::PrivateLinkage:
assert (0 && "PrivateLinkage should not be in the symbol table.");
case GlobalValue::InternalLinkage:
- FnSym.SetBind(ELFSym::STB_LOCAL);
+ FnSym.setBind(ELFSym::STB_LOCAL);
+ EW.SymbolList.push_front(FnSym);
break;
}
- // Set the symbol type as a function
- FnSym.SetType(ELFSym::STT_FUNC);
-
- FnSym.SectionIdx = ES->SectionIdx;
- FnSym.Size = CurBufferPtr-FnStartPtr;
-
- // Offset from start of Section
- FnSym.Value = FnStartPtr-BufferBegin;
-
- // Finally, add it to the symtab.
- EW.SymbolList.push_back(FnSym);
-
// Relocations
// -----------
// If we have emitted any relocations to function-specific objects such as
@@ -113,7 +112,6 @@ bool ELFCodeEmitter::finishFunction(MachineFunction &MF) {
for (unsigned i = 0, e = Relocations.size(); i != e; ++i) {
MachineRelocation &MR = Relocations[i];
intptr_t Addr;
-
if (MR.isBasicBlock()) {
Addr = getMachineBasicBlockAddress(MR.getBasicBlock());
MR.setConstantVal(ES->SectionIdx);