Provide c++11 headers from tr1 include directory and namespace. Work around weird namespacing bug in gcc-4.2.1 where class ld::Section conflicts with template mach_o::relocatable::Section by renaming the latter to MRFSection (could possibly be done using sed from ebuild or avoided by figuring out, what's actually going on with those namespaces). --- ./ld64-241.9/src/ld/InputFiles.h.gcc 2014-09-11 00:24:46.000000000 +0200 +++ ./ld64-241.9/src/ld/InputFiles.h 2015-01-12 22:12:18.000000000 +0100 @@ -46,6 +46,14 @@ #include #endif +#ifdef __GLIBCXX__ +#include +#define UNORDERED_MAP tr1::unordered_map +#else +#include +#define UNORDERED_MAP unordered_map +#endif + #include #include "Options.h" @@ -107,7 +115,7 @@ static void parseWorkerThread(InputFiles *inputFiles); void startThread(void (*threadFunc)(InputFiles *)) const; - typedef std::unordered_map InstallNameToDylib; + typedef std::UNORDERED_MAP InstallNameToDylib; const Options& _options; std::vector _inputFiles; --- ./ld64-241.9/src/ld/ld.cpp.gcc 2014-09-11 00:24:46.000000000 +0200 +++ ./ld64-241.9/src/ld/ld.cpp 2015-01-12 22:12:18.000000000 +0100 @@ -54,7 +54,13 @@ #include #include #include +#ifdef __GLIBCXX__ +#include +#define UNORDERED_MAP tr1::unordered_map +#else #include +#define UNORDERED_MAP unordered_map +#endif #include #include "Options.h" @@ -149,7 +155,7 @@ struct SectionEquals { bool operator()(const ld::Section* left, const ld::Section* right) const; }; - typedef std::unordered_map SectionInToOut; + typedef std::UNORDERED_MAP SectionInToOut; SectionInToOut _sectionInToFinalMap; --- ./ld64-241.9/src/ld/ld.hpp.gcc 2014-09-11 00:24:46.000000000 +0200 +++ ./ld64-241.9/src/ld/ld.hpp 2015-01-12 22:12:18.000000000 +0100 @@ -32,7 +32,13 @@ #include #include +#ifdef __GLIBCXX__ +#include +#define UNORDERED_SET tr1::unordered_set +#else #include +#define UNORDERED_SET unordered_set +#endif #include "configure.h" @@ -822,7 +828,7 @@ bool operator()(const char* left, const char* right) const { return (strcmp(left, right) == 0); } }; -typedef std::unordered_set CStringSet; +typedef std::UNORDERED_SET CStringSet; class Internal { --- ./ld64-241.9/src/ld/LinkEditClassic.hpp.gcc 2014-09-11 00:24:46.000000000 +0200 +++ ./ld64-241.9/src/ld/LinkEditClassic.hpp 2015-01-12 22:12:18.000000000 +0100 @@ -31,8 +31,13 @@ #include #include -#include +#ifdef __GLIBCXX__ +#include +#define UNORDERED_MAP tr1::unordered_map +#else #include +#define UNORDERED_MAP unordered_map +#endif #include "Options.h" #include "ld.hpp" @@ -92,7 +97,7 @@ private: enum { kBufferSize = 0x01000000 }; - typedef std::unordered_map StringToOffset; + typedef std::UNORDERED_MAP StringToOffset; const uint32_t _pointerSize; std::vector _fullBuffers; --- ./ld64-241.9/src/ld/Options.cpp.gcc 2014-11-04 00:25:08.000000000 +0100 +++ ./ld64-241.9/src/ld/Options.cpp 2015-01-12 22:12:18.000000000 +0100 @@ -4548,7 +4548,7 @@ // make sure all required exported symbols exist std::vector impliedExports; - for (NameSet::iterator it=fExportSymbols.regularBegin(); it != fExportSymbols.regularEnd(); ++it) { + for (NameSet::const_iterator it=fExportSymbols.regularBegin(); it != fExportSymbols.regularEnd(); ++it) { const char* name = *it; const int len = strlen(name); if ( (strcmp(&name[len-3], ".eh") == 0) || (strncmp(name, ".objc_category_name_", 20) == 0) ) { @@ -4580,7 +4580,7 @@ } // make sure all required re-exported symbols exist - for (NameSet::iterator it=fReExportSymbols.regularBegin(); it != fReExportSymbols.regularEnd(); ++it) { + for (NameSet::const_iterator it=fReExportSymbols.regularBegin(); it != fReExportSymbols.regularEnd(); ++it) { fInitialUndefines.push_back(*it); } --- ./ld64-241.9/src/ld/Options.h.gcc 2014-11-04 00:29:32.000000000 +0100 +++ ./ld64-241.9/src/ld/Options.h 2015-01-12 22:12:18.000000000 +0100 @@ -30,8 +30,17 @@ #include #include +#ifdef __GLIBCXX__ +#include +#include +#define UNORDERED_MAP tr1::unordered_map +#define UNORDERED_SET tr1::unordered_set +#else #include #include +#define UNORDERED_MAP unordered_map +#define UNORDERED_SET unordered_set +#endif #include "ld.hpp" #include "Snapshot.h" @@ -396,8 +405,8 @@ bool moveRwSymbol(const char* symName, const char* filePath, const char*& seg, bool& wildCardMatch) const; private: - typedef std::unordered_map NameToOrder; - typedef std::unordered_set NameSet; + typedef std::UNORDERED_MAP NameToOrder; + typedef std::UNORDERED_SET NameSet; enum ExportMode { kExportDefault, kExportSome, kDontExportSome }; enum LibrarySearchMode { kSearchDylibAndArchiveInEachDir, kSearchAllDirsForDylibsThenAllDirsForArchives }; enum InterposeMode { kInterposeNone, kInterposeAllExternal, kInterposeSome }; @@ -410,8 +419,8 @@ bool containsNonWildcard(const char*) const; bool empty() const { return fRegular.empty() && fWildCard.empty(); } bool hasWildCards() const { return !fWildCard.empty(); } - NameSet::iterator regularBegin() const { return fRegular.begin(); } - NameSet::iterator regularEnd() const { return fRegular.end(); } + NameSet::const_iterator regularBegin() const { return fRegular.begin(); } + NameSet::const_iterator regularEnd() const { return fRegular.end(); } void remove(const NameSet&); private: static bool hasWildCards(const char*); --- ./ld64-241.9/src/ld/OutputFile.cpp.gcc 2014-09-11 00:24:46.000000000 +0200 +++ ./ld64-241.9/src/ld/OutputFile.cpp 2015-01-12 22:12:18.000000000 +0100 @@ -50,7 +50,13 @@ #include #include #include +#ifdef __GLIBCXX__ +#include +#define UNORDERED_SET tr1::unordered_set +#else #include +#define UNORDERED_SET unordered_set +#endif #include #include @@ -4748,7 +4754,7 @@ const char* filename = NULL; bool wroteStartSO = false; state.stabs.reserve(atomsNeedingDebugNotes.size()*4); - std::unordered_set seenFiles; + std::UNORDERED_SET seenFiles; for (std::vector::iterator it=atomsNeedingDebugNotes.begin(); it != atomsNeedingDebugNotes.end(); it++) { const ld::Atom* atom = *it; const ld::File* atomFile = atom->file(); --- ./ld64-241.9/src/ld/parsers/archive_file.cpp.gcc 2014-09-11 00:24:46.000000000 +0200 +++ ./ld64-241.9/src/ld/parsers/archive_file.cpp 2015-01-12 22:12:18.000000000 +0100 @@ -33,7 +33,13 @@ #include #include #include +#ifdef __GLIBCXX__ +#include +#define UNORDERED_MAP tr1::unordered_map +#else #include +#define UNORDERED_MAP unordered_map +#endif #include "MachOFileAbstraction.hpp" #include "Architectures.hpp" @@ -112,7 +118,7 @@ struct MemberState { ld::relocatable::File* file; const Entry *entry; bool logged; bool loaded; uint32_t index;}; bool loadMember(MemberState& state, ld::File::AtomHandler& handler, const char *format, ...) const; - typedef std::unordered_map NameToEntryMap; + typedef std::UNORDERED_MAP NameToEntryMap; typedef typename A::P P; typedef typename A::P::E E; --- ./ld64-241.9/src/ld/parsers/lto_file.cpp.gcc 2014-11-04 00:59:51.000000000 +0100 +++ ./ld64-241.9/src/ld/parsers/lto_file.cpp 2015-01-12 22:12:18.000000000 +0100 @@ -33,8 +33,17 @@ #include #include #include +#ifdef __GLIBCXX__ +#include +#include +#define UNORDERED_MAP tr1::unordered_map +#define UNORDERED_SET tr1::unordered_set +#else #include #include +#define UNORDERED_MAP unordered_map +#define UNORDERED_SET unordered_set +#endif #include "MachOFileAbstraction.hpp" #include "Architectures.hpp" @@ -218,8 +227,8 @@ static void ltoDiagnosticHandler(lto_codegen_diagnostic_severity_t, const char*, void*); #endif - typedef std::unordered_set CStringSet; - typedef std::unordered_map CStringToAtom; + typedef std::UNORDERED_SET CStringSet; + typedef std::UNORDERED_MAP CStringToAtom; class AtomSyncer : public ld::File::AtomHandler { public: --- ./ld64-241.9/src/ld/parsers/macho_dylib_file.cpp.gcc 2014-09-11 00:24:46.000000000 +0200 +++ ./ld64-241.9/src/ld/parsers/macho_dylib_file.cpp 2015-01-12 22:12:18.000000000 +0100 @@ -34,8 +34,17 @@ #include #include #include -#include +#ifdef __GLIBCXX__ +#include +#include +#define UNORDERED_MAP tr1::unordered_map +#define UNORDERED_SET tr1::unordered_set +#else #include +#include +#define UNORDERED_MAP unordered_map +#define UNORDERED_SET unordered_set +#endif #include "Architectures.hpp" #include "MachOFileAbstraction.hpp" @@ -193,8 +202,8 @@ }; }; struct AtomAndWeak { ld::Atom* atom; bool weakDef; bool tlv; pint_t address; }; - typedef std::unordered_map NameToAtomMap; - typedef std::unordered_set NameSet; + typedef std::UNORDERED_MAP NameToAtomMap; + typedef std::UNORDERED_SET NameSet; struct Dependent { const char* path; File* dylib; bool reExport; }; @@ -562,14 +571,18 @@ if ( _s_logHashtable ) fprintf(stderr, "ld: building hashtable of %u toc entries for %s\n", dynamicInfo->nextdefsym(), this->path()); const macho_nlist

* start = &symbolTable[dynamicInfo->iextdefsym()]; const macho_nlist

* end = &start[dynamicInfo->nextdefsym()]; +#ifndef __GLIBCXX__ _atoms.reserve(dynamicInfo->nextdefsym()); // set initial bucket count +#endif for (const macho_nlist

* sym=start; sym < end; ++sym) { this->addSymbol(&strings[sym->n_strx()], (sym->n_desc() & N_WEAK_DEF) != 0, false, sym->n_value()); } } else { int32_t count = dynamicInfo->ntoc(); +#ifndef __GLIBCXX__ _atoms.reserve(count); // set initial bucket count +#endif if ( _s_logHashtable ) fprintf(stderr, "ld: building hashtable of %u entries for %s\n", count, this->path()); const struct dylib_table_of_contents* toc = (dylib_table_of_contents*)(fileContent + dynamicInfo->tocoff()); for (int32_t i = 0; i < count; ++i) { --- ./ld64-241.9/src/ld/parsers/macho_relocatable_file.cpp.gcc 2014-11-04 00:57:10.000000000 +0100 +++ ./ld64-241.9/src/ld/parsers/macho_relocatable_file.cpp 2015-01-12 22:22:53.000000000 +0100 @@ -62,7 +62,7 @@ // forward reference template class Parser; template class Atom; -template class Section; +template class MRFSection; template class CFISection; template class CUSection; @@ -102,14 +102,14 @@ const uint8_t* fileContent() { return _fileContent; } private: friend class Atom; - friend class Section; + friend class MRFSection; friend class Parser; friend class CFISection::OAS; typedef typename A::P P; const uint8_t* _fileContent; - Section** _sectionsArray; + MRFSection** _sectionsArray; uint8_t* _atomsArray; uint8_t* _aliasAtomsArray; uint32_t _sectionsArrayCount; @@ -134,14 +134,14 @@ template -class Section : public ld::Section +class MRFSection : public ld::Section { public: typedef typename A::P::uint_t pint_t; typedef typename A::P P; typedef typename A::P::E E; - virtual ~Section() { } + virtual ~MRFSection() { } class File& file() const { return _file; } const macho_section

* machoSection() const { return _machOSection; } uint32_t sectionNum(class Parser&) const; @@ -165,10 +165,10 @@ static const char* makeSectionName(const macho_section* s); protected: - Section(File& f, const macho_section* s) + MRFSection(File& f, const macho_section* s) : ld::Section(makeSegmentName(s), makeSectionName(s), sectionType(s)), _file(f), _machOSection(s), _beginAtoms(NULL), _endAtoms(NULL), _hasAliases(false) { } - Section(File& f, const char* segName, const char* sectName, ld::Section::Type t, bool hidden=false) + MRFSection(File& f, const char* segName, const char* sectName, ld::Section::Type t, bool hidden=false) : ld::Section(segName, sectName, t, hidden), _file(f), _machOSection(NULL), _beginAtoms(NULL), _endAtoms(NULL), _hasAliases(false) { } @@ -192,11 +192,11 @@ template -class CFISection : public Section +class CFISection : public MRFSection { public: CFISection(Parser& parser, File& f, const macho_section* s) - : Section(f, s) { } + : MRFSection(f, s) { } uint32_t cfiCount(Parser& parser); virtual ld::Atom::ContentType contentType() { return ld::Atom::typeCFI; } @@ -256,11 +256,11 @@ template -class CUSection : public Section +class CUSection : public MRFSection { public: CUSection(Parser& parser, File& f, const macho_section* s) - : Section(f, s) { } + : MRFSection(f, s) { } typedef typename A::P::uint_t pint_t; typedef typename A::P P; @@ -297,11 +297,11 @@ template -class TentativeDefinitionSection : public Section +class TentativeDefinitionSection : public MRFSection { public: TentativeDefinitionSection(Parser& parser, File& f) - : Section(f, "__DATA", "__comm/tent", ld::Section::typeTentativeDefs) {} + : MRFSection(f, "__DATA", "__comm/tent", ld::Section::typeTentativeDefs) {} virtual ld::Atom::ContentType contentType() { return ld::Atom::typeZeroFill; } virtual bool addFollowOnFixups() const { return false; } @@ -319,11 +319,11 @@ template -class AbsoluteSymbolSection : public Section +class AbsoluteSymbolSection : public MRFSection { public: AbsoluteSymbolSection(Parser& parser, File& f) - : Section(f, "__DATA", "__abs", ld::Section::typeAbsoluteSymbols, true) {} + : MRFSection(f, "__DATA", "__abs", ld::Section::typeAbsoluteSymbols, true) {} virtual ld::Atom::ContentType contentType() { return ld::Atom::typeUnclassified; } virtual bool dontDeadStrip() { return false; } @@ -345,7 +345,7 @@ template -class SymboledSection : public Section +class SymboledSection : public MRFSection { public: SymboledSection(Parser& parser, File& f, const macho_section* s); @@ -377,11 +377,11 @@ template -class ImplicitSizeSection : public Section +class ImplicitSizeSection : public MRFSection { public: ImplicitSizeSection(Parser& parser, File& f, const macho_section* s) - : Section(f, s) { } + : MRFSection(f, s) { } virtual uint32_t computeAtomCount(class Parser& parser, struct Parser::LabelAndCFIBreakIterator& it, const struct Parser::CFI_CU_InfoArrays&); virtual uint32_t appendAtoms(class Parser& parser, uint8_t* buffer, struct Parser::LabelAndCFIBreakIterator& it, const struct Parser::CFI_CU_InfoArrays&); protected: @@ -715,8 +715,8 @@ public: // methods for all atoms from mach-o object file - Section& sect() const { return (Section&)section(); } - File& machofile() const { return ((Section*)(this->_section))->file(); } + MRFSection& sect() const { return (MRFSection&)section(); } + File& machofile() const { return ((MRFSection*)(this->_section))->file(); } void setFixupsRange(uint32_t s, uint32_t c); void setUnwindInfoRange(uint32_t s, uint32_t c); void extendUnwindInfoRange(); @@ -733,7 +733,7 @@ typedef typename A::P::E E; typedef typename A::P::uint_t pint_t; // constuct via all attributes - Atom(Section& sct, const char* nm, pint_t addr, uint64_t sz, + Atom(MRFSection& sct, const char* nm, pint_t addr, uint64_t sz, ld::Atom::Definition d, ld::Atom::Combine c, ld::Atom::Scope s, ld::Atom::ContentType ct, ld::Atom::SymbolTableInclusion i, bool dds, bool thumb, bool al, ld::Atom::Alignment a) @@ -743,7 +743,7 @@ _unwindInfoStartIndex(0), _fixupsCount(0), _lineInfoCount(0), _unwindInfoCount(0) { } // construct via symbol table entry - Atom(Section& sct, Parser& parser, const macho_nlist

& sym, + Atom(MRFSection& sct, Parser& parser, const macho_nlist

& sym, uint64_t sz, bool alias=false) : ld::Atom((ld::Section&)sct, parser.definitionFromSymbol(sym), parser.combineFromSymbol(sym), parser.scopeFromSymbol(sym), @@ -766,7 +766,7 @@ private: friend class Parser; - friend class Section; + friend class MRFSection; friend class CStringSection; friend class AbsoluteSymbolSection; @@ -1031,8 +1031,8 @@ uint32_t undefinedStartIndex() { return _undefinedStartIndex; } uint32_t undefinedEndIndex() { return _undefinedEndIndex; } void addFixup(FixupInAtom f) { _allFixups.push_back(f); } - Section* sectionForNum(unsigned int sectNum); - Section* sectionForAddress(pint_t addr); + MRFSection* sectionForNum(unsigned int sectNum); + MRFSection* sectionForAddress(pint_t addr); Atom* findAtomByAddress(pint_t addr); Atom* findAtomByAddressOrNullIfStub(pint_t addr); Atom* findAtomByAddressOrLocalTargetOfStub(pint_t addr, uint32_t* offsetInAtom); @@ -1074,7 +1074,7 @@ : sortedSymbolIndexes(ssa), sortedSymbolCount(ssc), cfiStartsArray(cfisa), cfiStartsCount(cfisc), fileHasOverlappingSymbols(ols), newSection(false), cfiIndex(0), symIndex(0) {} - bool next(Parser& parser, const Section& sect, uint32_t sectNum, pint_t startAddr, pint_t endAddr, + bool next(Parser& parser, const MRFSection& sect, uint32_t sectNum, pint_t startAddr, pint_t endAddr, pint_t* addr, pint_t* size, const macho_nlist

** sym); pint_t peek(Parser& parser, pint_t startAddr, pint_t endAddr); void beginSection() { newSection = true; symIndex = 0; } @@ -1103,7 +1103,7 @@ private: - friend class Section; + friend class MRFSection; enum SectionType { sectionTypeIgnore, sectionTypeLiteral4, sectionTypeLiteral8, sectionTypeLiteral16, sectionTypeNonLazy, sectionTypeCFI, sectionTypeCString, sectionTypeCStringPointer, @@ -1448,7 +1448,7 @@ // was becuase of a label, the symbol). Returns false when no more chunks. // template -bool Parser::LabelAndCFIBreakIterator::next(Parser& parser, const Section& sect, uint32_t sectNum, pint_t startAddr, pint_t endAddr, +bool Parser::LabelAndCFIBreakIterator::next(Parser& parser, const MRFSection& sect, uint32_t sectNum, pint_t startAddr, pint_t endAddr, pint_t* addr, pint_t* size, const macho_nlist

** symbol) { // may not be a label on start of section, but need atom demarcation there @@ -1600,7 +1600,7 @@ } template <> -typename arm::P::uint_t Parser::realAddr(typename arm::P::uint_t addr) +arm::P::uint_t Parser::realAddr(arm::P::uint_t addr) { return addr & (-2); } @@ -1646,7 +1646,7 @@ uint32_t sortedSymbolIndexes[_symbolsInSections]; this->makeSortedSymbolsArray(sortedSymbolIndexes, sortedSectionIndexes); - // allocate Section object for each mach-o section + // allocate MRFSection object for each mach-o section makeSections(); // if it exists, do special early parsing of __compact_unwind section @@ -1743,7 +1743,7 @@ #endif } - Section** sections = _file->_sectionsArray; + MRFSection** sections = _file->_sectionsArray; uint32_t sectionsCount = _file->_sectionsArrayCount; // figure out how many atoms will be allocated and allocate @@ -2306,11 +2306,11 @@ _file->_swiftVersion = ((flags >> 8) & 0xFF); if ( sect->size() > 8 ) { warning("section %s/%s has unexpectedly large size %llu in %s", - sect->segname(), Section::makeSectionName(sect), sect->size(), _file->path()); + sect->segname(), MRFSection::makeSectionName(sect), sect->size(), _file->path()); } } else { - warning("can't parse %s/%s section in %s", sect->segname(), Section::makeSectionName(sect), _file->path()); + warning("can't parse %s/%s section in %s", sect->segname(), MRFSection::makeSectionName(sect), _file->path()); } continue; } @@ -2406,24 +2406,24 @@ // sort by address (mach-o object files don't aways have sections sorted) ::qsort(machOSects, count, sizeof(MachOSectionAndSectionClass

), MachOSectionAndSectionClass

::sorter); - // we will synthesize a dummy Section object for tentative definitions + // we will synthesize a dummy MRFSection object for tentative definitions if ( _tentativeDefinitionCount > 0 ) { totalSectionsSize += sizeof(TentativeDefinitionSection); machOSects[count++].type = sectionTypeTentativeDefinitions; } - // we will synthesize a dummy Section object for Absolute symbols + // we will synthesize a dummy MRFSection object for Absolute symbols if ( _absoluteSymbolCount > 0 ) { totalSectionsSize += sizeof(AbsoluteSymbolSection); machOSects[count++].type = sectionTypeAbsoluteSymbols; } // allocate one block for all Section objects as well as pointers to each - uint8_t* space = new uint8_t[totalSectionsSize+count*sizeof(Section*)]; - _file->_sectionsArray = (Section**)space; + uint8_t* space = new uint8_t[totalSectionsSize+count*sizeof(MRFSection*)]; + _file->_sectionsArray = (MRFSection**)space; _file->_sectionsArrayCount = count; - Section** objects = _file->_sectionsArray; - space += count*sizeof(Section*); + MRFSection** objects = _file->_sectionsArray; + space += count*sizeof(MRFSection*); for (uint32_t i=0; i < count; ++i) { switch ( machOSects[i].type ) { case sectionTypeIgnore: @@ -2511,7 +2511,7 @@ template -Section* Parser::sectionForAddress(typename A::P::uint_t addr) +MRFSection* Parser::sectionForAddress(typename A::P::uint_t addr) { for (uint32_t i=0; i < _file->_sectionsArrayCount; ++i ) { const macho_section* sect = _file->_sectionsArray[i]->machoSection(); @@ -2538,7 +2538,7 @@ } template -Section* Parser::sectionForNum(unsigned int num) +MRFSection* Parser::sectionForNum(unsigned int num) { for (uint32_t i=0; i < _file->_sectionsArrayCount; ++i ) { const macho_section* sect = _file->_sectionsArray[i]->machoSection(); @@ -2554,7 +2554,7 @@ template Atom* Parser::findAtomByAddress(pint_t addr) { - Section* section = this->sectionForAddress(addr); + MRFSection* section = this->sectionForAddress(addr); return section->findAtomByAddress(addr); } @@ -2611,7 +2611,7 @@ target.addend = 0; return; } - Section* section = this->sectionForAddress(addr); + MRFSection* section = this->sectionForAddress(addr); target.atom = section->findAtomByAddress(addr); target.addend = addr - target.atom->_objAddress; target.weakImport = false; @@ -2659,7 +2659,7 @@ } return; } - Section* section = this->sectionForNum(sectNum); + MRFSection* section = this->sectionForNum(sectNum); target.atom = section->findAtomByAddress(addr); if ( target.atom == NULL ) { typedef typename A::P::sint_t sint_t; @@ -3867,7 +3867,7 @@ } template -const char* Section::makeSegmentName(const macho_section* sect) +const char* MRFSection::makeSegmentName(const macho_section* sect) { // mach-o section record only has room for 16-byte seg/sect names // so a 16-byte name has no trailing zero @@ -3880,7 +3880,7 @@ } template -const char* Section::makeSectionName(const macho_section* sect) +const char* MRFSection::makeSectionName(const macho_section* sect) { const char* name = sect->sectname(); if ( strlen(name) < 16 ) @@ -3914,13 +3914,13 @@ } template -bool Section::readable(const macho_section* sect) +bool MRFSection::readable(const macho_section* sect) { return true; } template -bool Section::writable(const macho_section* sect) +bool MRFSection::writable(const macho_section* sect) { // mach-o .o files do not contain segment permissions // we just know TEXT is special @@ -3928,7 +3928,7 @@ } template -bool Section::exectuable(const macho_section* sect) +bool MRFSection::exectuable(const macho_section* sect) { // mach-o .o files do not contain segment permissions // we just know TEXT is special @@ -3937,7 +3937,7 @@ template -ld::Section::Type Section::sectionType(const macho_section* sect) +ld::Section::Type MRFSection::sectionType(const macho_section* sect) { switch ( sect->flags() & SECTION_TYPE ) { case S_ZEROFILL: @@ -4015,7 +4015,7 @@ template -Atom* Section::findContentAtomByAddress(pint_t addr, class Atom* start, class Atom* end) +Atom* MRFSection::findContentAtomByAddress(pint_t addr, class Atom* start, class Atom* end) { // do a binary search of atom array uint32_t atomCount = end - start; @@ -4047,7 +4047,7 @@ } template -ld::Atom::Alignment Section::alignmentForAddress(pint_t addr) +ld::Atom::Alignment MRFSection::alignmentForAddress(pint_t addr) { const uint32_t sectionAlignment = this->_machOSection->align(); uint32_t modulus = (addr % (1 << sectionAlignment)); @@ -4057,7 +4057,7 @@ } template -uint32_t Section::sectionNum(class Parser& parser) const +uint32_t MRFSection::sectionNum(class Parser& parser) const { if ( _machOSection == NULL ) return 0; @@ -4650,7 +4650,7 @@ // support __LD, __compact_unwind personality entries which are pointer to personality non-lazy pointer const pint_t* content = (pint_t*)(this->file().fileContent() + this->_machOSection->offset() + reloc->r_address()); pint_t nlPointerAddr = *content; - Section* nlSection = parser.sectionForAddress(nlPointerAddr); + MRFSection* nlSection = parser.sectionForAddress(nlPointerAddr); if ( nlSection->type() == ld::Section::typeCode ) { // personality function is defined in this .o file, so this is a direct reference to it // atoms may not be constructed yet, so scan symbol table for labels @@ -4677,7 +4677,7 @@ else { const pint_t* content = (pint_t*)(this->file().fileContent() + this->_machOSection->offset() + reloc->r_address()); pint_t personalityAddr = *content; - Section* personalitySection = parser.sectionForAddress(personalityAddr); + MRFSection* personalitySection = parser.sectionForAddress(personalityAddr); assert((personalitySection->type() == ld::Section::typeCode) && "personality column in __compact_unwind section is not pointer to function"); // atoms may not be constructed yet, so scan symbol table for labels const char* name = parser.scanSymbolTableForAddress(personalityAddr); @@ -4831,7 +4831,7 @@ template SymboledSection::SymboledSection(Parser& parser, File& f, const macho_section* s) - : Section(f, s), _type(ld::Atom::typeUnclassified) + : MRFSection(f, s), _type(ld::Atom::typeUnclassified) { switch ( s->flags() & SECTION_TYPE ) { case S_ZEROFILL: @@ -4877,7 +4877,7 @@ if ( ! this->_file.canScatterAtoms() ) return true; // call inherited - return Section::dontDeadStrip(); + return MRFSection::dontDeadStrip(); } return false; } @@ -5724,7 +5724,7 @@ template <> -uint32_t Section::x86_64PcRelOffset(uint8_t r_type) +uint32_t MRFSection::x86_64PcRelOffset(uint8_t r_type) { switch ( r_type ) { case X86_64_RELOC_SIGNED: @@ -5741,7 +5741,7 @@ template <> -bool Section::addRelocFixup(class Parser& parser, const macho_relocation_info

* reloc) +bool MRFSection::addRelocFixup(class Parser& parser, const macho_relocation_info

* reloc) { const macho_section

* sect = this->machoSection(); uint64_t srcAddr = sect->addr() + reloc->r_address(); @@ -5948,7 +5948,7 @@ template <> -bool Section::addRelocFixup(class Parser& parser, const macho_relocation_info

* reloc) +bool MRFSection::addRelocFixup(class Parser& parser, const macho_relocation_info

* reloc) { const macho_section

* sect = this->machoSection(); uint32_t srcAddr; @@ -6189,7 +6189,7 @@ #if SUPPORT_ARCH_arm_any template <> -bool Section::addRelocFixup(class Parser& parser, const macho_relocation_info

* reloc) +bool MRFSection::addRelocFixup(class Parser& parser, const macho_relocation_info

* reloc) { const macho_section

* sect = this->machoSection(); bool result = false; @@ -6656,7 +6656,7 @@ #if SUPPORT_ARCH_arm64 template <> -bool Section::addRelocFixup(class Parser& parser, const macho_relocation_info

* reloc) +bool MRFSection::addRelocFixup(class Parser& parser, const macho_relocation_info

* reloc) { bool result = false; Parser::SourceLocation src; @@ -7054,7 +7054,7 @@ #if SUPPORT_ARCH_arm64 template <> -void Section::addLOH(class Parser& parser, int kind, int count, const uint64_t addrs[]) { +void MRFSection::addLOH(class Parser& parser, int kind, int count, const uint64_t addrs[]) { switch (kind) { case LOH_ARM64_ADRP_ADRP: case LOH_ARM64_ADRP_LDR: @@ -7109,18 +7109,18 @@ extra.info.delta2 = (count > 1) ? ((addrs[1] - lowestAddress) >> 2) : 0; extra.info.delta3 = (count > 2) ? ((addrs[2] - lowestAddress) >> 2) : 0; extra.info.delta4 = (count > 3) ? ((addrs[3] - lowestAddress) >> 2) : 0; - typename Parser::SourceLocation src(inAtom, lowestAddress- inAtom->objectAddress()); + Parser::SourceLocation src(inAtom, lowestAddress- inAtom->objectAddress()); parser.addFixup(src, ld::Fixup::k1of1, ld::Fixup::kindLinkerOptimizationHint, extra.addend); } #endif template -void Section::addLOH(class Parser& parser, int kind, int count, const uint64_t addrs[]) { +void MRFSection::addLOH(class Parser& parser, int kind, int count, const uint64_t addrs[]) { } template -void Section::makeFixups(class Parser& parser, const struct Parser::CFI_CU_InfoArrays&) +void MRFSection::makeFixups(class Parser& parser, const struct Parser::CFI_CU_InfoArrays&) { const macho_section

* sect = this->machoSection(); const macho_relocation_info

* relocs = (macho_relocation_info

*)(file().fileContent() + sect->reloff()); @@ -7131,7 +7131,7 @@ ++r; // skip next } catch (const char* msg) { - throwf("in section %s,%s reloc %u: %s", sect->segname(), Section::makeSectionName(sect), r, msg); + throwf("in section %s,%s reloc %u: %s", sect->segname(), MRFSection::makeSectionName(sect), r, msg); } } @@ -7157,7 +7157,7 @@ } if ( !this->_altEntries.empty() && !this->addFollowOnFixups() ) { if ( _altEntries.count(_beginAtoms) != 0 ) - warning("N_ALT_ENTRY bit set on first atom in section %s/%s", sect->segname(), Section::makeSectionName(sect)); + warning("N_ALT_ENTRY bit set on first atom in section %s/%s", sect->segname(), MRFSection::makeSectionName(sect)); Atom* end = &_endAtoms[-1]; for(Atom* p = _beginAtoms; p < end; ++p) { --- ./ld64-241.9/src/ld/passes/dtrace_dof.cpp.gcc 2014-09-11 00:24:46.000000000 +0200 +++ ./ld64-241.9/src/ld/passes/dtrace_dof.cpp 2015-01-12 22:12:18.000000000 +0100 @@ -30,8 +30,17 @@ #include #include +#ifdef __GLIBCXX__ +#include +#include +#define UNORDERED_MAP tr1::unordered_map +#define UNORDERED_SET tr1::unordered_set +#else #include #include +#define UNORDERED_MAP unordered_map +#define UNORDERED_SET unordered_set +#endif #include "ld.hpp" #include "MachOFileAbstraction.hpp" @@ -111,8 +120,8 @@ uint32_t offset; const char* probeName; }; -typedef std::unordered_map, CStringHash, CStringEquals> ProviderToProbes; -typedef std::unordered_set CStringSet; +typedef std::UNORDERED_MAP, CStringHash, CStringEquals> ProviderToProbes; +typedef std::UNORDERED_SET CStringSet; --- ./ld64-241.9/src/ld/passes/order.cpp.gcc 2014-09-11 00:24:46.000000000 +0200 +++ ./ld64-241.9/src/ld/passes/order.cpp 2015-01-12 22:12:18.000000000 +0100 @@ -32,7 +32,13 @@ #include #include #include +#ifdef __GLIBCXX__ +#include +#define UNORDERED_MAP tr1::unordered_map +#else #include +#define UNORDERED_MAP unordered_map +#endif #include "ld.hpp" #include "order.h" @@ -85,7 +91,7 @@ ld::Internal& _state; }; - typedef std::unordered_map NameToAtom; + typedef std::UNORDERED_MAP NameToAtom; typedef std::map AtomToAtom; --- ./ld64-241.9/src/ld/Resolver.h.gcc 2014-09-11 00:24:46.000000000 +0200 +++ ./ld64-241.9/src/ld/Resolver.h 2015-01-12 22:12:18.000000000 +0100 @@ -42,7 +42,13 @@ #include #include +#ifdef __GLIBCXX__ +#include +#define UNORDERED_SET tr1::unordered_set +#else #include +#define UNORDERED_SET unordered_set +#endif #include "Options.h" #include "ld.hpp" @@ -105,7 +111,7 @@ void doLinkerOption(const std::vector& linkerOption, const char* fileName); void dumpAtoms(); - typedef std::unordered_set StringSet; + typedef std::UNORDERED_SET StringSet; class NotLive { public: --- ./ld64-241.9/src/ld/SymbolTable.h.gcc 2014-09-11 00:24:46.000000000 +0200 +++ ./ld64-241.9/src/ld/SymbolTable.h 2015-01-12 22:12:18.000000000 +0100 @@ -42,7 +42,13 @@ #include #include +#ifdef __GLIBCXX__ +#include +#define UNORDERED_MAP tr1::unordered_map +#else #include +#define UNORDERED_MAP unordered_map +#endif #include "Options.h" #include "ld.hpp" @@ -57,38 +63,38 @@ typedef uint32_t IndirectBindingSlot; private: - typedef std::unordered_map NameToSlot; + typedef std::UNORDERED_MAP NameToSlot; class ContentFuncs { public: size_t operator()(const ld::Atom*) const; bool operator()(const ld::Atom* left, const ld::Atom* right) const; }; - typedef std::unordered_map ContentToSlot; + typedef std::UNORDERED_MAP ContentToSlot; class ReferencesHashFuncs { public: size_t operator()(const ld::Atom*) const; bool operator()(const ld::Atom* left, const ld::Atom* right) const; }; - typedef std::unordered_map ReferencesToSlot; + typedef std::UNORDERED_MAP ReferencesToSlot; class CStringHashFuncs { public: size_t operator()(const ld::Atom*) const; bool operator()(const ld::Atom* left, const ld::Atom* right) const; }; - typedef std::unordered_map CStringToSlot; + typedef std::UNORDERED_MAP CStringToSlot; class UTF16StringHashFuncs { public: size_t operator()(const ld::Atom*) const; bool operator()(const ld::Atom* left, const ld::Atom* right) const; }; - typedef std::unordered_map UTF16StringToSlot; + typedef std::UNORDERED_MAP UTF16StringToSlot; typedef std::map SlotToName; - typedef std::unordered_map NameToMap; + typedef std::UNORDERED_MAP NameToMap; typedef std::vector DuplicatedSymbolAtomList; typedef std::map DuplicateSymbols; --- ./ld64-241.9/src/other/dyldinfo.cpp.gcc 2014-09-11 00:24:46.000000000 +0200 +++ ./ld64-241.9/src/other/dyldinfo.cpp 2015-01-12 22:12:18.000000000 +0100 @@ -33,7 +33,6 @@ #include #include -#include #include "configure.h" #include "MachOFileAbstraction.hpp" --- ./ld64-241.9/src/other/machochecker.cpp.gcc 2014-09-11 00:24:46.000000000 +0200 +++ ./ld64-241.9/src/other/machochecker.cpp 2015-01-12 22:12:18.000000000 +0100 @@ -33,7 +33,13 @@ #include #include +#ifdef __GLIBCXX__ +#include +#define UNORDERED_SET tr1::unordered_set +#else #include +#define UNORDERED_SET unordered_set +#endif #include "configure.h" @@ -124,7 +130,7 @@ bool operator()(const char* left, const char* right) const { return (strcmp(left, right) == 0); } }; - typedef std::unordered_set StringSet; + typedef std::UNORDERED_SET StringSet; MachOChecker(const uint8_t* fileContent, uint32_t fileLength, const char* path); void checkMachHeader(); --- ./ld64-241.9/src/other/unwinddump.cpp.gcc 2014-11-04 00:56:18.000000000 +0100 +++ ./ld64-241.9/src/other/unwinddump.cpp 2015-01-12 22:12:18.000000000 +0100 @@ -33,7 +33,6 @@ #include #include -#include #include "configure.h" #include "MachOFileAbstraction.hpp"