Index: lib/ReaderWriter/MachO/ArchHandler.h =================================================================== --- lib/ReaderWriter/MachO/ArchHandler.h +++ lib/ReaderWriter/MachO/ArchHandler.h @@ -255,6 +255,9 @@ virtual const StubInfo &stubInfo() = 0; + /// Utility method to check if an undefined reference is a dtrace reference + bool isDtraceSite(const Atom *target, bool &isProbe); + protected: ArchHandler(); Index: lib/ReaderWriter/MachO/ArchHandler.cpp =================================================================== --- lib/ReaderWriter/MachO/ArchHandler.cpp +++ lib/ReaderWriter/MachO/ArchHandler.cpp @@ -165,6 +165,21 @@ return nullptr; } +bool +ArchHandler::isDtraceSite(const Atom *target, bool &isProbe) { + DTraceSymbol dsym; + if (isa(target) && isDtraceSymbol(target->name(), &dsym)) { + if (dsym.type == "probe") { + isProbe = true; + return true; + } else if (dsym.type == "isenabled") { + isProbe = false; + return true; + } + } + return false; +} + } // namespace mach_o } // namespace lld Index: lib/ReaderWriter/MachO/ArchHandler_arm.cpp =================================================================== --- lib/ReaderWriter/MachO/ArchHandler_arm.cpp +++ lib/ReaderWriter/MachO/ArchHandler_arm.cpp @@ -164,6 +164,12 @@ // Kinds introduced by Passes: lazyPointer, /// Location contains a lazy pointer. lazyImmediateLocation, /// Location contains immediate value used in stub. + + // Dtrace support + dtraceProbeArm, /// ___dtrace_probe$… + dtraceIsEnabledArm, /// ___dtrace_isenabled$… + dtraceProbeThumb, + dtraceIsEnabledThumb, }; // Utility functions for inspecting/updating instructions. @@ -227,6 +233,10 @@ LLD_KIND_STRING_ENTRY(delta32), LLD_KIND_STRING_ENTRY(lazyPointer), LLD_KIND_STRING_ENTRY(lazyImmediateLocation), + LLD_KIND_STRING_ENTRY(dtraceProbeArm), + LLD_KIND_STRING_ENTRY(dtraceIsEnabledArm), + LLD_KIND_STRING_ENTRY(dtraceProbeThumb), + LLD_KIND_STRING_ENTRY(dtraceIsEnabledThumb), LLD_KIND_STRING_END }; @@ -523,6 +533,7 @@ uint64_t targetAddress; uint32_t instruction = *(const ulittle32_t *)fixupContent; int32_t displacement; + bool isProbe; switch (relocPattern(reloc)) { case ARM_THUMB_RELOC_BR22 | rPcRel | rExtern | rLength4: // ex: bl _foo (and _foo is undefined) @@ -532,6 +543,9 @@ *kind = thumb_bl22; if (E ec = atomFromSymbolIndex(reloc.symbol, target)) return ec; + if (isDtraceSite(*target, isProbe)) { + *kind = isProbe ? dtraceProbeThumb : dtraceIsEnabledThumb; + } // Instruction contains branch to addend. displacement = getDisplacementFromThumbBranch(instruction, fixupAddress); *addend = fixupAddress + 4 + displacement; @@ -568,6 +582,9 @@ *kind = arm_bl24; if (E ec = atomFromSymbolIndex(reloc.symbol, target)) return ec; + if (isDtraceSite(*target, isProbe)) { + *kind = isProbe ? dtraceProbeArm : dtraceIsEnabledArm; + } // Instruction contains branch to addend. displacement = getDisplacementFromArmBranch(instruction); *addend = fixupAddress + 8 + displacement; @@ -1003,6 +1020,30 @@ case lazyImmediateLocation: *loc32 = ref.addend(); break; + case dtraceProbeArm: + // change call site to a NOP + assert(((*loc32 & 0xFF000000) == 0xEB000000) && + "dtrace reloc is not a branch instruction."); + *loc32 = 0xE1A00000; + break; + case dtraceIsEnabledArm: + // change call site to 'eor r0, r0, r0' + assert(((*loc32 & 0xFF000000) == 0xEB000000) && + "dtrace reloc is not a branch instruction."); + *loc32 = 0xE0200000; + break; + case dtraceProbeThumb: + // change 32-bit blx call site to two thumb NOPs + assert(((*loc32 & 0xD000F800) == 0xD000F000) && + "dtrace reloc is not a branch instruction."); + *loc32 = 0x46C046C0; + break; + case dtraceIsEnabledThumb: + // change 32-bit blx call site to 'nop', 'eor r0, r0' + assert(((*loc32 & 0xD000F800) == 0xD000F000) && + "dtrace reloc is not a branch instruction."); + *loc32 = 0x46C04040; + break; case invalid: llvm_unreachable("invalid ARM Reference Kind"); break; @@ -1172,6 +1213,12 @@ case lazyImmediateLocation: // do nothing break; + case dtraceProbeArm: + case dtraceIsEnabledArm: + case dtraceProbeThumb: + case dtraceIsEnabledThumb: + // do nothing + break; case invalid: llvm_unreachable("invalid ARM Reference Kind"); break; @@ -1202,6 +1249,8 @@ break; case thumb_b22: case thumb_bl22: + case dtraceProbeThumb: + case dtraceIsEnabledThumb: if (useExternalReloc) { appendReloc(relocs, sectionOffset, symbolIndexForAtom(*ref.target()), 0, ARM_THUMB_RELOC_BR22 | rExtern | rPcRel | rLength4); @@ -1282,6 +1331,8 @@ break; case arm_b24: case arm_bl24: + case dtraceProbeArm: + case dtraceIsEnabledArm: if (useExternalReloc) { appendReloc(relocs, sectionOffset, symbolIndexForAtom(*ref.target()), 0, ARM_RELOC_BR24 | rExtern | rPcRel | rLength4); Index: lib/ReaderWriter/MachO/ArchHandler_arm64.cpp =================================================================== --- lib/ReaderWriter/MachO/ArchHandler_arm64.cpp +++ lib/ReaderWriter/MachO/ArchHandler_arm64.cpp @@ -195,6 +195,10 @@ /// relocatable object (yay for implicit contracts!). unwindInfoToEhFrame, /// Fix low 24 bits of compact unwind encoding to /// refer to __eh_frame entry. + + // Dtrace support + dtraceProbe, /// ___dtrace_probe$… + dtraceIsEnabled, /// ___dtrace_isenabled$… }; void applyFixupFinal(const Reference &ref, uint8_t *location, @@ -244,6 +248,8 @@ LLD_KIND_STRING_ENTRY(imageOffsetGot), LLD_KIND_STRING_ENTRY(unwindFDEToFunction), LLD_KIND_STRING_ENTRY(unwindInfoToEhFrame), + LLD_KIND_STRING_ENTRY(dtraceProbe), + LLD_KIND_STRING_ENTRY(dtraceIsEnabled), LLD_KIND_STRING_END }; @@ -363,9 +369,14 @@ switch (relocPattern(reloc)) { case ARM64_RELOC_BRANCH26 | rPcRel | rExtern | rLength4: // ex: bl _foo - *kind = branch26; if (auto ec = atomFromSymbolIndex(reloc.symbol, target)) return ec; + bool isProbe; + if (isDtraceSite(*target, isProbe)) { + *kind = isProbe ? dtraceProbe : dtraceIsEnabled; + } else { + *kind = branch26; + } *addend = 0; return std::error_code(); case ARM64_RELOC_PAGE21 | rPcRel | rExtern | rLength4: @@ -620,6 +631,18 @@ assert(value64 < 0xffffffU && "offset in __eh_frame too large"); *loc32 = (*loc32 & 0xff000000U) | value64; return; + case dtraceProbe: + // change call site to a NOP + assert(((*loc32 & 0xFC000000) == 0x94000000) && + "dtrace reloc is not a branch instruction."); + *loc32 = 0xD503201F; + return; + case dtraceIsEnabled: + // change call site to 'MOVZ X0,0' + assert(((*loc32 & 0xFC000000) == 0x94000000) && + "dtrace reloc is not a branch instruction."); + *loc32 = 0xD2800000; + return; case invalid: // Fall into llvm_unreachable(). break; @@ -690,6 +713,10 @@ case unwindFDEToFunction: // Do nothing for now return; + case dtraceProbe: + case dtraceIsEnabled: + // Do nothing + return; case invalid: // Fall into llvm_unreachable(). break; @@ -708,6 +735,8 @@ uint32_t sectionOffset = atomSectionOffset + ref.offsetInAtom(); switch (static_cast(ref.kindValue())) { case branch26: + case dtraceProbe: + case dtraceIsEnabled: if (ref.addend()) { appendReloc(relocs, sectionOffset, ref.addend(), 0, ARM64_RELOC_ADDEND | rLength4); Index: lib/ReaderWriter/MachO/ArchHandler_x86.cpp =================================================================== --- lib/ReaderWriter/MachO/ArchHandler_x86.cpp +++ lib/ReaderWriter/MachO/ArchHandler_x86.cpp @@ -151,6 +151,10 @@ // Kinds introduced by Passes: lazyPointer, /// Location contains a lazy pointer. lazyImmediateLocation, /// Location contains immediate value used in stub. + + // Dtrace support + dtraceProbe, /// ___dtrace_probe$… + dtraceIsEnabled, /// ___dtrace_isenabled$… }; static bool useExternalRelocationTo(const Atom &target); @@ -186,6 +190,8 @@ LLD_KIND_STRING_ENTRY(negDelta32), LLD_KIND_STRING_ENTRY(lazyPointer), LLD_KIND_STRING_ENTRY(lazyImmediateLocation), + LLD_KIND_STRING_ENTRY(dtraceProbe), + LLD_KIND_STRING_ENTRY(dtraceIsEnabled), LLD_KIND_STRING_END }; @@ -258,9 +264,14 @@ switch (relocPattern(reloc)) { case GENERIC_RELOC_VANILLA | rPcRel | rExtern | rLength4: // ex: call _foo (and _foo undefined) - *kind = branch32; if (E ec = atomFromSymbolIndex(reloc.symbol, target)) return ec; + bool isProbe; + if (isDtraceSite(*target, isProbe)) { + *kind = isProbe ? dtraceProbe : dtraceIsEnabled; + } else { + *kind = branch32; + } *addend = fixupAddress + 4 + (int32_t)*(const little32_t *)fixupContent; break; case GENERIC_RELOC_VANILLA | rPcRel | rLength4: @@ -469,6 +480,21 @@ case lazyImmediateLocation: *loc32 = ref.addend(); break; + case dtraceProbe: + // change call site to a NOP + assert((loc[-1] == 0xE8) && "dtrace reloc is not a call instruction."); + loc[-1] = 0x90; // 1-byte nop + *loc32 = 0x00401F0F; // 4-byte nop + break; + case dtraceIsEnabled: + // change call site to a clear eax + assert((loc[-1] == 0xE8) && "dtrace reloc is not a call instruction."); + loc[-1] = 0x33; // xorl eax,eax + loc[0] = 0xC0; + loc[1] = 0x90; // 1-byte nop + loc[2] = 0x90; // 1-byte nop + loc[3] = 0x90; // 1-byte nop + break; case invalid: llvm_unreachable("invalid x86 Reference Kind"); break; @@ -518,6 +544,10 @@ case lazyImmediateLocation: // do nothing break; + case dtraceProbe: + case dtraceIsEnabled: + // do nothing + break; case invalid: llvm_unreachable("invalid x86 Reference Kind"); break; @@ -564,6 +594,8 @@ case modeData: break; case branch32: + case dtraceProbe: + case dtraceIsEnabled: if (useExternalReloc) { appendReloc(relocs, sectionOffset, symbolIndexForAtom(*ref.target()), 0, GENERIC_RELOC_VANILLA | rExtern | rPcRel | rLength4); Index: lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp =================================================================== --- lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp +++ lib/ReaderWriter/MachO/ArchHandler_x86_64.cpp @@ -192,6 +192,10 @@ /// relocatable object (yay for implicit contracts!). unwindInfoToEhFrame, /// Fix low 24 bits of compact unwind encoding to /// refer to __eh_frame entry. + + // Dtrace support + dtraceProbe, /// ___dtrace_probe$… + dtraceIsEnabled, /// ___dtrace_isenabled$… }; Reference::KindValue kindFromReloc(const normalized::Relocation &reloc); @@ -215,22 +219,23 @@ ArchHandler_x86_64::~ArchHandler_x86_64() { } const Registry::KindStrings ArchHandler_x86_64::_sKindStrings[] = { - LLD_KIND_STRING_ENTRY(invalid), LLD_KIND_STRING_ENTRY(branch32), - LLD_KIND_STRING_ENTRY(ripRel32), LLD_KIND_STRING_ENTRY(ripRel32Minus1), - LLD_KIND_STRING_ENTRY(ripRel32Minus2), LLD_KIND_STRING_ENTRY(ripRel32Minus4), - LLD_KIND_STRING_ENTRY(ripRel32Anon), LLD_KIND_STRING_ENTRY(ripRel32GotLoad), - LLD_KIND_STRING_ENTRY(ripRel32GotLoadNowLea), - LLD_KIND_STRING_ENTRY(ripRel32Got), LLD_KIND_STRING_ENTRY(lazyPointer), - LLD_KIND_STRING_ENTRY(lazyImmediateLocation), - LLD_KIND_STRING_ENTRY(pointer64), LLD_KIND_STRING_ENTRY(pointer64Anon), - LLD_KIND_STRING_ENTRY(delta32), LLD_KIND_STRING_ENTRY(delta64), - LLD_KIND_STRING_ENTRY(delta32Anon), LLD_KIND_STRING_ENTRY(delta64Anon), - LLD_KIND_STRING_ENTRY(negDelta32), - LLD_KIND_STRING_ENTRY(imageOffset), LLD_KIND_STRING_ENTRY(imageOffsetGot), - LLD_KIND_STRING_ENTRY(unwindFDEToFunction), - LLD_KIND_STRING_ENTRY(unwindInfoToEhFrame), - LLD_KIND_STRING_END -}; + LLD_KIND_STRING_ENTRY(invalid), LLD_KIND_STRING_ENTRY(branch32), + LLD_KIND_STRING_ENTRY(ripRel32), LLD_KIND_STRING_ENTRY(ripRel32Minus1), + LLD_KIND_STRING_ENTRY(ripRel32Minus2), + LLD_KIND_STRING_ENTRY(ripRel32Minus4), LLD_KIND_STRING_ENTRY(ripRel32Anon), + LLD_KIND_STRING_ENTRY(ripRel32GotLoad), + LLD_KIND_STRING_ENTRY(ripRel32GotLoadNowLea), + LLD_KIND_STRING_ENTRY(ripRel32Got), LLD_KIND_STRING_ENTRY(lazyPointer), + LLD_KIND_STRING_ENTRY(lazyImmediateLocation), + LLD_KIND_STRING_ENTRY(pointer64), LLD_KIND_STRING_ENTRY(pointer64Anon), + LLD_KIND_STRING_ENTRY(delta32), LLD_KIND_STRING_ENTRY(delta64), + LLD_KIND_STRING_ENTRY(delta32Anon), LLD_KIND_STRING_ENTRY(delta64Anon), + LLD_KIND_STRING_ENTRY(negDelta32), LLD_KIND_STRING_ENTRY(imageOffset), + LLD_KIND_STRING_ENTRY(imageOffsetGot), + LLD_KIND_STRING_ENTRY(unwindFDEToFunction), + LLD_KIND_STRING_ENTRY(unwindInfoToEhFrame), + LLD_KIND_STRING_ENTRY(dtraceProbe), LLD_KIND_STRING_ENTRY(dtraceIsEnabled), + LLD_KIND_STRING_END}; const ArchHandler::StubInfo ArchHandler_x86_64::_sStubInfo = { "dyld_stub_binder", @@ -339,6 +344,9 @@ case ripRel32: if (E ec = atomFromSymbolIndex(reloc.symbol, target)) return ec; + bool isProbe; + if (*kind == branch32 && isDtraceSite(*target, isProbe)) + *kind = isProbe ? dtraceProbe : dtraceIsEnabled; *addend = *(const little32_t *)fixupContent; return std::error_code(); case ripRel32Minus1: @@ -535,6 +543,21 @@ *loc32 = (*loc32 & 0xff000000U) | val; return; } + case dtraceProbe: + // change call site to a NOP + assert((loc[-1] == 0xE8) && "dtrace reloc is not a call instruction."); + loc[-1] = 0x90; // 1-byte nop + *loc32 = 0x00401F0F; // 4-byte nop + return; + case dtraceIsEnabled: + // change call site to a clear eax + assert((loc[-1] == 0xE8) && "dtrace reloc is not a call instruction."); + loc[-1] = 0x33; // xorl eax,eax + loc[0] = 0xC0; + loc[1] = 0x90; // 1-byte nop + loc[2] = 0x90; // 1-byte nop + loc[3] = 0x90; // 1-byte nop + return; case invalid: // Fall into llvm_unreachable(). break; @@ -608,6 +631,10 @@ case unwindFDEToFunction: // Do nothing for now return; + case dtraceProbe: + case dtraceIsEnabled: + // do nothing for object + return; case invalid: // Fall into llvm_unreachable(). break; @@ -629,6 +656,8 @@ uint32_t sectionOffset = atomSectionOffset + ref.offsetInAtom(); switch (static_cast(ref.kindValue())) { case branch32: + case dtraceProbe: + case dtraceIsEnabled: appendReloc(relocs, sectionOffset, symbolIndexForAtom(*ref.target()), 0, X86_64_RELOC_BRANCH | rPcRel | rExtern | rLength4); return; Index: lib/ReaderWriter/MachO/File.h =================================================================== --- lib/ReaderWriter/MachO/File.h +++ lib/ReaderWriter/MachO/File.h @@ -20,6 +20,18 @@ namespace lld { namespace mach_o { +class DtraceUndefinedAtom : public SimpleUndefinedAtom { +public: + DtraceUndefinedAtom(const File &f, StringRef name) + : SimpleUndefinedAtom(f, name) { + assert(!name.empty() && "UndefinedAtoms must have a name"); + } + + CanBeNull canBeNull() const override { + return UndefinedAtom::canBeNullAtBuildtime; + } +}; + using lld::mach_o::normalized::Section; class MachOFile : public SimpleFile { @@ -98,8 +110,15 @@ // Make a copy of the atom's name that is owned by this file. name = name.copy(allocator()); } - SimpleUndefinedAtom *atom = - new (allocator()) SimpleUndefinedAtom(*this, name); + SimpleUndefinedAtom *atom; + if (normalized::isDtraceSymbol(name)) { + // dtrace symbols are placeholder symbols that should not be resolved. + // We mark them as 'canBeNullAtBuildtime' to make the resolver happy. + // Ideally we shouldn't event try to resolve them. + atom = new (allocator()) DtraceUndefinedAtom(*this, name); + } else { + atom = new (allocator()) SimpleUndefinedAtom(*this, name); + } addAtom(*atom); _undefAtoms[name] = atom; } Index: lib/ReaderWriter/MachO/MachONormalizedFile.h =================================================================== --- lib/ReaderWriter/MachO/MachONormalizedFile.h +++ lib/ReaderWriter/MachO/MachONormalizedFile.h @@ -204,6 +204,16 @@ DataRegionType kind; }; +/// Dtrace symbol info +struct DTraceSymbol { + StringRef type; + StringRef provider; + StringRef extra; +}; + +// Parse a symbol to dtermine if this is a dtrace runtime symbol. +// "___dtrace_$$ +bool isDtraceSymbol(StringRef symbol, DTraceSymbol *info = nullptr); /// A typedef so that YAML I/O can encode/decode mach_header.flags. LLVM_YAML_STRONG_TYPEDEF(uint32_t, FileFlags) Index: lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp =================================================================== --- lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp +++ lib/ReaderWriter/MachO/MachONormalizedFileBinaryReader.cpp @@ -565,6 +565,26 @@ MachOLinkingContext &_ctx; }; +bool isDtraceSymbol(StringRef symbol, DTraceSymbol *info) { + if (!symbol.startswith("___dtrace_")) + return false; + size_t sep = symbol.find('$'); + if (sep == StringRef::npos) + return false; + if (info) + info->type = symbol.slice(10, sep); + + sep++; // skip '$' + size_t sep2 = symbol.find('$', sep); + if (sep2 == StringRef::npos) + return false; + if (info) { + info->provider = symbol.slice(sep, sep2); + info->extra = symbol.substr(sep2 + 1); + } + return true; +} + } // namespace normalized } // namespace mach_o Index: lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp =================================================================== --- lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp +++ lib/ReaderWriter/MachO/MachONormalizedFileFromAtoms.cpp @@ -90,7 +90,6 @@ : name(n), address(0), size(0), access(0), normalizedSegmentIndex(0) { } - class Util { public: Util(const MachOLinkingContext &ctxt) @@ -839,14 +838,19 @@ // Sort undefined symbol alphabetically, then add to symbol table. std::vector undefs; undefs.reserve(128); - for (const UndefinedAtom *atom : atomFile.undefined()) { - AtomAndIndex ai = { atom, 0, N_EXT }; - undefs.push_back(ai); + if (rMode) { + // Only object can contains undefined atoms. atomFile though + // may contains canBeNullAtBuildTime symbols (dtrace) we want to ignore. + for (const UndefinedAtom *atom : atomFile.undefined()) { + AtomAndIndex ai = { atom, 0, N_EXT }; + undefs.push_back(ai); + } } for (const SharedLibraryAtom *atom : atomFile.sharedLibrary()) { AtomAndIndex ai = { atom, 0, N_EXT }; undefs.push_back(ai); } + std::sort(undefs.begin(), undefs.end(), AtomSorter()); const uint32_t start = file.globalSymbols.size() + file.localSymbols.size(); for (AtomAndIndex &ai : undefs) { Index: test/lit.cfg =================================================================== --- test/lit.cfg +++ test/lit.cfg @@ -148,6 +148,8 @@ config.available_features.add('debug') if re.search(r'ON', llvm_config_output_list[1]): config.available_features.add('asserts') +if re.search(r'AArch64', llvm_config_output_list[2]): + config.available_features.add('aarch64') if re.search(r'ARM', llvm_config_output_list[2]): config.available_features.add('arm') if re.search(r'Mips', llvm_config_output_list[2]): Index: test/mach-o/Inputs/dtrace-arm64.yaml =================================================================== --- test/mach-o/Inputs/dtrace-arm64.yaml +++ test/mach-o/Inputs/dtrace-arm64.yaml @@ -0,0 +1,124 @@ +--- !mach-o +arch: arm64 +file-type: MH_OBJECT +flags: [ MH_SUBSECTIONS_VIA_SYMBOLS ] +has-UUID: false +OS: unknown +sections: + - segment: __TEXT + section: __text + type: S_REGULAR + attributes: [ S_ATTR_PURE_INSTRUCTIONS ] + alignment: 2 + address: 0x0000000000000000 + content: [ 0xFD, 0x7B, 0xBF, 0xA9, 0xFD, 0x03, 0x00, 0x91, + 0xFF, 0x83, 0x00, 0xD1, 0x08, 0x00, 0x80, 0x52, + 0xA0, 0x23, 0x3F, 0x29, 0xE1, 0x0B, 0x00, 0xF9, + 0x00, 0x00, 0x00, 0x94, 0x01, 0x00, 0x00, 0x14, + 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x94, + 0xE0, 0x0F, 0x00, 0xB9, 0xE0, 0x0F, 0x40, 0xB9, + 0xE0, 0x0B, 0x00, 0xB9, 0xE0, 0x0B, 0x40, 0xB9, + 0x1F, 0x00, 0x00, 0x71, 0x41, 0x00, 0x00, 0x54, + 0x12, 0x00, 0x00, 0x14, 0x08, 0x00, 0x80, 0x52, + 0xE8, 0x07, 0x00, 0xB9, 0xE8, 0x07, 0x40, 0xB9, + 0x1F, 0x29, 0x00, 0x71, 0x4B, 0x00, 0x00, 0x54, + 0x0B, 0x00, 0x00, 0x14, 0x01, 0x00, 0x00, 0x14, + 0xE8, 0x07, 0x40, 0xB9, 0x00, 0x7D, 0x40, 0x93, + 0x00, 0x00, 0x00, 0x94, 0x01, 0x00, 0x00, 0x14, + 0xE8, 0x07, 0x40, 0xB9, 0xE9, 0x03, 0x00, 0x32, + 0x08, 0x01, 0x09, 0x0B, 0xE8, 0x07, 0x00, 0xB9, + 0xF3, 0xFF, 0xFF, 0x17, 0x01, 0x00, 0x00, 0x14, + 0x01, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x94, + 0x01, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x94, + 0x00, 0x00, 0x80, 0x52, 0xBF, 0x03, 0x00, 0x91, + 0xFD, 0x7B, 0xC1, 0xA8, 0xC0, 0x03, 0x5F, 0xD6 ] + relocations: + - offset: 0x00000018 + type: ARM64_RELOC_BRANCH26 + length: 2 + pc-rel: true + extern: true + symbol: 2 + - offset: 0x00000020 + type: ARM64_RELOC_BRANCH26 + length: 2 + pc-rel: true + extern: true + symbol: 5 + - offset: 0x00000024 + type: ARM64_RELOC_BRANCH26 + length: 2 + pc-rel: true + extern: true + symbol: 1 + - offset: 0x00000068 + type: ARM64_RELOC_BRANCH26 + length: 2 + pc-rel: true + extern: true + symbol: 4 + - offset: 0x0000008C + type: ARM64_RELOC_BRANCH26 + length: 2 + pc-rel: true + extern: true + symbol: 5 + - offset: 0x00000094 + type: ARM64_RELOC_BRANCH26 + length: 2 + pc-rel: true + extern: true + symbol: 3 +global-symbols: + - name: _main + type: N_SECT + scope: [ N_EXT ] + sect: 1 + value: 0x0000000000000000 +undefined-symbols: + - name: '___dtrace_isenabled$std$bar$v1' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_probe$provider_with_long_name$foo$v1' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_probe$provider_with_long_name_too$foo$v1' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_probe$std$bar$v1$696e7436345f74' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_probe$std$foo$v1' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_stability$provider_with_long_name$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_stability$provider_with_long_name_too$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_stability$std$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_typedefs$provider_with_long_name$v2' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_typedefs$provider_with_long_name_too$v2' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_typedefs$std$v2' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 +page-size: 0x00004000 +... Index: test/mach-o/Inputs/dtrace-armv7s-thumb.yaml =================================================================== --- test/mach-o/Inputs/dtrace-armv7s-thumb.yaml +++ test/mach-o/Inputs/dtrace-armv7s-thumb.yaml @@ -0,0 +1,117 @@ +--- !mach-o +arch: armv7s +file-type: MH_OBJECT +flags: [ MH_SUBSECTIONS_VIA_SYMBOLS ] +has-UUID: false +OS: unknown +sections: + - segment: __TEXT + section: __text + type: S_REGULAR + attributes: [ S_ATTR_PURE_INSTRUCTIONS ] + alignment: 2 + address: 0x0000000000000000 + content: [ 0x80, 0xB5, 0x6F, 0x46, 0x87, 0xB0, 0x00, 0x22, + 0xC0, 0xF2, 0x00, 0x02, 0x06, 0x92, 0x05, 0x90, + 0x04, 0x91, 0xFF, 0xF7, 0xF5, 0xFF, 0xFF, 0xE7, + 0xFF, 0xF7, 0xF2, 0xFF, 0xFF, 0xF7, 0xF0, 0xFF, + 0x03, 0x90, 0x03, 0x98, 0x02, 0x90, 0x02, 0x98, + 0x00, 0x28, 0x15, 0xD0, 0x00, 0x20, 0xC0, 0xF2, + 0x00, 0x00, 0x01, 0x90, 0x01, 0x98, 0x0A, 0x28, + 0x0D, 0xDA, 0xFF, 0xE7, 0x01, 0x98, 0x01, 0x46, + 0x4F, 0xEA, 0xE0, 0x72, 0x00, 0x91, 0x11, 0x46, + 0xFF, 0xF7, 0xDA, 0xFF, 0xFF, 0xE7, 0x01, 0x98, + 0x01, 0x30, 0x01, 0x90, 0xEE, 0xE7, 0xFF, 0xE7, + 0xFF, 0xE7, 0xFF, 0xF7, 0xD1, 0xFF, 0xFF, 0xE7, + 0xFF, 0xF7, 0xCE, 0xFF, 0x00, 0x20, 0xC0, 0xF2, + 0x00, 0x00, 0x07, 0xB0, 0x80, 0xBD ] + relocations: + - offset: 0x00000012 + type: ARM_THUMB_RELOC_BR22 + length: 2 + pc-rel: true + extern: true + symbol: 2 + - offset: 0x00000018 + type: ARM_THUMB_RELOC_BR22 + length: 2 + pc-rel: true + extern: true + symbol: 5 + - offset: 0x0000001C + type: ARM_THUMB_RELOC_BR22 + length: 2 + pc-rel: true + extern: true + symbol: 1 + - offset: 0x00000048 + type: ARM_THUMB_RELOC_BR22 + length: 2 + pc-rel: true + extern: true + symbol: 4 + - offset: 0x0000005A + type: ARM_THUMB_RELOC_BR22 + length: 2 + pc-rel: true + extern: true + symbol: 5 + - offset: 0x00000060 + type: ARM_THUMB_RELOC_BR22 + length: 2 + pc-rel: true + extern: true + symbol: 3 +global-symbols: + - name: _main + type: N_SECT + scope: [ N_EXT ] + sect: 1 + desc: [ N_ARM_THUMB_DEF ] + value: 0x0000000000000000 +undefined-symbols: + - name: '___dtrace_isenabled$std$bar$v1' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_probe$provider_with_long_name$foo$v1' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_probe$provider_with_long_name_too$foo$v1' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_probe$std$bar$v1$696e7436345f74' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_probe$std$foo$v1' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_stability$provider_with_long_name$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_stability$provider_with_long_name_too$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_stability$std$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_typedefs$provider_with_long_name$v2' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_typedefs$provider_with_long_name_too$v2' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_typedefs$std$v2' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 +... Index: test/mach-o/Inputs/dtrace-armv7s.yaml =================================================================== --- test/mach-o/Inputs/dtrace-armv7s.yaml +++ test/mach-o/Inputs/dtrace-armv7s.yaml @@ -0,0 +1,123 @@ +--- !mach-o +arch: armv7s +file-type: MH_OBJECT +flags: [ MH_SUBSECTIONS_VIA_SYMBOLS ] +has-UUID: false +OS: unknown +sections: + - segment: __TEXT + section: __text + type: S_REGULAR + attributes: [ S_ATTR_PURE_INSTRUCTIONS ] + alignment: 2 + address: 0x0000000000000000 + content: [ 0x80, 0x40, 0x2D, 0xE9, 0x0D, 0x70, 0xA0, 0xE1, + 0x1C, 0xD0, 0x4D, 0xE2, 0x00, 0x20, 0x00, 0xE3, + 0x04, 0x20, 0x07, 0xE5, 0x08, 0x00, 0x07, 0xE5, + 0x0C, 0x10, 0x07, 0xE5, 0xF7, 0xFF, 0xFF, 0xEB, + 0xFF, 0xFF, 0xFF, 0xEA, 0xF5, 0xFF, 0xFF, 0xEB, + 0xF4, 0xFF, 0xFF, 0xEB, 0x0C, 0x00, 0x8D, 0xE5, + 0x0C, 0x00, 0x9D, 0xE5, 0x08, 0x00, 0x8D, 0xE5, + 0x08, 0x00, 0x9D, 0xE5, 0x00, 0x00, 0x50, 0xE3, + 0x11, 0x00, 0x00, 0x0A, 0x00, 0x00, 0x00, 0xE3, + 0x04, 0x00, 0x8D, 0xE5, 0x04, 0x00, 0x9D, 0xE5, + 0x0A, 0x00, 0x50, 0xE3, 0x0B, 0x00, 0x00, 0xAA, + 0xFF, 0xFF, 0xFF, 0xEA, 0x04, 0x00, 0x9D, 0xE5, + 0x00, 0x10, 0xA0, 0xE1, 0xC0, 0x2F, 0xA0, 0xE1, + 0x00, 0x10, 0x8D, 0xE5, 0x02, 0x10, 0xA0, 0xE1, + 0xE2, 0xFF, 0xFF, 0xEB, 0xFF, 0xFF, 0xFF, 0xEA, + 0x04, 0x00, 0x9D, 0xE5, 0x01, 0x00, 0x80, 0xE2, + 0x04, 0x00, 0x8D, 0xE5, 0xF0, 0xFF, 0xFF, 0xEA, + 0xFF, 0xFF, 0xFF, 0xEA, 0xFF, 0xFF, 0xFF, 0xEA, + 0xDA, 0xFF, 0xFF, 0xEB, 0xFF, 0xFF, 0xFF, 0xEA, + 0xD8, 0xFF, 0xFF, 0xEB, 0x00, 0x00, 0x00, 0xE3, + 0x07, 0xD0, 0xA0, 0xE1, 0x80, 0x80, 0xBD, 0xE8 ] + relocations: + - offset: 0x0000001C + type: ARM_RELOC_BR24 + length: 2 + pc-rel: true + extern: true + symbol: 2 + - offset: 0x00000024 + type: ARM_RELOC_BR24 + length: 2 + pc-rel: true + extern: true + symbol: 5 + - offset: 0x00000028 + type: ARM_RELOC_BR24 + length: 2 + pc-rel: true + extern: true + symbol: 1 + - offset: 0x00000070 + type: ARM_RELOC_BR24 + length: 2 + pc-rel: true + extern: true + symbol: 4 + - offset: 0x00000090 + type: ARM_RELOC_BR24 + length: 2 + pc-rel: true + extern: true + symbol: 5 + - offset: 0x00000098 + type: ARM_RELOC_BR24 + length: 2 + pc-rel: true + extern: true + symbol: 3 +global-symbols: + - name: _main + type: N_SECT + scope: [ N_EXT ] + sect: 1 + value: 0x0000000000000000 +undefined-symbols: + - name: '___dtrace_isenabled$std$bar$v1' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_probe$provider_with_long_name$foo$v1' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_probe$provider_with_long_name_too$foo$v1' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_probe$std$bar$v1$696e7436345f74' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_probe$std$foo$v1' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_stability$provider_with_long_name$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_stability$provider_with_long_name_too$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_stability$std$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_typedefs$provider_with_long_name$v2' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_typedefs$provider_with_long_name_too$v2' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_typedefs$std$v2' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 +... Index: test/mach-o/Inputs/dtrace-x86.yaml =================================================================== --- test/mach-o/Inputs/dtrace-x86.yaml +++ test/mach-o/Inputs/dtrace-x86.yaml @@ -0,0 +1,123 @@ +--- !mach-o +arch: x86 +file-type: MH_OBJECT +flags: [ MH_SUBSECTIONS_VIA_SYMBOLS ] +has-UUID: false +OS: unknown +sections: + - segment: __TEXT + section: __text + type: S_REGULAR + attributes: [ S_ATTR_PURE_INSTRUCTIONS ] + alignment: 4 + address: 0x0000000000000000 + content: [ 0x55, 0x89, 0xE5, 0x83, 0xEC, 0x28, 0x8B, 0x45, + 0x0C, 0x8B, 0x4D, 0x08, 0xC7, 0x45, 0xFC, 0x00, + 0x00, 0x00, 0x00, 0x89, 0x4D, 0xF8, 0x89, 0x45, + 0xF4, 0xE8, 0xE2, 0xFF, 0xFF, 0xFF, 0xE9, 0x00, + 0x00, 0x00, 0x00, 0xE8, 0xD8, 0xFF, 0xFF, 0xFF, + 0xE8, 0xD3, 0xFF, 0xFF, 0xFF, 0x89, 0x45, 0xF0, + 0x8B, 0x45, 0xF0, 0x89, 0x45, 0xEC, 0x81, 0x7D, + 0xEC, 0x00, 0x00, 0x00, 0x00, 0x0F, 0x84, 0x47, + 0x00, 0x00, 0x00, 0xC7, 0x45, 0xE8, 0x00, 0x00, + 0x00, 0x00, 0x81, 0x7D, 0xE8, 0x0A, 0x00, 0x00, + 0x00, 0x0F, 0x8D, 0x2E, 0x00, 0x00, 0x00, 0xE9, + 0x00, 0x00, 0x00, 0x00, 0x8B, 0x45, 0xE8, 0x89, + 0xC1, 0xC1, 0xF9, 0x1F, 0x89, 0xE2, 0x89, 0x4A, + 0x04, 0x89, 0x02, 0xE8, 0x90, 0xFF, 0xFF, 0xFF, + 0xE9, 0x00, 0x00, 0x00, 0x00, 0x8B, 0x45, 0xE8, + 0x05, 0x01, 0x00, 0x00, 0x00, 0x89, 0x45, 0xE8, + 0xE9, 0xC5, 0xFF, 0xFF, 0xFF, 0xE9, 0x00, 0x00, + 0x00, 0x00, 0xE9, 0x00, 0x00, 0x00, 0x00, 0xE8, + 0x6C, 0xFF, 0xFF, 0xFF, 0xE9, 0x00, 0x00, 0x00, + 0x00, 0xE8, 0x62, 0xFF, 0xFF, 0xFF, 0xB8, 0x00, + 0x00, 0x00, 0x00, 0x83, 0xC4, 0x28, 0x5D, 0xC3 ] + relocations: + - offset: 0x0000001A + type: GENERIC_RELOC_VANILLA + length: 2 + pc-rel: true + extern: true + symbol: 2 + - offset: 0x00000024 + type: GENERIC_RELOC_VANILLA + length: 2 + pc-rel: true + extern: true + symbol: 5 + - offset: 0x00000029 + type: GENERIC_RELOC_VANILLA + length: 2 + pc-rel: true + extern: true + symbol: 1 + - offset: 0x0000006C + type: GENERIC_RELOC_VANILLA + length: 2 + pc-rel: true + extern: true + symbol: 4 + - offset: 0x00000090 + type: GENERIC_RELOC_VANILLA + length: 2 + pc-rel: true + extern: true + symbol: 5 + - offset: 0x0000009A + type: GENERIC_RELOC_VANILLA + length: 2 + pc-rel: true + extern: true + symbol: 3 +global-symbols: + - name: _main + type: N_SECT + scope: [ N_EXT ] + sect: 1 + value: 0x0000000000000000 +undefined-symbols: + - name: '___dtrace_isenabled$std$bar$v1' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_probe$provider_with_long_name$foo$v1' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_probe$provider_with_long_name_too$foo$v1' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_probe$std$bar$v1$696e7436345f74' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_probe$std$foo$v1' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_stability$provider_with_long_name$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_stability$provider_with_long_name_too$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_stability$std$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_typedefs$provider_with_long_name$v2' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_typedefs$provider_with_long_name_too$v2' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_typedefs$std$v2' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 +... Index: test/mach-o/Inputs/dtrace-x86_64.yaml =================================================================== --- test/mach-o/Inputs/dtrace-x86_64.yaml +++ test/mach-o/Inputs/dtrace-x86_64.yaml @@ -0,0 +1,155 @@ +# +# --- dtrace probe file --- +# provider std { +# probe foo(); +# probe bar(int64_t time); +# }; +# +# provider provider_with_long_name { +# probe foo(); +# }; +# +# provider provider_with_long_name_too { +# probe foo(); +# }; +# +# +# --- C source file --- +# int main(int argc, const char * argv[]) { +# PROVIDER_WITH_LONG_NAME_FOO(); +# +# STD_FOO(); +# if (STD_BAR_ENABLED()) { +# for (int i = 0; i < 10; ++i) { +# STD_BAR(i); +# } +# } +# STD_FOO(); +# +# PROVIDER_WITH_LONG_NAME_TOO_FOO(); +# return 0; +# } +# + +--- !mach-o +arch: x86_64 +file-type: MH_OBJECT +flags: [ MH_SUBSECTIONS_VIA_SYMBOLS ] +has-UUID: false +OS: unknown +sections: + - segment: __TEXT + section: __text + type: S_REGULAR + attributes: [ S_ATTR_PURE_INSTRUCTIONS, S_ATTR_SOME_INSTRUCTIONS ] + alignment: 4 + address: 0x0000000000000000 + content: [ 0x55, 0x48, 0x89, 0xE5, 0x48, 0x83, 0xEC, 0x20, + 0xC7, 0x45, 0xFC, 0x00, 0x00, 0x00, 0x00, 0x89, + 0x7D, 0xF8, 0x48, 0x89, 0x75, 0xF0, 0xE8, 0x00, + 0x00, 0x00, 0x00, 0xE9, 0x00, 0x00, 0x00, 0x00, + 0xE8, 0x00, 0x00, 0x00, 0x00, 0xE8, 0x00, 0x00, + 0x00, 0x00, 0x89, 0x45, 0xEC, 0x8B, 0x45, 0xEC, + 0x89, 0x45, 0xE8, 0x81, 0x7D, 0xE8, 0x00, 0x00, + 0x00, 0x00, 0x0F, 0x84, 0x3C, 0x00, 0x00, 0x00, + 0xC7, 0x45, 0xE4, 0x00, 0x00, 0x00, 0x00, 0x81, + 0x7D, 0xE4, 0x0A, 0x00, 0x00, 0x00, 0x0F, 0x8D, + 0x23, 0x00, 0x00, 0x00, 0xE9, 0x00, 0x00, 0x00, + 0x00, 0x48, 0x63, 0x7D, 0xE4, 0xE8, 0x00, 0x00, + 0x00, 0x00, 0xE9, 0x00, 0x00, 0x00, 0x00, 0x8B, + 0x45, 0xE4, 0x05, 0x01, 0x00, 0x00, 0x00, 0x89, + 0x45, 0xE4, 0xE9, 0xD0, 0xFF, 0xFF, 0xFF, 0xE9, + 0x00, 0x00, 0x00, 0x00, 0xE9, 0x00, 0x00, 0x00, + 0x00, 0xE8, 0x00, 0x00, 0x00, 0x00, 0xE9, 0x00, + 0x00, 0x00, 0x00, 0xE8, 0x00, 0x00, 0x00, 0x00, + 0xB8, 0x00, 0x00, 0x00, 0x00, 0x48, 0x83, 0xC4, + 0x20, 0x5D, 0xC3 ] + relocations: + - offset: 0x00000017 + type: X86_64_RELOC_BRANCH + length: 2 + pc-rel: true + extern: true + symbol: 2 + - offset: 0x00000021 + type: X86_64_RELOC_BRANCH + length: 2 + pc-rel: true + extern: true + symbol: 5 + - offset: 0x00000026 + type: X86_64_RELOC_BRANCH + length: 2 + pc-rel: true + extern: true + symbol: 1 + - offset: 0x0000005E + type: X86_64_RELOC_BRANCH + length: 2 + pc-rel: true + extern: true + symbol: 4 + - offset: 0x00000082 + type: X86_64_RELOC_BRANCH + length: 2 + pc-rel: true + extern: true + symbol: 5 + - offset: 0x0000008C + type: X86_64_RELOC_BRANCH + length: 2 + pc-rel: true + extern: true + symbol: 3 +global-symbols: + - name: _main + type: N_SECT + scope: [ N_EXT ] + sect: 1 + value: 0x0000000000000000 +undefined-symbols: + - name: '___dtrace_isenabled$std$bar$v1' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_probe$provider_with_long_name$foo$v1' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_probe$provider_with_long_name_too$foo$v1' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_probe$std$bar$v1$696e7436345f74' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_probe$std$foo$v1' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_stability$provider_with_long_name$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_stability$provider_with_long_name_too$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_stability$std$v1$1_1_0_1_1_0_1_1_0_1_1_0_1_1_0' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_typedefs$provider_with_long_name$v2' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_typedefs$provider_with_long_name_too$v2' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 + - name: '___dtrace_typedefs$std$v2' + type: N_UNDF + scope: [ N_EXT ] + value: 0x0000000000000000 +... Index: test/mach-o/dtrace-arm64.yaml =================================================================== --- test/mach-o/dtrace-arm64.yaml +++ test/mach-o/dtrace-arm64.yaml @@ -0,0 +1,11 @@ +# REQUIRES: aarch64 +# +# RUN: lld -flavor darwin -arch arm64 %p/Inputs/dtrace-arm64.yaml -o %t %p/Inputs/libSystem.yaml +# RUN: llvm-objdump -macho -d %t | FileCheck %s + +# CHECK: 1f 20 03 d5 nop +# CHECK: 1f 20 03 d5 nop +# CHECK: 00 00 80 d2 movz x0, #0 +# CHECK: 1f 20 03 d5 nop +# CHECK: 1f 20 03 d5 nop +# CHECK: 1f 20 03 d5 nop Index: test/mach-o/dtrace-armv7s.yaml =================================================================== --- test/mach-o/dtrace-armv7s.yaml +++ test/mach-o/dtrace-armv7s.yaml @@ -0,0 +1,32 @@ +# REQUIRES: arm +# +# RUN: lld -flavor darwin -arch armv7s %p/Inputs/dtrace-armv7s.yaml -o %t %p/Inputs/libSystem.yaml +# RUN: llvm-objdump -macho -d %t | FileCheck %s +# +# RUN: lld -flavor darwin -arch armv7s %p/Inputs/dtrace-armv7s-thumb.yaml -o %t %p/Inputs/libSystem.yaml +# RUN: llvm-objdump -macho -d %t | FileCheck --check-prefix CHECK-THUMB %s + +# CHECK: 00 00 a0 e1 mov r0, r0 +# CHECK: 00 00 a0 e1 mov r0, r0 +# CHECK: 00 00 20 e0 eor r0, r0, r0 +# CHECK: 00 00 a0 e1 mov r0, r0 +# CHECK: 00 00 a0 e1 mov r0, r0 +# CHECK: 00 00 a0 e1 mov r0, r0 + +# CHECK-THUMB: c0 46 mov r8, r8 +# CHECK-THUMB-NEXT: c0 46 mov r8, r8 + +# CHECK-THUMB: c0 46 mov r8, r8 +# CHECK-THUMB-NEXT: c0 46 mov r8, r8 + +# CHECK-THUMB: 40 40 eors r0, r0 +# CHECK-THUMB-NEXT: c0 46 mov r8, r8 + +# CHECK-THUMB: c0 46 mov r8, r8 +# CHECK-THUMB-NEXT: c0 46 mov r8, r8 + +# CHECK-THUMB: c0 46 mov r8, r8 +# CHECK-THUMB-NEXT: c0 46 mov r8, r8 + +# CHECK-THUMB: c0 46 mov r8, r8 +# CHECK-THUMB-NEXT: c0 46 mov r8, r8 Index: test/mach-o/dtrace-x86.yaml =================================================================== --- test/mach-o/dtrace-x86.yaml +++ test/mach-o/dtrace-x86.yaml @@ -0,0 +1,24 @@ +# REQUIRES: x86 +# +# RUN: lld -flavor darwin -arch i386 %p/Inputs/dtrace-x86.yaml -o %t %p/Inputs/libSystem.yaml +# RUN: llvm-objdump -macho -d %t | FileCheck %s + +# CHECK: 90 nop +# CHECK-NEXT: 0f 1f 40 00 nopl (%eax) + +# CHECK: 90 nop +# CHECK-NEXT: 0f 1f 40 00 nopl (%eax) + +# CHECK: 33 c0 xorl %eax, %eax +# CHECK-NEXT: 90 nop +# CHECK-NEXT: 90 nop +# CHECK-NEXT: 90 nop + +# CHECK: 90 nop +# CHECK-NEXT: 0f 1f 40 00 nopl (%eax) + +# CHECK: 90 nop +# CHECK-NEXT: 0f 1f 40 00 nopl (%eax) + +# CHECK: 90 nop +# CHECK-NEXT: 0f 1f 40 00 nopl (%eax) Index: test/mach-o/dtrace-x86_64.yaml =================================================================== --- test/mach-o/dtrace-x86_64.yaml +++ test/mach-o/dtrace-x86_64.yaml @@ -0,0 +1,24 @@ +# REQUIRES: x86 +# +# RUN: lld -flavor darwin -arch x86_64 %p/Inputs/dtrace-x86_64.yaml -o %t %p/Inputs/libSystem.yaml +# RUN: llvm-objdump -macho -d %t | FileCheck %s + +# CHECK: 90 nop +# CHECK-NEXT: 0f 1f 40 00 nopl (%rax) + +# CHECK: 90 nop +# CHECK-NEXT: 0f 1f 40 00 nopl (%rax) + +# CHECK: 33 c0 xorl %eax, %eax +# CHECK-NEXT: 90 nop +# CHECK-NEXT: 90 nop +# CHECK-NEXT: 90 nop + +# CHECK: 90 nop +# CHECK-NEXT: 0f 1f 40 00 nopl (%rax) + +# CHECK: 90 nop +# CHECK-NEXT: 0f 1f 40 00 nopl (%rax) + +# CHECK: 90 nop +# CHECK-NEXT: 0f 1f 40 00 nopl (%rax) Index: test/mach-o/parse-dtrace.yaml =================================================================== --- test/mach-o/parse-dtrace.yaml +++ test/mach-o/parse-dtrace.yaml @@ -0,0 +1,75 @@ +# Check we properly generate dtrace references for dtrace symbols + +# RUN: lld -flavor darwin -arch i386 -r -print_atoms %p/Inputs/dtrace-x86.yaml -o %t | FileCheck %s +# RUN: llvm-objdump -macho -r %t | FileCheck --check-prefix X86 %s +# X86: RELOCATION RECORDS FOR [__text]: +# X86-NEXT: GENERIC_RELOC_VANILLA ___dtrace_probe$provider_with_long_name$foo$v1 +# X86-NEXT: GENERIC_RELOC_VANILLA ___dtrace_probe$std$foo$v1 +# X86-NEXT: GENERIC_RELOC_VANILLA ___dtrace_isenabled$std$bar$v1 +# X86-NEXT: GENERIC_RELOC_VANILLA ___dtrace_probe$std$bar$v1$696e7436345f74 +# X86-NEXT: GENERIC_RELOC_VANILLA ___dtrace_probe$std$foo$v1 +# X86-NEXT: GENERIC_RELOC_VANILLA ___dtrace_probe$provider_with_long_name_too$foo$v1 + +# RUN: lld -flavor darwin -arch x86_64 -r -print_atoms %p/Inputs/dtrace-x86_64.yaml -o %t | FileCheck %s +# RUN: llvm-objdump -macho -r %t | FileCheck --check-prefix X86_64 %s +# X86_64: RELOCATION RECORDS FOR [__text]: +# X86_64-NEXT: X86_64_RELOC_BRANCH ___dtrace_probe$provider_with_long_name$foo$v1 +# X86_64-NEXT: X86_64_RELOC_BRANCH ___dtrace_probe$std$foo$v1 +# X86_64-NEXT: X86_64_RELOC_BRANCH ___dtrace_isenabled$std$bar$v1 +# X86_64-NEXT: X86_64_RELOC_BRANCH ___dtrace_probe$std$bar$v1$696e7436345f74 +# X86_64-NEXT: X86_64_RELOC_BRANCH ___dtrace_probe$std$foo$v1 +# X86_64-NEXT: X86_64_RELOC_BRANCH ___dtrace_probe$provider_with_long_name_too$foo$v1 + +# RUN: lld -flavor darwin -arch armv7s -r -print_atoms %p/Inputs/dtrace-armv7s.yaml -o %t | FileCheck %s +# RUN: llvm-objdump -macho -r %t | FileCheck --check-prefix ARM %s +# ARM: RELOCATION RECORDS FOR [__text]: +# ARM-NEXT: ARM_RELOC_BR24 ___dtrace_probe$provider_with_long_name$foo$v1 +# ARM-NEXT: ARM_RELOC_BR24 ___dtrace_probe$std$foo$v1 +# ARM-NEXT: ARM_RELOC_BR24 ___dtrace_isenabled$std$bar$v1 +# ARM-NEXT: ARM_RELOC_BR24 ___dtrace_probe$std$bar$v1$696e7436345f74 +# ARM-NEXT: ARM_RELOC_BR24 ___dtrace_probe$std$foo$v1 +# ARM-NEXT: ARM_RELOC_BR24 ___dtrace_probe$provider_with_long_name_too$foo$v1 + +# RUN: lld -flavor darwin -arch armv7s -r -print_atoms %p/Inputs/dtrace-armv7s-thumb.yaml -o %t | FileCheck %s +# RUN: llvm-objdump -macho -r %t | FileCheck --check-prefix THUMB %s +# THUMB: RELOCATION RECORDS FOR [__text]: +# THUMB-NEXT: ARM_THUMB_RELOC_BR22 ___dtrace_probe$provider_with_long_name$foo$v1 +# THUMB-NEXT: ARM_THUMB_RELOC_BR22 ___dtrace_probe$std$foo$v1 +# THUMB-NEXT: ARM_THUMB_RELOC_BR22 ___dtrace_isenabled$std$bar$v1 +# THUMB-NEXT: ARM_THUMB_RELOC_BR22 ___dtrace_probe$std$bar$v1$696e7436345f74 +# THUMB-NEXT: ARM_THUMB_RELOC_BR22 ___dtrace_probe$std$foo$v1 +# THUMB-NEXT: ARM_THUMB_RELOC_BR22 ___dtrace_probe$provider_with_long_name_too$foo$v1 + +# RUN: lld -flavor darwin -arch arm64 -r -print_atoms %p/Inputs/dtrace-arm64.yaml -o %t | FileCheck %s +# RUN: llvm-objdump -macho -r %t | FileCheck --check-prefix ARM64 %s +# ARM64: RELOCATION RECORDS FOR [__text]: +# ARM64-NEXT: ARM64_RELOC_BRANCH26 ___dtrace_probe$provider_with_long_name$foo$v1 +# ARM64-NEXT: ARM64_RELOC_BRANCH26 ___dtrace_probe$std$foo$v1 +# ARM64-NEXT: ARM64_RELOC_BRANCH26 ___dtrace_isenabled$std$bar$v1 +# ARM64-NEXT: ARM64_RELOC_BRANCH26 ___dtrace_probe$std$bar$v1$696e7436345f74 +# ARM64-NEXT: ARM64_RELOC_BRANCH26 ___dtrace_probe$std$foo$v1 +# ARM64-NEXT: ARM64_RELOC_BRANCH26 ___dtrace_probe$provider_with_long_name_too$foo$v1 + +# CHECK: kind: dtraceProbe +# CHECK-NEXT: offset: {{[0-9]+}} +# CHECK-NEXT: '___dtrace_probe$provider_with_long_name$foo$v1' + +# CHECK: kind: dtraceProbe +# CHECK-NEXT: offset: {{[0-9]+}} +# CHECK-NEXT: '___dtrace_probe$std$foo$v1' + +# CHECK: kind: dtraceIsEnabled +# CHECK-NEXT: offset: {{[0-9]+}} +# CHECK-NEXT: '___dtrace_isenabled$std$bar$v1' + +# CHECK: kind: dtraceProbe +# CHECK-NEXT: offset: {{[0-9]+}} +# CHECK-NEXT: '___dtrace_probe$std$bar$v1$696e7436345f74' + +# CHECK: kind: dtraceProbe +# CHECK-NEXT: offset: {{[0-9]+}} +# CHECK-NEXT: '___dtrace_probe$std$foo$v1' + +# CHECK: kind: dtraceProbe +# CHECK-NEXT: offset: {{[0-9]+}} +# CHECK-NEXT: '___dtrace_probe$provider_with_long_name_too$foo$v1'