clang-format WinCOFFObjectWriter.cpp. NFC.
llvm-svn: 238328
This commit is contained in:
parent
aad34d97f7
commit
11e9e210d0
|
@ -105,7 +105,6 @@ public:
|
|||
|
||||
class WinCOFFObjectWriter : public MCObjectWriter {
|
||||
public:
|
||||
|
||||
typedef std::vector<std::unique_ptr<COFFSymbol>> symbols;
|
||||
typedef std::vector<std::unique_ptr<COFFSection>> sections;
|
||||
|
||||
|
@ -240,15 +239,11 @@ bool COFFSymbol::should_keep() const {
|
|||
// Section class implementation
|
||||
|
||||
COFFSection::COFFSection(StringRef name)
|
||||
: Name(name)
|
||||
, MCData(nullptr)
|
||||
, Symbol(nullptr) {
|
||||
: Name(name), MCData(nullptr), Symbol(nullptr) {
|
||||
memset(&Header, 0, sizeof(Header));
|
||||
}
|
||||
|
||||
size_t COFFSection::size() {
|
||||
return COFF::SectionSize;
|
||||
}
|
||||
size_t COFFSection::size() { return COFF::SectionSize; }
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// WinCOFFObjectWriter class implementation
|
||||
|
@ -282,8 +277,7 @@ COFFSection *WinCOFFObjectWriter::createSection(StringRef Name) {
|
|||
/// A template used to lookup or create a symbol/section, and initialize it if
|
||||
/// needed.
|
||||
template <typename object_t, typename list_t>
|
||||
object_t *WinCOFFObjectWriter::createCOFFEntity(StringRef Name,
|
||||
list_t &List) {
|
||||
object_t *WinCOFFObjectWriter::createCOFFEntity(StringRef Name, list_t &List) {
|
||||
List.push_back(make_unique<object_t>(Name));
|
||||
|
||||
return List.back().get();
|
||||
|
@ -292,8 +286,8 @@ object_t *WinCOFFObjectWriter::createCOFFEntity(StringRef Name,
|
|||
/// This function takes a section data object from the assembler
|
||||
/// and creates the associated COFF section staging object.
|
||||
void WinCOFFObjectWriter::DefineSection(MCSectionData const &SectionData) {
|
||||
assert(SectionData.getSection().getVariant() == MCSection::SV_COFF
|
||||
&& "Got non-COFF section in the COFF backend!");
|
||||
assert(SectionData.getSection().getVariant() == MCSection::SV_COFF &&
|
||||
"Got non-COFF section in the COFF backend!");
|
||||
// FIXME: Not sure how to verify this (at least in a debug build).
|
||||
MCSectionCOFF const &Sec =
|
||||
static_cast<MCSectionCOFF const &>(SectionData.getSection());
|
||||
|
@ -323,20 +317,48 @@ void WinCOFFObjectWriter::DefineSection(MCSectionData const &SectionData) {
|
|||
|
||||
uint32_t &Characteristics = coff_section->Header.Characteristics;
|
||||
switch (Sec.getAlignment()) {
|
||||
case 1: Characteristics |= COFF::IMAGE_SCN_ALIGN_1BYTES; break;
|
||||
case 2: Characteristics |= COFF::IMAGE_SCN_ALIGN_2BYTES; break;
|
||||
case 4: Characteristics |= COFF::IMAGE_SCN_ALIGN_4BYTES; break;
|
||||
case 8: Characteristics |= COFF::IMAGE_SCN_ALIGN_8BYTES; break;
|
||||
case 16: Characteristics |= COFF::IMAGE_SCN_ALIGN_16BYTES; break;
|
||||
case 32: Characteristics |= COFF::IMAGE_SCN_ALIGN_32BYTES; break;
|
||||
case 64: Characteristics |= COFF::IMAGE_SCN_ALIGN_64BYTES; break;
|
||||
case 128: Characteristics |= COFF::IMAGE_SCN_ALIGN_128BYTES; break;
|
||||
case 256: Characteristics |= COFF::IMAGE_SCN_ALIGN_256BYTES; break;
|
||||
case 512: Characteristics |= COFF::IMAGE_SCN_ALIGN_512BYTES; break;
|
||||
case 1024: Characteristics |= COFF::IMAGE_SCN_ALIGN_1024BYTES; break;
|
||||
case 2048: Characteristics |= COFF::IMAGE_SCN_ALIGN_2048BYTES; break;
|
||||
case 4096: Characteristics |= COFF::IMAGE_SCN_ALIGN_4096BYTES; break;
|
||||
case 8192: Characteristics |= COFF::IMAGE_SCN_ALIGN_8192BYTES; break;
|
||||
case 1:
|
||||
Characteristics |= COFF::IMAGE_SCN_ALIGN_1BYTES;
|
||||
break;
|
||||
case 2:
|
||||
Characteristics |= COFF::IMAGE_SCN_ALIGN_2BYTES;
|
||||
break;
|
||||
case 4:
|
||||
Characteristics |= COFF::IMAGE_SCN_ALIGN_4BYTES;
|
||||
break;
|
||||
case 8:
|
||||
Characteristics |= COFF::IMAGE_SCN_ALIGN_8BYTES;
|
||||
break;
|
||||
case 16:
|
||||
Characteristics |= COFF::IMAGE_SCN_ALIGN_16BYTES;
|
||||
break;
|
||||
case 32:
|
||||
Characteristics |= COFF::IMAGE_SCN_ALIGN_32BYTES;
|
||||
break;
|
||||
case 64:
|
||||
Characteristics |= COFF::IMAGE_SCN_ALIGN_64BYTES;
|
||||
break;
|
||||
case 128:
|
||||
Characteristics |= COFF::IMAGE_SCN_ALIGN_128BYTES;
|
||||
break;
|
||||
case 256:
|
||||
Characteristics |= COFF::IMAGE_SCN_ALIGN_256BYTES;
|
||||
break;
|
||||
case 512:
|
||||
Characteristics |= COFF::IMAGE_SCN_ALIGN_512BYTES;
|
||||
break;
|
||||
case 1024:
|
||||
Characteristics |= COFF::IMAGE_SCN_ALIGN_1024BYTES;
|
||||
break;
|
||||
case 2048:
|
||||
Characteristics |= COFF::IMAGE_SCN_ALIGN_2048BYTES;
|
||||
break;
|
||||
case 4096:
|
||||
Characteristics |= COFF::IMAGE_SCN_ALIGN_4096BYTES;
|
||||
break;
|
||||
case 8192:
|
||||
Characteristics |= COFF::IMAGE_SCN_ALIGN_8192BYTES;
|
||||
break;
|
||||
default:
|
||||
llvm_unreachable("unsupported section alignment");
|
||||
}
|
||||
|
@ -510,8 +532,8 @@ bool WinCOFFObjectWriter::ExportSymbol(const MCSymbol &Symbol,
|
|||
}
|
||||
|
||||
bool WinCOFFObjectWriter::IsPhysicalSection(COFFSection *S) {
|
||||
return (S->Header.Characteristics
|
||||
& COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA) == 0;
|
||||
return (S->Header.Characteristics & COFF::IMAGE_SCN_CNT_UNINITIALIZED_DATA) ==
|
||||
0;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -682,9 +704,9 @@ void WinCOFFObjectWriter::RecordRelocation(
|
|||
const MCSymbol &Symbol = Target.getSymA()->getSymbol();
|
||||
const MCSymbol &A = Symbol;
|
||||
if (!Asm.hasSymbolData(A))
|
||||
Asm.getContext().reportFatalError(
|
||||
Fixup.getLoc(),
|
||||
Twine("symbol '") + A.getName() + "' can not be undefined");
|
||||
Asm.getContext().reportFatalError(Fixup.getLoc(),
|
||||
Twine("symbol '") + A.getName() +
|
||||
"' can not be undefined");
|
||||
|
||||
const MCSymbolData &A_SD = Asm.getSymbolData(A);
|
||||
|
||||
|
@ -756,9 +778,8 @@ void WinCOFFObjectWriter::RecordRelocation(
|
|||
++Reloc.Symb->Relocations;
|
||||
|
||||
Reloc.Data.VirtualAddress += Fixup.getOffset();
|
||||
Reloc.Data.Type =
|
||||
TargetObjectWriter->getRelocType(Target, Fixup, CrossSection,
|
||||
Asm.getBackend());
|
||||
Reloc.Data.Type = TargetObjectWriter->getRelocType(
|
||||
Target, Fixup, CrossSection, Asm.getBackend());
|
||||
|
||||
// FIXME: Can anyone explain what this does other than adjust for the size
|
||||
// of the offset?
|
||||
|
@ -838,8 +859,8 @@ void WinCOFFObjectWriter::WriteObject(MCAssembler &Asm,
|
|||
Header.NumberOfSections = NumberOfSections;
|
||||
Header.NumberOfSymbols = 0;
|
||||
|
||||
for (auto FI = Asm.file_names_begin(), FE = Asm.file_names_end();
|
||||
FI != FE; ++FI) {
|
||||
for (auto FI = Asm.file_names_begin(), FE = Asm.file_names_end(); FI != FE;
|
||||
++FI) {
|
||||
// round up to calculate the number of auxiliary symbols required
|
||||
unsigned SymbolSize = UseBigObj ? COFF::Symbol32Size : COFF::Symbol16Size;
|
||||
unsigned Count = (FI->size() + SymbolSize - 1) / SymbolSize;
|
||||
|
@ -930,10 +951,10 @@ void WinCOFFObjectWriter::WriteObject(MCAssembler &Asm,
|
|||
if (Assoc->Number == -1)
|
||||
continue;
|
||||
|
||||
Section->Symbol->Aux[0].Aux.SectionDefinition.Number = SectionIndices[Assoc];
|
||||
Section->Symbol->Aux[0].Aux.SectionDefinition.Number =
|
||||
SectionIndices[Assoc];
|
||||
}
|
||||
|
||||
|
||||
// Assign file offsets to COFF object file structures.
|
||||
|
||||
unsigned offset = 0;
|
||||
|
@ -1017,8 +1038,8 @@ void WinCOFFObjectWriter::WriteObject(MCAssembler &Asm,
|
|||
}
|
||||
}
|
||||
|
||||
for (i = Sections.begin(), ie = Sections.end(),
|
||||
j = Asm.begin(), je = Asm.end();
|
||||
for (i = Sections.begin(), ie = Sections.end(), j = Asm.begin(),
|
||||
je = Asm.end();
|
||||
(i != ie) && (j != je); ++i, ++j) {
|
||||
|
||||
if ((*i)->Number == -1)
|
||||
|
@ -1069,9 +1090,8 @@ void WinCOFFObjectWriter::WriteObject(MCAssembler &Asm,
|
|||
OS.write(Strings.data().data(), Strings.data().size());
|
||||
}
|
||||
|
||||
MCWinCOFFObjectTargetWriter::MCWinCOFFObjectTargetWriter(unsigned Machine_) :
|
||||
Machine(Machine_) {
|
||||
}
|
||||
MCWinCOFFObjectTargetWriter::MCWinCOFFObjectTargetWriter(unsigned Machine_)
|
||||
: Machine(Machine_) {}
|
||||
|
||||
// Pin the vtable to this file.
|
||||
void MCWinCOFFObjectTargetWriter::anchor() {}
|
||||
|
|
Loading…
Reference in New Issue