summaryrefslogtreecommitdiffstats
path: root/llvm/lib/MC/MachObjectWriter.cpp
diff options
context:
space:
mode:
authorJim Grosbach <grosbach@apple.com>2015-06-04 22:24:41 +0000
committerJim Grosbach <grosbach@apple.com>2015-06-04 22:24:41 +0000
commit36e60e9127374c83f2eb7c705d1bd0dcb2a54d18 (patch)
treee1eaa496683948d707612d06a656426df7efae39 /llvm/lib/MC/MachObjectWriter.cpp
parent39d451ba7650eb803fd17bf211babca186ab7bf5 (diff)
downloadbcm5719-llvm-36e60e9127374c83f2eb7c705d1bd0dcb2a54d18.tar.gz
bcm5719-llvm-36e60e9127374c83f2eb7c705d1bd0dcb2a54d18.zip
MC: Clean up naming in MCObjectWriter. NFC.
s/WriteObject/writeObject/ s/RecordRelocation/recordRelocation/ s/IsSymbolRefDifferenceFullyResolved/isSymbolRefDifferenceFullyResolved/ s/Write8/write8/ s/WriteLE16/writeLE16/ s/WriteLE32/writeLE32/ s/WriteLE64/writeLE64/ s/WriteBE16/writeBE16/ s/WriteBE32/writeBE32/ s/WriteBE64/writeBE64/ s/Write16/write16/ s/Write32/write32/ s/Write64/write64/ s/WriteZeroes/writeZeroes/ s/WriteBytes/writeBytes/ llvm-svn: 239108
Diffstat (limited to 'llvm/lib/MC/MachObjectWriter.cpp')
-rw-r--r--llvm/lib/MC/MachObjectWriter.cpp188
1 files changed, 94 insertions, 94 deletions
diff --git a/llvm/lib/MC/MachObjectWriter.cpp b/llvm/lib/MC/MachObjectWriter.cpp
index b0f60e3d070..8501e0a061c 100644
--- a/llvm/lib/MC/MachObjectWriter.cpp
+++ b/llvm/lib/MC/MachObjectWriter.cpp
@@ -132,17 +132,17 @@ void MachObjectWriter::WriteHeader(unsigned NumLoadCommands,
uint64_t Start = OS.tell();
(void) Start;
- Write32(is64Bit() ? MachO::MH_MAGIC_64 : MachO::MH_MAGIC);
+ write32(is64Bit() ? MachO::MH_MAGIC_64 : MachO::MH_MAGIC);
- Write32(TargetObjectWriter->getCPUType());
- Write32(TargetObjectWriter->getCPUSubtype());
+ write32(TargetObjectWriter->getCPUType());
+ write32(TargetObjectWriter->getCPUSubtype());
- Write32(MachO::MH_OBJECT);
- Write32(NumLoadCommands);
- Write32(LoadCommandsSize);
- Write32(Flags);
+ write32(MachO::MH_OBJECT);
+ write32(NumLoadCommands);
+ write32(LoadCommandsSize);
+ write32(Flags);
if (is64Bit())
- Write32(0); // reserved
+ write32(0); // reserved
assert(OS.tell() - Start ==
(is64Bit()?sizeof(MachO::mach_header_64): sizeof(MachO::mach_header)));
@@ -165,29 +165,29 @@ void MachObjectWriter::WriteSegmentLoadCommand(unsigned NumSections,
unsigned SegmentLoadCommandSize =
is64Bit() ? sizeof(MachO::segment_command_64):
sizeof(MachO::segment_command);
- Write32(is64Bit() ? MachO::LC_SEGMENT_64 : MachO::LC_SEGMENT);
- Write32(SegmentLoadCommandSize +
+ write32(is64Bit() ? MachO::LC_SEGMENT_64 : MachO::LC_SEGMENT);
+ write32(SegmentLoadCommandSize +
NumSections * (is64Bit() ? sizeof(MachO::section_64) :
sizeof(MachO::section)));
- WriteBytes("", 16);
+ writeBytes("", 16);
if (is64Bit()) {
- Write64(0); // vmaddr
- Write64(VMSize); // vmsize
- Write64(SectionDataStartOffset); // file offset
- Write64(SectionDataSize); // file size
+ write64(0); // vmaddr
+ write64(VMSize); // vmsize
+ write64(SectionDataStartOffset); // file offset
+ write64(SectionDataSize); // file size
} else {
- Write32(0); // vmaddr
- Write32(VMSize); // vmsize
- Write32(SectionDataStartOffset); // file offset
- Write32(SectionDataSize); // file size
+ write32(0); // vmaddr
+ write32(VMSize); // vmsize
+ write32(SectionDataStartOffset); // file offset
+ write32(SectionDataSize); // file size
}
// maxprot
- Write32(MachO::VM_PROT_READ | MachO::VM_PROT_WRITE | MachO::VM_PROT_EXECUTE);
+ write32(MachO::VM_PROT_READ | MachO::VM_PROT_WRITE | MachO::VM_PROT_EXECUTE);
// initprot
- Write32(MachO::VM_PROT_READ | MachO::VM_PROT_WRITE | MachO::VM_PROT_EXECUTE);
- Write32(NumSections);
- Write32(0); // flags
+ write32(MachO::VM_PROT_READ | MachO::VM_PROT_WRITE | MachO::VM_PROT_EXECUTE);
+ write32(NumSections);
+ write32(0); // flags
assert(OS.tell() - Start == SegmentLoadCommandSize);
}
@@ -212,30 +212,30 @@ void MachObjectWriter::WriteSection(const MCAssembler &Asm,
uint64_t Start = OS.tell();
(void) Start;
- WriteBytes(Section.getSectionName(), 16);
- WriteBytes(Section.getSegmentName(), 16);
+ writeBytes(Section.getSectionName(), 16);
+ writeBytes(Section.getSegmentName(), 16);
if (is64Bit()) {
- Write64(getSectionAddress(&Sec)); // address
- Write64(SectionSize); // size
+ write64(getSectionAddress(&Sec)); // address
+ write64(SectionSize); // size
} else {
- Write32(getSectionAddress(&Sec)); // address
- Write32(SectionSize); // size
+ write32(getSectionAddress(&Sec)); // address
+ write32(SectionSize); // size
}
- Write32(FileOffset);
+ write32(FileOffset);
unsigned Flags = Section.getTypeAndAttributes();
if (Section.hasInstructions())
Flags |= MachO::S_ATTR_SOME_INSTRUCTIONS;
assert(isPowerOf2_32(Section.getAlignment()) && "Invalid alignment!");
- Write32(Log2_32(Section.getAlignment()));
- Write32(NumRelocations ? RelocationsStart : 0);
- Write32(NumRelocations);
- Write32(Flags);
- Write32(IndirectSymBase.lookup(&Sec)); // reserved1
- Write32(Section.getStubSize()); // reserved2
+ write32(Log2_32(Section.getAlignment()));
+ write32(NumRelocations ? RelocationsStart : 0);
+ write32(NumRelocations);
+ write32(Flags);
+ write32(IndirectSymBase.lookup(&Sec)); // reserved1
+ write32(Section.getStubSize()); // reserved2
if (is64Bit())
- Write32(0); // reserved3
+ write32(0); // reserved3
assert(OS.tell() - Start == (is64Bit() ? sizeof(MachO::section_64) :
sizeof(MachO::section)));
@@ -250,12 +250,12 @@ void MachObjectWriter::WriteSymtabLoadCommand(uint32_t SymbolOffset,
uint64_t Start = OS.tell();
(void) Start;
- Write32(MachO::LC_SYMTAB);
- Write32(sizeof(MachO::symtab_command));
- Write32(SymbolOffset);
- Write32(NumSymbols);
- Write32(StringTableOffset);
- Write32(StringTableSize);
+ write32(MachO::LC_SYMTAB);
+ write32(sizeof(MachO::symtab_command));
+ write32(SymbolOffset);
+ write32(NumSymbols);
+ write32(StringTableOffset);
+ write32(StringTableSize);
assert(OS.tell() - Start == sizeof(MachO::symtab_command));
}
@@ -273,26 +273,26 @@ void MachObjectWriter::WriteDysymtabLoadCommand(uint32_t FirstLocalSymbol,
uint64_t Start = OS.tell();
(void) Start;
- Write32(MachO::LC_DYSYMTAB);
- Write32(sizeof(MachO::dysymtab_command));
- Write32(FirstLocalSymbol);
- Write32(NumLocalSymbols);
- Write32(FirstExternalSymbol);
- Write32(NumExternalSymbols);
- Write32(FirstUndefinedSymbol);
- Write32(NumUndefinedSymbols);
- Write32(0); // tocoff
- Write32(0); // ntoc
- Write32(0); // modtaboff
- Write32(0); // nmodtab
- Write32(0); // extrefsymoff
- Write32(0); // nextrefsyms
- Write32(IndirectSymbolOffset);
- Write32(NumIndirectSymbols);
- Write32(0); // extreloff
- Write32(0); // nextrel
- Write32(0); // locreloff
- Write32(0); // nlocrel
+ write32(MachO::LC_DYSYMTAB);
+ write32(sizeof(MachO::dysymtab_command));
+ write32(FirstLocalSymbol);
+ write32(NumLocalSymbols);
+ write32(FirstExternalSymbol);
+ write32(NumExternalSymbols);
+ write32(FirstUndefinedSymbol);
+ write32(NumUndefinedSymbols);
+ write32(0); // tocoff
+ write32(0); // ntoc
+ write32(0); // modtaboff
+ write32(0); // nmodtab
+ write32(0); // extrefsymoff
+ write32(0); // nextrefsyms
+ write32(IndirectSymbolOffset);
+ write32(NumIndirectSymbols);
+ write32(0); // extreloff
+ write32(0); // nextrel
+ write32(0); // locreloff
+ write32(0); // nlocrel
assert(OS.tell() - Start == sizeof(MachO::dysymtab_command));
}
@@ -390,17 +390,17 @@ void MachObjectWriter::WriteNlist(MachSymbolData &MSD,
// struct nlist (12 bytes)
- Write32(MSD.StringIndex);
- Write8(Type);
- Write8(SectionIndex);
+ write32(MSD.StringIndex);
+ write8(Type);
+ write8(SectionIndex);
// The Mach-O streamer uses the lowest 16-bits of the flags for the 'desc'
// value.
- Write16(Flags);
+ write16(Flags);
if (is64Bit())
- Write64(Address);
+ write64(Address);
else
- Write32(Address);
+ write32(Address);
}
void MachObjectWriter::WriteLinkeditLoadCommand(uint32_t Type,
@@ -409,10 +409,10 @@ void MachObjectWriter::WriteLinkeditLoadCommand(uint32_t Type,
uint64_t Start = OS.tell();
(void) Start;
- Write32(Type);
- Write32(sizeof(MachO::linkedit_data_command));
- Write32(DataOffset);
- Write32(DataSize);
+ write32(Type);
+ write32(sizeof(MachO::linkedit_data_command));
+ write32(DataOffset);
+ write32(DataSize);
assert(OS.tell() - Start == sizeof(MachO::linkedit_data_command));
}
@@ -433,28 +433,28 @@ void MachObjectWriter::WriteLinkerOptionsLoadCommand(
uint64_t Start = OS.tell();
(void) Start;
- Write32(MachO::LC_LINKER_OPTION);
- Write32(Size);
- Write32(Options.size());
+ write32(MachO::LC_LINKER_OPTION);
+ write32(Size);
+ write32(Options.size());
uint64_t BytesWritten = sizeof(MachO::linker_option_command);
for (const std::string &Option : Options) {
// Write each string, including the null byte.
- WriteBytes(Option.c_str(), Option.size() + 1);
+ writeBytes(Option.c_str(), Option.size() + 1);
BytesWritten += Option.size() + 1;
}
// Pad to a multiple of the pointer size.
- WriteBytes("", OffsetToAlignment(BytesWritten, is64Bit() ? 8 : 4));
+ writeBytes("", OffsetToAlignment(BytesWritten, is64Bit() ? 8 : 4));
assert(OS.tell() - Start == Size);
}
-void MachObjectWriter::RecordRelocation(MCAssembler &Asm,
+void MachObjectWriter::recordRelocation(MCAssembler &Asm,
const MCAsmLayout &Layout,
const MCFragment *Fragment,
const MCFixup &Fixup, MCValue Target,
bool &IsPCRel, uint64_t &FixedValue) {
- TargetObjectWriter->RecordRelocation(this, Asm, Layout, Fragment, Fixup,
+ TargetObjectWriter->recordRelocation(this, Asm, Layout, Fragment, Fixup,
Target, FixedValue);
}
@@ -644,7 +644,7 @@ void MachObjectWriter::ExecutePostLayoutBinding(MCAssembler &Asm,
BindIndirectSymbols(Asm);
}
-bool MachObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(
+bool MachObjectWriter::isSymbolRefDifferenceFullyResolvedImpl(
const MCAssembler &Asm, const MCSymbol &SymA, const MCFragment &FB,
bool InSet, bool IsPCRel) const {
if (InSet)
@@ -711,7 +711,7 @@ bool MachObjectWriter::IsSymbolRefDifferenceFullyResolvedImpl(
return false;
}
-void MachObjectWriter::WriteObject(MCAssembler &Asm,
+void MachObjectWriter::writeObject(MCAssembler &Asm,
const MCAsmLayout &Layout) {
// Compute symbol table information and bind symbol indices.
ComputeSymbolTable(Asm, LocalSymbolData, ExternalSymbolData,
@@ -815,11 +815,11 @@ void MachObjectWriter::WriteObject(MCAssembler &Asm,
assert(VersionInfo.Major < 65536 && "unencodable major target version");
uint32_t EncodedVersion = VersionInfo.Update | (VersionInfo.Minor << 8) |
(VersionInfo.Major << 16);
- Write32(VersionInfo.Kind == MCVM_OSXVersionMin ? MachO::LC_VERSION_MIN_MACOSX :
+ write32(VersionInfo.Kind == MCVM_OSXVersionMin ? MachO::LC_VERSION_MIN_MACOSX :
MachO::LC_VERSION_MIN_IPHONEOS);
- Write32(sizeof(MachO::version_min_command));
- Write32(EncodedVersion);
- Write32(0); // reserved.
+ write32(sizeof(MachO::version_min_command));
+ write32(EncodedVersion);
+ write32(0); // reserved.
}
// Write the data-in-code load command, if used.
@@ -893,8 +893,8 @@ void MachObjectWriter::WriteObject(MCAssembler &Asm,
// (approximately, the exact algorithm is more complicated than this).
std::vector<RelAndSymbol> &Relocs = Relocations[&Sec];
for (const RelAndSymbol &Rel : make_range(Relocs.rbegin(), Relocs.rend())) {
- Write32(Rel.MRE.r_word0);
- Write32(Rel.MRE.r_word1);
+ write32(Rel.MRE.r_word0);
+ write32(Rel.MRE.r_word1);
}
}
@@ -910,9 +910,9 @@ void MachObjectWriter::WriteObject(MCAssembler &Asm,
<< " end: " << End << "(" << Data->End->getName() << ")"
<< " size: " << End - Start
<< "\n");
- Write32(Start);
- Write16(End - Start);
- Write16(Data->Kind);
+ write32(Start);
+ write16(End - Start);
+ write16(Data->Kind);
}
// Write out the loh commands, if there is one.
@@ -922,7 +922,7 @@ void MachObjectWriter::WriteObject(MCAssembler &Asm,
#endif
Asm.getLOHContainer().emit(*this, Layout);
// Pad to a multiple of the pointer size.
- WriteBytes("", OffsetToAlignment(LOHRawSize, is64Bit() ? 8 : 4));
+ writeBytes("", OffsetToAlignment(LOHRawSize, is64Bit() ? 8 : 4));
assert(OS.tell() - Start == LOHSize);
}
@@ -942,12 +942,12 @@ void MachObjectWriter::WriteObject(MCAssembler &Asm,
uint32_t Flags = MachO::INDIRECT_SYMBOL_LOCAL;
if (it->Symbol->isAbsolute())
Flags |= MachO::INDIRECT_SYMBOL_ABS;
- Write32(Flags);
+ write32(Flags);
continue;
}
}
- Write32(it->Symbol->getIndex());
+ write32(it->Symbol->getIndex());
}
// FIXME: Check that offsets match computed ones.
OpenPOWER on IntegriCloud