X-Git-Url: https://git.saurik.com/apple/ld64.git/blobdiff_plain/a645023da60d22e86be13f7b4d97adeff8bc6665..2a0ed0a31db9961dcb7c87964091b22401c4d69b:/src/ld/passes/tlvp.cpp diff --git a/src/ld/passes/tlvp.cpp b/src/ld/passes/tlvp.cpp index f40d018..aec9562 100644 --- a/src/ld/passes/tlvp.cpp +++ b/src/ld/passes/tlvp.cpp @@ -30,7 +30,6 @@ #include #include -#include #include "ld.hpp" #include "tlvp.h" @@ -49,11 +48,9 @@ public: symbolTableNotIn, false, false, false, ld::Atom::Alignment(3)), _fixup(0, ld::Fixup::k1of1, ld::Fixup::kindStoreTargetAddressLittleEndian64, target), _target(target) - { _fixup.weakImport = weakImport; internal.addAtom(*this); } + { _fixup.weakImport = weakImport; internal.addAtom(*this); } virtual const ld::File* file() const { return NULL; } - virtual bool translationUnitSource(const char** dir, const char**) const - { return false; } virtual const char* name() const { return _target->name(); } virtual uint64_t size() const { return 8; } virtual uint64_t objectAddress() const { return 0; } @@ -145,6 +142,10 @@ void doPass(const Options& opts, ld::Internal& internal) case ld::Fixup::kindStoreTargetAddressX86Abs32TLVLoad: case ld::Fixup::kindStoreX86PCRel32TLVLoad: case ld::Fixup::kindStoreX86Abs32TLVLoad: +#if SUPPORT_ARCH_arm64 + case ld::Fixup::kindStoreTargetAddressARM64TLVPLoadPage21: + case ld::Fixup::kindStoreTargetAddressARM64TLVPLoadPageOff12: +#endif ref.fixupWithTLVStore = fit; break; default: @@ -172,14 +173,6 @@ void doPass(const Options& opts, ld::Internal& internal) if ( pos == weakImportMap.end() ) { // target not in weakImportMap, so add weakImportMap[it->targetOfTLV] = it->fixupWithTarget->weakImport; - // If only weak_import symbols are used, linker should use LD_LOAD_WEAK_DYLIB - const ld::dylib::File* dylib = dynamic_cast(it->targetOfTLV->file()); - if ( dylib != NULL ) { - if ( it->fixupWithTarget->weakImport ) - (const_cast(dylib))->setUsingWeakImportedSymbols(); - else - (const_cast(dylib))->setUsingNonWeakImportedSymbols(); - } } else { // target in weakImportMap, check for weakness mismatch @@ -241,6 +234,14 @@ void doPass(const Options& opts, ld::Internal& internal) case ld::Fixup::kindStoreX86Abs32TLVLoad: it->fixupWithTLVStore->kind = ld::Fixup::kindStoreX86Abs32TLVLoadNowLEA; break; +#if SUPPORT_ARCH_arm64 + case ld::Fixup::kindStoreTargetAddressARM64TLVPLoadPage21: + it->fixupWithTLVStore->kind = ld::Fixup::kindStoreTargetAddressARM64TLVPLoadNowLeaPage21; + break; + case ld::Fixup::kindStoreTargetAddressARM64TLVPLoadPageOff12: + it->fixupWithTLVStore->kind = ld::Fixup::kindStoreTargetAddressARM64TLVPLoadNowLeaPageOff12; + break; +#endif default: assert(0 && "bad store kind for TLV optimization"); } @@ -264,6 +265,9 @@ void doPass(const Options& opts, ld::Internal& internal) continue; for (std::vector::iterator ait=sect->atoms.begin(); ait != sect->atoms.end(); ++ait) { const ld::Atom* atom = *ait; + if ( ! opts.canUseThreadLocalVariables() ) { + throwf("targeted OS version does not support use of thread local variables in %s", atom->name()); + } for (ld::Fixup::iterator fit = atom->fixupsBegin(), end=atom->fixupsEnd(); fit != end; ++fit) { if ( fit->offsetInAtom != 0 ) { assert(fit->binding == ld::Fixup::bindingDirectlyBound && "thread variable def contains pointer to global");