diff options
author | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2009-06-11 19:16:03 +0000 |
---|---|---|
committer | Bruno Cardoso Lopes <bruno.cardoso@gmail.com> | 2009-06-11 19:16:03 +0000 |
commit | c997d45ae5d2e25643d3ccc2c4ae44dcca6cdf5b (patch) | |
tree | bf08515a7ca0c2daa4a84208bb1074e5994e204e /lib/CodeGen/ELFCodeEmitter.cpp | |
parent | 3590abfda093eb5b5e4536727d2e4195400b7716 (diff) | |
download | external_llvm-c997d45ae5d2e25643d3ccc2c4ae44dcca6cdf5b.zip external_llvm-c997d45ae5d2e25643d3ccc2c4ae44dcca6cdf5b.tar.gz external_llvm-c997d45ae5d2e25643d3ccc2c4ae44dcca6cdf5b.tar.bz2 |
Support for ELF Visibility
Emission for globals, using the correct data sections
Function alignment can be computed for each target using TargetELFWriterInfo
Some small fixes
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@73201 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/ELFCodeEmitter.cpp')
-rw-r--r-- | lib/CodeGen/ELFCodeEmitter.cpp | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/lib/CodeGen/ELFCodeEmitter.cpp b/lib/CodeGen/ELFCodeEmitter.cpp index c7bd873..780ec57 100644 --- a/lib/CodeGen/ELFCodeEmitter.cpp +++ b/lib/CodeGen/ELFCodeEmitter.cpp @@ -15,7 +15,6 @@ #include "llvm/Function.h" #include "llvm/CodeGen/MachineConstantPool.h" #include "llvm/CodeGen/MachineJumpTableInfo.h" -#include "llvm/Target/TargetData.h" #include "llvm/Target/TargetMachine.h" #include "llvm/Support/Debug.h" @@ -28,27 +27,21 @@ namespace llvm { /// startFunction - This callback is invoked when a new machine function is /// about to be emitted. void ELFCodeEmitter::startFunction(MachineFunction &MF) { - const TargetData *TD = TM.getTargetData(); - const Function *F = MF.getFunction(); - - // Align the output buffer to the appropriate alignment, power of 2. - unsigned FnAlign = F->getAlignment(); - unsigned TDAlign = TD->getPrefTypeAlignment(F->getType()); - unsigned Align = std::max(FnAlign, TDAlign); - assert(!(Align & (Align-1)) && "Alignment is not a power of two!"); - // Get the ELF Section that this function belongs in. ES = &EW.getTextSection(); + DOUT << "processing function: " << MF.getFunction()->getName() << "\n"; + // FIXME: better memory management, this will be replaced by BinaryObjects ES->SectionData.reserve(4096); BufferBegin = &ES->SectionData[0]; BufferEnd = BufferBegin + ES->SectionData.capacity(); - // Upgrade the section alignment if required. + // Align the output buffer with function alignment, and + // upgrade the section alignment if required + unsigned Align = + TM.getELFWriterInfo()->getFunctionAlignment(MF.getFunction()); if (ES->Align < Align) ES->Align = Align; - - // Round the size up to the correct alignment for starting the new function. ES->Size = (ES->Size + (Align-1)) & (-Align); // Snaity check on allocated space for text section |