projects
/
oota-llvm.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Move common symbol related information from MCSectionData to MCSymbol.
[oota-llvm.git]
/
lib
/
MC
/
MachObjectWriter.cpp
diff --git
a/lib/MC/MachObjectWriter.cpp
b/lib/MC/MachObjectWriter.cpp
index 7a4200136d26f6ed78cb3d1d4c52da8da35b313e..6d8e7ae147fb5f0e97748cfcfa1c6e1b7575b74c 100644
(file)
--- a/
lib/MC/MachObjectWriter.cpp
+++ b/
lib/MC/MachObjectWriter.cpp
@@
-197,7
+197,6
@@
void MachObjectWriter::WriteSection(const MCAssembler &Asm,
const MCSection &Sec, uint64_t FileOffset,
uint64_t RelocationsStart,
unsigned NumRelocations) {
const MCSection &Sec, uint64_t FileOffset,
uint64_t RelocationsStart,
unsigned NumRelocations) {
- const MCSectionData &SD = Sec.getSectionData();
uint64_t SectionSize = Layout.getSectionAddressSize(&Sec);
const MCSectionMachO &Section = cast<MCSectionMachO>(Sec);
uint64_t SectionSize = Layout.getSectionAddressSize(&Sec);
const MCSectionMachO &Section = cast<MCSectionMachO>(Sec);
@@
-216,10
+215,10
@@
void MachObjectWriter::WriteSection(const MCAssembler &Asm,
WriteBytes(Section.getSectionName(), 16);
WriteBytes(Section.getSegmentName(), 16);
if (is64Bit()) {
WriteBytes(Section.getSectionName(), 16);
WriteBytes(Section.getSegmentName(), 16);
if (is64Bit()) {
- Write64(getSectionAddress(&S
D.getSection()
)); // address
+ Write64(getSectionAddress(&S
ec
)); // address
Write64(SectionSize); // size
} else {
Write64(SectionSize); // size
} else {
- Write32(getSectionAddress(&S
D.getSection()
)); // address
+ Write32(getSectionAddress(&S
ec
)); // address
Write32(SectionSize); // size
}
Write32(FileOffset);
Write32(SectionSize); // size
}
Write32(FileOffset);
@@
-233,7
+232,7
@@
void MachObjectWriter::WriteSection(const MCAssembler &Asm,
Write32(NumRelocations ? RelocationsStart : 0);
Write32(NumRelocations);
Write32(Flags);
Write32(NumRelocations ? RelocationsStart : 0);
Write32(NumRelocations);
Write32(Flags);
- Write32(IndirectSymBase.lookup(&S
D.getSection()
)); // reserved1
+ Write32(IndirectSymBase.lookup(&S
ec
)); // reserved1
Write32(Section.getStubSize()); // reserved2
if (is64Bit())
Write32(0); // reserved3
Write32(Section.getStubSize()); // reserved2
if (is64Bit())
Write32(0); // reserved3
@@
-374,13
+373,13
@@
void MachObjectWriter::WriteNlist(MachSymbolData &MSD,
Address = AliaseeInfo->StringIndex;
else if (Symbol->isDefined())
Address = getSymbolAddress(OrigSymbol, Layout);
Address = AliaseeInfo->StringIndex;
else if (Symbol->isDefined())
Address = getSymbolAddress(OrigSymbol, Layout);
- else if (
Data.
isCommon()) {
+ else if (
Symbol->
isCommon()) {
// Common symbols are encoded with the size in the address
// field, and their alignment in the flags.
// Common symbols are encoded with the size in the address
// field, and their alignment in the flags.
- Address =
Data.
getCommonSize();
+ Address =
Symbol->
getCommonSize();
// Common alignment is packed into the 'desc' bits.
// Common alignment is packed into the 'desc' bits.
- if (unsigned Align =
Data.
getCommonAlignment()) {
+ if (unsigned Align =
Symbol->
getCommonAlignment()) {
unsigned Log2Size = Log2_32(Align);
assert((1U << Log2Size) == Align && "Invalid 'common' alignment!");
if (Log2Size > 15)
unsigned Log2Size = Log2_32(Align);
assert((1U << Log2Size) == Align && "Invalid 'common' alignment!");
if (Log2Size > 15)
@@
-478,8
+477,7
@@
void MachObjectWriter::BindIndirectSymbols(MCAssembler &Asm) {
// or stub section.
for (MCAssembler::indirect_symbol_iterator it = Asm.indirect_symbol_begin(),
ie = Asm.indirect_symbol_end(); it != ie; ++it) {
// or stub section.
for (MCAssembler::indirect_symbol_iterator it = Asm.indirect_symbol_begin(),
ie = Asm.indirect_symbol_end(); it != ie; ++it) {
- const MCSectionMachO &Section =
- cast<MCSectionMachO>(it->SectionData->getSection());
+ const MCSectionMachO &Section = cast<MCSectionMachO>(*it->Section);
if (Section.getType() != MachO::S_NON_LAZY_SYMBOL_POINTERS &&
Section.getType() != MachO::S_LAZY_SYMBOL_POINTERS &&
if (Section.getType() != MachO::S_NON_LAZY_SYMBOL_POINTERS &&
Section.getType() != MachO::S_LAZY_SYMBOL_POINTERS &&
@@
-494,15
+492,13
@@
void MachObjectWriter::BindIndirectSymbols(MCAssembler &Asm) {
unsigned IndirectIndex = 0;
for (MCAssembler::indirect_symbol_iterator it = Asm.indirect_symbol_begin(),
ie = Asm.indirect_symbol_end(); it != ie; ++it, ++IndirectIndex) {
unsigned IndirectIndex = 0;
for (MCAssembler::indirect_symbol_iterator it = Asm.indirect_symbol_begin(),
ie = Asm.indirect_symbol_end(); it != ie; ++it, ++IndirectIndex) {
- const MCSectionMachO &Section =
- cast<MCSectionMachO>(it->SectionData->getSection());
+ const MCSectionMachO &Section = cast<MCSectionMachO>(*it->Section);
if (Section.getType() != MachO::S_NON_LAZY_SYMBOL_POINTERS)
continue;
// Initialize the section indirect symbol base, if necessary.
if (Section.getType() != MachO::S_NON_LAZY_SYMBOL_POINTERS)
continue;
// Initialize the section indirect symbol base, if necessary.
- IndirectSymBase.insert(
- std::make_pair(&it->SectionData->getSection(), IndirectIndex));
+ IndirectSymBase.insert(std::make_pair(it->Section, IndirectIndex));
Asm.getOrCreateSymbolData(*it->Symbol);
}
Asm.getOrCreateSymbolData(*it->Symbol);
}
@@
-511,16
+507,14
@@
void MachObjectWriter::BindIndirectSymbols(MCAssembler &Asm) {
IndirectIndex = 0;
for (MCAssembler::indirect_symbol_iterator it = Asm.indirect_symbol_begin(),
ie = Asm.indirect_symbol_end(); it != ie; ++it, ++IndirectIndex) {
IndirectIndex = 0;
for (MCAssembler::indirect_symbol_iterator it = Asm.indirect_symbol_begin(),
ie = Asm.indirect_symbol_end(); it != ie; ++it, ++IndirectIndex) {
- const MCSectionMachO &Section =
- cast<MCSectionMachO>(it->SectionData->getSection());
+ const MCSectionMachO &Section = cast<MCSectionMachO>(*it->Section);
if (Section.getType() != MachO::S_LAZY_SYMBOL_POINTERS &&
Section.getType() != MachO::S_SYMBOL_STUBS)
continue;
// Initialize the section indirect symbol base, if necessary.
if (Section.getType() != MachO::S_LAZY_SYMBOL_POINTERS &&
Section.getType() != MachO::S_SYMBOL_STUBS)
continue;
// Initialize the section indirect symbol base, if necessary.
- IndirectSymBase.insert(
- std::make_pair(&it->SectionData->getSection(), IndirectIndex));
+ IndirectSymBase.insert(std::make_pair(it->Section, IndirectIndex));
// Set the symbol type to undefined lazy, but only on construction.
//
// Set the symbol type to undefined lazy, but only on construction.
//
@@
-699,7
+693,7
@@
bool MachObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(
if (!hasReliableSymbolDifference) {
if (!SA.isInSection() || &SecA != &SecB ||
(!SA.isTemporary() &&
if (!hasReliableSymbolDifference) {
if (!SA.isInSection() || &SecA != &SecB ||
(!SA.isTemporary() &&
- FB.getAtom() !=
Asm.getSymbolData(SA
).getFragment()->getAtom() &&
+ FB.getAtom() !=
SA.getData(
).getFragment()->getAtom() &&
Asm.getSubsectionsViaSymbols()))
return false;
return true;
Asm.getSubsectionsViaSymbols()))
return false;
return true;
@@
-723,7
+717,7
@@
bool MachObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(
if (&SecA != &SecB)
return false;
if (&SecA != &SecB)
return false;
- const MCFragment *FA =
Asm.getSymbolData(SA
).getFragment();
+ const MCFragment *FA =
SA.getData(
).getFragment();
// Bail if the symbol has no fragment.
if (!FA)
// Bail if the symbol has no fragment.
if (!FA)
@@
-803,7
+797,6
@@
void MachObjectWriter::WriteObject(MCAssembler &Asm,
for (MCAssembler::const_iterator it = Asm.begin(),
ie = Asm.end(); it != ie; ++it) {
const MCSection &Sec = *it;
for (MCAssembler::const_iterator it = Asm.begin(),
ie = Asm.end(); it != ie; ++it) {
const MCSection &Sec = *it;
- const MCSectionData &SD = it->getSectionData();
uint64_t Address = getSectionAddress(&Sec);
uint64_t Size = Layout.getSectionAddressSize(&Sec);
uint64_t FileSize = Layout.getSectionFileSize(&Sec);
uint64_t Address = getSectionAddress(&Sec);
uint64_t Size = Layout.getSectionAddressSize(&Sec);
uint64_t FileSize = Layout.getSectionFileSize(&Sec);
@@
-811,7
+804,7
@@
void MachObjectWriter::WriteObject(MCAssembler &Asm,
VMSize = std::max(VMSize, Address + Size);
VMSize = std::max(VMSize, Address + Size);
- if (
SD.getSection().
isVirtualSection())
+ if (
it->
isVirtualSection())
continue;
SectionDataSize = std::max(SectionDataSize, Address + Size);
continue;
SectionDataSize = std::max(SectionDataSize, Address + Size);
@@
-913,10
+906,10
@@
void MachObjectWriter::WriteObject(MCAssembler &Asm,
// Write the actual section data.
for (MCAssembler::const_iterator it = Asm.begin(),
ie = Asm.end(); it != ie; ++it) {
// Write the actual section data.
for (MCAssembler::const_iterator it = Asm.begin(),
ie = Asm.end(); it != ie; ++it) {
-
const MCSectionData &SD = it->getSectionData()
;
- Asm.writeSectionData(&S
D
, Layout);
+
MCSection &Sec = *it
;
+ Asm.writeSectionData(&S
ec
, Layout);
- uint64_t Pad = getPaddingSize(&
*it
, Layout);
+ uint64_t Pad = getPaddingSize(&
Sec
, Layout);
WriteZeros(Pad);
}
WriteZeros(Pad);
}
@@
-972,11
+965,10
@@
void MachObjectWriter::WriteObject(MCAssembler &Asm,
// Indirect symbols in the non-lazy symbol pointer section have some
// special handling.
const MCSectionMachO &Section =
// Indirect symbols in the non-lazy symbol pointer section have some
// special handling.
const MCSectionMachO &Section =
-
static_cast<const MCSectionMachO&>(it->SectionData->getSection()
);
+
static_cast<const MCSectionMachO &>(*it->Section
);
if (Section.getType() == MachO::S_NON_LAZY_SYMBOL_POINTERS) {
// If this symbol is defined and internal, mark it as such.
if (Section.getType() == MachO::S_NON_LAZY_SYMBOL_POINTERS) {
// If this symbol is defined and internal, mark it as such.
- if (it->Symbol->isDefined() &&
- !Asm.getSymbolData(*it->Symbol).isExternal()) {
+ if (it->Symbol->isDefined() && !it->Symbol->getData().isExternal()) {
uint32_t Flags = MachO::INDIRECT_SYMBOL_LOCAL;
if (it->Symbol->isAbsolute())
Flags |= MachO::INDIRECT_SYMBOL_ABS;
uint32_t Flags = MachO::INDIRECT_SYMBOL_LOCAL;
if (it->Symbol->isAbsolute())
Flags |= MachO::INDIRECT_SYMBOL_ABS;