summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC
diff options
context:
space:
mode:
authorRafael Espindola <rafael.espindola@gmail.com>2010-11-17 20:03:54 +0000
committerRafael Espindola <rafael.espindola@gmail.com>2010-11-17 20:03:54 +0000
commit7a2cd8b5401ef57af7bd5164c4305961708fe264 (patch)
tree1b0d9bde0cc63a8543653d8a3396e84652429c3a /llvm/lib/MC
parentbced7ae04663b4b9e30b5f8a6d9479f467cb60cb (diff)
downloadbcm5719-llvm-7a2cd8b5401ef57af7bd5164c4305961708fe264.tar.gz
bcm5719-llvm-7a2cd8b5401ef57af7bd5164c4305961708fe264.zip
make isVirtualSection a virtual method on MCSection. Chris' suggestion.
llvm-svn: 119547
Diffstat (limited to 'llvm/lib/MC')
-rw-r--r--llvm/lib/MC/MCAssembler.cpp10
-rw-r--r--llvm/lib/MC/MCSectionCOFF.cpp4
-rw-r--r--llvm/lib/MC/MCSectionELF.cpp4
-rw-r--r--llvm/lib/MC/MCSectionMachO.cpp6
-rw-r--r--llvm/lib/MC/MachObjectWriter.cpp4
5 files changed, 21 insertions, 7 deletions
diff --git a/llvm/lib/MC/MCAssembler.cpp b/llvm/lib/MC/MCAssembler.cpp
index c80dc3c2483..a23bab25a4d 100644
--- a/llvm/lib/MC/MCAssembler.cpp
+++ b/llvm/lib/MC/MCAssembler.cpp
@@ -54,10 +54,10 @@ MCAsmLayout::MCAsmLayout(MCAssembler &Asm)
{
// Compute the section layout order. Virtual sections must go last.
for (MCAssembler::iterator it = Asm.begin(), ie = Asm.end(); it != ie; ++it)
- if (!Asm.getBackend().isVirtualSection(it->getSection()))
+ if (!it->getSection().isVirtualSection())
SectionOrder.push_back(&*it);
for (MCAssembler::iterator it = Asm.begin(), ie = Asm.end(); it != ie; ++it)
- if (Asm.getBackend().isVirtualSection(it->getSection()))
+ if (it->getSection().isVirtualSection())
SectionOrder.push_back(&*it);
}
@@ -157,7 +157,7 @@ uint64_t MCAsmLayout::getSectionAddressSize(const MCSectionData *SD) const {
uint64_t MCAsmLayout::getSectionFileSize(const MCSectionData *SD) const {
// Virtual sections have no file size.
- if (getAssembler().getBackend().isVirtualSection(SD->getSection()))
+ if (SD->getSection().isVirtualSection())
return 0;
// Otherwise, the file size is the same as the address space size.
@@ -541,7 +541,7 @@ void MCAssembler::WriteSectionData(const MCSectionData *SD,
const MCAsmLayout &Layout,
MCObjectWriter *OW) const {
// Ignore virtual sections.
- if (getBackend().isVirtualSection(SD->getSection())) {
+ if (SD->getSection().isVirtualSection()) {
assert(Layout.getSectionFileSize(SD) == 0 && "Invalid size for section!");
// Check that contents are only things legal inside a virtual section.
@@ -630,7 +630,7 @@ void MCAssembler::Finish(MCObjectWriter *Writer) {
continue;
// Ignore virtual sections, they don't cause file size modifications.
- if (getBackend().isVirtualSection(SD->getSection()))
+ if (SD->getSection().isVirtualSection())
continue;
// Otherwise, create a new align fragment at the end of the previous
diff --git a/llvm/lib/MC/MCSectionCOFF.cpp b/llvm/lib/MC/MCSectionCOFF.cpp
index 0909df42227..90091f06e9a 100644
--- a/llvm/lib/MC/MCSectionCOFF.cpp
+++ b/llvm/lib/MC/MCSectionCOFF.cpp
@@ -78,3 +78,7 @@ void MCSectionCOFF::PrintSwitchToSection(const MCAsmInfo &MAI,
bool MCSectionCOFF::UseCodeAlign() const {
return getKind().isText();
}
+
+bool MCSectionCOFF::isVirtualSection() const {
+ return getCharacteristics() & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA;
+}
diff --git a/llvm/lib/MC/MCSectionELF.cpp b/llvm/lib/MC/MCSectionELF.cpp
index ab72a0ebf96..59568adf708 100644
--- a/llvm/lib/MC/MCSectionELF.cpp
+++ b/llvm/lib/MC/MCSectionELF.cpp
@@ -107,6 +107,10 @@ bool MCSectionELF::UseCodeAlign() const {
return getFlags() & MCSectionELF::SHF_EXECINSTR;
}
+bool MCSectionELF::isVirtualSection() const {
+ return getType() == MCSectionELF::SHT_NOBITS;
+}
+
// HasCommonSymbols - True if this section holds common symbols, this is
// indicated on the ELF object file by a symbol with SHN_COMMON section
// header index.
diff --git a/llvm/lib/MC/MCSectionMachO.cpp b/llvm/lib/MC/MCSectionMachO.cpp
index 0b74636d422..43268e63bbd 100644
--- a/llvm/lib/MC/MCSectionMachO.cpp
+++ b/llvm/lib/MC/MCSectionMachO.cpp
@@ -152,6 +152,12 @@ bool MCSectionMachO::UseCodeAlign() const {
return hasAttribute(MCSectionMachO::S_ATTR_PURE_INSTRUCTIONS);
}
+bool MCSectionMachO::isVirtualSection() const {
+ return (getType() == MCSectionMachO::S_ZEROFILL ||
+ getType() == MCSectionMachO::S_GB_ZEROFILL ||
+ getType() == MCSectionMachO::S_THREAD_LOCAL_ZEROFILL);
+}
+
/// StripSpaces - This removes leading and trailing spaces from the StringRef.
static void StripSpaces(StringRef &Str) {
while (!Str.empty() && isspace(Str[0]))
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index 41c11fba1d0..729a437b18f 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -371,7 +371,7 @@ public:
uint64_t SectionSize = Layout.getSectionSize(&SD);
// The offset is unused for virtual sections.
- if (Asm.getBackend().isVirtualSection(SD.getSection())) {
+ if (SD.getSection().isVirtualSection()) {
assert(Layout.getSectionFileSize(&SD) == 0 && "Invalid file size!");
FileOffset = 0;
}
@@ -1191,7 +1191,7 @@ public:
VMSize = std::max(VMSize, Address + Size);
- if (Asm.getBackend().isVirtualSection(SD.getSection()))
+ if (SD.getSection().isVirtualSection())
continue;
SectionDataSize = std::max(SectionDataSize, Address + Size);
OpenPOWER on IntegriCloud