MC: Rename isVirtualSection to isBssSection
The term BSS (Block Started by Symbol) is a standard, widely recognized term, available in the a.out object file format and adopted by formats like COFF, XCOFF, Mach-O (called S_ZEROFILL while `__bss` is also used), and ELF. To avoid introducing unfamiliar terms, we should use isBSSSection instead of isVirtualSection.
This commit is contained in:
parent
343f7475be
commit
6201761e96
@ -91,8 +91,7 @@ private:
|
||||
bool IsRegistered : 1;
|
||||
|
||||
bool IsText : 1;
|
||||
|
||||
bool IsVirtual : 1;
|
||||
bool IsBss : 1;
|
||||
|
||||
/// Whether the section contains linker-relaxable fragments. If true, the
|
||||
/// offset between two locations may not be fully resolved.
|
||||
@ -176,9 +175,9 @@ public:
|
||||
/// instead of 0s.
|
||||
virtual bool useCodeAlign() const = 0;
|
||||
|
||||
/// Check whether this section is "virtual", that is has no actual object
|
||||
/// file contents.
|
||||
bool isVirtualSection() const { return IsVirtual; }
|
||||
/// Return true if this is a BSS section (e.g., ELF .bss or .tbss) that does
|
||||
/// not store content and is typically initialized to zeroes by the runtime.
|
||||
bool isBssSection() const { return IsBss; }
|
||||
|
||||
virtual StringRef getVirtualSectionKind() const;
|
||||
};
|
||||
|
||||
@ -111,7 +111,7 @@ public:
|
||||
|
||||
// Returns the text style for a section. Only defined for ED and PR sections.
|
||||
GOFF::ESDTextStyle getTextStyle() const {
|
||||
assert((isED() || isPR() || isVirtualSection()) && "Expect ED or PR section");
|
||||
assert((isED() || isPR() || isBssSection()) && "Expect ED or PR section");
|
||||
if (isED())
|
||||
return EDAttributes.TextStyle;
|
||||
if (isPR())
|
||||
|
||||
@ -809,7 +809,7 @@ void AsmPrinter::emitGlobalVariable(const GlobalVariable *GV) {
|
||||
|
||||
// If we have a bss global going to a section that supports the
|
||||
// zerofill directive, do so here.
|
||||
if (GVKind.isBSS() && MAI->isMachO() && TheSection->isVirtualSection()) {
|
||||
if (GVKind.isBSS() && MAI->isMachO() && TheSection->isBssSection()) {
|
||||
if (Size == 0)
|
||||
Size = 1; // zerofill of 0 bytes is undefined.
|
||||
emitLinkage(GV, GVSym);
|
||||
|
||||
@ -362,7 +362,7 @@ uint64_t MCAssembler::getSectionAddressSize(const MCSection &Sec) const {
|
||||
|
||||
uint64_t MCAssembler::getSectionFileSize(const MCSection &Sec) const {
|
||||
// Virtual sections have no file size.
|
||||
if (Sec.isVirtualSection())
|
||||
if (Sec.isBssSection())
|
||||
return 0;
|
||||
return getSectionAddressSize(Sec);
|
||||
}
|
||||
@ -559,7 +559,7 @@ void MCAssembler::writeSectionData(raw_ostream &OS,
|
||||
const MCSection *Sec) const {
|
||||
assert(getBackendPtr() && "Expected assembler backend");
|
||||
|
||||
if (Sec->isVirtualSection()) {
|
||||
if (Sec->isBssSection()) {
|
||||
assert(getSectionFileSize(*Sec) == 0 && "Invalid size for section!");
|
||||
|
||||
// Ensure no fixups or non-zero bytes are written to BSS sections, catching
|
||||
|
||||
@ -393,7 +393,7 @@ void MCMachOStreamer::emitZerofill(MCSection *Section, MCSymbol *Symbol,
|
||||
// On darwin all virtual sections have zerofill type. Disallow the usage of
|
||||
// .zerofill in non-virtual functions. If something similar is needed, use
|
||||
// .space or .zero.
|
||||
if (!Section->isVirtualSection()) {
|
||||
if (!Section->isBssSection()) {
|
||||
getContext().reportError(
|
||||
Loc, "The usage of .zerofill is restricted to sections of "
|
||||
"ZEROFILL type. Use .zero or .space instead.");
|
||||
|
||||
@ -3404,7 +3404,7 @@ bool AsmParser::parseDirectiveAlign(bool IsPow2, uint8_t ValueSize) {
|
||||
const MCSection *Section = getStreamer().getCurrentSectionOnly();
|
||||
assert(Section && "must have section to emit alignment");
|
||||
|
||||
if (HasFillExpr && FillExpr != 0 && Section->isVirtualSection()) {
|
||||
if (HasFillExpr && FillExpr != 0 && Section->isBssSection()) {
|
||||
ReturnVal |=
|
||||
Warning(FillExprLoc, "ignoring non-zero fill value in " +
|
||||
Section->getVirtualSectionKind() +
|
||||
|
||||
@ -21,7 +21,7 @@ using namespace llvm;
|
||||
MCSection::MCSection(SectionVariant V, StringRef Name, bool IsText,
|
||||
bool IsVirtual, MCSymbol *Begin)
|
||||
: Begin(Begin), HasInstructions(false), IsRegistered(false), IsText(IsText),
|
||||
IsVirtual(IsVirtual), LinkerRelaxable(false), Name(Name), Variant(V) {
|
||||
IsBss(IsVirtual), LinkerRelaxable(false), Name(Name), Variant(V) {
|
||||
// The initial subsection number is 0. Create a fragment list.
|
||||
CurFragList = &Subsections.emplace_back(0u, FragList{}).second;
|
||||
}
|
||||
|
||||
@ -131,7 +131,7 @@ uint64_t MachObjectWriter::getPaddingSize(const MCAssembler &Asm,
|
||||
return 0;
|
||||
|
||||
const MCSection &NextSec = *SectionOrder[Next];
|
||||
if (NextSec.isVirtualSection())
|
||||
if (NextSec.isBssSection())
|
||||
return 0;
|
||||
return offsetToAlignment(EndAddr, NextSec.getAlign());
|
||||
}
|
||||
@ -267,7 +267,7 @@ void MachObjectWriter::writeSection(const MCAssembler &Asm,
|
||||
const MCSectionMachO &Section = cast<MCSectionMachO>(Sec);
|
||||
|
||||
// The offset is unused for virtual sections.
|
||||
if (Section.isVirtualSection()) {
|
||||
if (Section.isBssSection()) {
|
||||
assert(Asm.getSectionFileSize(Sec) == 0 && "Invalid file size!");
|
||||
FileOffset = 0;
|
||||
}
|
||||
@ -682,13 +682,13 @@ void MachObjectWriter::computeSectionAddresses(const MCAssembler &Asm) {
|
||||
unsigned i = 0;
|
||||
// Compute the section layout order. Virtual sections must go last.
|
||||
for (MCSection &Sec : Asm) {
|
||||
if (!Sec.isVirtualSection()) {
|
||||
if (!Sec.isBssSection()) {
|
||||
SectionOrder.push_back(&Sec);
|
||||
cast<MCSectionMachO>(Sec).setLayoutOrder(i++);
|
||||
}
|
||||
}
|
||||
for (MCSection &Sec : Asm) {
|
||||
if (Sec.isVirtualSection()) {
|
||||
if (Sec.isBssSection()) {
|
||||
SectionOrder.push_back(&Sec);
|
||||
cast<MCSectionMachO>(Sec).setLayoutOrder(i++);
|
||||
}
|
||||
@ -883,7 +883,7 @@ uint64_t MachObjectWriter::writeObject() {
|
||||
|
||||
VMSize = std::max(VMSize, Address + Size);
|
||||
|
||||
if (Sec.isVirtualSection())
|
||||
if (Sec.isBssSection())
|
||||
continue;
|
||||
|
||||
SectionDataSize = std::max(SectionDataSize, Address + Size);
|
||||
@ -915,7 +915,7 @@ uint64_t MachObjectWriter::writeObject() {
|
||||
unsigned Flags = Sec.getTypeAndAttributes();
|
||||
if (Sec.hasInstructions())
|
||||
Flags |= MachO::S_ATTR_SOME_INSTRUCTIONS;
|
||||
if (!cast<MCSectionMachO>(Sec).isVirtualSection() &&
|
||||
if (!cast<MCSectionMachO>(Sec).isBssSection() &&
|
||||
!isUInt<32>(SectionStart)) {
|
||||
getContext().reportError(
|
||||
SMLoc(), "cannot encode offset of section; object file too large");
|
||||
|
||||
@ -64,14 +64,14 @@ struct Section {
|
||||
return static_cast<MachO::SectionType>(Flags & MachO::SECTION_TYPE);
|
||||
}
|
||||
|
||||
bool isVirtualSection() const {
|
||||
bool isBssSection() const {
|
||||
return (getType() == MachO::S_ZEROFILL ||
|
||||
getType() == MachO::S_GB_ZEROFILL ||
|
||||
getType() == MachO::S_THREAD_LOCAL_ZEROFILL);
|
||||
}
|
||||
|
||||
bool hasValidOffset() const {
|
||||
return !(isVirtualSection() || OriginalOffset == 0);
|
||||
return !(isBssSection() || OriginalOffset == 0);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
@ -112,7 +112,7 @@ size_t MachOWriter::totalSize() const {
|
||||
for (const std::unique_ptr<Section> &S : LC.Sections) {
|
||||
if (!S->hasValidOffset()) {
|
||||
assert((S->Offset == 0) && "Skipped section's offset must be zero");
|
||||
assert((S->isVirtualSection() || S->Size == 0) &&
|
||||
assert((S->isBssSection() || S->Size == 0) &&
|
||||
"Non-zero-fill sections with zero offset must have zero size");
|
||||
continue;
|
||||
}
|
||||
@ -240,7 +240,7 @@ void MachOWriter::writeSections() {
|
||||
for (const std::unique_ptr<Section> &Sec : LC.Sections) {
|
||||
if (!Sec->hasValidOffset()) {
|
||||
assert((Sec->Offset == 0) && "Skipped section's offset must be zero");
|
||||
assert((Sec->isVirtualSection() || Sec->Size == 0) &&
|
||||
assert((Sec->isBssSection() || Sec->Size == 0) &&
|
||||
"Non-zero-fill sections with zero offset must have zero size");
|
||||
continue;
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user