summaryrefslogtreecommitdiffstats
path: root/lld/lib/ReaderWriter/MachO
diff options
context:
space:
mode:
authorShankar Easwaran <shankare@codeaurora.org>2014-01-27 03:09:26 +0000
committerShankar Easwaran <shankare@codeaurora.org>2014-01-27 03:09:26 +0000
commit3d8de47f76529dba40fc34d497576d9cb51330bc (patch)
tree143515f3acdefd2c6c53e2553af9b34ff120a13d /lld/lib/ReaderWriter/MachO
parenta64ba010f040003685c507c82237dae9fd4e6f59 (diff)
downloadbcm5719-llvm-3d8de47f76529dba40fc34d497576d9cb51330bc.tar.gz
bcm5719-llvm-3d8de47f76529dba40fc34d497576d9cb51330bc.zip
Fix trailing whitespace.
llvm-svn: 200182
Diffstat (limited to 'lld/lib/ReaderWriter/MachO')
-rw-r--r--lld/lib/ReaderWriter/MachO/GOTPass.hpp8
-rw-r--r--lld/lib/ReaderWriter/MachO/MachONormalizedFile.h66
-rw-r--r--lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp58
-rw-r--r--lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h28
-rw-r--r--lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp142
-rw-r--r--lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp94
-rw-r--r--lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp160
-rw-r--r--lld/lib/ReaderWriter/MachO/StubAtoms.hpp12
-rw-r--r--lld/lib/ReaderWriter/MachO/WriterMachO.cpp8
9 files changed, 288 insertions, 288 deletions
diff --git a/lld/lib/ReaderWriter/MachO/GOTPass.hpp b/lld/lib/ReaderWriter/MachO/GOTPass.hpp
index 4342b3e0c04..9f99fc14699 100644
--- a/lld/lib/ReaderWriter/MachO/GOTPass.hpp
+++ b/lld/lib/ReaderWriter/MachO/GOTPass.hpp
@@ -34,18 +34,18 @@ public:
}
virtual void updateReferenceToGOT(const Reference*, bool targetIsNowGOT) {
-
+
}
virtual const DefinedAtom* makeGOTEntry(const Atom&) {
return nullptr;
}
-
+
};
-} // namespace mach_o
-} // namespace lld
+} // namespace mach_o
+} // namespace lld
#endif // LLD_READER_WRITER_MACHO_GOT_PASS_H
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFile.h b/lld/lib/ReaderWriter/MachO/MachONormalizedFile.h
index 435202a97a6..b135998d87a 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFile.h
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFile.h
@@ -10,34 +10,34 @@
///
/// \file These data structures comprise the "normalized" view of
/// mach-o object files. The normalized view is an in-memory only data structure
-/// which is always in native endianness and pointer size.
-///
-/// The normalized view easily converts to and from YAML using YAML I/O.
+/// which is always in native endianness and pointer size.
+///
+/// The normalized view easily converts to and from YAML using YAML I/O.
///
/// The normalized view converts to and from binary mach-o object files using
/// the writeBinary() and readBinary() functions.
///
-/// The normalized view converts to and from lld::Atoms using the
+/// The normalized view converts to and from lld::Atoms using the
/// normalizedToAtoms() and normalizedFromAtoms().
///
/// Overall, the conversion paths available look like:
///
-/// +---------------+
-/// | binary mach-o |
-/// +---------------+
+/// +---------------+
+/// | binary mach-o |
+/// +---------------+
/// ^
/// |
/// v
-/// +------------+ +------+
-/// | normalized | <-> | yaml |
-/// +------------+ +------+
+/// +------------+ +------+
+/// | normalized | <-> | yaml |
+/// +------------+ +------+
/// ^
/// |
/// v
-/// +-------+
+/// +-------+
/// | Atoms |
-/// +-------+
-///
+/// +-------+
+///
#include "lld/Core/Error.h"
#include "lld/Core/LLVM.h"
@@ -76,9 +76,9 @@ namespace normalized {
/// encoded in one of two different bit-field patterns. This
/// normalized form has the union of all possible fields.
struct Relocation {
- Relocation() : offset(0), scattered(false),
- type(llvm::MachO::GENERIC_RELOC_VANILLA),
- length(0), pcRel(false), isExtern(false), value(0),
+ Relocation() : offset(0), scattered(false),
+ type(llvm::MachO::GENERIC_RELOC_VANILLA),
+ length(0), pcRel(false), isExtern(false), value(0),
symbol(0) { }
Hex32 offset;
@@ -106,7 +106,7 @@ LLVM_YAML_STRONG_TYPEDEF(uint32_t, SectionAttr);
/// Mach-O has a 32-bit and 64-bit section record. This normalized form
/// can support either kind.
struct Section {
- Section() : type(llvm::MachO::S_REGULAR),
+ Section() : type(llvm::MachO::S_REGULAR),
attributes(0), alignment(0), address(0) { }
StringRef segmentName;
@@ -129,7 +129,7 @@ LLVM_YAML_STRONG_TYPEDEF(uint16_t, SymbolDesc);
/// Mach-O has a 32-bit and 64-bit symbol table entry (nlist), and the symbol
/// type and scope and mixed in the same n_type field. This normalized form
-/// works for any pointer size and separates out the type and scope.
+/// works for any pointer size and separates out the type and scope.
struct Symbol {
Symbol() : type(llvm::MachO::N_UNDF), scope(0), sect(0), desc(0), value(0) { }
@@ -195,25 +195,25 @@ struct Export {
/// A typedef so that YAML I/O can encode/decode mach_header.flags.
LLVM_YAML_STRONG_TYPEDEF(uint32_t, FileFlags);
-///
+///
struct NormalizedFile {
- NormalizedFile() : arch(MachOLinkingContext::arch_unknown),
+ NormalizedFile() : arch(MachOLinkingContext::arch_unknown),
fileType(llvm::MachO::MH_OBJECT),
- flags(0),
- hasUUID(false),
+ flags(0),
+ hasUUID(false),
os(MachOLinkingContext::OS::unknown) { }
-
+
MachOLinkingContext::Arch arch;
HeaderFileType fileType;
FileFlags flags;
std::vector<Segment> segments; // Not used in object files.
std::vector<Section> sections;
-
+
// Symbols sorted by kind.
std::vector<Symbol> localSymbols;
std::vector<Symbol> globalSymbols;
std::vector<Symbol> undefinedSymbols;
-
+
// Maps to load commands with no LINKEDIT content (final linked images only).
std::vector<DependentDylib> dependentDylibs;
StringRef installName;
@@ -224,20 +224,20 @@ struct NormalizedFile {
Hex64 sourceVersion;
Hex32 minOSverson;
Hex32 sdkVersion;
-
+
// Maps to load commands with LINKEDIT content (final linked images only).
std::vector<RebaseLocation> rebasingInfo;
std::vector<BindLocation> bindingInfo;
std::vector<BindLocation> weakBindingInfo;
std::vector<BindLocation> lazyBindingInfo;
std::vector<Export> exportInfo;
-
+
// TODO:
// code-signature
// split-seg-info
// function-starts
// data-in-code
-
+
// For any allocations in this struct which need to be owned by this struct.
BumpPtrAllocator ownedAllocations;
};
@@ -249,28 +249,28 @@ readBinary(std::unique_ptr<MemoryBuffer> &mb,
const MachOLinkingContext::Arch arch);
/// Takes in-memory normalized view and writes a mach-o object file.
-error_code
+error_code
writeBinary(const NormalizedFile &file, StringRef path);
size_t headerAndLoadCommandsSize(const NormalizedFile &file);
/// Parses a yaml encoded mach-o file to produce an in-memory normalized view.
-ErrorOr<std::unique_ptr<NormalizedFile>>
+ErrorOr<std::unique_ptr<NormalizedFile>>
readYaml(std::unique_ptr<MemoryBuffer> &mb);
/// Writes a yaml encoded mach-o files given an in-memory normalized view.
-error_code
+error_code
writeYaml(const NormalizedFile &file, raw_ostream &out);
/// Takes in-memory normalized dylib or object and parses it into lld::File
ErrorOr<std::unique_ptr<lld::File>>
-normalizedToAtoms(const NormalizedFile &normalizedFile, StringRef path,
+normalizedToAtoms(const NormalizedFile &normalizedFile, StringRef path,
bool copyRefs);
/// Takes atoms and generates a normalized macho-o view.
-ErrorOr<std::unique_ptr<NormalizedFile>>
+ErrorOr<std::unique_ptr<NormalizedFile>>
normalizedFromAtoms(const lld::File &atomFile, const MachOLinkingContext &ctxt);
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
index 7b3b36de358..4d793706d9d 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp
@@ -50,9 +50,9 @@ namespace mach_o {
namespace normalized {
// Utility to call a lambda expression on each load command.
-static error_code
+static error_code
forEachLoadCommand(StringRef lcRange, unsigned lcCount, bool swap, bool is64,
- std::function<bool (uint32_t cmd, uint32_t size,
+ std::function<bool (uint32_t cmd, uint32_t size,
const char* lc)> func) {
const char* p = lcRange.begin();
for (unsigned i=0; i < lcCount; ++i) {
@@ -66,25 +66,25 @@ forEachLoadCommand(StringRef lcRange, unsigned lcCount, bool swap, bool is64,
}
if ( (p + slc->cmdsize) > lcRange.end() )
return llvm::make_error_code(llvm::errc::executable_format_error);
-
+
if (func(slc->cmd, slc->cmdsize, p))
return error_code::success();
-
+
p += slc->cmdsize;
- }
-
+ }
+
return error_code::success();
}
-static error_code
-appendRelocations(Relocations &relocs, StringRef buffer, bool swap,
+static error_code
+appendRelocations(Relocations &relocs, StringRef buffer, bool swap,
bool bigEndian, uint32_t reloff, uint32_t nreloc) {
if ((reloff + nreloc*8) > buffer.size())
return llvm::make_error_code(llvm::errc::executable_format_error);
- const any_relocation_info* relocsArray =
+ const any_relocation_info* relocsArray =
reinterpret_cast<const any_relocation_info*>(buffer.begin()+reloff);
-
+
for(uint32_t i=0; i < nreloc; ++i) {
relocs.push_back(unpackRelocation(relocsArray[i], swap, bigEndian));
}
@@ -186,27 +186,27 @@ readBinary(std::unique_ptr<MemoryBuffer> &mb,
// Walk load commands looking for segments/sections and the symbol table.
- error_code ec = forEachLoadCommand(lcRange, lcCount, swap, is64,
+ error_code ec = forEachLoadCommand(lcRange, lcCount, swap, is64,
[&] (uint32_t cmd, uint32_t size, const char* lc) -> bool {
if (is64) {
if (cmd == LC_SEGMENT_64) {
- const segment_command_64 *seg =
+ const segment_command_64 *seg =
reinterpret_cast<const segment_command_64*>(lc);
const unsigned sectionCount = (swap ? SwapByteOrder(seg->nsects)
: seg->nsects);
const section_64 *sects = reinterpret_cast<const section_64*>
(lc + sizeof(segment_command_64));
- const unsigned lcSize = sizeof(segment_command_64)
+ const unsigned lcSize = sizeof(segment_command_64)
+ sectionCount*sizeof(section_64);
// Verify sections don't extend beyond end of segment load command.
- if (lcSize > size)
+ if (lcSize > size)
return llvm::make_error_code(llvm::errc::executable_format_error);
for (unsigned i=0; i < sectionCount; ++i) {
const section_64 *sect = &sects[i];
Section section;
section.segmentName = getString16(sect->segname);
section.sectionName = getString16(sect->sectname);
- section.type = (SectionType)(read32(swap, sect->flags)
+ section.type = (SectionType)(read32(swap, sect->flags)
& SECTION_TYPE);
section.attributes = read32(swap, sect->flags) & SECTION_ATTRIBUTES;
section.alignment = read32(swap, sect->align);
@@ -217,31 +217,31 @@ readBinary(std::unique_ptr<MemoryBuffer> &mb,
// Note: this assign() is copying the content bytes. Ideally,
// we can use a custom allocator for vector to avoid the copy.
section.content = llvm::makeArrayRef(content, contentSize);
- appendRelocations(section.relocations, mb->getBuffer(),
- swap, isBigEndianArch, read32(swap, sect->reloff),
+ appendRelocations(section.relocations, mb->getBuffer(),
+ swap, isBigEndianArch, read32(swap, sect->reloff),
read32(swap, sect->nreloc));
f->sections.push_back(section);
}
}
} else {
if (cmd == LC_SEGMENT) {
- const segment_command *seg =
+ const segment_command *seg =
reinterpret_cast<const segment_command*>(lc);
const unsigned sectionCount = (swap ? SwapByteOrder(seg->nsects)
: seg->nsects);
const section *sects = reinterpret_cast<const section*>
(lc + sizeof(segment_command));
- const unsigned lcSize = sizeof(segment_command)
+ const unsigned lcSize = sizeof(segment_command)
+ sectionCount*sizeof(section);
// Verify sections don't extend beyond end of segment load command.
- if (lcSize > size)
+ if (lcSize > size)
return llvm::make_error_code(llvm::errc::executable_format_error);
for (unsigned i=0; i < sectionCount; ++i) {
const section *sect = &sects[i];
Section section;
section.segmentName = getString16(sect->segname);
section.sectionName = getString16(sect->sectname);
- section.type = (SectionType)(read32(swap, sect->flags)
+ section.type = (SectionType)(read32(swap, sect->flags)
& SECTION_TYPE);
section.attributes = read32(swap, sect->flags) & SECTION_ATTRIBUTES;
section.alignment = read32(swap, sect->align);
@@ -252,8 +252,8 @@ readBinary(std::unique_ptr<MemoryBuffer> &mb,
// Note: this assign() is copying the content bytes. Ideally,
// we can use a custom allocator for vector to avoid the copy.
section.content = llvm::makeArrayRef(content, contentSize);
- appendRelocations(section.relocations, mb->getBuffer(),
- swap, isBigEndianArch, read32(swap, sect->reloff),
+ appendRelocations(section.relocations, mb->getBuffer(),
+ swap, isBigEndianArch, read32(swap, sect->reloff),
read32(swap, sect->nreloc));
f->sections.push_back(section);
}
@@ -264,7 +264,7 @@ readBinary(std::unique_ptr<MemoryBuffer> &mb,
const char *strings = start + read32(swap, st->stroff);
const uint32_t strSize = read32(swap, st->strsize);
// Validate string pool and symbol table all in buffer.
- if ( read32(swap, st->stroff)+read32(swap, st->strsize)
+ if ( read32(swap, st->stroff)+read32(swap, st->strsize)
> objSize )
return llvm::make_error_code(llvm::errc::executable_format_error);
if (is64) {
@@ -282,7 +282,7 @@ readBinary(std::unique_ptr<MemoryBuffer> &mb,
tempSym = *sin; swapStruct(tempSym); sin = &tempSym;
}
Symbol sout;
- if (sin->n_strx > strSize)
+ if (sin->n_strx > strSize)
return llvm::make_error_code(llvm::errc::executable_format_error);
sout.name = &strings[sin->n_strx];
sout.type = (NListType)(sin->n_type & N_TYPE);
@@ -297,7 +297,7 @@ readBinary(std::unique_ptr<MemoryBuffer> &mb,
else
f->localSymbols.push_back(sout);
}
- } else {
+ } else {
const uint32_t symOffset = read32(swap, st->symoff);
const uint32_t symCount = read32(swap, st->nsyms);
if ( symOffset+(symCount*sizeof(nlist)) > objSize)
@@ -312,7 +312,7 @@ readBinary(std::unique_ptr<MemoryBuffer> &mb,
tempSym = *sin; swapStruct(tempSym); sin = &tempSym;
}
Symbol sout;
- if (sin->n_strx > strSize)
+ if (sin->n_strx > strSize)
return llvm::make_error_code(llvm::errc::executable_format_error);
sout.name = &strings[sin->n_strx];
sout.type = (NListType)(sin->n_type & N_TYPE);
@@ -329,12 +329,12 @@ readBinary(std::unique_ptr<MemoryBuffer> &mb,
}
}
} else if (cmd == LC_DYSYMTAB) {
- // TODO: indirect symbols
+ // TODO: indirect symbols
}
return false;
});
- if (ec)
+ if (ec)
return ec;
return std::move(f);
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
index 7f598592a95..5f8b9de7627 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryUtils.h
@@ -194,30 +194,30 @@ inline uint64_t read64(bool swap, uint64_t value) {
-inline uint32_t
-bitFieldExtract(uint32_t value, bool isBigEndianBigField, uint8_t firstBit,
+inline uint32_t
+bitFieldExtract(uint32_t value, bool isBigEndianBigField, uint8_t firstBit,
uint8_t bitCount) {
- const uint32_t mask = ((1<<bitCount)-1);
+ const uint32_t mask = ((1<<bitCount)-1);
const uint8_t shift = isBigEndianBigField ? (32-firstBit-bitCount) : firstBit;
return (value >> shift) & mask;
}
-inline void
-bitFieldSet(uint32_t &bits, bool isBigEndianBigField, uint32_t newBits,
+inline void
+bitFieldSet(uint32_t &bits, bool isBigEndianBigField, uint32_t newBits,
uint8_t firstBit, uint8_t bitCount) {
- const uint32_t mask = ((1<<bitCount)-1);
+ const uint32_t mask = ((1<<bitCount)-1);
assert((newBits & mask) == newBits);
const uint8_t shift = isBigEndianBigField ? (32-firstBit-bitCount) : firstBit;
bits &= ~(mask << shift);
bits |= (newBits << shift);
}
-inline Relocation
-unpackRelocation(const llvm::MachO::any_relocation_info &r, bool swap,
+inline Relocation
+unpackRelocation(const llvm::MachO::any_relocation_info &r, bool swap,
bool isBigEndian) {
uint32_t r0 = read32(swap, r.r_word0);
uint32_t r1 = read32(swap, r.r_word1);
-
+
Relocation result;
if (r0 & llvm::MachO::R_SCATTERED) {
// scattered relocation record always laid out like big endian bit field
@@ -242,14 +242,14 @@ unpackRelocation(const llvm::MachO::any_relocation_info &r, bool swap,
result.symbol = bitFieldExtract(r1, isBigEndian, 0, 24);
}
return result;
-}
+}
-inline llvm::MachO::any_relocation_info
+inline llvm::MachO::any_relocation_info
packRelocation(const Relocation &r, bool swap, bool isBigEndian) {
uint32_t r0 = 0;
uint32_t r1 = 0;
-
+
if (r.scattered) {
r1 = r.value;
bitFieldSet(r0, true, r.offset, 8, 24);
@@ -265,12 +265,12 @@ packRelocation(const Relocation &r, bool swap, bool isBigEndian) {
bitFieldSet(r1, isBigEndian, r.pcRel, 24, 1);
bitFieldSet(r1, isBigEndian, r.symbol, 0, 24);
}
-
+
llvm::MachO::any_relocation_info result;
result.r_word0 = swap ? SwapByteOrder(r0) : r0;
result.r_word1 = swap ? SwapByteOrder(r1) : r1;
return result;
-}
+}
inline StringRef getString16(const char s[16]) {
StringRef x = s;
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
index beecd331594..7b0b501c3b0 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileBinaryWriter.cpp
@@ -8,18 +8,18 @@
//===----------------------------------------------------------------------===//
///
-/// \file For mach-o object files, this implementation converts normalized
+/// \file For mach-o object files, this implementation converts normalized
/// mach-o in memory to mach-o binary on disk.
///
-/// +---------------+
-/// | binary mach-o |
-/// +---------------+
+/// +---------------+
+/// | binary mach-o |
+/// +---------------+
/// ^
/// |
/// |
-/// +------------+
-/// | normalized |
-/// +------------+
+/// +------------+
+/// | normalized |
+/// +------------+
#include "MachONormalizedFile.h"
#include "MachONormalizedFileBinaryUtils.h"
@@ -51,7 +51,7 @@ namespace mach_o {
namespace normalized {
/// Utility class for writing a mach-o binary file given an in-memory
-/// normalized file.
+/// normalized file.
class MachOFileLayout {
public:
/// All layout computation is done in the constructor.
@@ -60,11 +60,11 @@ public:
/// Returns the final file size as computed in the constructor.
size_t size() const;
- /// Writes the normalized file as a binary mach-o file to the specified
+ /// Writes the normalized file as a binary mach-o file to the specified
/// path. This does not have a stream interface because the generated
/// file may need the 'x' bit set.
error_code writeBinary(StringRef path);
-
+
private:
uint32_t loadCommandsSize(uint32_t &count);
void buildFileOffsets();
@@ -101,7 +101,7 @@ private:
typedef llvm::MachO::section section;
enum { LC = llvm::MachO::LC_SEGMENT };
};
-
+
template <typename T>
error_code writeSingleSegmentLoadCommand(uint8_t *&lc);
template <typename T>
@@ -109,7 +109,7 @@ private:
uint32_t pointerAlign(uint32_t value);
static StringRef dyldPath();
-
+
class ByteBuffer {
public:
ByteBuffer() : _ostream(_bytes) { }
@@ -141,7 +141,7 @@ private:
// Stream ivar must be after SmallVector ivar to construct properly.
llvm::raw_svector_ostream _ostream;
};
-
+
struct SegExtraInfo {
uint32_t fileOffset;
@@ -152,7 +152,7 @@ private:
uint32_t fileOffset;
};
typedef std::map<const Section*, SectionExtraInfo> SectionMap;
-
+
const NormalizedFile &_file;
error_code _ec;
uint8_t *_buffer;
@@ -207,19 +207,19 @@ StringRef MachOFileLayout::dyldPath() {
uint32_t MachOFileLayout::pointerAlign(uint32_t value) {
return llvm::RoundUpToAlignment(value, _is64 ? 8 : 4);
-}
+}
-
-MachOFileLayout::MachOFileLayout(const NormalizedFile &file)
+
+MachOFileLayout::MachOFileLayout(const NormalizedFile &file)
: _file(file),
_is64(MachOLinkingContext::is64Bit(file.arch)),
_swap(!MachOLinkingContext::isHostEndian(file.arch)),
_bigEndianArch(MachOLinkingContext::isBigEndian(file.arch)),
_seg1addr(INT64_MAX) {
_startOfLoadCommands = _is64 ? sizeof(mach_header_64) : sizeof(mach_header);
- const size_t segCommandBaseSize =
+ const size_t segCommandBaseSize =
(_is64 ? sizeof(segment_command_64) : sizeof(segment_command));
const size_t sectsSize = (_is64 ? sizeof(section_64) : sizeof(section));
if (file.fileType == llvm::MachO::MH_OBJECT) {
@@ -229,7 +229,7 @@ MachOFileLayout::MachOFileLayout(const NormalizedFile &file)
+ file.sections.size() * sectsSize
+ sizeof(symtab_command);
_countOfLoadCommands = 2;
-
+
// Accumulate size of each section.
_startOfSectionsContent = _endOfLoadCommands;
_endOfSectionsContent = _startOfSectionsContent;
@@ -239,21 +239,21 @@ MachOFileLayout::MachOFileLayout(const NormalizedFile &file)
_endOfSectionsContent += sect.content.size();
relocCount += sect.relocations.size();
}
-
+
computeSymbolTableSizes();
-
+
// Align start of relocations.
- _startOfRelocations = pointerAlign(_endOfSectionsContent);
+ _startOfRelocations = pointerAlign(_endOfSectionsContent);
_startOfSymbols = _startOfRelocations + relocCount * 8;
// Add Indirect symbol table.
_startOfIndirectSymbols = _startOfSymbols + _symbolTableSize;
// Align start of symbol table and symbol strings.
- _startOfSymbolStrings = _startOfIndirectSymbols
+ _startOfSymbolStrings = _startOfIndirectSymbols
+ pointerAlign(_indirectSymbolTableCount * sizeof(uint32_t));
- _endOfSymbolStrings = _startOfSymbolStrings
+ _endOfSymbolStrings = _startOfSymbolStrings
+ pointerAlign(_symbolStringPoolSize);
_endOfLinkEdit = _endOfSymbolStrings;
- DEBUG_WITH_TYPE("MachOFileLayout",
+ DEBUG_WITH_TYPE("MachOFileLayout",
llvm::dbgs() << "MachOFileLayout()\n"
<< " startOfLoadCommands=" << _startOfLoadCommands << "\n"
<< " countOfLoadCommands=" << _countOfLoadCommands << "\n"
@@ -266,13 +266,13 @@ MachOFileLayout::MachOFileLayout(const NormalizedFile &file)
<< " endOfSectionsContent=" << _endOfSectionsContent << "\n");
} else {
// Final linked images have one load command per segment.
- _endOfLoadCommands = _startOfLoadCommands
+ _endOfLoadCommands = _startOfLoadCommands
+ loadCommandsSize(_countOfLoadCommands);
// Assign section file offsets.
buildFileOffsets();
buildLinkEditInfo();
-
+
// LINKEDIT of final linked images has in order:
// rebase info, binding info, lazy binding info, weak binding info,
// indirect symbol table, symbol table, symbol table strings.
@@ -285,12 +285,12 @@ MachOFileLayout::MachOFileLayout(const NormalizedFile &file)
_startOfSymbols = _endOfLazyBindingInfo;
_startOfIndirectSymbols = _startOfSymbols + _symbolTableSize;
- _startOfSymbolStrings = _startOfIndirectSymbols
+ _startOfSymbolStrings = _startOfIndirectSymbols
+ pointerAlign(_indirectSymbolTableCount * sizeof(uint32_t));
- _endOfSymbolStrings = _startOfSymbolStrings
+ _endOfSymbolStrings = _startOfSymbolStrings
+ pointerAlign(_symbolStringPoolSize);
_endOfLinkEdit = _endOfSymbolStrings;
- DEBUG_WITH_TYPE("MachOFileLayout",
+ DEBUG_WITH_TYPE("MachOFileLayout",
llvm::dbgs() << "MachOFileLayout()\n"
<< " startOfLoadCommands=" << _startOfLoadCommands << "\n"
<< " countOfLoadCommands=" << _countOfLoadCommands << "\n"
@@ -312,8 +312,8 @@ MachOFileLayout::MachOFileLayout(const NormalizedFile &file)
uint32_t MachOFileLayout::loadCommandsSize(uint32_t &count) {
uint32_t size = 0;
count = 0;
-
- const size_t segCommandSize =
+
+ const size_t segCommandSize =
(_is64 ? sizeof(segment_command_64) : sizeof(segment_command));
const size_t sectionSize = (_is64 ? sizeof(section_64) : sizeof(section));
@@ -325,21 +325,21 @@ uint32_t MachOFileLayout::loadCommandsSize(uint32_t &count) {
// Add one LC_SEGMENT for implicit __LINKEDIT segment
size += segCommandSize;
++count;
-
+
// Add LC_DYLD_INFO
size += sizeof(dyld_info_command);
++count;
-
+
// Add LC_SYMTAB
size += sizeof(symtab_command);
++count;
-
+
// Add LC_DYSYMTAB
if (_file.fileType != llvm::MachO::MH_PRELOAD) {
size += sizeof(dysymtab_command);
++count;
}
-
+
// If main executable add LC_LOAD_DYLINKER and LC_MAIN
if (_file.fileType == llvm::MachO::MH_EXECUTE) {
size += pointerAlign(sizeof(dylinker_command) + dyldPath().size()+1);
@@ -347,13 +347,13 @@ uint32_t MachOFileLayout::loadCommandsSize(uint32_t &count) {
size += sizeof(entry_point_command);
++count;
}
-
+
// Add LC_LOAD_DYLIB for each dependent dylib.
for (const DependentDylib &dep : _file.dependentDylibs) {
size += sizeof(dylib_command) + pointerAlign(dep.path.size()+1);
++count;
}
-
+
return size;
}
@@ -385,8 +385,8 @@ void MachOFileLayout::buildFileOffsets() {
}
}
}
-
- // Verify no sections overlap
+
+ // Verify no sections overlap
for (const Section &s1 : _file.sections) {
for (const Section &s2 : _file.sections) {
if (&s1 == &s2)
@@ -397,7 +397,7 @@ void MachOFileLayout::buildFileOffsets() {
}
}
}
-
+
// Build side table of extra info about segments and sections.
SegExtraInfo t;
t.fileOffset = 0;
@@ -410,7 +410,7 @@ void MachOFileLayout::buildFileOffsets() {
for (const Section &s : _file.sections) {
_sectInfo[&s] = t2;
for (const Segment &sg : _file.segments) {
- if ((s.address >= sg.address)
+ if ((s.address >= sg.address)
&& (s.address+s.content.size() <= sg.address+sg.size)) {
if (!sg.name.equals(s.segmentName)) {
_ec = llvm::make_error_code(llvm::errc::executable_format_error);
@@ -420,23 +420,23 @@ void MachOFileLayout::buildFileOffsets() {
}
}
}
-
+
// Assign file offsets.
uint32_t fileOffset = 0;
- DEBUG_WITH_TYPE("MachOFileLayout",
+ DEBUG_WITH_TYPE("MachOFileLayout",
llvm::dbgs() << "buildFileOffsets()\n");
for (const Segment &sg : _file.segments) {
// FIXME: 4096 should be inferred from segments in normalized file.
_segInfo[&sg].fileOffset = llvm::RoundUpToAlignment(fileOffset, 4096);
if ((_seg1addr == INT64_MAX) && sg.access)
_seg1addr = sg.address;
- DEBUG_WITH_TYPE("MachOFileLayout",
+ DEBUG_WITH_TYPE("MachOFileLayout",
llvm::dbgs() << " segment=" << sg.name
<< ", fileOffset=" << _segInfo[&sg].fileOffset << "\n");
for (const Section *s : _segInfo[&sg].sections) {
fileOffset = s->address - sg.address + _segInfo[&sg].fileOffset;
_sectInfo[s].fileOffset = fileOffset;
- DEBUG_WITH_TYPE("MachOFileLayout",
+ DEBUG_WITH_TYPE("MachOFileLayout",
llvm::dbgs() << " section=" << s->sectionName
<< ", fileOffset=" << fileOffset << "\n");
}
@@ -463,7 +463,7 @@ void MachOFileLayout::writeMachHeader() {
swapStruct(*mh);
}
-uint32_t MachOFileLayout::indirectSymbolIndex(const Section &sect,
+uint32_t MachOFileLayout::indirectSymbolIndex(const Section &sect,
uint32_t &index) {
if (sect.indirectSymbols.empty())
return 0;
@@ -486,7 +486,7 @@ template <typename T>
error_code MachOFileLayout::writeSingleSegmentLoadCommand(uint8_t *&lc) {
typename T::command* seg = reinterpret_cast<typename T::command*>(lc);
seg->cmd = T::LC;
- seg->cmdsize = sizeof(typename T::command)
+ seg->cmdsize = sizeof(typename T::command)
+ _file.sections.size() * sizeof(typename T::section);
uint8_t *next = lc + seg->cmdsize;
memset(seg->segname, 0, 16);
@@ -536,7 +536,7 @@ error_code MachOFileLayout::writeSegmentLoadCommands(uint8_t *&lc) {
SegExtraInfo &segInfo = _segInfo[&seg];
typename T::command* cmd = reinterpret_cast<typename T::command*>(lc);
cmd->cmd = T::LC;
- cmd->cmdsize = sizeof(typename T::command)
+ cmd->cmdsize = sizeof(typename T::command)
+ segInfo.sections.size() * sizeof(typename T::section);
uint8_t *next = lc + cmd->cmdsize;
setString16(seg.name, cmd->segname);
@@ -567,7 +567,7 @@ error_code MachOFileLayout::writeSegmentLoadCommands(uint8_t *&lc) {
if (_swap)
swapStruct(*sect);
++sect;
- }
+ }
lc = reinterpret_cast<uint8_t*>(next);
}
// Add implicit __LINKEDIT segment
@@ -605,7 +605,7 @@ error_code MachOFileLayout::writeLoadCommands() {
st->cmd = LC_SYMTAB;
st->cmdsize = sizeof(symtab_command);
st->symoff = _startOfSymbols;
- st->nsyms = _file.localSymbols.size() + _file.globalSymbols.size()
+ st->nsyms = _file.localSymbols.size() + _file.globalSymbols.size()
+ _file.undefinedSymbols.size();
st->stroff = _startOfSymbolStrings;
st->strsize = _endOfSymbolStrings - _startOfSymbolStrings;
@@ -617,7 +617,7 @@ error_code MachOFileLayout::writeLoadCommands() {
ec = writeSegmentLoadCommands<MachO64Trait>(lc);
else
ec = writeSegmentLoadCommands<MachO32Trait>(lc);
-
+
// Add LC_DYLD_INFO_ONLY.
dyld_info_command* di = reinterpret_cast<dyld_info_command*>(lc);
di->cmd = LC_DYLD_INFO_ONLY;
@@ -641,14 +641,14 @@ error_code MachOFileLayout::writeLoadCommands() {
st->cmd = LC_SYMTAB;
st->cmdsize = sizeof(symtab_command);
st->symoff = _startOfSymbols;
- st->nsyms = _file.localSymbols.size() + _file.globalSymbols.size()
+ st->nsyms = _file.localSymbols.size() + _file.globalSymbols.size()
+ _file.undefinedSymbols.size();
st->stroff = _startOfSymbolStrings;
st->strsize = _endOfSymbolStrings - _startOfSymbolStrings;
if (_swap)
swapStruct(*st);
lc += sizeof(symtab_command);
-
+
// Add LC_DYSYMTAB
if (_file.fileType != llvm::MachO::MH_PRELOAD) {
dysymtab_command* dst = reinterpret_cast<dysymtab_command*>(lc);
@@ -666,7 +666,7 @@ error_code MachOFileLayout::writeLoadCommands() {
dst->nmodtab = 0;
dst->extrefsymoff = 0;
dst->nextrefsyms = 0;
- dst->indirectsymoff = _startOfIndirectSymbols;
+ dst->indirectsymoff = _startOfIndirectSymbols;
dst->nindirectsyms = _indirectSymbolTableCount;
dst->extreloff = 0;
dst->nextrel = 0;
@@ -676,7 +676,7 @@ error_code MachOFileLayout::writeLoadCommands() {
swapStruct(*dst);
lc += sizeof(dysymtab_command);
}
-
+
// If main executable, add LC_LOAD_DYLINKER and LC_MAIN.
if (_file.fileType == llvm::MachO::MH_EXECUTE) {
// Build LC_LOAD_DYLINKER load command.
@@ -700,7 +700,7 @@ error_code MachOFileLayout::writeLoadCommands() {
swapStruct(*ep);
lc += sizeof(entry_point_command);
}
-
+
// Add LC_LOAD_DYLIB commands
for (const DependentDylib &dep : _file.dependentDylibs) {
dylib_command* dc = reinterpret_cast<dylib_command*>(lc);
@@ -717,7 +717,7 @@ error_code MachOFileLayout::writeLoadCommands() {
lc[sizeof(dylib_command)+dep.path.size()] = '\0';
lc += size;
}
-
+
}
return ec;
}
@@ -818,12 +818,12 @@ void MachOFileLayout::writeRebaseInfo() {
}
void MachOFileLayout::writeBindingInfo() {
- memcpy(&_buffer[_startOfBindingInfo],
+ memcpy(&_buffer[_startOfBindingInfo],
_bindingInfo.bytes(), _bindingInfo.size());
}
void MachOFileLayout::writeLazyBindingInfo() {
- memcpy(&_buffer[_startOfLazyBindingInfo],
+ memcpy(&_buffer[_startOfLazyBindingInfo],
_lazyBindingInfo.bytes(), _lazyBindingInfo.size());
}
@@ -842,12 +842,12 @@ void MachOFileLayout::buildRebaseInfo() {
// TODO: compress rebasing info.
for (const RebaseLocation& entry : _file.rebasingInfo) {
_rebaseInfo.append_byte(REBASE_OPCODE_SET_TYPE_IMM | entry.kind);
- _rebaseInfo.append_byte(REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
+ _rebaseInfo.append_byte(REBASE_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
| entry.segIndex);
_rebaseInfo.append_uleb128(entry.segOffset);
_rebaseInfo.append_uleb128(REBASE_OPCODE_DO_REBASE_IMM_TIMES | 1);
}
- _rebaseInfo.append_byte(REBASE_OPCODE_DONE);
+ _rebaseInfo.append_byte(REBASE_OPCODE_DONE);
_rebaseInfo.align(_is64 ? 8 : 4);
}
@@ -855,7 +855,7 @@ void MachOFileLayout::buildBindInfo() {
// TODO: compress bind info.
for (const BindLocation& entry : _file.bindingInfo) {
_bindingInfo.append_byte(BIND_OPCODE_SET_TYPE_IMM | entry.kind);
- _bindingInfo.append_byte(BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
+ _bindingInfo.append_byte(BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
| entry.segIndex);
_bindingInfo.append_uleb128(entry.segOffset);
_bindingInfo.append_byte(BIND_OPCODE_SET_DYLIB_ORDINAL_IMM | entry.ordinal);
@@ -867,14 +867,14 @@ void MachOFileLayout::buildBindInfo() {
}
_bindingInfo.append_byte(BIND_OPCODE_DO_BIND);
}
- _bindingInfo.append_byte(BIND_OPCODE_DONE);
+ _bindingInfo.append_byte(BIND_OPCODE_DONE);
_bindingInfo.align(_is64 ? 8 : 4);
}
void MachOFileLayout::buildLazyBindInfo() {
for (const BindLocation& entry : _file.lazyBindingInfo) {
_lazyBindingInfo.append_byte(BIND_OPCODE_SET_TYPE_IMM | entry.kind);
- _lazyBindingInfo.append_byte(BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
+ _lazyBindingInfo.append_byte(BIND_OPCODE_SET_SEGMENT_AND_OFFSET_ULEB
| entry.segIndex);
_lazyBindingInfo.append_uleb128(entry.segOffset);
_lazyBindingInfo.append_byte(BIND_OPCODE_SET_DYLIB_ORDINAL_IMM | entry.ordinal);
@@ -882,17 +882,17 @@ void MachOFileLayout::buildLazyBindInfo() {
_lazyBindingInfo.append_string(entry.symbolName);
_lazyBindingInfo.append_byte(BIND_OPCODE_DO_BIND);
}
- _lazyBindingInfo.append_byte(BIND_OPCODE_DONE);
+ _lazyBindingInfo.append_byte(BIND_OPCODE_DONE);
_lazyBindingInfo.align(_is64 ? 8 : 4);
}
void MachOFileLayout::computeSymbolTableSizes() {
// MachO symbol tables have three ranges: locals, globals, and undefines
const size_t nlistSize = (_is64 ? sizeof(nlist_64) : sizeof(nlist));
- _symbolTableSize = nlistSize * (_file.localSymbols.size()
+ _symbolTableSize = nlistSize * (_file.localSymbols.size()
+ _file.globalSymbols.size()
+ _file.undefinedSymbols.size());
- _symbolStringPoolSize = 0;
+ _symbolStringPoolSize = 0;
for (const Symbol &sym : _file.localSymbols) {
_symbolStringPoolSize += (sym.name.size()+1);
}
@@ -904,7 +904,7 @@ void MachOFileLayout::computeSymbolTableSizes() {
}
_symbolTableLocalsStartIndex = 0;
_symbolTableGlobalsStartIndex = _file.localSymbols.size();
- _symbolTableUndefinesStartIndex = _symbolTableGlobalsStartIndex
+ _symbolTableUndefinesStartIndex = _symbolTableGlobalsStartIndex
+ _file.globalSymbols.size();
_indirectSymbolTableCount = 0;
@@ -941,7 +941,7 @@ error_code MachOFileLayout::writeBinary(StringRef path) {
ec = llvm::FileOutputBuffer::create(path, size(), fob, flags);
if (ec)
return ec;
-
+
// Write content.
_buffer = fob->getBufferStart();
writeMachHeader();
@@ -958,7 +958,7 @@ error_code MachOFileLayout::writeBinary(StringRef path) {
/// Takes in-memory normalized view and writes a mach-o object file.
-error_code
+error_code
writeBinary(const NormalizedFile &file, StringRef path) {
MachOFileLayout layout(file);
return layout.writeBinary(path);
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
index f671ff8c768..1c333b94257 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp
@@ -16,9 +16,9 @@
/// ^
/// |
/// |
-/// +-------+
+/// +-------+
/// | Atoms |
-/// +-------+
+/// +-------+
#include "MachONormalizedFile.h"
#include "ReferenceKinds.h"
@@ -53,7 +53,7 @@ struct AtomInfo {
struct SectionInfo {
SectionInfo(StringRef seg, StringRef sect, SectionType type, uint32_t attr=0);
-
+
StringRef segmentName;
StringRef sectionName;
SectionType type;
@@ -66,15 +66,15 @@ struct SectionInfo {
uint32_t finalSectionIndex;
};
-SectionInfo::SectionInfo(StringRef sg, StringRef sct, SectionType t, uint32_t a)
- : segmentName(sg), sectionName(sct), type(t), attributes(a),
- address(0), size(0), alignment(0),
+SectionInfo::SectionInfo(StringRef sg, StringRef sct, SectionType t, uint32_t a)
+ : segmentName(sg), sectionName(sct), type(t), attributes(a),
+ address(0), size(0), alignment(0),
normalizedSectionIndex(0), finalSectionIndex(0) {
}
struct SegmentInfo {
SegmentInfo(StringRef name);
-
+
StringRef name;
uint64_t address;
uint64_t size;
@@ -82,7 +82,7 @@ struct SegmentInfo {
std::vector<SectionInfo*> sections;
};
-SegmentInfo::SegmentInfo(StringRef n)
+SegmentInfo::SegmentInfo(StringRef n)
: name(n), address(0), size(0), access(0) {
}
@@ -108,10 +108,10 @@ public:
private:
typedef std::map<DefinedAtom::ContentType, SectionInfo*> TypeToSection;
typedef llvm::DenseMap<const Atom*, uint64_t> AtomToAddress;
-
+
struct DylibInfo { int ordinal; bool hasWeak; bool hasNonWeak; };
typedef llvm::StringMap<DylibInfo> DylibPathToInfo;
-
+
SectionInfo *sectionForAtom(const DefinedAtom*);
SectionInfo *makeSection(DefinedAtom::ContentType);
void appendAtom(SectionInfo *sect, const DefinedAtom *atom);
@@ -121,15 +121,15 @@ private:
void copySectionContent(SectionInfo *si, ContentBytes &content);
uint8_t scopeBits(const DefinedAtom* atom);
int dylibOrdinal(const SharedLibraryAtom *sa);
- void segIndexForSection(const SectionInfo *sect,
+ void segIndexForSection(const SectionInfo *sect,
uint8_t &segmentIndex, uint64_t &segmentStartAddr);
const Atom *targetOfLazyPointer(const DefinedAtom *lpAtom);
const Atom *targetOfStub(const DefinedAtom *stubAtom);
bool belongsInGlobalSymbolsSection(const DefinedAtom* atom);
void appendSection(SectionInfo *si, NormalizedFile &file);
- void appendReloc(const DefinedAtom *atom, const Reference *ref,
+ void appendReloc(const DefinedAtom *atom, const Reference *ref,
Relocations &relocations);
-
+
static uint64_t alignTo(uint64_t value, uint8_t align2);
typedef llvm::DenseMap<const Atom*, uint32_t> AtomToIndex;
struct AtomAndIndex { const Atom *atom; uint32_t index; };
@@ -160,7 +160,7 @@ SectionInfo *Util::makeSection(DefinedAtom::ContentType type) {
switch ( type ) {
case DefinedAtom::typeCode:
return new (_allocator) SectionInfo("__TEXT", "__text",
- S_REGULAR, S_ATTR_PURE_INSTRUCTIONS
+ S_REGULAR, S_ATTR_PURE_INSTRUCTIONS
| S_ATTR_SOME_INSTRUCTIONS);
case DefinedAtom::typeCString:
return new (_allocator) SectionInfo("__TEXT", "__cstring",
@@ -195,7 +195,7 @@ SectionInfo *Util::sectionForAtom(const DefinedAtom *atom) {
_sectionMap[type] = si;
return si;
}
-
+
void Util::appendAtom(SectionInfo *sect, const DefinedAtom *atom) {
// Figure out offset for atom in this section given alignment constraints.
@@ -250,7 +250,7 @@ unsigned Util::SegmentSorter::weight(const SegmentInfo *seg) {
.Default(100);
}
-bool Util::SegmentSorter::operator()(const SegmentInfo *left,
+bool Util::SegmentSorter::operator()(const SegmentInfo *left,
const SegmentInfo *right) {
return (weight(left) < weight(right));
}
@@ -267,7 +267,7 @@ unsigned Util::TextSectionSorter::weight(const SectionInfo *sect) {
.Default(10);
}
-bool Util::TextSectionSorter::operator()(const SectionInfo *left,
+bool Util::TextSectionSorter::operator()(const SectionInfo *left,
const SectionInfo *right) {
return (weight(left) < weight(right));
}
@@ -291,15 +291,15 @@ void Util::organizeSections() {
}
// Sort segments.
std::sort(_segmentInfos.begin(), _segmentInfos.end(), SegmentSorter());
-
+
// Sort sections within segments.
for (SegmentInfo *seg : _segmentInfos) {
if (seg->name.equals("__TEXT")) {
- std::sort(seg->sections.begin(), seg->sections.end(),
+ std::sort(seg->sections.begin(), seg->sections.end(),
TextSectionSorter());
}
}
-
+
// Record final section indexes.
uint32_t sectionIndex = 1;
for (SegmentInfo *seg : _segmentInfos) {
@@ -331,7 +331,7 @@ void Util::layoutSectionsInTextSegment(SegmentInfo *seg, uint64_t &addr) {
seg->address = addr;
// Walks sections starting at end to calculate padding for start.
int64_t taddr = 0;
- for (auto it = seg->sections.rbegin(); it != seg->sections.rend(); ++it) {
+ for (auto it = seg->sections.rbegin(); it != seg->sections.rend(); ++it) {
SectionInfo *sect = *it;
taddr -= sect->size;
taddr = taddr & (0 - (1 << sect->alignment));
@@ -362,17 +362,17 @@ void Util::assignAddressesToSections() {
else
layoutSectionsInSegment(seg, address);
}
- DEBUG_WITH_TYPE("WriterMachO-norm",
+ DEBUG_WITH_TYPE("WriterMachO-norm",
llvm::dbgs() << "assignAddressesToSections()\n";
for (SegmentInfo *sgi : _segmentInfos) {
llvm::dbgs() << " address=" << llvm::format("0x%08llX", sgi->address)
<< ", size=" << llvm::format("0x%08llX", sgi->size)
- << ", segment-name='" << sgi->name
+ << ", segment-name='" << sgi->name
<< "'\n";
for (SectionInfo *si : sgi->sections) {
llvm::dbgs()<< " addr=" << llvm::format("0x%08llX", si->address)
<< ", size=" << llvm::format("0x%08llX", si->size)
- << ", section-name='" << si->sectionName
+ << ", section-name='" << si->sectionName
<< "\n";
}
}
@@ -382,10 +382,10 @@ void Util::assignAddressesToSections() {
sect->address = alignTo(address, sect->alignment);
address = sect->address + sect->size;
}
- DEBUG_WITH_TYPE("WriterMachO-norm",
+ DEBUG_WITH_TYPE("WriterMachO-norm",
llvm::dbgs() << "assignAddressesToSections()\n";
for (SectionInfo *si : _sectionInfos) {
- llvm::dbgs() << " section=" << si->sectionName
+ llvm::dbgs() << " section=" << si->sectionName
<< " address= " << llvm::format("0x%08X", si->address)
<< " size= " << llvm::format("0x%08X", si->size)
<< "\n";
@@ -499,19 +499,19 @@ uint8_t Util::scopeBits(const DefinedAtom* atom) {
llvm_unreachable("Unknown scope");
}
-bool Util::AtomSorter::operator()(const AtomAndIndex &left,
+bool Util::AtomSorter::operator()(const AtomAndIndex &left,
const AtomAndIndex &right) {
return (left.atom->name().compare(right.atom->name()) < 0);
}
-
+
bool Util::belongsInGlobalSymbolsSection(const DefinedAtom* atom) {
return (atom->scope() == Atom::scopeGlobal);
}
void Util::addSymbols(const lld::File &atomFile, NormalizedFile &file) {
// Mach-O symbol table has three regions: locals, globals, undefs.
-
+
// Add all local (non-global) symbols in address order
std::vector<AtomAndIndex> globals;
globals.reserve(512);
@@ -525,7 +525,7 @@ void Util::addSymbols(const lld::File &atomFile, NormalizedFile &file) {
} else {
Symbol sym;
sym.name = atom->name();
- sym.type = N_SECT;
+ sym.type = N_SECT;
sym.scope = scopeBits(atom);
sym.sect = sect->finalSectionIndex;
sym.desc = 0;
@@ -535,21 +535,21 @@ void Util::addSymbols(const lld::File &atomFile, NormalizedFile &file) {
}
}
}
-
+
// Sort global symbol alphabetically, then add to symbol table.
std::sort(globals.begin(), globals.end(), AtomSorter());
for (AtomAndIndex &ai : globals) {
Symbol sym;
sym.name = ai.atom->name();
- sym.type = N_SECT;
+ sym.type = N_SECT;
sym.scope = scopeBits(static_cast<const DefinedAtom*>(ai.atom));
sym.sect = ai.index;
sym.desc = 0;
sym.value = _atomToAddress[ai.atom];
file.globalSymbols.push_back(sym);
}
-
-
+
+
// Sort undefined symbol alphabetically, then add to symbol table.
std::vector<AtomAndIndex> undefs;
undefs.reserve(128);
@@ -566,7 +566,7 @@ void Util::addSymbols(const lld::File &atomFile, NormalizedFile &file) {
for (AtomAndIndex &ai : undefs) {
Symbol sym;
sym.name = ai.atom->name();
- sym.type = N_UNDF;
+ sym.type = N_UNDF;
sym.scope = N_EXT;
sym.sect = 0;
sym.desc = 0;
@@ -690,7 +690,7 @@ void Util::segIndexForSection(const SectionInfo *sect, uint8_t &segmentIndex,
uint64_t &segmentStartAddr) {
segmentIndex = 0;
for (const SegmentInfo *seg : _segmentInfos) {
- if ((seg->address <= sect->address)
+ if ((seg->address <= sect->address)
&& (seg->address+seg->size >= sect->address+sect->size)) {
segmentStartAddr = seg->address;
return;
@@ -701,7 +701,7 @@ void Util::segIndexForSection(const SectionInfo *sect, uint8_t &segmentIndex,
}
-void Util::appendReloc(const DefinedAtom *atom, const Reference *ref,
+void Util::appendReloc(const DefinedAtom *atom, const Reference *ref,
Relocations &relocations) {
// TODO: convert Reference to normalized relocation
}
@@ -709,7 +709,7 @@ void Util::appendReloc(const DefinedAtom *atom, const Reference *ref,
void Util::addSectionRelocs(const lld::File &, NormalizedFile &file) {
if (_context.outputFileType() != llvm::MachO::MH_OBJECT)
return;
-
+
for (SectionInfo *si : _sectionInfos) {
Section &normSect = file.sections[si->normalizedSectionIndex];
for (const AtomInfo &info : si->atomsAndOffsets) {
@@ -721,7 +721,7 @@ void Util::addSectionRelocs(const lld::File &, NormalizedFile &file) {
}
}
-void Util::addRebaseAndBindingInfo(const lld::File &atomFile,
+void Util::addRebaseAndBindingInfo(const lld::File &atomFile,
NormalizedFile &nFile) {
if (_context.outputFileType() == llvm::MachO::MH_OBJECT)
return;
@@ -733,7 +733,7 @@ void Util::addRebaseAndBindingInfo(const lld::File &atomFile,
for (const AtomInfo &info : sect->atomsAndOffsets) {
const DefinedAtom *atom = info.atom;
for (const Reference *ref : *atom) {
- uint64_t segmentOffset = _atomToAddress[atom] + ref->offsetInAtom()
+ uint64_t segmentOffset = _atomToAddress[atom] + ref->offsetInAtom()
- segmentStartAddr;
const Atom* targ = ref->target();
if (_context.kindHandler().isPointer(*ref)) {
@@ -753,7 +753,7 @@ void Util::addRebaseAndBindingInfo(const lld::File &atomFile,
bind.kind = llvm::MachO::BIND_TYPE_POINTER;
bind.canBeNull = sa->canBeNullAtRuntime();
bind.ordinal = dylibOrdinal(sa);
- bind.symbolName = targ->name();
+ bind.symbolName = targ->name();
bind.addend = ref->addend();
nFile.bindingInfo.push_back(bind);
}
@@ -765,7 +765,7 @@ void Util::addRebaseAndBindingInfo(const lld::File &atomFile,
bind.kind = llvm::MachO::BIND_TYPE_POINTER;
bind.canBeNull = false; //sa->canBeNullAtRuntime();
bind.ordinal = 1;
- bind.symbolName = targ->name();
+ bind.symbolName = targ->name();
bind.addend = ref->addend();
nFile.lazyBindingInfo.push_back(bind);
}
@@ -786,16 +786,16 @@ namespace mach_o {
namespace normalized {
/// Convert a set of Atoms into a normalized mach-o file.
-ErrorOr<std::unique_ptr<NormalizedFile>>
-normalizedFromAtoms(const lld::File &atomFile,
+ErrorOr<std::unique_ptr<NormalizedFile>>
+normalizedFromAtoms(const lld::File &atomFile,
const MachOLinkingContext &context) {
- // The util object buffers info until the normalized file can be made.
+ // The util object buffers info until the normalized file can be made.
Util util(context);
util.assignAtomsToSections(atomFile);
util.organizeSections();
util.assignAddressesToSections();
util.buildAtomToAddressMap();
-
+
std::unique_ptr<NormalizedFile> f(new NormalizedFile());
NormalizedFile &normFile = *f.get();
f->arch = context.arch();
@@ -809,7 +809,7 @@ normalizedFromAtoms(const lld::File &atomFile,
util.addRebaseAndBindingInfo(atomFile, normFile);
util.addSectionRelocs(atomFile, normFile);
util.copyEntryPointAddress(normFile);
-
+
return std::move(f);
}
diff --git a/lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp b/lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
index 5a5a9449158..766cdf8696c 100644
--- a/lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
+++ b/lld/lib/ReaderWriter/MachO/MachONormalizedFileYAML.cpp
@@ -11,9 +11,9 @@
/// \file For mach-o object files, this implementation uses YAML I/O to
/// provide the convert between YAML and the normalized mach-o (NM).
///
-/// +------------+ +------+
-/// | normalized | <-> | yaml |
-/// +------------+ +------+
+/// +------------+ +------+
+/// | normalized | <-> | yaml |
+/// +------------+ +------+
#include "MachONormalizedFile.h"
@@ -138,13 +138,13 @@ struct ScalarEnumerationTraits<lld::MachOLinkingContext::Arch> {
template <>
struct ScalarEnumerationTraits<lld::MachOLinkingContext::OS> {
static void enumeration(IO &io, lld::MachOLinkingContext::OS &value) {
- io.enumCase(value, "unknown",
+ io.enumCase(value, "unknown",
lld::MachOLinkingContext::OS::unknown);
- io.enumCase(value, "Mac OS X",
+ io.enumCase(value, "Mac OS X",
lld::MachOLinkingContext::OS::macOSX);
- io.enumCase(value, "iOS",
+ io.enumCase(value, "iOS",
lld::MachOLinkingContext::OS::iOS);
- io.enumCase(value, "iOS Simulator",
+ io.enumCase(value, "iOS Simulator",
lld::MachOLinkingContext::OS::iOS_simulator);
}
};
@@ -164,9 +164,9 @@ struct ScalarEnumerationTraits<HeaderFileType> {
template <>
struct ScalarBitSetTraits<FileFlags> {
static void bitset(IO &io, FileFlags &value) {
- io.bitSetCase(value, "MH_TWOLEVEL",
+ io.bitSetCase(value, "MH_TWOLEVEL",
llvm::MachO::MH_TWOLEVEL);
- io.bitSetCase(value, "MH_SUBSECTIONS_VIA_SYMBOLS",
+ io.bitSetCase(value, "MH_SUBSECTIONS_VIA_SYMBOLS",
llvm::MachO::MH_SUBSECTIONS_VIA_SYMBOLS);
}
};
@@ -175,49 +175,49 @@ struct ScalarBitSetTraits<FileFlags> {
template <>
struct ScalarEnumerationTraits<SectionType> {
static void enumeration(IO &io, SectionType &value) {
- io.enumCase(value, "S_REGULAR",
+ io.enumCase(value, "S_REGULAR",
llvm::MachO::S_REGULAR);
- io.enumCase(value, "S_ZEROFILL",
+ io.enumCase(value, "S_ZEROFILL",
llvm::MachO::S_ZEROFILL);
- io.enumCase(value, "S_CSTRING_LITERALS",
+ io.enumCase(value, "S_CSTRING_LITERALS",
llvm::MachO::S_CSTRING_LITERALS);
- io.enumCase(value, "S_4BYTE_LITERALS",
+ io.enumCase(value, "S_4BYTE_LITERALS",
llvm::MachO::S_4BYTE_LITERALS);
- io.enumCase(value, "S_8BYTE_LITERALS",
+ io.enumCase(value, "S_8BYTE_LITERALS",
llvm::MachO::S_8BYTE_LITERALS);
- io.enumCase(value, "S_LITERAL_POINTERS",
+ io.enumCase(value, "S_LITERAL_POINTERS",
llvm::MachO::S_LITERAL_POINTERS);
- io.enumCase(value, "S_NON_LAZY_SYMBOL_POINTERS",
+ io.enumCase(value, "S_NON_LAZY_SYMBOL_POINTERS",
llvm::MachO::S_NON_LAZY_SYMBOL_POINTERS);
- io.enumCase(value, "S_LAZY_SYMBOL_POINTERS",
+ io.enumCase(value, "S_LAZY_SYMBOL_POINTERS",
llvm::MachO::S_LAZY_SYMBOL_POINTERS);
- io.enumCase(value, "S_SYMBOL_STUBS",
+ io.enumCase(value, "S_SYMBOL_STUBS",
llvm::MachO::S_SYMBOL_STUBS);
- io.enumCase(value, "S_MOD_INIT_FUNC_POINTERS",
+ io.enumCase(value, "S_MOD_INIT_FUNC_POINTERS",
llvm::MachO::S_MOD_INIT_FUNC_POINTERS);
- io.enumCase(value, "S_MOD_TERM_FUNC_POINTERS",
+ io.enumCase(value, "S_MOD_TERM_FUNC_POINTERS",
llvm::MachO::S_MOD_TERM_FUNC_POINTERS);
- io.enumCase(value, "S_COALESCED",
+ io.enumCase(value, "S_COALESCED",
llvm::MachO::S_COALESCED);
- io.enumCase(value, "S_GB_ZEROFILL",
+ io.enumCase(value, "S_GB_ZEROFILL",
llvm::MachO::S_GB_ZEROFILL);
- io.enumCase(value, "S_INTERPOSING",
+ io.enumCase(value, "S_INTERPOSING",
llvm::MachO::S_INTERPOSING);
- io.enumCase(value, "S_16BYTE_LITERALS",
+ io.enumCase(value, "S_16BYTE_LITERALS",
llvm::MachO::S_16BYTE_LITERALS);
- io.enumCase(value, "S_DTRACE_DOF",
+ io.enumCase(value, "S_DTRACE_DOF",
llvm::MachO::S_DTRACE_DOF);
- io.enumCase(value, "S_LAZY_DYLIB_SYMBOL_POINTERS",
+ io.enumCase(value, "S_LAZY_DYLIB_SYMBOL_POINTERS",
llvm::MachO::S_LAZY_DYLIB_SYMBOL_POINTERS);
- io.enumCase(value, "S_THREAD_LOCAL_REGULAR",
+ io.enumCase(value, "S_THREAD_LOCAL_REGULAR",
llvm::MachO::S_THREAD_LOCAL_REGULAR);
- io.enumCase(value, "S_THREAD_LOCAL_ZEROFILL",
+ io.enumCase(value, "S_THREAD_LOCAL_ZEROFILL",
llvm::MachO::S_THREAD_LOCAL_ZEROFILL);
- io.enumCase(value, "S_THREAD_LOCAL_VARIABLES",
+ io.enumCase(value, "S_THREAD_LOCAL_VARIABLES",
llvm::MachO::S_THREAD_LOCAL_VARIABLES);
- io.enumCase(value, "S_THREAD_LOCAL_VARIABLE_POINTERS",
+ io.enumCase(value, "S_THREAD_LOCAL_VARIABLE_POINTERS",
llvm::MachO::S_THREAD_LOCAL_VARIABLE_POINTERS);
- io.enumCase(value, "S_THREAD_LOCAL_INIT_FUNCTION_POINTERS",
+ io.enumCase(value, "S_THREAD_LOCAL_INIT_FUNCTION_POINTERS",
llvm::MachO::S_THREAD_LOCAL_INIT_FUNCTION_POINTERS);
}
};
@@ -225,15 +225,15 @@ struct ScalarEnumerationTraits<SectionType> {
template <>
struct ScalarBitSetTraits<SectionAttr> {
static void bitset(IO &io, SectionAttr &value) {
- io.bitSetCase(value, "S_ATTR_PURE_INSTRUCTIONS",
+ io.bitSetCase(value, "S_ATTR_PURE_INSTRUCTIONS",
llvm::MachO::S_ATTR_PURE_INSTRUCTIONS);
- io.bitSetCase(value, "S_ATTR_SOME_INSTRUCTIONS",
+ io.bitSetCase(value, "S_ATTR_SOME_INSTRUCTIONS",
llvm::MachO::S_ATTR_SOME_INSTRUCTIONS);
- io.bitSetCase(value, "S_ATTR_NO_DEAD_STRIP",
+ io.bitSetCase(value, "S_ATTR_NO_DEAD_STRIP",
llvm::MachO::S_ATTR_NO_DEAD_STRIP);
- io.bitSetCase(value, "S_ATTR_EXT_RELOC",
+ io.bitSetCase(value, "S_ATTR_EXT_RELOC",
llvm::MachO::S_ATTR_EXT_RELOC);
- io.bitSetCase(value, "S_ATTR_LOC_RELOC",
+ io.bitSetCase(value, "S_ATTR_LOC_RELOC",
llvm::MachO::S_ATTR_LOC_RELOC);
}
};
@@ -306,7 +306,7 @@ struct MappingTraits<Section> {
std::copy(_normalizedContent.begin(), _normalizedContent.end(), bytes);
return makeArrayRef(bytes, size);
}
-
+
IO &_io;
ContentBytes _normalizedContent;
};
@@ -340,57 +340,57 @@ struct ScalarEnumerationTraits<RelocationInfoType> {
assert(file != nullptr);
switch (file->arch) {
case lld::MachOLinkingContext::arch_x86_64:
- io.enumCase(value, "X86_64_RELOC_UNSIGNED",
+ io.enumCase(value, "X86_64_RELOC_UNSIGNED",
llvm::MachO::X86_64_RELOC_UNSIGNED);
- io.enumCase(value, "X86_64_RELOC_SIGNED",
+ io.enumCase(value, "X86_64_RELOC_SIGNED",
llvm::MachO::X86_64_RELOC_SIGNED);
- io.enumCase(value, "X86_64_RELOC_BRANCH",
+ io.enumCase(value, "X86_64_RELOC_BRANCH",
llvm::MachO::X86_64_RELOC_BRANCH);
- io.enumCase(value, "X86_64_RELOC_GOT_LOAD",
+ io.enumCase(value, "X86_64_RELOC_GOT_LOAD",
llvm::MachO::X86_64_RELOC_GOT_LOAD);
- io.enumCase(value, "X86_64_RELOC_GOT",
+ io.enumCase(value, "X86_64_RELOC_GOT",
llvm::MachO::X86_64_RELOC_GOT);
- io.enumCase(value, "X86_64_RELOC_SUBTRACTOR",
+ io.enumCase(value, "X86_64_RELOC_SUBTRACTOR",
llvm::MachO::X86_64_RELOC_SUBTRACTOR);
- io.enumCase(value, "X86_64_RELOC_SIGNED_1",
+ io.enumCase(value, "X86_64_RELOC_SIGNED_1",
llvm::MachO::X86_64_RELOC_SIGNED_1);
- io.enumCase(value, "X86_64_RELOC_SIGNED_2",
+ io.enumCase(value, "X86_64_RELOC_SIGNED_2",
llvm::MachO::X86_64_RELOC_SIGNED_2);
- io.enumCase(value, "X86_64_RELOC_SIGNED_4",
+ io.enumCase(value, "X86_64_RELOC_SIGNED_4",
llvm::MachO::X86_64_RELOC_SIGNED_4);
- io.enumCase(value, "X86_64_RELOC_TLV",
+ io.enumCase(value, "X86_64_RELOC_TLV",
llvm::MachO::X86_64_RELOC_TLV);
break;
case lld::MachOLinkingContext::arch_x86:
- io.enumCase(value, "GENERIC_RELOC_VANILLA",
+ io.enumCase(value, "GENERIC_RELOC_VANILLA",
llvm::MachO::GENERIC_RELOC_VANILLA);
- io.enumCase(value, "GENERIC_RELOC_PAIR",
+ io.enumCase(value, "GENERIC_RELOC_PAIR",
llvm::MachO::GENERIC_RELOC_PAIR);
- io.enumCase(value, "GENERIC_RELOC_SECTDIFF",
+ io.enumCase(value, "GENERIC_RELOC_SECTDIFF",
llvm::MachO::GENERIC_RELOC_SECTDIFF);
- io.enumCase(value, "GENERIC_RELOC_LOCAL_SECTDIFF",
+ io.enumCase(value, "GENERIC_RELOC_LOCAL_SECTDIFF",
llvm::MachO::GENERIC_RELOC_LOCAL_SECTDIFF);
- io.enumCase(value, "GENERIC_RELOC_TLV",
+ io.enumCase(value, "GENERIC_RELOC_TLV",
llvm::MachO::GENERIC_RELOC_TLV);
break;
case lld::MachOLinkingContext::arch_armv6:
case lld::MachOLinkingContext::arch_armv7:
case lld::MachOLinkingContext::arch_armv7s:
- io.enumCase(value, "ARM_RELOC_VANILLA",
+ io.enumCase(value, "ARM_RELOC_VANILLA",
llvm::MachO::ARM_RELOC_VANILLA);
- io.enumCase(value, "ARM_RELOC_PAIR",
+ io.enumCase(value, "ARM_RELOC_PAIR",
llvm::MachO::ARM_RELOC_PAIR);
- io.enumCase(value, "ARM_RELOC_SECTDIFF",
+ io.enumCase(value, "ARM_RELOC_SECTDIFF",
llvm::MachO::ARM_RELOC_SECTDIFF);
- io.enumCase(value, "ARM_RELOC_LOCAL_SECTDIFF",
+ io.enumCase(value, "ARM_RELOC_LOCAL_SECTDIFF",
llvm::MachO::ARM_RELOC_LOCAL_SECTDIFF);
- io.enumCase(value, "ARM_RELOC_BR24",
+ io.enumCase(value, "ARM_RELOC_BR24",
llvm::MachO::ARM_RELOC_BR24);
- io.enumCase(value, "ARM_THUMB_RELOC_BR22",
+ io.enumCase(value, "ARM_THUMB_RELOC_BR22",
llvm::MachO::ARM_THUMB_RELOC_BR22);
- io.enumCase(value, "ARM_RELOC_HALF",
+ io.enumCase(value, "ARM_RELOC_HALF",
llvm::MachO::ARM_RELOC_HALF);
- io.enumCase(value, "ARM_RELOC_HALF_SECTDIFF",
+ io.enumCase(value, "ARM_RELOC_HALF_SECTDIFF",
llvm::MachO::ARM_RELOC_HALF_SECTDIFF);
break;
default:
@@ -470,15 +470,15 @@ struct MappingTraits<Segment> {
template <>
struct ScalarEnumerationTraits<LoadCommandType> {
static void enumeration(IO &io, LoadCommandType &value) {
- io.enumCase(value, "LC_LOAD_DYLIB",
+ io.enumCase(value, "LC_LOAD_DYLIB",
llvm::MachO::LC_LOAD_DYLIB);
- io.enumCase(value, "LC_LOAD_WEAK_DYLIB",
+ io.enumCase(value, "LC_LOAD_WEAK_DYLIB",
llvm::MachO::LC_LOAD_WEAK_DYLIB);
- io.enumCase(value, "LC_REEXPORT_DYLIB",
+ io.enumCase(value, "LC_REEXPORT_DYLIB",
llvm::MachO::LC_REEXPORT_DYLIB);
- io.enumCase(value, "LC_LOAD_UPWARD_DYLIB",
+ io.enumCase(value, "LC_LOAD_UPWARD_DYLIB",
llvm::MachO::LC_LOAD_UPWARD_DYLIB);
- io.enumCase(value, "LC_LAZY_LOAD_DYLIB",
+ io.enumCase(value, "LC_LAZY_LOAD_DYLIB",
llvm::MachO::LC_LAZY_LOAD_DYLIB);
}
};
@@ -495,11 +495,11 @@ struct MappingTraits<DependentDylib> {
template <>
struct ScalarEnumerationTraits<RebaseType> {
static void enumeration(IO &io, RebaseType &value) {
- io.enumCase(value, "REBASE_TYPE_POINTER",
+ io.enumCase(value, "REBASE_TYPE_POINTER",
llvm::MachO::REBASE_TYPE_POINTER);
- io.enumCase(value, "REBASE_TYPE_TEXT_PCREL32",
+ io.enumCase(value, "REBASE_TYPE_TEXT_PCREL32",
llvm::MachO::REBASE_TYPE_TEXT_PCREL32);
- io.enumCase(value, "REBASE_TYPE_TEXT_ABSOLUTE32",
+ io.enumCase(value, "REBASE_TYPE_TEXT_ABSOLUTE32",
llvm::MachO::REBASE_TYPE_TEXT_ABSOLUTE32);
}
};
@@ -510,7 +510,7 @@ struct MappingTraits<RebaseLocation> {
static void mapping(IO &io, RebaseLocation& rebase) {
io.mapRequired("segment-index", rebase.segIndex);
io.mapRequired("segment-offset", rebase.segOffset);
- io.mapOptional("kind", rebase.kind,
+ io.mapOptional("kind", rebase.kind,
llvm::MachO::REBASE_TYPE_POINTER);
}
};
@@ -520,11 +520,11 @@ struct MappingTraits<RebaseLocation> {
template <>
struct ScalarEnumerationTraits<BindType> {
static void enumeration(IO &io, BindType &value) {
- io.enumCase(value, "BIND_TYPE_POINTER",
+ io.enumCase(value, "BIND_TYPE_POINTER",
llvm::MachO::BIND_TYPE_POINTER);
- io.enumCase(value, "BIND_TYPE_TEXT_ABSOLUTE32",
+ io.enumCase(value, "BIND_TYPE_TEXT_ABSOLUTE32",
llvm::MachO::BIND_TYPE_TEXT_ABSOLUTE32);
- io.enumCase(value, "BIND_TYPE_TEXT_PCREL32",
+ io.enumCase(value, "BIND_TYPE_TEXT_PCREL32",
llvm::MachO::BIND_TYPE_TEXT_PCREL32);
}
};
@@ -534,7 +534,7 @@ struct MappingTraits<BindLocation> {
static void mapping(IO &io, BindLocation &bind) {
io.mapRequired("segment-index", bind.segIndex);
io.mapRequired("segment-offset", bind.segOffset);
- io.mapOptional("kind", bind.kind,
+ io.mapOptional("kind", bind.kind,
llvm::MachO::BIND_TYPE_POINTER);
io.mapOptional("can-be-null", bind.canBeNull, false);
io.mapRequired("ordinal", bind.ordinal);
@@ -547,9 +547,9 @@ struct MappingTraits<BindLocation> {
template <>
struct ScalarEnumerationTraits<ExportSymbolKind> {
static void enumeration(IO &io, ExportSymbolKind &value) {
- io.enumCase(value, "EXPORT_SYMBOL_FLAGS_KIND_REGULAR",
+ io.enumCase(value, "EXPORT_SYMBOL_FLAGS_KIND_REGULAR",
llvm::MachO::EXPORT_SYMBOL_FLAGS_KIND_REGULAR);
- io.enumCase(value, "EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCALl",
+ io.enumCase(value, "EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCALl",
llvm::MachO::EXPORT_SYMBOL_FLAGS_KIND_THREAD_LOCAL);
}
};
@@ -557,11 +557,11 @@ struct ScalarEnumerationTraits<ExportSymbolKind> {
template <>
struct ScalarBitSetTraits<ExportFlags> {
static void bitset(IO &io, ExportFlags &value) {
- io.bitSetCase(value, "EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION",
+ io.bitSetCase(value, "EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION",
llvm::MachO::EXPORT_SYMBOL_FLAGS_WEAK_DEFINITION);
- io.bitSetCase(value, "EXPORT_SYMBOL_FLAGS_REEXPORT",
+ io.bitSetCase(value, "EXPORT_SYMBOL_FLAGS_REEXPORT",
llvm::MachO::EXPORT_SYMBOL_FLAGS_REEXPORT);
- io.bitSetCase(value, "EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER",
+ io.bitSetCase(value, "EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER",
llvm::MachO::EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER);
}
};
@@ -572,7 +572,7 @@ struct MappingTraits<Export> {
static void mapping(IO &io, Export &exp) {
io.mapRequired("name", exp.name);
io.mapRequired("offset", exp.offset);
- io.mapOptional("kind", exp.kind,
+ io.mapOptional("kind", exp.kind,
llvm::MachO::EXPORT_SYMBOL_FLAGS_KIND_REGULAR);
io.mapOptional("flags", exp.flags);
io.mapOptional("other-offset", exp.otherOffset, Hex32(0));
@@ -619,7 +619,7 @@ struct MappingTraits<NormalizedFile> {
namespace lld {
namespace mach_o {
-/// Handles !mach-o tagged yaml documents.
+/// Handles !mach-o tagged yaml documents.
bool MachOYamlIOTaggedDocumentHandler::handledDocTag(llvm::yaml::IO &io,
const lld::File *&file) const {
if (!io.mapTag("!mach-o"))
diff --git a/lld/lib/ReaderWriter/MachO/StubAtoms.hpp b/lld/lib/ReaderWriter/MachO/StubAtoms.hpp
index ae0707f7835..daf7e7b3d0a 100644
--- a/lld/lib/ReaderWriter/MachO/StubAtoms.hpp
+++ b/lld/lib/ReaderWriter/MachO/StubAtoms.hpp
@@ -31,9 +31,9 @@ namespace mach_o {
//
class StubBinderAtom : public SharedLibraryAtom {
public:
- StubBinderAtom(const File &f) : _file(f) {
+ StubBinderAtom(const File &f) : _file(f) {
}
-
+
virtual const File& file() const {
return _file;
}
@@ -45,7 +45,7 @@ public:
virtual StringRef loadName() const {
return StringRef("/usr/lib/libSystem.B.dylib");
}
-
+
virtual bool canBeNullAtRuntime() const {
return false;
}
@@ -57,15 +57,15 @@ public:
virtual uint64_t size() const LLVM_OVERRIDE {
return 0;
}
-
+
private:
const File &_file;
};
-} // namespace mach_o
-} // namespace lld
+} // namespace mach_o
+} // namespace lld
#endif // LLD_READER_WRITER_MACHO_STUB_ATOMS_H
diff --git a/lld/lib/ReaderWriter/MachO/WriterMachO.cpp b/lld/lib/ReaderWriter/MachO/WriterMachO.cpp
index 009818a6798..b223387473c 100644
--- a/lld/lib/ReaderWriter/MachO/WriterMachO.cpp
+++ b/lld/lib/ReaderWriter/MachO/WriterMachO.cpp
@@ -34,18 +34,18 @@ public:
virtual error_code writeFile(const lld::File &file, StringRef path) {
// Construct empty normalized file from atoms.
- ErrorOr<std::unique_ptr<NormalizedFile>> nFile =
+ ErrorOr<std::unique_ptr<NormalizedFile>> nFile =
normalized::normalizedFromAtoms(file, _context);
if (error_code ec = nFile.getError())
return ec;
-
+
// For debugging, write out yaml form of normalized file.
//writeYaml(*nFile->get(), llvm::errs());
-
+
// Write normalized file as mach-o binary.
return writeBinary(*nFile->get(), path);
}
-
+
virtual bool createImplicitFiles(std::vector<std::unique_ptr<File> > &r) {
if (_context.outputFileType() == llvm::MachO::MH_EXECUTE) {
// When building main executables, add _main as required entry point.
OpenPOWER on IntegriCloud