]> git.saurik.com Git - apple/ld64.git/blobdiff - src/other/ObjectDump.cpp
ld64-409.12.tar.gz
[apple/ld64.git] / src / other / ObjectDump.cpp
index 55e1068b7f429f90c4b5394f7a3eca7f2099cedb..5a355dc952f7ac33b3e77869ef1096baf416f09a 100644 (file)
@@ -35,6 +35,8 @@
 #include "parsers/macho_relocatable_file.h"
 #include "parsers/lto_file.h"
 
+const ld::VersionSet ld::File::_platforms;
+
 static bool                    sDumpContent= true;
 static bool                    sDumpStabs      = false;
 static bool                    sSort           = true;
@@ -396,11 +398,13 @@ struct AtomSorter
                                        rightString = (char*)cstringAtom->rawContentPointer();
                                }
                        }
-                       assert(leftString != NULL);
-                       assert(rightString != NULL);
-                       diff = strcmp(leftString, rightString);
-                       if ( diff != 0 )
-                               return (diff < 0);
+                       if ( leftString != rightString ) {
+                               assert(leftString != NULL);
+                               assert(rightString != NULL);
+                               diff = strcmp(leftString, rightString);
+                               if ( diff != 0 )
+                                       return (diff < 0);
+                       }
                }
                else if ( left->section().type() == ld::Section::typeLiteral4 ) {
                        // if literal sort by content
@@ -804,6 +808,47 @@ void dumper::dumpFixup(const ld::Fixup* ref)
                case ld::Fixup::kindStoreThumbHigh16:
                        printf(", then store high-16 in Thumb movt");
                        break;
+#if SUPPORT_ARCH_arm64
+               case ld::Fixup::kindStoreARM64Branch26:
+                       printf(", then store as ARM64 26-bit pcrel branch");
+                       break;
+               case ld::Fixup::kindStoreARM64Page21:
+                       printf(", then store as ARM64 21-bit pcrel ADRP");
+                       break;
+               case ld::Fixup::kindStoreARM64PageOff12:
+                       printf(", then store as ARM64 12-bit offset");
+                       break;
+               case ld::Fixup::kindStoreARM64GOTLoadPage21:
+                       printf(", then store as ARM64 21-bit pcrel ADRP of GOT");
+                       break;
+               case ld::Fixup::kindStoreARM64GOTLoadPageOff12:
+                       printf(", then store as ARM64 12-bit page offset of GOT");
+                       break;
+               case ld::Fixup::kindStoreARM64GOTLeaPage21:
+                       printf(", then store as ARM64 21-bit pcrel ADRP of GOT lea");
+                       break;
+               case ld::Fixup::kindStoreARM64GOTLeaPageOff12:
+                       printf(", then store as ARM64 12-bit page offset of GOT lea");
+                       break;
+               case ld::Fixup::kindStoreARM64TLVPLoadPage21:
+                       printf(", then store as ARM64 21-bit pcrel ADRP of TLVP");
+                       break;
+               case ld::Fixup::kindStoreARM64TLVPLoadPageOff12:
+                       printf(", then store as ARM64 12-bit page offset of TLVP");
+                       break;
+               case ld::Fixup::kindStoreARM64TLVPLoadNowLeaPage21:
+                       printf(", then store as ARM64 21-bit pcrel ADRP of lea of TLVP");
+                       break;
+               case ld::Fixup::kindStoreARM64TLVPLoadNowLeaPageOff12:
+                       printf(", then store as ARM64 12-bit page offset of lea of TLVP");
+                       break;
+               case ld::Fixup::kindStoreARM64PointerToGOT:
+                       printf(", then store as 64-bit pointer to GOT entry");
+                       break;
+               case ld::Fixup::kindStoreARM64PCRelToGOT:
+                       printf(", then store as 32-bit delta to GOT entry");
+                       break;
+#endif
                case ld::Fixup::kindDtraceExtra:
                        printf("dtrace static probe extra info");
                        break;
@@ -825,12 +870,23 @@ void dumper::dumpFixup(const ld::Fixup* ref)
                case ld::Fixup::kindStoreThumbDtraceIsEnableSiteClear:
                        printf("Thumb dtrace static is-enabled site");
                        break;
+#if SUPPORT_ARCH_arm64
+               case ld::Fixup::kindStoreARM64DtraceCallSiteNop:
+                       printf("ARM64 dtrace static probe site");
+                       break;
+               case ld::Fixup::kindStoreARM64DtraceIsEnableSiteClear:
+                       printf("ARM64 dtrace static is-enabled site");
+                       break;
+#endif
                case ld::Fixup::kindLazyTarget:
                        printf("lazy reference to external symbol %s", referenceTargetAtomName(ref));
                        break;
                case ld::Fixup::kindSetLazyOffset:
                        printf("offset of lazy binding info for %s", referenceTargetAtomName(ref));
                        break;
+               case ld::Fixup::kindIslandTarget:
+                       printf("ultimate target of island %s", referenceTargetAtomName(ref));
+                       break;
                case ld::Fixup::kindDataInCodeStartData:
                        printf("start of data in code");
                        break;
@@ -849,6 +905,46 @@ void dumper::dumpFixup(const ld::Fixup* ref)
                case ld::Fixup::kindDataInCodeEnd:
                        printf("end of data in code");
                        break;
+               case ld::Fixup::kindLinkerOptimizationHint:
+#if SUPPORT_ARCH_arm64
+                       ld::Fixup::LOH_arm64 extra;
+                       extra.addend = ref->u.addend;
+                       printf("ARM64 hint: ");
+                       switch(extra.info.kind) {
+                               case LOH_ARM64_ADRP_ADRP:
+                                       printf("ADRP-ADRP");
+                                       break;
+                               case LOH_ARM64_ADRP_LDR:
+                                       printf("ADRP-LDR");
+                                       break;
+                               case LOH_ARM64_ADRP_ADD_LDR:
+                                       printf("ADRP-ADD-LDR");
+                                       break;
+                               case LOH_ARM64_ADRP_LDR_GOT_LDR:
+                                       printf("ADRP-LDR-GOT-LDR");
+                                       break;
+                               case LOH_ARM64_ADRP_ADD_STR:
+                                       printf("ADRP-ADD-STR");
+                                       break;
+                               case LOH_ARM64_ADRP_LDR_GOT_STR:
+                                       printf("ADRP-LDR-GOT-STR");
+                                       break;
+                               case LOH_ARM64_ADRP_ADD:
+                                       printf("ADRP-ADD");
+                                       break;
+                               default:
+                                       printf("kind=%d", extra.info.kind);
+                                       break;
+                       }
+                       printf(", offset1=0x%X", (extra.info.delta1 << 2)  + ref->offsetInAtom);
+                       if ( extra.info.count > 0 )
+                               printf(", offset2=0x%X", (extra.info.delta2 << 2) + ref->offsetInAtom);
+                       if ( extra.info.count > 1 )
+                               printf(", offset3=0x%X", (extra.info.delta3 << 2)  + ref->offsetInAtom);
+                       if ( extra.info.count > 2 )
+                               printf(", offset4=0x%X", (extra.info.delta4 << 2)  + ref->offsetInAtom);
+#endif                 
+                       break;
                case ld::Fixup::kindStoreTargetAddressLittleEndian32:
                        printf("store 32-bit little endian address of %s", referenceTargetAtomName(ref));
                        break;
@@ -898,6 +994,42 @@ void dumper::dumpFixup(const ld::Fixup* ref)
                case ld::Fixup::kindSetTargetTLVTemplateOffsetLittleEndian32:
                case ld::Fixup::kindSetTargetTLVTemplateOffsetLittleEndian64:
                        printf("tlv template offset of %s", referenceTargetAtomName(ref));
+                       break;
+#if SUPPORT_ARCH_arm64
+               case ld::Fixup::kindStoreTargetAddressARM64Branch26:
+                       printf("ARM64 store 26-bit pcrel branch to %s", referenceTargetAtomName(ref));
+                       break;
+               case ld::Fixup::kindStoreTargetAddressARM64Page21:
+                       printf("ARM64 store 21-bit pcrel ADRP to %s", referenceTargetAtomName(ref));
+                       break;
+               case ld::Fixup::kindStoreTargetAddressARM64PageOff12:
+                       printf("ARM64 store 12-bit page offset of %s", referenceTargetAtomName(ref));
+                       break;
+               case ld::Fixup::kindStoreTargetAddressARM64GOTLoadPage21:
+                       printf("ARM64 store 21-bit pcrel ADRP to GOT for %s", referenceTargetAtomName(ref));
+                       break;
+               case ld::Fixup::kindStoreTargetAddressARM64GOTLoadPageOff12:
+                       printf("ARM64 store 12-bit page offset of GOT of %s", referenceTargetAtomName(ref));
+                       break;
+               case ld::Fixup::kindStoreTargetAddressARM64GOTLeaPage21:
+                       printf("ARM64 store 21-bit pcrel ADRP to GOT lea for %s", referenceTargetAtomName(ref));
+                       break;
+               case ld::Fixup::kindStoreTargetAddressARM64GOTLeaPageOff12:
+                       printf("ARM64 store 12-bit page offset of GOT lea of %s", referenceTargetAtomName(ref));
+                       break;
+               case ld::Fixup::kindStoreTargetAddressARM64TLVPLoadPage21:
+                       printf("ARM64 store 21-bit pcrel ADRP to TLV for %s", referenceTargetAtomName(ref));
+                       break;
+               case ld::Fixup::kindStoreTargetAddressARM64TLVPLoadPageOff12:
+                       printf("ARM64 store 12-bit page offset of TLV of %s", referenceTargetAtomName(ref));
+                       break;
+               case ld::Fixup::kindStoreTargetAddressARM64TLVPLoadNowLeaPage21:
+                       printf("ARM64 store 21-bit pcrel ADRP to lea for TLV for %s", referenceTargetAtomName(ref));
+                       break;
+               case ld::Fixup::kindStoreTargetAddressARM64TLVPLoadNowLeaPageOff12:
+                       printf("ARM64 store 12-bit page offset of lea for TLV of %s", referenceTargetAtomName(ref));
+                       break;
+#endif
                //default:
                //      printf("unknown fixup");
                //      break;
@@ -1116,13 +1248,21 @@ static ld::relocatable::File* createReader(const char* path)
        objOpts.architecture            = sPreferredArch;
        objOpts.objSubtypeMustMatch = false;
        objOpts.logAllFiles                     = false;
-       objOpts.convertUnwindInfo       = true;
+       objOpts.warnUnwindConversionProblems    = true;
+       objOpts.keepDwarfUnwind         = false;
+       objOpts.forceDwarfConversion = false;
+       objOpts.verboseOptimizationHints = true;
+       objOpts.armUsesZeroCostExceptions = true;
        objOpts.subType                         = sPreferredSubArch;
+       objOpts.treateBitcodeAsData  = false;
+       objOpts.usingBitcode            = true;
 #if 1
        if ( ! foundFatSlice ) {
                cpu_type_t archOfObj;
                cpu_subtype_t subArchOfObj;
-               if ( mach_o::relocatable::isObjectFile(p, &archOfObj, &subArchOfObj) ) {
+               ld::Platform platform;
+               uint32_t minOS;
+               if ( mach_o::relocatable::isObjectFile(p, &archOfObj, &subArchOfObj, &platform, &minOS) ) {
                        objOpts.architecture = archOfObj;
                        objOpts.subType = subArchOfObj;
                }
@@ -1133,7 +1273,7 @@ static ld::relocatable::File* createReader(const char* path)
                return objResult;
 
        // see if it is an llvm object file
-       objResult = lto::parse(p, fileLen, path, stat_buf.st_mtime, sPreferredArch, sPreferredSubArch, false);
+       objResult = lto::parse(p, fileLen, path, stat_buf.st_mtime, ld::File::Ordinal::NullOrdinal(), sPreferredArch, sPreferredSubArch, false, true);
        if ( objResult != NULL ) 
                return objResult;