summaryrefslogtreecommitdiffstats
path: root/lib/CodeGen/ELFWriter.cpp
diff options
context:
space:
mode:
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>2009-08-13 05:07:35 +0000
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>2009-08-13 05:07:35 +0000
commitb808588a3a5febe931896b3779d159ba90d836f7 (patch)
treee07ae309748105f8a462ce435a66f3412dce5ba6 /lib/CodeGen/ELFWriter.cpp
parent62728dc14d05e9a677664b784c4f5c6e188aa11a (diff)
downloadexternal_llvm-b808588a3a5febe931896b3779d159ba90d836f7.zip
external_llvm-b808588a3a5febe931896b3779d159ba90d836f7.tar.gz
external_llvm-b808588a3a5febe931896b3779d159ba90d836f7.tar.bz2
Change MCSectionELF to represent a section semantically instead of
syntactically as a string, very similiar to what Chris did with MachO. The parsing support and validation is not introduced yet. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@78890 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/ELFWriter.cpp')
-rw-r--r--lib/CodeGen/ELFWriter.cpp36
1 files changed, 20 insertions, 16 deletions
diff --git a/lib/CodeGen/ELFWriter.cpp b/lib/CodeGen/ELFWriter.cpp
index ff41338..4ad2f8b 100644
--- a/lib/CodeGen/ELFWriter.cpp
+++ b/lib/CodeGen/ELFWriter.cpp
@@ -43,7 +43,7 @@
#include "llvm/CodeGen/MachineCodeEmitter.h"
#include "llvm/CodeGen/MachineConstantPool.h"
#include "llvm/MC/MCContext.h"
-#include "llvm/MC/MCSection.h"
+#include "llvm/MC/MCSectionELF.h"
#include "llvm/Target/TargetAsmInfo.h"
#include "llvm/Target/TargetData.h"
#include "llvm/Target/TargetELFWriterInfo.h"
@@ -178,30 +178,32 @@ void ELFWriter::addExternalSymbol(const char *External) {
// getCtorSection - Get the static constructor section
ELFSection &ELFWriter::getCtorSection() {
- const MCSection *Ctor = TLOF.getStaticCtorSection();
- return getSection(((MCSectionELF*)Ctor)->getName(), ELFSection::SHT_PROGBITS,
+ const MCSectionELF *Ctor = (const MCSectionELF *)TLOF.getStaticCtorSection();
+ return getSection(Ctor->getSectionName(), ELFSection::SHT_PROGBITS,
getElfSectionFlags(Ctor->getKind()));
}
// getDtorSection - Get the static destructor section
ELFSection &ELFWriter::getDtorSection() {
- const MCSection *Dtor = TLOF.getStaticDtorSection();
- return getSection(((MCSectionELF*)Dtor)->getName(), ELFSection::SHT_PROGBITS,
+ const MCSectionELF *Dtor = (const MCSectionELF *)TLOF.getStaticDtorSection();
+ return getSection(Dtor->getSectionName(), ELFSection::SHT_PROGBITS,
getElfSectionFlags(Dtor->getKind()));
}
// getTextSection - Get the text section for the specified function
ELFSection &ELFWriter::getTextSection(Function *F) {
- const MCSection *Text = TLOF.SectionForGlobal(F, Mang, TM);
- return getSection(((MCSectionELF*)Text)->getName(), ELFSection::SHT_PROGBITS,
+ const MCSectionELF *Text =
+ (const MCSectionELF *)TLOF.SectionForGlobal(F, Mang, TM);
+ return getSection(Text->getSectionName(), ELFSection::SHT_PROGBITS,
getElfSectionFlags(Text->getKind()));
}
// getJumpTableSection - Get a read only section for constants when
// emitting jump tables. TODO: add PIC support
ELFSection &ELFWriter::getJumpTableSection() {
- const MCSection *JT = TLOF.getSectionForConstant(SectionKind::getReadOnly());
- return getSection(((MCSectionELF*)JT)->getName(),
+ const MCSectionELF *JT =
+ (const MCSectionELF *)TLOF.getSectionForConstant(SectionKind::getReadOnly());
+ return getSection(JT->getSectionName(),
ELFSection::SHT_PROGBITS,
getElfSectionFlags(JT->getKind()),
TM.getTargetData()->getPointerABIAlignment());
@@ -226,8 +228,9 @@ ELFSection &ELFWriter::getConstantPoolSection(MachineConstantPoolEntry &CPE) {
}
}
- const MCSection *CPSect = TLOF.getSectionForConstant(Kind);
- return getSection(((MCSectionELF*)CPSect)->getName(),
+ const MCSectionELF *CPSect =
+ (const MCSectionELF *)TLOF.getSectionForConstant(Kind);
+ return getSection(CPSect->getSectionName(),
ELFSection::SHT_PROGBITS,
getElfSectionFlags(Kind),
CPE.getAlignment());
@@ -358,8 +361,9 @@ void ELFWriter::EmitGlobal(const GlobalValue *GV) {
return;
// Get the ELF section where this global belongs from TLOF
- const MCSection *S = TLOF.SectionForGlobal(GV, Mang, TM);
- SectionKind Kind = ((MCSectionELF*)S)->getKind();
+ const MCSectionELF *S =
+ (const MCSectionELF *)TLOF.SectionForGlobal(GV, Mang, TM);
+ SectionKind Kind = S->getKind();
unsigned SectionFlags = getElfSectionFlags(Kind);
// The symbol align should update the section alignment if needed
@@ -370,7 +374,7 @@ void ELFWriter::EmitGlobal(const GlobalValue *GV) {
if (isELFCommonSym(GVar)) {
GblSym->SectionIdx = ELFSection::SHN_COMMON;
- getSection(((MCSectionELF*)S)->getName(),
+ getSection(S->getSectionName(),
ELFSection::SHT_NOBITS, SectionFlags, 1);
// A new linkonce section is created for each global in the
@@ -380,7 +384,7 @@ void ELFWriter::EmitGlobal(const GlobalValue *GV) {
} else if (isELFBssSym(GVar, Kind)) {
ELFSection &ES =
- getSection(((MCSectionELF*)S)->getName(), ELFSection::SHT_NOBITS,
+ getSection(S->getSectionName(), ELFSection::SHT_NOBITS,
SectionFlags);
GblSym->SectionIdx = ES.SectionIdx;
@@ -396,7 +400,7 @@ void ELFWriter::EmitGlobal(const GlobalValue *GV) {
} else { // The symbol must go to some kind of data section
ELFSection &ES =
- getSection(((MCSectionELF*)S)->getName(), ELFSection::SHT_PROGBITS,
+ getSection(S->getSectionName(), ELFSection::SHT_PROGBITS,
SectionFlags);
GblSym->SectionIdx = ES.SectionIdx;