aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/MC/MCObjectFileInfo.cpp
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2015-08-14 13:31:17 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2015-08-14 13:31:17 +0000
commit90eb70c8a76db399d9128a4f70af8cd393374694 (patch)
tree4e14ff48776f0434aaf21deed18abe88d4f70103 /llvm/lib/MC/MCObjectFileInfo.cpp
parent078ab134ea73c01059acaa45f1d52d964727b612 (diff)
downloadllvm-90eb70c8a76db399d9128a4f70af8cd393374694.zip
llvm-90eb70c8a76db399d9128a4f70af8cd393374694.tar.gz
llvm-90eb70c8a76db399d9128a4f70af8cd393374694.tar.bz2
Centralize the information about which object format we are using.
Other than some places that were handling unknown as ELF, this should have no change. The test updates are because we were detecting arm-coff or x86_64-win64-coff as ELF targets before. It is not clear if the enum should live on the Triple. At least now it lives in a single location and should be easier to move somewhere else. llvm-svn: 245047
Diffstat (limited to 'llvm/lib/MC/MCObjectFileInfo.cpp')
-rw-r--r--llvm/lib/MC/MCObjectFileInfo.cpp40
1 files changed, 21 insertions, 19 deletions
diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index 576827a..ade4b49 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -767,25 +767,19 @@ void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple,
TT = TheTriple;
- Triple::ArchType Arch = TT.getArch();
- // FIXME: Checking for Arch here to filter out bogus triples such as
- // cellspu-apple-darwin. Perhaps we should fix in Triple?
- if ((Arch == Triple::x86 || Arch == Triple::x86_64 ||
- Arch == Triple::arm || Arch == Triple::thumb ||
- Arch == Triple::aarch64 ||
- Arch == Triple::ppc || Arch == Triple::ppc64 ||
- Arch == Triple::UnknownArch) &&
- TT.isOSBinFormatMachO()) {
- Env = IsMachO;
+ Triple::ObjectFormatType Format = TT.getObjectFormat();
+ switch (Format) {
+ case Triple::MachO:
initMachOMCObjectFileInfo(TT);
- } else if ((Arch == Triple::x86 || Arch == Triple::x86_64 ||
- Arch == Triple::arm || Arch == Triple::thumb) &&
- (TT.isOSWindows() && TT.getObjectFormat() == Triple::COFF)) {
- Env = IsCOFF;
+ break;
+ case Triple::COFF:
initCOFFMCObjectFileInfo(TT);
- } else {
- Env = IsELF;
+ break;
+ case Triple::ELF:
initELFMCObjectFileInfo(TT);
+ break;
+ case Triple::UnknownObjectFormat:
+ break;
}
}
@@ -801,7 +795,9 @@ MCSection *MCObjectFileInfo::getDwarfTypesSection(uint64_t Hash) const {
}
void MCObjectFileInfo::InitEHFrameSection() {
- if (Env == IsMachO)
+ Triple::ObjectFormatType Format = TT.getObjectFormat();
+ switch (Format) {
+ case Triple::MachO:
EHFrameSection =
Ctx->getMachOSection("__TEXT", "__eh_frame",
MachO::S_COALESCED |
@@ -809,14 +805,20 @@ void MCObjectFileInfo::InitEHFrameSection() {
MachO::S_ATTR_STRIP_STATIC_SYMS |
MachO::S_ATTR_LIVE_SUPPORT,
SectionKind::getReadOnly());
- else if (Env == IsELF)
+ break;
+ case Triple::ELF:
EHFrameSection =
Ctx->getELFSection(".eh_frame", EHSectionType, EHSectionFlags);
- else
+ break;
+ case Triple::COFF:
EHFrameSection =
Ctx->getCOFFSection(".eh_frame",
COFF::IMAGE_SCN_CNT_INITIALIZED_DATA |
COFF::IMAGE_SCN_MEM_READ |
COFF::IMAGE_SCN_MEM_WRITE,
SectionKind::getDataRel());
+ break;
+ case Triple::UnknownObjectFormat:
+ break;
+ }
}