summaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/ELFCodeEmitter.cpp
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-06-08 15:36:37 +0000
committered <ed@FreeBSD.org>2009-06-08 15:36:37 +0000
commitde000e339094f8c6e06a635dac9a803861416ec6 (patch)
tree674737fb36b447a4141b2fbaf40d3465434fdfad /lib/CodeGen/ELFCodeEmitter.cpp
parente65fe1a3e103e3aa81b69704d20eb95f54097271 (diff)
downloadFreeBSD-src-de000e339094f8c6e06a635dac9a803861416ec6.zip
FreeBSD-src-de000e339094f8c6e06a635dac9a803861416ec6.tar.gz
Import LLVM r73070.
Now I'm going to stop importing code for a while. I spent a lot of time the last couple of days figuring out which LLVM commit caused g++ to miscompile, which in its turn caused Clang to miscompile the next build. I had to run `make buildworld' twice each time I bisected a revision.
Diffstat (limited to 'lib/CodeGen/ELFCodeEmitter.cpp')
-rw-r--r--lib/CodeGen/ELFCodeEmitter.cpp28
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/CodeGen/ELFCodeEmitter.cpp b/lib/CodeGen/ELFCodeEmitter.cpp
index 9af276b..c7bd873 100644
--- a/lib/CodeGen/ELFCodeEmitter.cpp
+++ b/lib/CodeGen/ELFCodeEmitter.cpp
@@ -73,6 +73,9 @@ bool ELFCodeEmitter::finishFunction(MachineFunction &MF) {
// Add a symbol to represent the function.
ELFSym FnSym(MF.getFunction());
+ // Update Section Size
+ ES->Size = CurBufferPtr - BufferBegin;
+
// Figure out the binding (linkage) of the symbol.
switch (MF.getFunction()->getLinkage()) {
default:
@@ -106,8 +109,29 @@ bool ELFCodeEmitter::finishFunction(MachineFunction &MF) {
// Finally, add it to the symtab.
EW.SymbolTable.push_back(FnSym);
- // Update Section Size
- ES->Size = CurBufferPtr - BufferBegin;
+ // Relocations
+ // -----------
+ // If we have emitted any relocations to function-specific objects such as
+ // basic blocks, constant pools entries, or jump tables, record their
+ // addresses now so that we can rewrite them with the correct addresses
+ // later.
+ 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);
+ MR.setResultPointer((void*)Addr);
+ } else if (MR.isGlobalValue()) {
+ EW.PendingGlobals.insert(MR.getGlobalValue());
+ } else {
+ assert(0 && "Unhandled relocation type");
+ }
+ ES->Relocations.push_back(MR);
+ }
+ Relocations.clear();
+
return false;
}
OpenPOWER on IntegriCloud