diff options
Diffstat (limited to 'llvm/unittests/ExecutionEngine/Orc')
10 files changed, 5634 insertions, 0 deletions
diff --git a/llvm/unittests/ExecutionEngine/Orc/CMakeLists.txt b/llvm/unittests/ExecutionEngine/Orc/CMakeLists.txt index b06aa25..7b563d7 100644 --- a/llvm/unittests/ExecutionEngine/Orc/CMakeLists.txt +++ b/llvm/unittests/ExecutionEngine/Orc/CMakeLists.txt @@ -26,6 +26,7 @@ add_llvm_unittest(OrcJITTests    IndirectionUtilsTest.cpp    JITTargetMachineBuilderTest.cpp    LazyCallThroughAndReexportsTest.cpp +  LibraryResolverTest.cpp    LookupAndRecordAddrsTest.cpp    MachOPlatformTest.cpp    MapperJITLinkMemoryManagerTest.cpp diff --git a/llvm/unittests/ExecutionEngine/Orc/Inputs/A/A_linux.yaml b/llvm/unittests/ExecutionEngine/Orc/Inputs/A/A_linux.yaml new file mode 100644 index 0000000..afd1d9e --- /dev/null +++ b/llvm/unittests/ExecutionEngine/Orc/Inputs/A/A_linux.yaml @@ -0,0 +1,460 @@ +--- !ELF +FileHeader: +  Class:           ELFCLASS64 +  Data:            ELFDATA2LSB +  Type:            ET_DYN +  Machine:         EM_X86_64 +ProgramHeaders: +  - Type:            PT_LOAD +    Flags:           [ PF_R ] +    FirstSec:        .note.gnu.property +    LastSec:         .rela.plt +    Align:           0x1000 +    Offset:          0x0 +  - Type:            PT_LOAD +    Flags:           [ PF_X, PF_R ] +    FirstSec:        .init +    LastSec:         .fini +    VAddr:           0x1000 +    Align:           0x1000 +    Offset:          0x1000 +  - Type:            PT_LOAD +    Flags:           [ PF_R ] +    FirstSec:        .rodata +    LastSec:         .eh_frame +    VAddr:           0x2000 +    Align:           0x1000 +    Offset:          0x2000 +  - Type:            PT_LOAD +    Flags:           [ PF_W, PF_R ] +    FirstSec:        .init_array +    LastSec:         .bss +    VAddr:           0x3E10 +    Align:           0x1000 +    Offset:          0x2E10 +  - Type:            PT_DYNAMIC +    Flags:           [ PF_W, PF_R ] +    FirstSec:        .dynamic +    LastSec:         .dynamic +    VAddr:           0x3E20 +    Align:           0x8 +    Offset:          0x2E20 +  - Type:            PT_NOTE +    Flags:           [ PF_R ] +    FirstSec:        .note.gnu.property +    LastSec:         .note.gnu.property +    VAddr:           0x2A8 +    Align:           0x8 +    Offset:          0x2A8 +  - Type:            PT_NOTE +    Flags:           [ PF_R ] +    FirstSec:        .note.gnu.build-id +    LastSec:         .note.gnu.build-id +    VAddr:           0x2C8 +    Align:           0x4 +    Offset:          0x2C8 +  - Type:            PT_GNU_PROPERTY +    Flags:           [ PF_R ] +    FirstSec:        .note.gnu.property +    LastSec:         .note.gnu.property +    VAddr:           0x2A8 +    Align:           0x8 +    Offset:          0x2A8 +  - Type:            PT_GNU_EH_FRAME +    Flags:           [ PF_R ] +    FirstSec:        .eh_frame_hdr +    LastSec:         .eh_frame_hdr +    VAddr:           0x2010 +    Align:           0x4 +    Offset:          0x2010 +  - Type:            PT_GNU_STACK +    Flags:           [ PF_W, PF_R ] +    Align:           0x10 +    Offset:          0x0 +  - Type:            PT_GNU_RELRO +    Flags:           [ PF_R ] +    FirstSec:        .init_array +    LastSec:         .got +    VAddr:           0x3E10 +    Offset:          0x2E10 +Sections: +  - Name:            .note.gnu.property +    Type:            SHT_NOTE +    Flags:           [ SHF_ALLOC ] +    Address:         0x2A8 +    AddressAlign:    0x8 +    Notes: +      - Name:            GNU +        Desc:            020000C0040000000300000000000000 +        Type:            NT_GNU_PROPERTY_TYPE_0 +  - Name:            .note.gnu.build-id +    Type:            SHT_NOTE +    Flags:           [ SHF_ALLOC ] +    Address:         0x2C8 +    AddressAlign:    0x4 +    Notes: +      - Name:            GNU +        Desc:            73604396C95840D5C380A0950F085A778F94EE7C +        Type:            NT_PRPSINFO +  - Name:            .gnu.hash +    Type:            SHT_GNU_HASH +    Flags:           [ SHF_ALLOC ] +    Address:         0x2F0 +    Link:            .dynsym +    AddressAlign:    0x8 +    Header: +      SymNdx:          0x6 +      Shift2:          0x6 +    BloomFilter:     [ 0x400000080000 ] +    HashBuckets:     [ 0x0, 0x6 ] +    HashValues:      [ 0x7C9DCB93 ] +  - Name:            .dynsym +    Type:            SHT_DYNSYM +    Flags:           [ SHF_ALLOC ] +    Address:         0x318 +    Link:            .dynstr +    AddressAlign:    0x8 +  - Name:            .dynstr +    Type:            SHT_STRTAB +    Flags:           [ SHF_ALLOC ] +    Address:         0x3C0 +    AddressAlign:    0x1 +  - Name:            .gnu.version +    Type:            SHT_GNU_versym +    Flags:           [ SHF_ALLOC ] +    Address:         0x436 +    Link:            .dynsym +    AddressAlign:    0x2 +    Entries:         [ 0, 1, 2, 1, 1, 2, 1 ] +  - Name:            .gnu.version_r +    Type:            SHT_GNU_verneed +    Flags:           [ SHF_ALLOC ] +    Address:         0x448 +    Link:            .dynstr +    AddressAlign:    0x8 +    Dependencies: +      - Version:         1 +        File:            libc.so.6 +        Entries: +          - Name:            GLIBC_2.2.5 +            Hash:            157882997 +            Flags:           0 +            Other:           2 +  - Name:            .rela.dyn +    Type:            SHT_RELA +    Flags:           [ SHF_ALLOC ] +    Address:         0x468 +    Link:            .dynsym +    AddressAlign:    0x8 +    Relocations: +      - Offset:          0x3E10 +        Type:            R_X86_64_RELATIVE +        Addend:          4368 +      - Offset:          0x3E18 +        Type:            R_X86_64_RELATIVE +        Addend:          4304 +      - Offset:          0x4020 +        Type:            R_X86_64_RELATIVE +        Addend:          16416 +      - Offset:          0x3FE0 +        Symbol:          _ITM_deregisterTMCloneTable +        Type:            R_X86_64_GLOB_DAT +      - Offset:          0x3FE8 +        Symbol:          __gmon_start__ +        Type:            R_X86_64_GLOB_DAT +      - Offset:          0x3FF0 +        Symbol:          _ITM_registerTMCloneTable +        Type:            R_X86_64_GLOB_DAT +      - Offset:          0x3FF8 +        Symbol:          __cxa_finalize +        Type:            R_X86_64_GLOB_DAT +  - Name:            .rela.plt +    Type:            SHT_RELA +    Flags:           [ SHF_ALLOC, SHF_INFO_LINK ] +    Address:         0x510 +    Link:            .dynsym +    AddressAlign:    0x8 +    Info:            .got.plt +    Relocations: +      - Offset:          0x4018 +        Symbol:          puts +        Type:            R_X86_64_JUMP_SLOT +  - Name:            .init +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1000 +    AddressAlign:    0x4 +    Offset:          0x1000 +    Content:         F30F1EFA4883EC08488B05D92F00004885C07402FFD04883C408C3 +  - Name:            .plt +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1020 +    AddressAlign:    0x10 +    EntSize:         0x10 +    Content:         FF35E22F0000F2FF25E32F00000F1F00F30F1EFA6800000000F2E9E1FFFFFF90 +  - Name:            .plt.got +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1040 +    AddressAlign:    0x10 +    EntSize:         0x10 +    Content:         F30F1EFAF2FF25AD2F00000F1F440000 +  - Name:            .plt.sec +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1050 +    AddressAlign:    0x10 +    EntSize:         0x10 +    Content:         F30F1EFAF2FF25BD2F00000F1F440000 +  - Name:            .text +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1060 +    AddressAlign:    0x10 +    Content:         488D3DC12F0000488D05BA2F00004839F87415488B05662F00004885C07409FFE00F1F8000000000C30F1F8000000000488D3D912F0000488D358A2F00004829FE4889F048C1EE3F48C1F8034801C648D1FE7414488B05352F00004885C07408FFE0660F1F440000C30F1F8000000000F30F1EFA803D4D2F000000752B5548833D122F0000004889E5740C488B3D2E2F0000E849FFFFFFE864FFFFFFC605252F0000015DC30F1F00C30F1F8000000000F30F1EFAE977FFFFFFF30F1EFA554889E5488D05D80E00004889C7E820FFFFFF905DC3 +  - Name:            .fini +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1134 +    AddressAlign:    0x4 +    Content:         F30F1EFA4883EC084883C408C3 +  - Name:            .rodata +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC ] +    Address:         0x2000 +    AddressAlign:    0x1 +    Offset:          0x2000 +    Content:         48656C6C6F2066726F6D204100 +  - Name:            .eh_frame_hdr +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC ] +    Address:         0x2010 +    AddressAlign:    0x4 +    Content:         011B033B2C0000000400000010F0FFFF4800000030F0FFFF7000000040F0FFFF8800000009F1FFFFA0000000 +  - Name:            .eh_frame +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC ] +    Address:         0x2040 +    AddressAlign:    0x8 +    Content:         1400000000000000017A5200017810011B0C070890010000240000001C000000C0EFFFFF20000000000E10460E184A0F0B770880003F1A3A2A332422000000001400000044000000B8EFFFFF100000000000000000000000140000005C000000B0EFFFFF1000000000000000000000001C0000007400000061F0FFFF1A00000000450E108602430D06510C070800000000000000 +  - Name:            .init_array +    Type:            SHT_INIT_ARRAY +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x3E10 +    AddressAlign:    0x8 +    EntSize:         0x8 +    Offset:          0x2E10 +    Content:         '1011000000000000' +  - Name:            .fini_array +    Type:            SHT_FINI_ARRAY +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x3E18 +    AddressAlign:    0x8 +    EntSize:         0x8 +    Content:         D010000000000000 +  - Name:            .dynamic +    Type:            SHT_DYNAMIC +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x3E20 +    Link:            .dynstr +    AddressAlign:    0x8 +    Entries: +      - Tag:             DT_NEEDED +        Value:           0x5F +      - Tag:             DT_INIT +        Value:           0x1000 +      - Tag:             DT_FINI +        Value:           0x1134 +      - Tag:             DT_INIT_ARRAY +        Value:           0x3E10 +      - Tag:             DT_INIT_ARRAYSZ +        Value:           0x8 +      - Tag:             DT_FINI_ARRAY +        Value:           0x3E18 +      - Tag:             DT_FINI_ARRAYSZ +        Value:           0x8 +      - Tag:             DT_GNU_HASH +        Value:           0x2F0 +      - Tag:             DT_STRTAB +        Value:           0x3C0 +      - Tag:             DT_SYMTAB +        Value:           0x318 +      - Tag:             DT_STRSZ +        Value:           0x75 +      - Tag:             DT_SYMENT +        Value:           0x18 +      - Tag:             DT_PLTGOT +        Value:           0x4000 +      - Tag:             DT_PLTRELSZ +        Value:           0x18 +      - Tag:             DT_PLTREL +        Value:           0x7 +      - Tag:             DT_JMPREL +        Value:           0x510 +      - Tag:             DT_RELA +        Value:           0x468 +      - Tag:             DT_RELASZ +        Value:           0xA8 +      - Tag:             DT_RELAENT +        Value:           0x18 +      - Tag:             DT_VERNEED +        Value:           0x448 +      - Tag:             DT_VERNEEDNUM +        Value:           0x1 +      - Tag:             DT_VERSYM +        Value:           0x436 +      - Tag:             DT_RELACOUNT +        Value:           0x3 +      - Tag:             DT_NULL +        Value:           0x0 +      - Tag:             DT_NULL +        Value:           0x0 +      - Tag:             DT_NULL +        Value:           0x0 +      - Tag:             DT_NULL +        Value:           0x0 +      - Tag:             DT_NULL +        Value:           0x0 +  - Name:            .got +    Type:            SHT_PROGBITS +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x3FE0 +    AddressAlign:    0x8 +    EntSize:         0x8 +    Content:         '0000000000000000000000000000000000000000000000000000000000000000' +  - Name:            .got.plt +    Type:            SHT_PROGBITS +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x4000 +    AddressAlign:    0x8 +    EntSize:         0x8 +    Content:         '203E000000000000000000000000000000000000000000003010000000000000' +  - Name:            .data +    Type:            SHT_PROGBITS +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x4020 +    AddressAlign:    0x8 +    Content:         '2040000000000000' +  - Name:            .bss +    Type:            SHT_NOBITS +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x4028 +    AddressAlign:    0x1 +    Size:            0x8 +  - Name:            .comment +    Type:            SHT_PROGBITS +    Flags:           [ SHF_MERGE, SHF_STRINGS ] +    AddressAlign:    0x1 +    EntSize:         0x1 +    Content:         4743433A20285562756E74752031312E342E302D317562756E7475317E32322E30342E32292031312E342E3000 +Symbols: +  - Name:            crtstuff.c +    Type:            STT_FILE +    Index:           SHN_ABS +  - Name:            deregister_tm_clones +    Type:            STT_FUNC +    Section:         .text +    Value:           0x1060 +  - Name:            register_tm_clones +    Type:            STT_FUNC +    Section:         .text +    Value:           0x1090 +  - Name:            __do_global_dtors_aux +    Type:            STT_FUNC +    Section:         .text +    Value:           0x10D0 +  - Name:            completed.0 +    Type:            STT_OBJECT +    Section:         .bss +    Value:           0x4028 +    Size:            0x1 +  - Name:            __do_global_dtors_aux_fini_array_entry +    Type:            STT_OBJECT +    Section:         .fini_array +    Value:           0x3E18 +  - Name:            frame_dummy +    Type:            STT_FUNC +    Section:         .text +    Value:           0x1110 +  - Name:            __frame_dummy_init_array_entry +    Type:            STT_OBJECT +    Section:         .init_array +    Value:           0x3E10 +  - Name:            libA.c +    Type:            STT_FILE +    Index:           SHN_ABS +  - Name:            'crtstuff.c (1)' +    Type:            STT_FILE +    Index:           SHN_ABS +  - Name:            __FRAME_END__ +    Type:            STT_OBJECT +    Section:         .eh_frame +    Value:           0x20D0 +  - Type:            STT_FILE +    Index:           SHN_ABS +  - Name:            _fini +    Type:            STT_FUNC +    Section:         .fini +    Value:           0x1134 +  - Name:            __dso_handle +    Type:            STT_OBJECT +    Section:         .data +    Value:           0x4020 +  - Name:            _DYNAMIC +    Type:            STT_OBJECT +    Section:         .dynamic +    Value:           0x3E20 +  - Name:            __GNU_EH_FRAME_HDR +    Section:         .eh_frame_hdr +    Value:           0x2010 +  - Name:            __TMC_END__ +    Type:            STT_OBJECT +    Section:         .data +    Value:           0x4028 +  - Name:            _GLOBAL_OFFSET_TABLE_ +    Type:            STT_OBJECT +    Section:         .got.plt +    Value:           0x4000 +  - Name:            _init +    Type:            STT_FUNC +    Section:         .init +    Value:           0x1000 +  - Name:            _ITM_deregisterTMCloneTable +    Binding:         STB_WEAK +  - Name:            'puts@GLIBC_2.2.5' +    Type:            STT_FUNC +    Binding:         STB_GLOBAL +  - Name:            sayA +    Type:            STT_FUNC +    Section:         .text +    Binding:         STB_GLOBAL +    Value:           0x1119 +    Size:            0x1A +  - Name:            __gmon_start__ +    Binding:         STB_WEAK +  - Name:            _ITM_registerTMCloneTable +    Binding:         STB_WEAK +  - Name:            '__cxa_finalize@GLIBC_2.2.5' +    Type:            STT_FUNC +    Binding:         STB_WEAK +DynamicSymbols: +  - Name:            _ITM_deregisterTMCloneTable +    Binding:         STB_WEAK +  - Name:            puts +    Type:            STT_FUNC +    Binding:         STB_GLOBAL +  - Name:            __gmon_start__ +    Binding:         STB_WEAK +  - Name:            _ITM_registerTMCloneTable +    Binding:         STB_WEAK +  - Name:            __cxa_finalize +    Type:            STT_FUNC +    Binding:         STB_WEAK +  - Name:            sayA +    Type:            STT_FUNC +    Section:         .text +    Binding:         STB_GLOBAL +    Value:           0x1119 +    Size:            0x1A +... diff --git a/llvm/unittests/ExecutionEngine/Orc/Inputs/A/A_macho.yaml b/llvm/unittests/ExecutionEngine/Orc/Inputs/A/A_macho.yaml new file mode 100644 index 0000000..2e851a90 --- /dev/null +++ b/llvm/unittests/ExecutionEngine/Orc/Inputs/A/A_macho.yaml @@ -0,0 +1,723 @@ +--- !fat-mach-o +FatHeader: +  magic:           0xCAFEBABE +  nfat_arch:       3 +FatArchs: +  - cputype:         0x1000007 +    cpusubtype:      0x3 +    offset:          0x1000 +    size:            8376 +    align:           12 +  - cputype:         0x100000C +    cpusubtype:      0x0 +    offset:          0x4000 +    size:            33376 +    align:           14 +  - cputype:         0x100000C +    cpusubtype:      0x80000002 +    offset:          0x10000 +    size:            33376 +    align:           14 +Slices: +  - !mach-o +    FileHeader: +      magic:           0xFEEDFACF +      cputype:         0x1000007 +      cpusubtype:      0x3 +      filetype:        0x6 +      ncmds:           14 +      sizeofcmds:      960 +      flags:           0x100085 +      reserved:        0x0 +    LoadCommands: +      - cmd:             LC_SEGMENT_64 +        cmdsize:         392 +        segname:         __TEXT +        vmaddr:          0 +        vmsize:          4096 +        fileoff:         0 +        filesize:        4096 +        maxprot:         5 +        initprot:        5 +        nsects:          4 +        flags:           0 +        Sections: +          - sectname:        __text +            segname:         __TEXT +            addr:            0xF80 +            size:            20 +            offset:          0xF80 +            align:           4 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000400 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         554889E5488D3D0F000000B000E8020000005DC3 +          - sectname:        __stubs +            segname:         __TEXT +            addr:            0xF94 +            size:            6 +            offset:          0xF94 +            align:           1 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000408 +            reserved1:       0x0 +            reserved2:       0x6 +            reserved3:       0x0 +            content:         FF2566000000 +          - sectname:        __cstring +            segname:         __TEXT +            addr:            0xF9A +            size:            14 +            offset:          0xF9A +            align:           0 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x2 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         48656C6C6F2066726F6D20410A00 +          - sectname:        __unwind_info +            segname:         __TEXT +            addr:            0xFA8 +            size:            88 +            offset:          0xFA8 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x0 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         010000001C000000000000001C000000000000001C00000002000000800F00004000000040000000940F00000000000040000000000000000000000000000000030000000C00010010000100000000000000000100000000 +      - cmd:             LC_SEGMENT_64 +        cmdsize:         152 +        segname:         __DATA_CONST +        vmaddr:          4096 +        vmsize:          4096 +        fileoff:         4096 +        filesize:        4096 +        maxprot:         3 +        initprot:        3 +        nsects:          1 +        flags:           16 +        Sections: +          - sectname:        __got +            segname:         __DATA_CONST +            addr:            0x1000 +            size:            8 +            offset:          0x1000 +            align:           3 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x6 +            reserved1:       0x1 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         '0000000000000080' +      - cmd:             LC_SEGMENT_64 +        cmdsize:         72 +        segname:         __LINKEDIT +        vmaddr:          8192 +        vmsize:          4096 +        fileoff:         8192 +        filesize:        184 +        maxprot:         1 +        initprot:        1 +        nsects:          0 +        flags:           0 +      - cmd:             LC_ID_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       1 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libA.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_DYLD_CHAINED_FIXUPS +        cmdsize:         16 +        dataoff:         8192 +        datasize:        96 +      - cmd:             LC_DYLD_EXPORTS_TRIE +        cmdsize:         16 +        dataoff:         8288 +        datasize:        24 +      - cmd:             LC_SYMTAB +        cmdsize:         24 +        symoff:          8320 +        nsyms:           2 +        stroff:          8360 +        strsize:         16 +      - cmd:             LC_DYSYMTAB +        cmdsize:         80 +        ilocalsym:       0 +        nlocalsym:       0 +        iextdefsym:      0 +        nextdefsym:      1 +        iundefsym:       1 +        nundefsym:       1 +        tocoff:          0 +        ntoc:            0 +        modtaboff:       0 +        nmodtab:         0 +        extrefsymoff:    0 +        nextrefsyms:     0 +        indirectsymoff:  8352 +        nindirectsyms:   2 +        extreloff:       0 +        nextrel:         0 +        locreloff:       0 +        nlocrel:         0 +      - cmd:             LC_UUID +        cmdsize:         24 +        uuid:            ADFFA141-C3EE-37CD-B1E7-906D69F81BCB +      - cmd:             LC_BUILD_VERSION +        cmdsize:         32 +        platform:        1 +        minos:           983040 +        sdk:             983552 +        ntools:          1 +        Tools: +          - tool:            3 +            version:         73074435 +      - cmd:             LC_SOURCE_VERSION +        cmdsize:         16 +        version:         0 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         56 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 88539136 +          compatibility_version: 65536 +        Content:         '/usr/lib/libSystem.B.dylib' +        ZeroPadBytes:    6 +      - cmd:             LC_FUNCTION_STARTS +        cmdsize:         16 +        dataoff:         8312 +        datasize:        8 +      - cmd:             LC_DATA_IN_CODE +        cmdsize:         16 +        dataoff:         8320 +        datasize:        0 +    LinkEditData: +      ExportTrie: +        TerminalSize:    0 +        NodeOffset:      0 +        Name:            '' +        Flags:           0x0 +        Address:         0x0 +        Other:           0x0 +        ImportName:      '' +        Children: +          - TerminalSize:    3 +            NodeOffset:      13 +            Name:            _sayA +            Flags:           0x0 +            Address:         0xF80 +            Other:           0x0 +            ImportName:      '' +      NameList: +        - n_strx:          2 +          n_type:          0xF +          n_sect:          1 +          n_desc:          0 +          n_value:         3968 +        - n_strx:          8 +          n_type:          0x1 +          n_sect:          0 +          n_desc:          256 +          n_value:         0 +      StringTable: +        - ' ' +        - _sayA +        - _printf +      IndirectSymbols: [ 0x1, 0x1 ] +      FunctionStarts:  [ 0xF80 ] +      ChainedFixups:   [ 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x48,  +                         0x0, 0x0, 0x0, 0x50, 0x0, 0x0, 0x0, 0x1, 0x0,  +                         0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x18, 0x0, 0x0, 0x0, 0x0, 0x10, 0x6, 0x0,  +                         0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x2, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5F, 0x70, 0x72,  +                         0x69, 0x6E, 0x74, 0x66, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0 ] +  - !mach-o +    FileHeader: +      magic:           0xFEEDFACF +      cputype:         0x100000C +      cpusubtype:      0x0 +      filetype:        0x6 +      ncmds:           15 +      sizeofcmds:      976 +      flags:           0x100085 +      reserved:        0x0 +    LoadCommands: +      - cmd:             LC_SEGMENT_64 +        cmdsize:         392 +        segname:         __TEXT +        vmaddr:          0 +        vmsize:          16384 +        fileoff:         0 +        filesize:        16384 +        maxprot:         5 +        initprot:        5 +        nsects:          4 +        flags:           0 +        Sections: +          - sectname:        __text +            segname:         __TEXT +            addr:            0x3F70 +            size:            28 +            offset:          0x3F70 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000400 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         FD7BBFA9FD0300910000009000603E9103000094FD7BC1A8C0035FD6 +          - sectname:        __stubs +            segname:         __TEXT +            addr:            0x3F8C +            size:            12 +            offset:          0x3F8C +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000408 +            reserved1:       0x0 +            reserved2:       0xC +            reserved3:       0x0 +            content:         100000B0100240F900021FD6 +          - sectname:        __cstring +            segname:         __TEXT +            addr:            0x3F98 +            size:            14 +            offset:          0x3F98 +            align:           0 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x2 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         48656C6C6F2066726F6D20410A00 +          - sectname:        __unwind_info +            segname:         __TEXT +            addr:            0x3FA8 +            size:            88 +            offset:          0x3FA8 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x0 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         010000001C000000000000001C000000000000001C00000002000000703F000040000000400000008C3F00000000000040000000000000000000000000000000030000000C00010010000100000000000000000400000000 +      - cmd:             LC_SEGMENT_64 +        cmdsize:         152 +        segname:         __DATA_CONST +        vmaddr:          16384 +        vmsize:          16384 +        fileoff:         16384 +        filesize:        16384 +        maxprot:         3 +        initprot:        3 +        nsects:          1 +        flags:           16 +        Sections: +          - sectname:        __got +            segname:         __DATA_CONST +            addr:            0x4000 +            size:            8 +            offset:          0x4000 +            align:           3 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x6 +            reserved1:       0x1 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         '0000000000000080' +      - cmd:             LC_SEGMENT_64 +        cmdsize:         72 +        segname:         __LINKEDIT +        vmaddr:          32768 +        vmsize:          16384 +        fileoff:         32768 +        filesize:        608 +        maxprot:         1 +        initprot:        1 +        nsects:          0 +        flags:           0 +      - cmd:             LC_ID_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       1 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libA.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_DYLD_CHAINED_FIXUPS +        cmdsize:         16 +        dataoff:         32768 +        datasize:        96 +      - cmd:             LC_DYLD_EXPORTS_TRIE +        cmdsize:         16 +        dataoff:         32864 +        datasize:        24 +      - cmd:             LC_SYMTAB +        cmdsize:         24 +        symoff:          32896 +        nsyms:           2 +        stroff:          32936 +        strsize:         16 +      - cmd:             LC_DYSYMTAB +        cmdsize:         80 +        ilocalsym:       0 +        nlocalsym:       0 +        iextdefsym:      0 +        nextdefsym:      1 +        iundefsym:       1 +        nundefsym:       1 +        tocoff:          0 +        ntoc:            0 +        modtaboff:       0 +        nmodtab:         0 +        extrefsymoff:    0 +        nextrefsyms:     0 +        indirectsymoff:  32928 +        nindirectsyms:   2 +        extreloff:       0 +        nextrel:         0 +        locreloff:       0 +        nlocrel:         0 +      - cmd:             LC_UUID +        cmdsize:         24 +        uuid:            C45227E0-C6C0-3137-969B-36AABF9D5487 +      - cmd:             LC_BUILD_VERSION +        cmdsize:         32 +        platform:        1 +        minos:           983040 +        sdk:             983552 +        ntools:          1 +        Tools: +          - tool:            3 +            version:         73074435 +      - cmd:             LC_SOURCE_VERSION +        cmdsize:         16 +        version:         0 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         56 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 88539136 +          compatibility_version: 65536 +        Content:         '/usr/lib/libSystem.B.dylib' +        ZeroPadBytes:    6 +      - cmd:             LC_FUNCTION_STARTS +        cmdsize:         16 +        dataoff:         32888 +        datasize:        8 +      - cmd:             LC_DATA_IN_CODE +        cmdsize:         16 +        dataoff:         32896 +        datasize:        0 +      - cmd:             LC_CODE_SIGNATURE +        cmdsize:         16 +        dataoff:         32960 +        datasize:        416 +    LinkEditData: +      ExportTrie: +        TerminalSize:    0 +        NodeOffset:      0 +        Name:            '' +        Flags:           0x0 +        Address:         0x0 +        Other:           0x0 +        ImportName:      '' +        Children: +          - TerminalSize:    3 +            NodeOffset:      13 +            Name:            _sayA +            Flags:           0x0 +            Address:         0x3F70 +            Other:           0x0 +            ImportName:      '' +      NameList: +        - n_strx:          2 +          n_type:          0xF +          n_sect:          1 +          n_desc:          0 +          n_value:         16240 +        - n_strx:          8 +          n_type:          0x1 +          n_sect:          0 +          n_desc:          256 +          n_value:         0 +      StringTable: +        - ' ' +        - _sayA +        - _printf +      IndirectSymbols: [ 0x1, 0x1 ] +      FunctionStarts:  [ 0x3F70 ] +      ChainedFixups:   [ 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x48,  +                         0x0, 0x0, 0x0, 0x50, 0x0, 0x0, 0x0, 0x1, 0x0,  +                         0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x18, 0x0, 0x0, 0x0, 0x0, 0x40, 0x6, 0x0,  +                         0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x2, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5F, 0x70, 0x72,  +                         0x69, 0x6E, 0x74, 0x66, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0 ] +  - !mach-o +    FileHeader: +      magic:           0xFEEDFACF +      cputype:         0x100000C +      cpusubtype:      0x80000002 +      filetype:        0x6 +      ncmds:           15 +      sizeofcmds:      976 +      flags:           0x100085 +      reserved:        0x0 +    LoadCommands: +      - cmd:             LC_SEGMENT_64 +        cmdsize:         392 +        segname:         __TEXT +        vmaddr:          0 +        vmsize:          16384 +        fileoff:         0 +        filesize:        16384 +        maxprot:         5 +        initprot:        5 +        nsects:          4 +        flags:           0 +        Sections: +          - sectname:        __text +            segname:         __TEXT +            addr:            0x3F68 +            size:            32 +            offset:          0x3F68 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000400 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         7F2303D5FD7BBFA9FD0300910000009000603E9103000094FD7BC1A8FF0F5FD6 +          - sectname:        __auth_stubs +            segname:         __TEXT +            addr:            0x3F88 +            size:            16 +            offset:          0x3F88 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000408 +            reserved1:       0x0 +            reserved2:       0x10 +            reserved3:       0x0 +            content:         110000B031020091300240F9110A1FD7 +          - sectname:        __cstring +            segname:         __TEXT +            addr:            0x3F98 +            size:            14 +            offset:          0x3F98 +            align:           0 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x2 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         48656C6C6F2066726F6D20410A00 +          - sectname:        __unwind_info +            segname:         __TEXT +            addr:            0x3FA8 +            size:            88 +            offset:          0x3FA8 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x0 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         010000001C000000000000001C000000000000001C00000002000000683F00004000000040000000883F00000000000040000000000000000000000000000000030000000C00010010000100000000000000000400000000 +      - cmd:             LC_SEGMENT_64 +        cmdsize:         152 +        segname:         __DATA_CONST +        vmaddr:          16384 +        vmsize:          16384 +        fileoff:         16384 +        filesize:        16384 +        maxprot:         3 +        initprot:        3 +        nsects:          1 +        flags:           16 +        Sections: +          - sectname:        __auth_got +            segname:         __DATA_CONST +            addr:            0x4000 +            size:            8 +            offset:          0x4000 +            align:           3 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x6 +            reserved1:       0x1 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         00000000000001C0 +      - cmd:             LC_SEGMENT_64 +        cmdsize:         72 +        segname:         __LINKEDIT +        vmaddr:          32768 +        vmsize:          16384 +        fileoff:         32768 +        filesize:        608 +        maxprot:         1 +        initprot:        1 +        nsects:          0 +        flags:           0 +      - cmd:             LC_ID_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       1 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libA.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_DYLD_CHAINED_FIXUPS +        cmdsize:         16 +        dataoff:         32768 +        datasize:        96 +      - cmd:             LC_DYLD_EXPORTS_TRIE +        cmdsize:         16 +        dataoff:         32864 +        datasize:        24 +      - cmd:             LC_SYMTAB +        cmdsize:         24 +        symoff:          32896 +        nsyms:           2 +        stroff:          32936 +        strsize:         16 +      - cmd:             LC_DYSYMTAB +        cmdsize:         80 +        ilocalsym:       0 +        nlocalsym:       0 +        iextdefsym:      0 +        nextdefsym:      1 +        iundefsym:       1 +        nundefsym:       1 +        tocoff:          0 +        ntoc:            0 +        modtaboff:       0 +        nmodtab:         0 +        extrefsymoff:    0 +        nextrefsyms:     0 +        indirectsymoff:  32928 +        nindirectsyms:   2 +        extreloff:       0 +        nextrel:         0 +        locreloff:       0 +        nlocrel:         0 +      - cmd:             LC_UUID +        cmdsize:         24 +        uuid:            C9DC00C2-E721-365C-9C2D-E9FDB7C838BB +      - cmd:             LC_BUILD_VERSION +        cmdsize:         32 +        platform:        1 +        minos:           983040 +        sdk:             983552 +        ntools:          1 +        Tools: +          - tool:            3 +            version:         73074435 +      - cmd:             LC_SOURCE_VERSION +        cmdsize:         16 +        version:         0 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         56 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 88539136 +          compatibility_version: 65536 +        Content:         '/usr/lib/libSystem.B.dylib' +        ZeroPadBytes:    6 +      - cmd:             LC_FUNCTION_STARTS +        cmdsize:         16 +        dataoff:         32888 +        datasize:        8 +      - cmd:             LC_DATA_IN_CODE +        cmdsize:         16 +        dataoff:         32896 +        datasize:        0 +      - cmd:             LC_CODE_SIGNATURE +        cmdsize:         16 +        dataoff:         32960 +        datasize:        416 +    LinkEditData: +      ExportTrie: +        TerminalSize:    0 +        NodeOffset:      0 +        Name:            '' +        Flags:           0x0 +        Address:         0x0 +        Other:           0x0 +        ImportName:      '' +        Children: +          - TerminalSize:    3 +            NodeOffset:      13 +            Name:            _sayA +            Flags:           0x0 +            Address:         0x3F68 +            Other:           0x0 +            ImportName:      '' +      NameList: +        - n_strx:          2 +          n_type:          0xF +          n_sect:          1 +          n_desc:          0 +          n_value:         16232 +        - n_strx:          8 +          n_type:          0x1 +          n_sect:          0 +          n_desc:          256 +          n_value:         0 +      StringTable: +        - ' ' +        - _sayA +        - _printf +      IndirectSymbols: [ 0x1, 0x1 ] +      FunctionStarts:  [ 0x3F68 ] +      ChainedFixups:   [ 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x48,  +                         0x0, 0x0, 0x0, 0x50, 0x0, 0x0, 0x0, 0x1, 0x0,  +                         0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x18, 0x0, 0x0, 0x0, 0x0, 0x40, 0xC, 0x0,  +                         0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x2, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5F, 0x70, 0x72,  +                         0x69, 0x6E, 0x74, 0x66, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0 ] +... diff --git a/llvm/unittests/ExecutionEngine/Orc/Inputs/B/B_linux.yaml b/llvm/unittests/ExecutionEngine/Orc/Inputs/B/B_linux.yaml new file mode 100644 index 0000000..fe4393e --- /dev/null +++ b/llvm/unittests/ExecutionEngine/Orc/Inputs/B/B_linux.yaml @@ -0,0 +1,460 @@ +--- !ELF +FileHeader: +  Class:           ELFCLASS64 +  Data:            ELFDATA2LSB +  Type:            ET_DYN +  Machine:         EM_X86_64 +ProgramHeaders: +  - Type:            PT_LOAD +    Flags:           [ PF_R ] +    FirstSec:        .note.gnu.property +    LastSec:         .rela.plt +    Align:           0x1000 +    Offset:          0x0 +  - Type:            PT_LOAD +    Flags:           [ PF_X, PF_R ] +    FirstSec:        .init +    LastSec:         .fini +    VAddr:           0x1000 +    Align:           0x1000 +    Offset:          0x1000 +  - Type:            PT_LOAD +    Flags:           [ PF_R ] +    FirstSec:        .rodata +    LastSec:         .eh_frame +    VAddr:           0x2000 +    Align:           0x1000 +    Offset:          0x2000 +  - Type:            PT_LOAD +    Flags:           [ PF_W, PF_R ] +    FirstSec:        .init_array +    LastSec:         .bss +    VAddr:           0x3E10 +    Align:           0x1000 +    Offset:          0x2E10 +  - Type:            PT_DYNAMIC +    Flags:           [ PF_W, PF_R ] +    FirstSec:        .dynamic +    LastSec:         .dynamic +    VAddr:           0x3E20 +    Align:           0x8 +    Offset:          0x2E20 +  - Type:            PT_NOTE +    Flags:           [ PF_R ] +    FirstSec:        .note.gnu.property +    LastSec:         .note.gnu.property +    VAddr:           0x2A8 +    Align:           0x8 +    Offset:          0x2A8 +  - Type:            PT_NOTE +    Flags:           [ PF_R ] +    FirstSec:        .note.gnu.build-id +    LastSec:         .note.gnu.build-id +    VAddr:           0x2C8 +    Align:           0x4 +    Offset:          0x2C8 +  - Type:            PT_GNU_PROPERTY +    Flags:           [ PF_R ] +    FirstSec:        .note.gnu.property +    LastSec:         .note.gnu.property +    VAddr:           0x2A8 +    Align:           0x8 +    Offset:          0x2A8 +  - Type:            PT_GNU_EH_FRAME +    Flags:           [ PF_R ] +    FirstSec:        .eh_frame_hdr +    LastSec:         .eh_frame_hdr +    VAddr:           0x2010 +    Align:           0x4 +    Offset:          0x2010 +  - Type:            PT_GNU_STACK +    Flags:           [ PF_W, PF_R ] +    Align:           0x10 +    Offset:          0x0 +  - Type:            PT_GNU_RELRO +    Flags:           [ PF_R ] +    FirstSec:        .init_array +    LastSec:         .got +    VAddr:           0x3E10 +    Offset:          0x2E10 +Sections: +  - Name:            .note.gnu.property +    Type:            SHT_NOTE +    Flags:           [ SHF_ALLOC ] +    Address:         0x2A8 +    AddressAlign:    0x8 +    Notes: +      - Name:            GNU +        Desc:            020000C0040000000300000000000000 +        Type:            NT_GNU_PROPERTY_TYPE_0 +  - Name:            .note.gnu.build-id +    Type:            SHT_NOTE +    Flags:           [ SHF_ALLOC ] +    Address:         0x2C8 +    AddressAlign:    0x4 +    Notes: +      - Name:            GNU +        Desc:            6337F7C1BF21A1DE17630C55602EB4CAC50435BB +        Type:            NT_PRPSINFO +  - Name:            .gnu.hash +    Type:            SHT_GNU_HASH +    Flags:           [ SHF_ALLOC ] +    Address:         0x2F0 +    Link:            .dynsym +    AddressAlign:    0x8 +    Header: +      SymNdx:          0x6 +      Shift2:          0x6 +    BloomFilter:     [ 0x400000100000 ] +    HashBuckets:     [ 0x6, 0x0 ] +    HashValues:      [ 0x7C9DCB95 ] +  - Name:            .dynsym +    Type:            SHT_DYNSYM +    Flags:           [ SHF_ALLOC ] +    Address:         0x318 +    Link:            .dynstr +    AddressAlign:    0x8 +  - Name:            .dynstr +    Type:            SHT_STRTAB +    Flags:           [ SHF_ALLOC ] +    Address:         0x3C0 +    AddressAlign:    0x1 +  - Name:            .gnu.version +    Type:            SHT_GNU_versym +    Flags:           [ SHF_ALLOC ] +    Address:         0x436 +    Link:            .dynsym +    AddressAlign:    0x2 +    Entries:         [ 0, 1, 2, 1, 1, 2, 1 ] +  - Name:            .gnu.version_r +    Type:            SHT_GNU_verneed +    Flags:           [ SHF_ALLOC ] +    Address:         0x448 +    Link:            .dynstr +    AddressAlign:    0x8 +    Dependencies: +      - Version:         1 +        File:            libc.so.6 +        Entries: +          - Name:            GLIBC_2.2.5 +            Hash:            157882997 +            Flags:           0 +            Other:           2 +  - Name:            .rela.dyn +    Type:            SHT_RELA +    Flags:           [ SHF_ALLOC ] +    Address:         0x468 +    Link:            .dynsym +    AddressAlign:    0x8 +    Relocations: +      - Offset:          0x3E10 +        Type:            R_X86_64_RELATIVE +        Addend:          4368 +      - Offset:          0x3E18 +        Type:            R_X86_64_RELATIVE +        Addend:          4304 +      - Offset:          0x4020 +        Type:            R_X86_64_RELATIVE +        Addend:          16416 +      - Offset:          0x3FE0 +        Symbol:          _ITM_deregisterTMCloneTable +        Type:            R_X86_64_GLOB_DAT +      - Offset:          0x3FE8 +        Symbol:          __gmon_start__ +        Type:            R_X86_64_GLOB_DAT +      - Offset:          0x3FF0 +        Symbol:          _ITM_registerTMCloneTable +        Type:            R_X86_64_GLOB_DAT +      - Offset:          0x3FF8 +        Symbol:          __cxa_finalize +        Type:            R_X86_64_GLOB_DAT +  - Name:            .rela.plt +    Type:            SHT_RELA +    Flags:           [ SHF_ALLOC, SHF_INFO_LINK ] +    Address:         0x510 +    Link:            .dynsym +    AddressAlign:    0x8 +    Info:            .got.plt +    Relocations: +      - Offset:          0x4018 +        Symbol:          puts +        Type:            R_X86_64_JUMP_SLOT +  - Name:            .init +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1000 +    AddressAlign:    0x4 +    Offset:          0x1000 +    Content:         F30F1EFA4883EC08488B05D92F00004885C07402FFD04883C408C3 +  - Name:            .plt +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1020 +    AddressAlign:    0x10 +    EntSize:         0x10 +    Content:         FF35E22F0000F2FF25E32F00000F1F00F30F1EFA6800000000F2E9E1FFFFFF90 +  - Name:            .plt.got +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1040 +    AddressAlign:    0x10 +    EntSize:         0x10 +    Content:         F30F1EFAF2FF25AD2F00000F1F440000 +  - Name:            .plt.sec +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1050 +    AddressAlign:    0x10 +    EntSize:         0x10 +    Content:         F30F1EFAF2FF25BD2F00000F1F440000 +  - Name:            .text +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1060 +    AddressAlign:    0x10 +    Content:         488D3DC12F0000488D05BA2F00004839F87415488B05662F00004885C07409FFE00F1F8000000000C30F1F8000000000488D3D912F0000488D358A2F00004829FE4889F048C1EE3F48C1F8034801C648D1FE7414488B05352F00004885C07408FFE0660F1F440000C30F1F8000000000F30F1EFA803D4D2F000000752B5548833D122F0000004889E5740C488B3D2E2F0000E849FFFFFFE864FFFFFFC605252F0000015DC30F1F00C30F1F8000000000F30F1EFAE977FFFFFFF30F1EFA554889E5488D05D80E00004889C7E820FFFFFF905DC3 +  - Name:            .fini +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1134 +    AddressAlign:    0x4 +    Content:         F30F1EFA4883EC084883C408C3 +  - Name:            .rodata +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC ] +    Address:         0x2000 +    AddressAlign:    0x1 +    Offset:          0x2000 +    Content:         48656C6C6F2066726F6D204200 +  - Name:            .eh_frame_hdr +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC ] +    Address:         0x2010 +    AddressAlign:    0x4 +    Content:         011B033B2C0000000400000010F0FFFF4800000030F0FFFF7000000040F0FFFF8800000009F1FFFFA0000000 +  - Name:            .eh_frame +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC ] +    Address:         0x2040 +    AddressAlign:    0x8 +    Content:         1400000000000000017A5200017810011B0C070890010000240000001C000000C0EFFFFF20000000000E10460E184A0F0B770880003F1A3A2A332422000000001400000044000000B8EFFFFF100000000000000000000000140000005C000000B0EFFFFF1000000000000000000000001C0000007400000061F0FFFF1A00000000450E108602430D06510C070800000000000000 +  - Name:            .init_array +    Type:            SHT_INIT_ARRAY +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x3E10 +    AddressAlign:    0x8 +    EntSize:         0x8 +    Offset:          0x2E10 +    Content:         '1011000000000000' +  - Name:            .fini_array +    Type:            SHT_FINI_ARRAY +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x3E18 +    AddressAlign:    0x8 +    EntSize:         0x8 +    Content:         D010000000000000 +  - Name:            .dynamic +    Type:            SHT_DYNAMIC +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x3E20 +    Link:            .dynstr +    AddressAlign:    0x8 +    Entries: +      - Tag:             DT_NEEDED +        Value:           0x5F +      - Tag:             DT_INIT +        Value:           0x1000 +      - Tag:             DT_FINI +        Value:           0x1134 +      - Tag:             DT_INIT_ARRAY +        Value:           0x3E10 +      - Tag:             DT_INIT_ARRAYSZ +        Value:           0x8 +      - Tag:             DT_FINI_ARRAY +        Value:           0x3E18 +      - Tag:             DT_FINI_ARRAYSZ +        Value:           0x8 +      - Tag:             DT_GNU_HASH +        Value:           0x2F0 +      - Tag:             DT_STRTAB +        Value:           0x3C0 +      - Tag:             DT_SYMTAB +        Value:           0x318 +      - Tag:             DT_STRSZ +        Value:           0x75 +      - Tag:             DT_SYMENT +        Value:           0x18 +      - Tag:             DT_PLTGOT +        Value:           0x4000 +      - Tag:             DT_PLTRELSZ +        Value:           0x18 +      - Tag:             DT_PLTREL +        Value:           0x7 +      - Tag:             DT_JMPREL +        Value:           0x510 +      - Tag:             DT_RELA +        Value:           0x468 +      - Tag:             DT_RELASZ +        Value:           0xA8 +      - Tag:             DT_RELAENT +        Value:           0x18 +      - Tag:             DT_VERNEED +        Value:           0x448 +      - Tag:             DT_VERNEEDNUM +        Value:           0x1 +      - Tag:             DT_VERSYM +        Value:           0x436 +      - Tag:             DT_RELACOUNT +        Value:           0x3 +      - Tag:             DT_NULL +        Value:           0x0 +      - Tag:             DT_NULL +        Value:           0x0 +      - Tag:             DT_NULL +        Value:           0x0 +      - Tag:             DT_NULL +        Value:           0x0 +      - Tag:             DT_NULL +        Value:           0x0 +  - Name:            .got +    Type:            SHT_PROGBITS +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x3FE0 +    AddressAlign:    0x8 +    EntSize:         0x8 +    Content:         '0000000000000000000000000000000000000000000000000000000000000000' +  - Name:            .got.plt +    Type:            SHT_PROGBITS +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x4000 +    AddressAlign:    0x8 +    EntSize:         0x8 +    Content:         '203E000000000000000000000000000000000000000000003010000000000000' +  - Name:            .data +    Type:            SHT_PROGBITS +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x4020 +    AddressAlign:    0x8 +    Content:         '2040000000000000' +  - Name:            .bss +    Type:            SHT_NOBITS +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x4028 +    AddressAlign:    0x1 +    Size:            0x8 +  - Name:            .comment +    Type:            SHT_PROGBITS +    Flags:           [ SHF_MERGE, SHF_STRINGS ] +    AddressAlign:    0x1 +    EntSize:         0x1 +    Content:         4743433A20285562756E74752031312E342E302D317562756E7475317E32322E30342E32292031312E342E3000 +Symbols: +  - Name:            crtstuff.c +    Type:            STT_FILE +    Index:           SHN_ABS +  - Name:            deregister_tm_clones +    Type:            STT_FUNC +    Section:         .text +    Value:           0x1060 +  - Name:            register_tm_clones +    Type:            STT_FUNC +    Section:         .text +    Value:           0x1090 +  - Name:            __do_global_dtors_aux +    Type:            STT_FUNC +    Section:         .text +    Value:           0x10D0 +  - Name:            completed.0 +    Type:            STT_OBJECT +    Section:         .bss +    Value:           0x4028 +    Size:            0x1 +  - Name:            __do_global_dtors_aux_fini_array_entry +    Type:            STT_OBJECT +    Section:         .fini_array +    Value:           0x3E18 +  - Name:            frame_dummy +    Type:            STT_FUNC +    Section:         .text +    Value:           0x1110 +  - Name:            __frame_dummy_init_array_entry +    Type:            STT_OBJECT +    Section:         .init_array +    Value:           0x3E10 +  - Name:            libB.c +    Type:            STT_FILE +    Index:           SHN_ABS +  - Name:            'crtstuff.c (1)' +    Type:            STT_FILE +    Index:           SHN_ABS +  - Name:            __FRAME_END__ +    Type:            STT_OBJECT +    Section:         .eh_frame +    Value:           0x20D0 +  - Type:            STT_FILE +    Index:           SHN_ABS +  - Name:            _fini +    Type:            STT_FUNC +    Section:         .fini +    Value:           0x1134 +  - Name:            __dso_handle +    Type:            STT_OBJECT +    Section:         .data +    Value:           0x4020 +  - Name:            _DYNAMIC +    Type:            STT_OBJECT +    Section:         .dynamic +    Value:           0x3E20 +  - Name:            __GNU_EH_FRAME_HDR +    Section:         .eh_frame_hdr +    Value:           0x2010 +  - Name:            __TMC_END__ +    Type:            STT_OBJECT +    Section:         .data +    Value:           0x4028 +  - Name:            _GLOBAL_OFFSET_TABLE_ +    Type:            STT_OBJECT +    Section:         .got.plt +    Value:           0x4000 +  - Name:            _init +    Type:            STT_FUNC +    Section:         .init +    Value:           0x1000 +  - Name:            _ITM_deregisterTMCloneTable +    Binding:         STB_WEAK +  - Name:            'puts@GLIBC_2.2.5' +    Type:            STT_FUNC +    Binding:         STB_GLOBAL +  - Name:            __gmon_start__ +    Binding:         STB_WEAK +  - Name:            sayB +    Type:            STT_FUNC +    Section:         .text +    Binding:         STB_GLOBAL +    Value:           0x1119 +    Size:            0x1A +  - Name:            _ITM_registerTMCloneTable +    Binding:         STB_WEAK +  - Name:            '__cxa_finalize@GLIBC_2.2.5' +    Type:            STT_FUNC +    Binding:         STB_WEAK +DynamicSymbols: +  - Name:            _ITM_deregisterTMCloneTable +    Binding:         STB_WEAK +  - Name:            puts +    Type:            STT_FUNC +    Binding:         STB_GLOBAL +  - Name:            __gmon_start__ +    Binding:         STB_WEAK +  - Name:            _ITM_registerTMCloneTable +    Binding:         STB_WEAK +  - Name:            __cxa_finalize +    Type:            STT_FUNC +    Binding:         STB_WEAK +  - Name:            sayB +    Type:            STT_FUNC +    Section:         .text +    Binding:         STB_GLOBAL +    Value:           0x1119 +    Size:            0x1A +... diff --git a/llvm/unittests/ExecutionEngine/Orc/Inputs/B/B_macho.yaml b/llvm/unittests/ExecutionEngine/Orc/Inputs/B/B_macho.yaml new file mode 100644 index 0000000..3d57c4f --- /dev/null +++ b/llvm/unittests/ExecutionEngine/Orc/Inputs/B/B_macho.yaml @@ -0,0 +1,723 @@ +--- !fat-mach-o +FatHeader: +  magic:           0xCAFEBABE +  nfat_arch:       3 +FatArchs: +  - cputype:         0x1000007 +    cpusubtype:      0x3 +    offset:          0x1000 +    size:            8376 +    align:           12 +  - cputype:         0x100000C +    cpusubtype:      0x0 +    offset:          0x4000 +    size:            33376 +    align:           14 +  - cputype:         0x100000C +    cpusubtype:      0x80000002 +    offset:          0x10000 +    size:            33376 +    align:           14 +Slices: +  - !mach-o +    FileHeader: +      magic:           0xFEEDFACF +      cputype:         0x1000007 +      cpusubtype:      0x3 +      filetype:        0x6 +      ncmds:           14 +      sizeofcmds:      960 +      flags:           0x100085 +      reserved:        0x0 +    LoadCommands: +      - cmd:             LC_SEGMENT_64 +        cmdsize:         392 +        segname:         __TEXT +        vmaddr:          0 +        vmsize:          4096 +        fileoff:         0 +        filesize:        4096 +        maxprot:         5 +        initprot:        5 +        nsects:          4 +        flags:           0 +        Sections: +          - sectname:        __text +            segname:         __TEXT +            addr:            0xF80 +            size:            20 +            offset:          0xF80 +            align:           4 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000400 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         554889E5488D3D0F000000B000E8020000005DC3 +          - sectname:        __stubs +            segname:         __TEXT +            addr:            0xF94 +            size:            6 +            offset:          0xF94 +            align:           1 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000408 +            reserved1:       0x0 +            reserved2:       0x6 +            reserved3:       0x0 +            content:         FF2566000000 +          - sectname:        __cstring +            segname:         __TEXT +            addr:            0xF9A +            size:            14 +            offset:          0xF9A +            align:           0 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x2 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         48656C6C6F2066726F6D20420A00 +          - sectname:        __unwind_info +            segname:         __TEXT +            addr:            0xFA8 +            size:            88 +            offset:          0xFA8 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x0 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         010000001C000000000000001C000000000000001C00000002000000800F00004000000040000000940F00000000000040000000000000000000000000000000030000000C00010010000100000000000000000100000000 +      - cmd:             LC_SEGMENT_64 +        cmdsize:         152 +        segname:         __DATA_CONST +        vmaddr:          4096 +        vmsize:          4096 +        fileoff:         4096 +        filesize:        4096 +        maxprot:         3 +        initprot:        3 +        nsects:          1 +        flags:           16 +        Sections: +          - sectname:        __got +            segname:         __DATA_CONST +            addr:            0x1000 +            size:            8 +            offset:          0x1000 +            align:           3 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x6 +            reserved1:       0x1 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         '0000000000000080' +      - cmd:             LC_SEGMENT_64 +        cmdsize:         72 +        segname:         __LINKEDIT +        vmaddr:          8192 +        vmsize:          4096 +        fileoff:         8192 +        filesize:        184 +        maxprot:         1 +        initprot:        1 +        nsects:          0 +        flags:           0 +      - cmd:             LC_ID_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       1 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libB.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_DYLD_CHAINED_FIXUPS +        cmdsize:         16 +        dataoff:         8192 +        datasize:        96 +      - cmd:             LC_DYLD_EXPORTS_TRIE +        cmdsize:         16 +        dataoff:         8288 +        datasize:        24 +      - cmd:             LC_SYMTAB +        cmdsize:         24 +        symoff:          8320 +        nsyms:           2 +        stroff:          8360 +        strsize:         16 +      - cmd:             LC_DYSYMTAB +        cmdsize:         80 +        ilocalsym:       0 +        nlocalsym:       0 +        iextdefsym:      0 +        nextdefsym:      1 +        iundefsym:       1 +        nundefsym:       1 +        tocoff:          0 +        ntoc:            0 +        modtaboff:       0 +        nmodtab:         0 +        extrefsymoff:    0 +        nextrefsyms:     0 +        indirectsymoff:  8352 +        nindirectsyms:   2 +        extreloff:       0 +        nextrel:         0 +        locreloff:       0 +        nlocrel:         0 +      - cmd:             LC_UUID +        cmdsize:         24 +        uuid:            88B60B3C-13D3-3D7E-AEED-5F3E991FDF08 +      - cmd:             LC_BUILD_VERSION +        cmdsize:         32 +        platform:        1 +        minos:           983040 +        sdk:             983552 +        ntools:          1 +        Tools: +          - tool:            3 +            version:         73074435 +      - cmd:             LC_SOURCE_VERSION +        cmdsize:         16 +        version:         0 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         56 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 88539136 +          compatibility_version: 65536 +        Content:         '/usr/lib/libSystem.B.dylib' +        ZeroPadBytes:    6 +      - cmd:             LC_FUNCTION_STARTS +        cmdsize:         16 +        dataoff:         8312 +        datasize:        8 +      - cmd:             LC_DATA_IN_CODE +        cmdsize:         16 +        dataoff:         8320 +        datasize:        0 +    LinkEditData: +      ExportTrie: +        TerminalSize:    0 +        NodeOffset:      0 +        Name:            '' +        Flags:           0x0 +        Address:         0x0 +        Other:           0x0 +        ImportName:      '' +        Children: +          - TerminalSize:    3 +            NodeOffset:      13 +            Name:            _sayB +            Flags:           0x0 +            Address:         0xF80 +            Other:           0x0 +            ImportName:      '' +      NameList: +        - n_strx:          2 +          n_type:          0xF +          n_sect:          1 +          n_desc:          0 +          n_value:         3968 +        - n_strx:          8 +          n_type:          0x1 +          n_sect:          0 +          n_desc:          256 +          n_value:         0 +      StringTable: +        - ' ' +        - _sayB +        - _printf +      IndirectSymbols: [ 0x1, 0x1 ] +      FunctionStarts:  [ 0xF80 ] +      ChainedFixups:   [ 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x48,  +                         0x0, 0x0, 0x0, 0x50, 0x0, 0x0, 0x0, 0x1, 0x0,  +                         0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x18, 0x0, 0x0, 0x0, 0x0, 0x10, 0x6, 0x0,  +                         0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x2, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5F, 0x70, 0x72,  +                         0x69, 0x6E, 0x74, 0x66, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0 ] +  - !mach-o +    FileHeader: +      magic:           0xFEEDFACF +      cputype:         0x100000C +      cpusubtype:      0x0 +      filetype:        0x6 +      ncmds:           15 +      sizeofcmds:      976 +      flags:           0x100085 +      reserved:        0x0 +    LoadCommands: +      - cmd:             LC_SEGMENT_64 +        cmdsize:         392 +        segname:         __TEXT +        vmaddr:          0 +        vmsize:          16384 +        fileoff:         0 +        filesize:        16384 +        maxprot:         5 +        initprot:        5 +        nsects:          4 +        flags:           0 +        Sections: +          - sectname:        __text +            segname:         __TEXT +            addr:            0x3F70 +            size:            28 +            offset:          0x3F70 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000400 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         FD7BBFA9FD0300910000009000603E9103000094FD7BC1A8C0035FD6 +          - sectname:        __stubs +            segname:         __TEXT +            addr:            0x3F8C +            size:            12 +            offset:          0x3F8C +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000408 +            reserved1:       0x0 +            reserved2:       0xC +            reserved3:       0x0 +            content:         100000B0100240F900021FD6 +          - sectname:        __cstring +            segname:         __TEXT +            addr:            0x3F98 +            size:            14 +            offset:          0x3F98 +            align:           0 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x2 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         48656C6C6F2066726F6D20420A00 +          - sectname:        __unwind_info +            segname:         __TEXT +            addr:            0x3FA8 +            size:            88 +            offset:          0x3FA8 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x0 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         010000001C000000000000001C000000000000001C00000002000000703F000040000000400000008C3F00000000000040000000000000000000000000000000030000000C00010010000100000000000000000400000000 +      - cmd:             LC_SEGMENT_64 +        cmdsize:         152 +        segname:         __DATA_CONST +        vmaddr:          16384 +        vmsize:          16384 +        fileoff:         16384 +        filesize:        16384 +        maxprot:         3 +        initprot:        3 +        nsects:          1 +        flags:           16 +        Sections: +          - sectname:        __got +            segname:         __DATA_CONST +            addr:            0x4000 +            size:            8 +            offset:          0x4000 +            align:           3 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x6 +            reserved1:       0x1 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         '0000000000000080' +      - cmd:             LC_SEGMENT_64 +        cmdsize:         72 +        segname:         __LINKEDIT +        vmaddr:          32768 +        vmsize:          16384 +        fileoff:         32768 +        filesize:        608 +        maxprot:         1 +        initprot:        1 +        nsects:          0 +        flags:           0 +      - cmd:             LC_ID_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       1 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libB.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_DYLD_CHAINED_FIXUPS +        cmdsize:         16 +        dataoff:         32768 +        datasize:        96 +      - cmd:             LC_DYLD_EXPORTS_TRIE +        cmdsize:         16 +        dataoff:         32864 +        datasize:        24 +      - cmd:             LC_SYMTAB +        cmdsize:         24 +        symoff:          32896 +        nsyms:           2 +        stroff:          32936 +        strsize:         16 +      - cmd:             LC_DYSYMTAB +        cmdsize:         80 +        ilocalsym:       0 +        nlocalsym:       0 +        iextdefsym:      0 +        nextdefsym:      1 +        iundefsym:       1 +        nundefsym:       1 +        tocoff:          0 +        ntoc:            0 +        modtaboff:       0 +        nmodtab:         0 +        extrefsymoff:    0 +        nextrefsyms:     0 +        indirectsymoff:  32928 +        nindirectsyms:   2 +        extreloff:       0 +        nextrel:         0 +        locreloff:       0 +        nlocrel:         0 +      - cmd:             LC_UUID +        cmdsize:         24 +        uuid:            90C3787A-22E1-35AE-9284-97A4842F88AF +      - cmd:             LC_BUILD_VERSION +        cmdsize:         32 +        platform:        1 +        minos:           983040 +        sdk:             983552 +        ntools:          1 +        Tools: +          - tool:            3 +            version:         73074435 +      - cmd:             LC_SOURCE_VERSION +        cmdsize:         16 +        version:         0 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         56 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 88539136 +          compatibility_version: 65536 +        Content:         '/usr/lib/libSystem.B.dylib' +        ZeroPadBytes:    6 +      - cmd:             LC_FUNCTION_STARTS +        cmdsize:         16 +        dataoff:         32888 +        datasize:        8 +      - cmd:             LC_DATA_IN_CODE +        cmdsize:         16 +        dataoff:         32896 +        datasize:        0 +      - cmd:             LC_CODE_SIGNATURE +        cmdsize:         16 +        dataoff:         32960 +        datasize:        416 +    LinkEditData: +      ExportTrie: +        TerminalSize:    0 +        NodeOffset:      0 +        Name:            '' +        Flags:           0x0 +        Address:         0x0 +        Other:           0x0 +        ImportName:      '' +        Children: +          - TerminalSize:    3 +            NodeOffset:      13 +            Name:            _sayB +            Flags:           0x0 +            Address:         0x3F70 +            Other:           0x0 +            ImportName:      '' +      NameList: +        - n_strx:          2 +          n_type:          0xF +          n_sect:          1 +          n_desc:          0 +          n_value:         16240 +        - n_strx:          8 +          n_type:          0x1 +          n_sect:          0 +          n_desc:          256 +          n_value:         0 +      StringTable: +        - ' ' +        - _sayB +        - _printf +      IndirectSymbols: [ 0x1, 0x1 ] +      FunctionStarts:  [ 0x3F70 ] +      ChainedFixups:   [ 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x48,  +                         0x0, 0x0, 0x0, 0x50, 0x0, 0x0, 0x0, 0x1, 0x0,  +                         0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x18, 0x0, 0x0, 0x0, 0x0, 0x40, 0x6, 0x0,  +                         0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x2, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5F, 0x70, 0x72,  +                         0x69, 0x6E, 0x74, 0x66, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0 ] +  - !mach-o +    FileHeader: +      magic:           0xFEEDFACF +      cputype:         0x100000C +      cpusubtype:      0x80000002 +      filetype:        0x6 +      ncmds:           15 +      sizeofcmds:      976 +      flags:           0x100085 +      reserved:        0x0 +    LoadCommands: +      - cmd:             LC_SEGMENT_64 +        cmdsize:         392 +        segname:         __TEXT +        vmaddr:          0 +        vmsize:          16384 +        fileoff:         0 +        filesize:        16384 +        maxprot:         5 +        initprot:        5 +        nsects:          4 +        flags:           0 +        Sections: +          - sectname:        __text +            segname:         __TEXT +            addr:            0x3F68 +            size:            32 +            offset:          0x3F68 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000400 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         7F2303D5FD7BBFA9FD0300910000009000603E9103000094FD7BC1A8FF0F5FD6 +          - sectname:        __auth_stubs +            segname:         __TEXT +            addr:            0x3F88 +            size:            16 +            offset:          0x3F88 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000408 +            reserved1:       0x0 +            reserved2:       0x10 +            reserved3:       0x0 +            content:         110000B031020091300240F9110A1FD7 +          - sectname:        __cstring +            segname:         __TEXT +            addr:            0x3F98 +            size:            14 +            offset:          0x3F98 +            align:           0 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x2 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         48656C6C6F2066726F6D20420A00 +          - sectname:        __unwind_info +            segname:         __TEXT +            addr:            0x3FA8 +            size:            88 +            offset:          0x3FA8 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x0 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         010000001C000000000000001C000000000000001C00000002000000683F00004000000040000000883F00000000000040000000000000000000000000000000030000000C00010010000100000000000000000400000000 +      - cmd:             LC_SEGMENT_64 +        cmdsize:         152 +        segname:         __DATA_CONST +        vmaddr:          16384 +        vmsize:          16384 +        fileoff:         16384 +        filesize:        16384 +        maxprot:         3 +        initprot:        3 +        nsects:          1 +        flags:           16 +        Sections: +          - sectname:        __auth_got +            segname:         __DATA_CONST +            addr:            0x4000 +            size:            8 +            offset:          0x4000 +            align:           3 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x6 +            reserved1:       0x1 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         00000000000001C0 +      - cmd:             LC_SEGMENT_64 +        cmdsize:         72 +        segname:         __LINKEDIT +        vmaddr:          32768 +        vmsize:          16384 +        fileoff:         32768 +        filesize:        608 +        maxprot:         1 +        initprot:        1 +        nsects:          0 +        flags:           0 +      - cmd:             LC_ID_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       1 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libB.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_DYLD_CHAINED_FIXUPS +        cmdsize:         16 +        dataoff:         32768 +        datasize:        96 +      - cmd:             LC_DYLD_EXPORTS_TRIE +        cmdsize:         16 +        dataoff:         32864 +        datasize:        24 +      - cmd:             LC_SYMTAB +        cmdsize:         24 +        symoff:          32896 +        nsyms:           2 +        stroff:          32936 +        strsize:         16 +      - cmd:             LC_DYSYMTAB +        cmdsize:         80 +        ilocalsym:       0 +        nlocalsym:       0 +        iextdefsym:      0 +        nextdefsym:      1 +        iundefsym:       1 +        nundefsym:       1 +        tocoff:          0 +        ntoc:            0 +        modtaboff:       0 +        nmodtab:         0 +        extrefsymoff:    0 +        nextrefsyms:     0 +        indirectsymoff:  32928 +        nindirectsyms:   2 +        extreloff:       0 +        nextrel:         0 +        locreloff:       0 +        nlocrel:         0 +      - cmd:             LC_UUID +        cmdsize:         24 +        uuid:            76B41B3A-00EC-388B-A432-478A96772CC4 +      - cmd:             LC_BUILD_VERSION +        cmdsize:         32 +        platform:        1 +        minos:           983040 +        sdk:             983552 +        ntools:          1 +        Tools: +          - tool:            3 +            version:         73074435 +      - cmd:             LC_SOURCE_VERSION +        cmdsize:         16 +        version:         0 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         56 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 88539136 +          compatibility_version: 65536 +        Content:         '/usr/lib/libSystem.B.dylib' +        ZeroPadBytes:    6 +      - cmd:             LC_FUNCTION_STARTS +        cmdsize:         16 +        dataoff:         32888 +        datasize:        8 +      - cmd:             LC_DATA_IN_CODE +        cmdsize:         16 +        dataoff:         32896 +        datasize:        0 +      - cmd:             LC_CODE_SIGNATURE +        cmdsize:         16 +        dataoff:         32960 +        datasize:        416 +    LinkEditData: +      ExportTrie: +        TerminalSize:    0 +        NodeOffset:      0 +        Name:            '' +        Flags:           0x0 +        Address:         0x0 +        Other:           0x0 +        ImportName:      '' +        Children: +          - TerminalSize:    3 +            NodeOffset:      13 +            Name:            _sayB +            Flags:           0x0 +            Address:         0x3F68 +            Other:           0x0 +            ImportName:      '' +      NameList: +        - n_strx:          2 +          n_type:          0xF +          n_sect:          1 +          n_desc:          0 +          n_value:         16232 +        - n_strx:          8 +          n_type:          0x1 +          n_sect:          0 +          n_desc:          256 +          n_value:         0 +      StringTable: +        - ' ' +        - _sayB +        - _printf +      IndirectSymbols: [ 0x1, 0x1 ] +      FunctionStarts:  [ 0x3F68 ] +      ChainedFixups:   [ 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x48,  +                         0x0, 0x0, 0x0, 0x50, 0x0, 0x0, 0x0, 0x1, 0x0,  +                         0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x18, 0x0, 0x0, 0x0, 0x0, 0x40, 0xC, 0x0,  +                         0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x2, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5F, 0x70, 0x72,  +                         0x69, 0x6E, 0x74, 0x66, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0 ] +... diff --git a/llvm/unittests/ExecutionEngine/Orc/Inputs/C/C_linux.yaml b/llvm/unittests/ExecutionEngine/Orc/Inputs/C/C_linux.yaml new file mode 100644 index 0000000..3fabf9a --- /dev/null +++ b/llvm/unittests/ExecutionEngine/Orc/Inputs/C/C_linux.yaml @@ -0,0 +1,450 @@ +--- !ELF +FileHeader: +  Class:           ELFCLASS64 +  Data:            ELFDATA2LSB +  Type:            ET_DYN +  Machine:         EM_X86_64 +ProgramHeaders: +  - Type:            PT_LOAD +    Flags:           [ PF_R ] +    FirstSec:        .note.gnu.property +    LastSec:         .rela.plt +    Align:           0x1000 +    Offset:          0x0 +  - Type:            PT_LOAD +    Flags:           [ PF_X, PF_R ] +    FirstSec:        .init +    LastSec:         .fini +    VAddr:           0x1000 +    Align:           0x1000 +    Offset:          0x1000 +  - Type:            PT_LOAD +    Flags:           [ PF_R ] +    FirstSec:        .eh_frame_hdr +    LastSec:         .eh_frame +    VAddr:           0x2000 +    Align:           0x1000 +    Offset:          0x2000 +  - Type:            PT_LOAD +    Flags:           [ PF_W, PF_R ] +    FirstSec:        .init_array +    LastSec:         .bss +    VAddr:           0x3E10 +    Align:           0x1000 +    Offset:          0x2E10 +  - Type:            PT_DYNAMIC +    Flags:           [ PF_W, PF_R ] +    FirstSec:        .dynamic +    LastSec:         .dynamic +    VAddr:           0x3E20 +    Align:           0x8 +    Offset:          0x2E20 +  - Type:            PT_NOTE +    Flags:           [ PF_R ] +    FirstSec:        .note.gnu.property +    LastSec:         .note.gnu.property +    VAddr:           0x2A8 +    Align:           0x8 +    Offset:          0x2A8 +  - Type:            PT_NOTE +    Flags:           [ PF_R ] +    FirstSec:        .note.gnu.build-id +    LastSec:         .note.gnu.build-id +    VAddr:           0x2C8 +    Align:           0x4 +    Offset:          0x2C8 +  - Type:            PT_GNU_PROPERTY +    Flags:           [ PF_R ] +    FirstSec:        .note.gnu.property +    LastSec:         .note.gnu.property +    VAddr:           0x2A8 +    Align:           0x8 +    Offset:          0x2A8 +  - Type:            PT_GNU_EH_FRAME +    Flags:           [ PF_R ] +    FirstSec:        .eh_frame_hdr +    LastSec:         .eh_frame_hdr +    VAddr:           0x2000 +    Align:           0x4 +    Offset:          0x2000 +  - Type:            PT_GNU_STACK +    Flags:           [ PF_W, PF_R ] +    Align:           0x10 +    Offset:          0x0 +  - Type:            PT_GNU_RELRO +    Flags:           [ PF_R ] +    FirstSec:        .init_array +    LastSec:         .got +    VAddr:           0x3E10 +    Offset:          0x2E10 +Sections: +  - Name:            .note.gnu.property +    Type:            SHT_NOTE +    Flags:           [ SHF_ALLOC ] +    Address:         0x2A8 +    AddressAlign:    0x8 +    Notes: +      - Name:            GNU +        Desc:            020000C0040000000300000000000000 +        Type:            NT_GNU_PROPERTY_TYPE_0 +  - Name:            .note.gnu.build-id +    Type:            SHT_NOTE +    Flags:           [ SHF_ALLOC ] +    Address:         0x2C8 +    AddressAlign:    0x4 +    Notes: +      - Name:            GNU +        Desc:            0318D63E46BF31CEFF90D5C7F0475D9F78676EC8 +        Type:            NT_PRPSINFO +  - Name:            .gnu.hash +    Type:            SHT_GNU_HASH +    Flags:           [ SHF_ALLOC ] +    Address:         0x2F0 +    Link:            .dynsym +    AddressAlign:    0x8 +    Header: +      SymNdx:          0x8 +      Shift2:          0x6 +    BloomFilter:     [ 0x400000200000 ] +    HashBuckets:     [ 0x0, 0x8 ] +    HashValues:      [ 0x7C9DCB95 ] +  - Name:            .dynsym +    Type:            SHT_DYNSYM +    Flags:           [ SHF_ALLOC ] +    Address:         0x318 +    Link:            .dynstr +    AddressAlign:    0x8 +  - Name:            .dynstr +    Type:            SHT_STRTAB +    Flags:           [ SHF_ALLOC ] +    Address:         0x3F0 +    AddressAlign:    0x1 +    Content:         "6C6962412E736F006C6962422E736F006C69625A2E736F00244F524947494E2F2E2E2F413A244F524947494E2F2E2E2F423A244F524947494E2F2E2E2F5A" +  - Name:            .rela.dyn +    Type:            SHT_RELA +    Flags:           [ SHF_ALLOC ] +    Address:         0x498 +    Link:            .dynsym +    AddressAlign:    0x8 +    Relocations: +      - Offset:          0x3E10 +        Type:            R_X86_64_RELATIVE +        Addend:          4432 +      - Offset:          0x3E18 +        Type:            R_X86_64_RELATIVE +        Addend:          4368 +      - Offset:          0x4030 +        Type:            R_X86_64_RELATIVE +        Addend:          16432 +      - Offset:          0x3FE0 +        Symbol:          __cxa_finalize +        Type:            R_X86_64_GLOB_DAT +      - Offset:          0x3FE8 +        Symbol:          _ITM_registerTMCloneTable +        Type:            R_X86_64_GLOB_DAT +      - Offset:          0x3FF0 +        Symbol:          _ITM_deregisterTMCloneTable +        Type:            R_X86_64_GLOB_DAT +      - Offset:          0x3FF8 +        Symbol:          __gmon_start__ +        Type:            R_X86_64_GLOB_DAT +  - Name:            .rela.plt +    Type:            SHT_RELA +    Flags:           [ SHF_ALLOC, SHF_INFO_LINK ] +    Address:         0x540 +    Link:            .dynsym +    AddressAlign:    0x8 +    Info:            .got.plt +    Relocations: +      - Offset:          0x4018 +        Symbol:          sayA +        Type:            R_X86_64_JUMP_SLOT +      - Offset:          0x4020 +        Symbol:          sayB +        Type:            R_X86_64_JUMP_SLOT +      - Offset:          0x4028 +        Symbol:          sayZ +        Type:            R_X86_64_JUMP_SLOT +  - Name:            .init +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1000 +    AddressAlign:    0x4 +    Offset:          0x1000 +    Content:         F30F1EFA4883EC08488B05E92F00004885C07402FFD04883C408C3 +  - Name:            .plt +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1020 +    AddressAlign:    0x10 +    EntSize:         0x10 +    Content:         FF35E22F0000F2FF25E32F00000F1F00F30F1EFA6800000000F2E9E1FFFFFF90F30F1EFA6801000000F2E9D1FFFFFF90F30F1EFA6802000000F2E9C1FFFFFF90 +  - Name:            .plt.got +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1060 +    AddressAlign:    0x10 +    EntSize:         0x10 +    Content:         F30F1EFAF2FF25752F00000F1F440000 +  - Name:            .plt.sec +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1070 +    AddressAlign:    0x10 +    EntSize:         0x10 +    Content:         F30F1EFAF2FF259D2F00000F1F440000F30F1EFAF2FF25952F00000F1F440000F30F1EFAF2FF258D2F00000F1F440000 +  - Name:            .text +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x10A0 +    AddressAlign:    0x10 +    Content:         488D3D912F0000488D058A2F00004839F87415488B05362F00004885C07409FFE00F1F8000000000C30F1F8000000000488D3D612F0000488D355A2F00004829FE4889F048C1EE3F48C1F8034801C648D1FE7414488B05ED2E00004885C07408FFE0660F1F440000C30F1F8000000000F30F1EFA803D1D2F000000752B5548833DBA2E0000004889E5740C488B3DFE2E0000E829FFFFFFE864FFFFFFC605F52E0000015DC30F1F00C30F1F8000000000F30F1EFAE977FFFFFFF30F1EFA554889E5B800000000E805FFFFFFB800000000E80BFFFFFFB800000000E811FFFFFF905DC3 +  - Name:            .fini +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1184 +    AddressAlign:    0x4 +    Content:         F30F1EFA4883EC084883C408C3 +  - Name:            .eh_frame_hdr +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC ] +    Address:         0x2000 +    AddressAlign:    0x4 +    Offset:          0x2000 +    Content:         011B033B2C0000000400000020F0FFFF4800000060F0FFFF7000000070F0FFFF8800000059F1FFFFA0000000 +  - Name:            .eh_frame +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC ] +    Address:         0x2030 +    AddressAlign:    0x8 +    Content:         1400000000000000017A5200017810011B0C070890010000240000001C000000D0EFFFFF40000000000E10460E184A0F0B770880003F1A3A2A332422000000001400000044000000E8EFFFFF100000000000000000000000140000005C000000E0EFFFFF3000000000000000000000001C00000074000000B1F0FFFF2900000000450E108602430D06600C070800000000000000 +  - Name:            .init_array +    Type:            SHT_INIT_ARRAY +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x3E10 +    AddressAlign:    0x8 +    EntSize:         0x8 +    Offset:          0x2E10 +    Content:         '5011000000000000' +  - Name:            .fini_array +    Type:            SHT_FINI_ARRAY +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x3E18 +    AddressAlign:    0x8 +    EntSize:         0x8 +    Content:         '1011000000000000' +  - Name:            .dynamic +    Type:            SHT_DYNAMIC +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x3E20 +    Link:            .dynstr +    AddressAlign:    0x8 +    Entries: +      - Tag:             DT_NEEDED +        Value:           0x0 +      - Tag:             DT_NEEDED +        Value:           0x8 +      - Tag:             DT_NEEDED +        Value:           0x10 +      - Tag:             DT_RUNPATH +        Value:           0x18 +      - Tag:             DT_INIT +        Value:           0x1000 +      - Tag:             DT_FINI +        Value:           0x1184 +      - Tag:             DT_INIT_ARRAY +        Value:           0x3E10 +      - Tag:             DT_INIT_ARRAYSZ +        Value:           0x8 +      - Tag:             DT_FINI_ARRAY +        Value:           0x3E18 +      - Tag:             DT_FINI_ARRAYSZ +        Value:           0x8 +      - Tag:             DT_GNU_HASH +        Value:           0x2F0 +      - Tag:             DT_STRTAB +        Value:           0x3F0 +      - Tag:             DT_SYMTAB +        Value:           0x318 +      - Tag:             DT_STRSZ +        Value:           0xA8 +      - Tag:             DT_SYMENT +        Value:           0x18 +      - Tag:             DT_PLTGOT +        Value:           0x4000 +      - Tag:             DT_PLTRELSZ +        Value:           0x48 +      - Tag:             DT_PLTREL +        Value:           0x7 +      - Tag:             DT_JMPREL +        Value:           0x540 +      - Tag:             DT_RELA +        Value:           0x498 +      - Tag:             DT_RELASZ +        Value:           0xA8 +      - Tag:             DT_RELAENT +        Value:           0x18 +      - Tag:             DT_RELACOUNT +        Value:           0x3 +      - Tag:             DT_NULL +        Value:           0x0 +      - Tag:             DT_NULL +        Value:           0x0 +      - Tag:             DT_NULL +        Value:           0x0 +      - Tag:             DT_NULL +        Value:           0x0 +      - Tag:             DT_NULL +        Value:           0x0 +  - Name:            .got +    Type:            SHT_PROGBITS +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x3FE0 +    AddressAlign:    0x8 +    EntSize:         0x8 +    Content:         '0000000000000000000000000000000000000000000000000000000000000000' +  - Name:            .got.plt +    Type:            SHT_PROGBITS +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x4000 +    AddressAlign:    0x8 +    EntSize:         0x8 +    Content:         '203E00000000000000000000000000000000000000000000301000000000000040100000000000005010000000000000' +  - Name:            .data +    Type:            SHT_PROGBITS +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x4030 +    AddressAlign:    0x8 +    Content:         '3040000000000000' +  - Name:            .bss +    Type:            SHT_NOBITS +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x4038 +    AddressAlign:    0x1 +    Size:            0x8 +  - Name:            .comment +    Type:            SHT_PROGBITS +    Flags:           [ SHF_MERGE, SHF_STRINGS ] +    AddressAlign:    0x1 +    EntSize:         0x1 +    Content:         4743433A20285562756E74752031312E342E302D317562756E7475317E32322E30342E32292031312E342E3000 +Symbols: +  - Name:            crtstuff.c +    Type:            STT_FILE +    Index:           SHN_ABS +  - Name:            deregister_tm_clones +    Type:            STT_FUNC +    Section:         .text +    Value:           0x10A0 +  - Name:            register_tm_clones +    Type:            STT_FUNC +    Section:         .text +    Value:           0x10D0 +  - Name:            __do_global_dtors_aux +    Type:            STT_FUNC +    Section:         .text +    Value:           0x1110 +  - Name:            completed.0 +    Type:            STT_OBJECT +    Section:         .bss +    Value:           0x4038 +    Size:            0x1 +  - Name:            __do_global_dtors_aux_fini_array_entry +    Type:            STT_OBJECT +    Section:         .fini_array +    Value:           0x3E18 +  - Name:            frame_dummy +    Type:            STT_FUNC +    Section:         .text +    Value:           0x1150 +  - Name:            __frame_dummy_init_array_entry +    Type:            STT_OBJECT +    Section:         .init_array +    Value:           0x3E10 +  - Name:            libC.c +    Type:            STT_FILE +    Index:           SHN_ABS +  - Name:            'crtstuff.c (1)' +    Type:            STT_FILE +    Index:           SHN_ABS +  - Name:            __FRAME_END__ +    Type:            STT_OBJECT +    Section:         .eh_frame +    Value:           0x20C0 +  - Type:            STT_FILE +    Index:           SHN_ABS +  - Name:            _DYNAMIC +    Type:            STT_OBJECT +    Section:         .dynamic +    Value:           0x3E20 +  - Name:            __TMC_END__ +    Type:            STT_OBJECT +    Section:         .data +    Value:           0x4038 +  - Name:            __dso_handle +    Type:            STT_OBJECT +    Section:         .data +    Value:           0x4030 +  - Name:            _init +    Type:            STT_FUNC +    Section:         .init +    Value:           0x1000 +  - Name:            __GNU_EH_FRAME_HDR +    Section:         .eh_frame_hdr +    Value:           0x2000 +  - Name:            _fini +    Type:            STT_FUNC +    Section:         .fini +    Value:           0x1184 +  - Name:            _GLOBAL_OFFSET_TABLE_ +    Type:            STT_OBJECT +    Section:         .got.plt +    Value:           0x4000 +  - Name:            __cxa_finalize +    Binding:         STB_WEAK +  - Name:            sayC +    Type:            STT_FUNC +    Section:         .text +    Binding:         STB_GLOBAL +    Value:           0x1159 +    Size:            0x29 +  - Name:            _ITM_registerTMCloneTable +    Binding:         STB_WEAK +  - Name:            _ITM_deregisterTMCloneTable +    Binding:         STB_WEAK +  - Name:            sayA +    Type:            STT_FUNC +    Binding:         STB_GLOBAL +  - Name:            sayB +    Type:            STT_FUNC +    Binding:         STB_GLOBAL +  - Name:            sayZ +    Type:            STT_FUNC +    Binding:         STB_GLOBAL +  - Name:            __gmon_start__ +    Binding:         STB_WEAK +DynamicSymbols: +  - Name:            __cxa_finalize +    Binding:         STB_WEAK +  - Name:            _ITM_registerTMCloneTable +    Binding:         STB_WEAK +  - Name:            _ITM_deregisterTMCloneTable +    Binding:         STB_WEAK +  - Name:            sayA +    Type:            STT_FUNC +    Binding:         STB_GLOBAL +  - Name:            sayB +    Type:            STT_FUNC +    Binding:         STB_GLOBAL +  - Name:            sayZ +    Type:            STT_FUNC +    Binding:         STB_GLOBAL +  - Name:            __gmon_start__ +    Binding:         STB_WEAK +  - Name:            sayC +    Type:            STT_FUNC +    Section:         .text +    Binding:         STB_GLOBAL +    Value:           0x1159 +    Size:            0x29 +... diff --git a/llvm/unittests/ExecutionEngine/Orc/Inputs/C/C_macho.yaml b/llvm/unittests/ExecutionEngine/Orc/Inputs/C/C_macho.yaml new file mode 100644 index 0000000..ba33483 --- /dev/null +++ b/llvm/unittests/ExecutionEngine/Orc/Inputs/C/C_macho.yaml @@ -0,0 +1,870 @@ +--- !fat-mach-o +FatHeader: +  magic:           0xCAFEBABE +  nfat_arch:       3 +FatArchs: +  - cputype:         0x1000007 +    cpusubtype:      0x3 +    offset:          0x1000 +    size:            8456 +    align:           12 +  - cputype:         0x100000C +    cpusubtype:      0x0 +    offset:          0x4000 +    size:            33456 +    align:           14 +  - cputype:         0x100000C +    cpusubtype:      0x80000002 +    offset:          0x10000 +    size:            33456 +    align:           14 +Slices: +  - !mach-o +    FileHeader: +      magic:           0xFEEDFACF +      cputype:         0x1000007 +      cpusubtype:      0x3 +      filetype:        0x6 +      ncmds:           20 +      sizeofcmds:      1120 +      flags:           0x100085 +      reserved:        0x0 +    LoadCommands: +      - cmd:             LC_SEGMENT_64 +        cmdsize:         312 +        segname:         __TEXT +        vmaddr:          0 +        vmsize:          4096 +        fileoff:         0 +        filesize:        4096 +        maxprot:         5 +        initprot:        5 +        nsects:          3 +        flags:           0 +        Sections: +          - sectname:        __text +            segname:         __TEXT +            addr:            0xF70 +            size:            27 +            offset:          0xF70 +            align:           4 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000400 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         554889E5B000E811000000B000E810000000B000E80F0000005DC3 +          - sectname:        __stubs +            segname:         __TEXT +            addr:            0xF8C +            size:            18 +            offset:          0xF8C +            align:           1 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000408 +            reserved1:       0x0 +            reserved2:       0x6 +            reserved3:       0x0 +            content:         FF256E000000FF2570000000FF2572000000 +          - sectname:        __unwind_info +            segname:         __TEXT +            addr:            0xFA0 +            size:            88 +            offset:          0xFA0 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x0 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         010000001C000000000000001C000000000000001C00000002000000700F000040000000400000008B0F00000000000040000000000000000000000000000000030000000C00010010000100000000000000000100000000 +      - cmd:             LC_SEGMENT_64 +        cmdsize:         152 +        segname:         __DATA_CONST +        vmaddr:          4096 +        vmsize:          4096 +        fileoff:         4096 +        filesize:        4096 +        maxprot:         3 +        initprot:        3 +        nsects:          1 +        flags:           16 +        Sections: +          - sectname:        __got +            segname:         __DATA_CONST +            addr:            0x1000 +            size:            24 +            offset:          0x1000 +            align:           3 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x6 +            reserved1:       0x3 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         '000000000000108001000000000010800200000000000080' +      - cmd:             LC_SEGMENT_64 +        cmdsize:         72 +        segname:         __LINKEDIT +        vmaddr:          8192 +        vmsize:          4096 +        fileoff:         8192 +        filesize:        264 +        maxprot:         1 +        initprot:        1 +        nsects:          0 +        flags:           0 +      - cmd:             LC_ID_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       1 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libC.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_DYLD_CHAINED_FIXUPS +        cmdsize:         16 +        dataoff:         8192 +        datasize:        112 +      - cmd:             LC_DYLD_EXPORTS_TRIE +        cmdsize:         16 +        dataoff:         8304 +        datasize:        24 +      - cmd:             LC_SYMTAB +        cmdsize:         24 +        symoff:          8336 +        nsyms:           4 +        stroff:          8424 +        strsize:         32 +      - cmd:             LC_DYSYMTAB +        cmdsize:         80 +        ilocalsym:       0 +        nlocalsym:       0 +        iextdefsym:      0 +        nextdefsym:      1 +        iundefsym:       1 +        nundefsym:       3 +        tocoff:          0 +        ntoc:            0 +        modtaboff:       0 +        nmodtab:         0 +        extrefsymoff:    0 +        nextrefsyms:     0 +        indirectsymoff:  8400 +        nindirectsyms:   6 +        extreloff:       0 +        nextrel:         0 +        locreloff:       0 +        nlocrel:         0 +      - cmd:             LC_UUID +        cmdsize:         24 +        uuid:            2AA1F9E9-F250-366F-B382-51A91DE06BED +      - cmd:             LC_BUILD_VERSION +        cmdsize:         32 +        platform:        1 +        minos:           983040 +        sdk:             983552 +        ntools:          1 +        Tools: +          - tool:            3 +            version:         73074435 +      - cmd:             LC_SOURCE_VERSION +        cmdsize:         16 +        version:         0 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libA.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libB.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libZ.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         56 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 88539136 +          compatibility_version: 65536 +        Content:         '/usr/lib/libSystem.B.dylib' +        ZeroPadBytes:    6 +      - cmd:             LC_RPATH +        cmdsize:         32 +        path:            12 +        Content:         '@loader_path/../A' +        ZeroPadBytes:    3 +      - cmd:             LC_RPATH +        cmdsize:         32 +        path:            12 +        Content:         '@loader_path/../B' +        ZeroPadBytes:    3 +      - cmd:             LC_RPATH +        cmdsize:         32 +        path:            12 +        Content:         '@loader_path/../Z' +        ZeroPadBytes:    3 +      - cmd:             LC_FUNCTION_STARTS +        cmdsize:         16 +        dataoff:         8328 +        datasize:        8 +      - cmd:             LC_DATA_IN_CODE +        cmdsize:         16 +        dataoff:         8336 +        datasize:        0 +    LinkEditData: +      ExportTrie: +        TerminalSize:    0 +        NodeOffset:      0 +        Name:            '' +        Flags:           0x0 +        Address:         0x0 +        Other:           0x0 +        ImportName:      '' +        Children: +          - TerminalSize:    3 +            NodeOffset:      13 +            Name:            _sayC +            Flags:           0x0 +            Address:         0xF70 +            Other:           0x0 +            ImportName:      '' +      NameList: +        - n_strx:          2 +          n_type:          0xF +          n_sect:          1 +          n_desc:          0 +          n_value:         3952 +        - n_strx:          8 +          n_type:          0x1 +          n_sect:          0 +          n_desc:          256 +          n_value:         0 +        - n_strx:          14 +          n_type:          0x1 +          n_sect:          0 +          n_desc:          512 +          n_value:         0 +        - n_strx:          20 +          n_type:          0x1 +          n_sect:          0 +          n_desc:          768 +          n_value:         0 +      StringTable: +        - ' ' +        - _sayC +        - _sayA +        - _sayB +        - _sayZ +        - '' +        - '' +        - '' +        - '' +        - '' +        - '' +      IndirectSymbols: [ 0x1, 0x2, 0x3, 0x1, 0x2, 0x3 ] +      FunctionStarts:  [ 0xF70 ] +      ChainedFixups:   [ 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x48,  +                         0x0, 0x0, 0x0, 0x58, 0x0, 0x0, 0x0, 0x3, 0x0,  +                         0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x18, 0x0, 0x0, 0x0, 0x0, 0x10, 0x6, 0x0,  +                         0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x2, 0x0,  +                         0x0, 0x2, 0xE, 0x0, 0x0, 0x3, 0x1A, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x0, 0x5F, 0x73, 0x61, 0x79,  +                         0x41, 0x0, 0x5F, 0x73, 0x61, 0x79, 0x42, 0x0,  +                         0x5F, 0x73, 0x61, 0x79, 0x5A, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0 ] +  - !mach-o +    FileHeader: +      magic:           0xFEEDFACF +      cputype:         0x100000C +      cpusubtype:      0x0 +      filetype:        0x6 +      ncmds:           21 +      sizeofcmds:      1136 +      flags:           0x100085 +      reserved:        0x0 +    LoadCommands: +      - cmd:             LC_SEGMENT_64 +        cmdsize:         312 +        segname:         __TEXT +        vmaddr:          0 +        vmsize:          16384 +        fileoff:         0 +        filesize:        16384 +        maxprot:         5 +        initprot:        5 +        nsects:          3 +        flags:           0 +        Sections: +          - sectname:        __text +            segname:         __TEXT +            addr:            0x3F68 +            size:            28 +            offset:          0x3F68 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000400 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         FD7BBFA9FD030091050000940700009409000094FD7BC1A8C0035FD6 +          - sectname:        __stubs +            segname:         __TEXT +            addr:            0x3F84 +            size:            36 +            offset:          0x3F84 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000408 +            reserved1:       0x0 +            reserved2:       0xC +            reserved3:       0x0 +            content:         100000B0100240F900021FD6100000B0100640F900021FD6100000B0100A40F900021FD6 +          - sectname:        __unwind_info +            segname:         __TEXT +            addr:            0x3FA8 +            size:            88 +            offset:          0x3FA8 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x0 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         010000001C000000000000001C000000000000001C00000002000000683F00004000000040000000843F00000000000040000000000000000000000000000000030000000C00010010000100000000000000000400000000 +      - cmd:             LC_SEGMENT_64 +        cmdsize:         152 +        segname:         __DATA_CONST +        vmaddr:          16384 +        vmsize:          16384 +        fileoff:         16384 +        filesize:        16384 +        maxprot:         3 +        initprot:        3 +        nsects:          1 +        flags:           16 +        Sections: +          - sectname:        __got +            segname:         __DATA_CONST +            addr:            0x4000 +            size:            24 +            offset:          0x4000 +            align:           3 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x6 +            reserved1:       0x3 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         '000000000000108001000000000010800200000000000080' +      - cmd:             LC_SEGMENT_64 +        cmdsize:         72 +        segname:         __LINKEDIT +        vmaddr:          32768 +        vmsize:          16384 +        fileoff:         32768 +        filesize:        688 +        maxprot:         1 +        initprot:        1 +        nsects:          0 +        flags:           0 +      - cmd:             LC_ID_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       1 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libC.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_DYLD_CHAINED_FIXUPS +        cmdsize:         16 +        dataoff:         32768 +        datasize:        112 +      - cmd:             LC_DYLD_EXPORTS_TRIE +        cmdsize:         16 +        dataoff:         32880 +        datasize:        24 +      - cmd:             LC_SYMTAB +        cmdsize:         24 +        symoff:          32912 +        nsyms:           4 +        stroff:          33000 +        strsize:         32 +      - cmd:             LC_DYSYMTAB +        cmdsize:         80 +        ilocalsym:       0 +        nlocalsym:       0 +        iextdefsym:      0 +        nextdefsym:      1 +        iundefsym:       1 +        nundefsym:       3 +        tocoff:          0 +        ntoc:            0 +        modtaboff:       0 +        nmodtab:         0 +        extrefsymoff:    0 +        nextrefsyms:     0 +        indirectsymoff:  32976 +        nindirectsyms:   6 +        extreloff:       0 +        nextrel:         0 +        locreloff:       0 +        nlocrel:         0 +      - cmd:             LC_UUID +        cmdsize:         24 +        uuid:            02B69690-925D-35EE-A8AB-6D99813D2A16 +      - cmd:             LC_BUILD_VERSION +        cmdsize:         32 +        platform:        1 +        minos:           983040 +        sdk:             983552 +        ntools:          1 +        Tools: +          - tool:            3 +            version:         73074435 +      - cmd:             LC_SOURCE_VERSION +        cmdsize:         16 +        version:         0 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libA.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libB.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libZ.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         56 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 88539136 +          compatibility_version: 65536 +        Content:         '/usr/lib/libSystem.B.dylib' +        ZeroPadBytes:    6 +      - cmd:             LC_RPATH +        cmdsize:         32 +        path:            12 +        Content:         '@loader_path/../A' +        ZeroPadBytes:    3 +      - cmd:             LC_RPATH +        cmdsize:         32 +        path:            12 +        Content:         '@loader_path/../B' +        ZeroPadBytes:    3 +      - cmd:             LC_RPATH +        cmdsize:         32 +        path:            12 +        Content:         '@loader_path/../Z' +        ZeroPadBytes:    3 +      - cmd:             LC_FUNCTION_STARTS +        cmdsize:         16 +        dataoff:         32904 +        datasize:        8 +      - cmd:             LC_DATA_IN_CODE +        cmdsize:         16 +        dataoff:         32912 +        datasize:        0 +      - cmd:             LC_CODE_SIGNATURE +        cmdsize:         16 +        dataoff:         33040 +        datasize:        416 +    LinkEditData: +      ExportTrie: +        TerminalSize:    0 +        NodeOffset:      0 +        Name:            '' +        Flags:           0x0 +        Address:         0x0 +        Other:           0x0 +        ImportName:      '' +        Children: +          - TerminalSize:    3 +            NodeOffset:      13 +            Name:            _sayC +            Flags:           0x0 +            Address:         0x3F68 +            Other:           0x0 +            ImportName:      '' +      NameList: +        - n_strx:          2 +          n_type:          0xF +          n_sect:          1 +          n_desc:          0 +          n_value:         16232 +        - n_strx:          8 +          n_type:          0x1 +          n_sect:          0 +          n_desc:          256 +          n_value:         0 +        - n_strx:          14 +          n_type:          0x1 +          n_sect:          0 +          n_desc:          512 +          n_value:         0 +        - n_strx:          20 +          n_type:          0x1 +          n_sect:          0 +          n_desc:          768 +          n_value:         0 +      StringTable: +        - ' ' +        - _sayC +        - _sayA +        - _sayB +        - _sayZ +        - '' +        - '' +        - '' +        - '' +        - '' +        - '' +      IndirectSymbols: [ 0x1, 0x2, 0x3, 0x1, 0x2, 0x3 ] +      FunctionStarts:  [ 0x3F68 ] +      ChainedFixups:   [ 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x48,  +                         0x0, 0x0, 0x0, 0x58, 0x0, 0x0, 0x0, 0x3, 0x0,  +                         0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x18, 0x0, 0x0, 0x0, 0x0, 0x40, 0x6, 0x0,  +                         0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x2, 0x0,  +                         0x0, 0x2, 0xE, 0x0, 0x0, 0x3, 0x1A, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x0, 0x5F, 0x73, 0x61, 0x79,  +                         0x41, 0x0, 0x5F, 0x73, 0x61, 0x79, 0x42, 0x0,  +                         0x5F, 0x73, 0x61, 0x79, 0x5A, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0 ] +  - !mach-o +    FileHeader: +      magic:           0xFEEDFACF +      cputype:         0x100000C +      cpusubtype:      0x80000002 +      filetype:        0x6 +      ncmds:           21 +      sizeofcmds:      1136 +      flags:           0x100085 +      reserved:        0x0 +    LoadCommands: +      - cmd:             LC_SEGMENT_64 +        cmdsize:         312 +        segname:         __TEXT +        vmaddr:          0 +        vmsize:          16384 +        fileoff:         0 +        filesize:        16384 +        maxprot:         5 +        initprot:        5 +        nsects:          3 +        flags:           0 +        Sections: +          - sectname:        __text +            segname:         __TEXT +            addr:            0x3F58 +            size:            32 +            offset:          0x3F58 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000400 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         7F2303D5FD7BBFA9FD03009105000094080000940B000094FD7BC1A8FF0F5FD6 +          - sectname:        __auth_stubs +            segname:         __TEXT +            addr:            0x3F78 +            size:            48 +            offset:          0x3F78 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000408 +            reserved1:       0x0 +            reserved2:       0x10 +            reserved3:       0x0 +            content:         110000B031020091300240F9110A1FD7110000B031220091300240F9110A1FD7110000B031420091300240F9110A1FD7 +          - sectname:        __unwind_info +            segname:         __TEXT +            addr:            0x3FA8 +            size:            88 +            offset:          0x3FA8 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x0 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         010000001C000000000000001C000000000000001C00000002000000583F00004000000040000000783F00000000000040000000000000000000000000000000030000000C00010010000100000000000000000400000000 +      - cmd:             LC_SEGMENT_64 +        cmdsize:         152 +        segname:         __DATA_CONST +        vmaddr:          16384 +        vmsize:          16384 +        fileoff:         16384 +        filesize:        16384 +        maxprot:         3 +        initprot:        3 +        nsects:          1 +        flags:           16 +        Sections: +          - sectname:        __auth_got +            segname:         __DATA_CONST +            addr:            0x4000 +            size:            24 +            offset:          0x4000 +            align:           3 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x6 +            reserved1:       0x3 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         00000000000009C001000000000009C002000000000001C0 +      - cmd:             LC_SEGMENT_64 +        cmdsize:         72 +        segname:         __LINKEDIT +        vmaddr:          32768 +        vmsize:          16384 +        fileoff:         32768 +        filesize:        688 +        maxprot:         1 +        initprot:        1 +        nsects:          0 +        flags:           0 +      - cmd:             LC_ID_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       1 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libC.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_DYLD_CHAINED_FIXUPS +        cmdsize:         16 +        dataoff:         32768 +        datasize:        112 +      - cmd:             LC_DYLD_EXPORTS_TRIE +        cmdsize:         16 +        dataoff:         32880 +        datasize:        24 +      - cmd:             LC_SYMTAB +        cmdsize:         24 +        symoff:          32912 +        nsyms:           4 +        stroff:          33000 +        strsize:         32 +      - cmd:             LC_DYSYMTAB +        cmdsize:         80 +        ilocalsym:       0 +        nlocalsym:       0 +        iextdefsym:      0 +        nextdefsym:      1 +        iundefsym:       1 +        nundefsym:       3 +        tocoff:          0 +        ntoc:            0 +        modtaboff:       0 +        nmodtab:         0 +        extrefsymoff:    0 +        nextrefsyms:     0 +        indirectsymoff:  32976 +        nindirectsyms:   6 +        extreloff:       0 +        nextrel:         0 +        locreloff:       0 +        nlocrel:         0 +      - cmd:             LC_UUID +        cmdsize:         24 +        uuid:            F54076AA-8888-3DED-8BDF-BC7FB3E6FE8A +      - cmd:             LC_BUILD_VERSION +        cmdsize:         32 +        platform:        1 +        minos:           983040 +        sdk:             983552 +        ntools:          1 +        Tools: +          - tool:            3 +            version:         73074435 +      - cmd:             LC_SOURCE_VERSION +        cmdsize:         16 +        version:         0 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libA.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libB.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libZ.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         56 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 88539136 +          compatibility_version: 65536 +        Content:         '/usr/lib/libSystem.B.dylib' +        ZeroPadBytes:    6 +      - cmd:             LC_RPATH +        cmdsize:         32 +        path:            12 +        Content:         '@loader_path/../A' +        ZeroPadBytes:    3 +      - cmd:             LC_RPATH +        cmdsize:         32 +        path:            12 +        Content:         '@loader_path/../B' +        ZeroPadBytes:    3 +      - cmd:             LC_RPATH +        cmdsize:         32 +        path:            12 +        Content:         '@loader_path/../Z' +        ZeroPadBytes:    3 +      - cmd:             LC_FUNCTION_STARTS +        cmdsize:         16 +        dataoff:         32904 +        datasize:        8 +      - cmd:             LC_DATA_IN_CODE +        cmdsize:         16 +        dataoff:         32912 +        datasize:        0 +      - cmd:             LC_CODE_SIGNATURE +        cmdsize:         16 +        dataoff:         33040 +        datasize:        416 +    LinkEditData: +      ExportTrie: +        TerminalSize:    0 +        NodeOffset:      0 +        Name:            '' +        Flags:           0x0 +        Address:         0x0 +        Other:           0x0 +        ImportName:      '' +        Children: +          - TerminalSize:    3 +            NodeOffset:      13 +            Name:            _sayC +            Flags:           0x0 +            Address:         0x3F58 +            Other:           0x0 +            ImportName:      '' +      NameList: +        - n_strx:          2 +          n_type:          0xF +          n_sect:          1 +          n_desc:          0 +          n_value:         16216 +        - n_strx:          8 +          n_type:          0x1 +          n_sect:          0 +          n_desc:          256 +          n_value:         0 +        - n_strx:          14 +          n_type:          0x1 +          n_sect:          0 +          n_desc:          512 +          n_value:         0 +        - n_strx:          20 +          n_type:          0x1 +          n_sect:          0 +          n_desc:          768 +          n_value:         0 +      StringTable: +        - ' ' +        - _sayC +        - _sayA +        - _sayB +        - _sayZ +        - '' +        - '' +        - '' +        - '' +        - '' +        - '' +      IndirectSymbols: [ 0x1, 0x2, 0x3, 0x1, 0x2, 0x3 ] +      FunctionStarts:  [ 0x3F58 ] +      ChainedFixups:   [ 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x48,  +                         0x0, 0x0, 0x0, 0x58, 0x0, 0x0, 0x0, 0x3, 0x0,  +                         0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x18, 0x0, 0x0, 0x0, 0x0, 0x40, 0xC, 0x0,  +                         0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x2, 0x0,  +                         0x0, 0x2, 0xE, 0x0, 0x0, 0x3, 0x1A, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x0, 0x5F, 0x73, 0x61, 0x79,  +                         0x41, 0x0, 0x5F, 0x73, 0x61, 0x79, 0x42, 0x0,  +                         0x5F, 0x73, 0x61, 0x79, 0x5A, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0 ] +... diff --git a/llvm/unittests/ExecutionEngine/Orc/Inputs/Z/Z_linux.yaml b/llvm/unittests/ExecutionEngine/Orc/Inputs/Z/Z_linux.yaml new file mode 100644 index 0000000..5561f29 --- /dev/null +++ b/llvm/unittests/ExecutionEngine/Orc/Inputs/Z/Z_linux.yaml @@ -0,0 +1,460 @@ +--- !ELF +FileHeader: +  Class:           ELFCLASS64 +  Data:            ELFDATA2LSB +  Type:            ET_DYN +  Machine:         EM_X86_64 +ProgramHeaders: +  - Type:            PT_LOAD +    Flags:           [ PF_R ] +    FirstSec:        .note.gnu.property +    LastSec:         .rela.plt +    Align:           0x1000 +    Offset:          0x0 +  - Type:            PT_LOAD +    Flags:           [ PF_X, PF_R ] +    FirstSec:        .init +    LastSec:         .fini +    VAddr:           0x1000 +    Align:           0x1000 +    Offset:          0x1000 +  - Type:            PT_LOAD +    Flags:           [ PF_R ] +    FirstSec:        .rodata +    LastSec:         .eh_frame +    VAddr:           0x2000 +    Align:           0x1000 +    Offset:          0x2000 +  - Type:            PT_LOAD +    Flags:           [ PF_W, PF_R ] +    FirstSec:        .init_array +    LastSec:         .bss +    VAddr:           0x3E10 +    Align:           0x1000 +    Offset:          0x2E10 +  - Type:            PT_DYNAMIC +    Flags:           [ PF_W, PF_R ] +    FirstSec:        .dynamic +    LastSec:         .dynamic +    VAddr:           0x3E20 +    Align:           0x8 +    Offset:          0x2E20 +  - Type:            PT_NOTE +    Flags:           [ PF_R ] +    FirstSec:        .note.gnu.property +    LastSec:         .note.gnu.property +    VAddr:           0x2A8 +    Align:           0x8 +    Offset:          0x2A8 +  - Type:            PT_NOTE +    Flags:           [ PF_R ] +    FirstSec:        .note.gnu.build-id +    LastSec:         .note.gnu.build-id +    VAddr:           0x2C8 +    Align:           0x4 +    Offset:          0x2C8 +  - Type:            PT_GNU_PROPERTY +    Flags:           [ PF_R ] +    FirstSec:        .note.gnu.property +    LastSec:         .note.gnu.property +    VAddr:           0x2A8 +    Align:           0x8 +    Offset:          0x2A8 +  - Type:            PT_GNU_EH_FRAME +    Flags:           [ PF_R ] +    FirstSec:        .eh_frame_hdr +    LastSec:         .eh_frame_hdr +    VAddr:           0x2010 +    Align:           0x4 +    Offset:          0x2010 +  - Type:            PT_GNU_STACK +    Flags:           [ PF_W, PF_R ] +    Align:           0x10 +    Offset:          0x0 +  - Type:            PT_GNU_RELRO +    Flags:           [ PF_R ] +    FirstSec:        .init_array +    LastSec:         .got +    VAddr:           0x3E10 +    Offset:          0x2E10 +Sections: +  - Name:            .note.gnu.property +    Type:            SHT_NOTE +    Flags:           [ SHF_ALLOC ] +    Address:         0x2A8 +    AddressAlign:    0x8 +    Notes: +      - Name:            GNU +        Desc:            020000C0040000000300000000000000 +        Type:            NT_GNU_PROPERTY_TYPE_0 +  - Name:            .note.gnu.build-id +    Type:            SHT_NOTE +    Flags:           [ SHF_ALLOC ] +    Address:         0x2C8 +    AddressAlign:    0x4 +    Notes: +      - Name:            GNU +        Desc:            640A4A3AC0DF6BA3DAC3B51CCD727245117E0B30 +        Type:            NT_PRPSINFO +  - Name:            .gnu.hash +    Type:            SHT_GNU_HASH +    Flags:           [ SHF_ALLOC ] +    Address:         0x2F0 +    Link:            .dynsym +    AddressAlign:    0x8 +    Header: +      SymNdx:          0x6 +      Shift2:          0x6 +    BloomFilter:     [ 0x500000000000 ] +    HashBuckets:     [ 0x6, 0x0 ] +    HashValues:      [ 0x7C9DCBAD ] +  - Name:            .dynsym +    Type:            SHT_DYNSYM +    Flags:           [ SHF_ALLOC ] +    Address:         0x318 +    Link:            .dynstr +    AddressAlign:    0x8 +  - Name:            .dynstr +    Type:            SHT_STRTAB +    Flags:           [ SHF_ALLOC ] +    Address:         0x3C0 +    AddressAlign:    0x1 +  - Name:            .gnu.version +    Type:            SHT_GNU_versym +    Flags:           [ SHF_ALLOC ] +    Address:         0x436 +    Link:            .dynsym +    AddressAlign:    0x2 +    Entries:         [ 0, 1, 2, 1, 1, 2, 1 ] +  - Name:            .gnu.version_r +    Type:            SHT_GNU_verneed +    Flags:           [ SHF_ALLOC ] +    Address:         0x448 +    Link:            .dynstr +    AddressAlign:    0x8 +    Dependencies: +      - Version:         1 +        File:            libc.so.6 +        Entries: +          - Name:            GLIBC_2.2.5 +            Hash:            157882997 +            Flags:           0 +            Other:           2 +  - Name:            .rela.dyn +    Type:            SHT_RELA +    Flags:           [ SHF_ALLOC ] +    Address:         0x468 +    Link:            .dynsym +    AddressAlign:    0x8 +    Relocations: +      - Offset:          0x3E10 +        Type:            R_X86_64_RELATIVE +        Addend:          4368 +      - Offset:          0x3E18 +        Type:            R_X86_64_RELATIVE +        Addend:          4304 +      - Offset:          0x4020 +        Type:            R_X86_64_RELATIVE +        Addend:          16416 +      - Offset:          0x3FE0 +        Symbol:          _ITM_deregisterTMCloneTable +        Type:            R_X86_64_GLOB_DAT +      - Offset:          0x3FE8 +        Symbol:          __gmon_start__ +        Type:            R_X86_64_GLOB_DAT +      - Offset:          0x3FF0 +        Symbol:          _ITM_registerTMCloneTable +        Type:            R_X86_64_GLOB_DAT +      - Offset:          0x3FF8 +        Symbol:          __cxa_finalize +        Type:            R_X86_64_GLOB_DAT +  - Name:            .rela.plt +    Type:            SHT_RELA +    Flags:           [ SHF_ALLOC, SHF_INFO_LINK ] +    Address:         0x510 +    Link:            .dynsym +    AddressAlign:    0x8 +    Info:            .got.plt +    Relocations: +      - Offset:          0x4018 +        Symbol:          puts +        Type:            R_X86_64_JUMP_SLOT +  - Name:            .init +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1000 +    AddressAlign:    0x4 +    Offset:          0x1000 +    Content:         F30F1EFA4883EC08488B05D92F00004885C07402FFD04883C408C3 +  - Name:            .plt +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1020 +    AddressAlign:    0x10 +    EntSize:         0x10 +    Content:         FF35E22F0000F2FF25E32F00000F1F00F30F1EFA6800000000F2E9E1FFFFFF90 +  - Name:            .plt.got +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1040 +    AddressAlign:    0x10 +    EntSize:         0x10 +    Content:         F30F1EFAF2FF25AD2F00000F1F440000 +  - Name:            .plt.sec +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1050 +    AddressAlign:    0x10 +    EntSize:         0x10 +    Content:         F30F1EFAF2FF25BD2F00000F1F440000 +  - Name:            .text +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1060 +    AddressAlign:    0x10 +    Content:         488D3DC12F0000488D05BA2F00004839F87415488B05662F00004885C07409FFE00F1F8000000000C30F1F8000000000488D3D912F0000488D358A2F00004829FE4889F048C1EE3F48C1F8034801C648D1FE7414488B05352F00004885C07408FFE0660F1F440000C30F1F8000000000F30F1EFA803D4D2F000000752B5548833D122F0000004889E5740C488B3D2E2F0000E849FFFFFFE864FFFFFFC605252F0000015DC30F1F00C30F1F8000000000F30F1EFAE977FFFFFFF30F1EFA554889E5488D05D80E00004889C7E820FFFFFF905DC3 +  - Name:            .fini +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC, SHF_EXECINSTR ] +    Address:         0x1134 +    AddressAlign:    0x4 +    Content:         F30F1EFA4883EC084883C408C3 +  - Name:            .rodata +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC ] +    Address:         0x2000 +    AddressAlign:    0x1 +    Offset:          0x2000 +    Content:         48656C6C6F2066726F6D205A00 +  - Name:            .eh_frame_hdr +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC ] +    Address:         0x2010 +    AddressAlign:    0x4 +    Content:         011B033B2C0000000400000010F0FFFF4800000030F0FFFF7000000040F0FFFF8800000009F1FFFFA0000000 +  - Name:            .eh_frame +    Type:            SHT_PROGBITS +    Flags:           [ SHF_ALLOC ] +    Address:         0x2040 +    AddressAlign:    0x8 +    Content:         1400000000000000017A5200017810011B0C070890010000240000001C000000C0EFFFFF20000000000E10460E184A0F0B770880003F1A3A2A332422000000001400000044000000B8EFFFFF100000000000000000000000140000005C000000B0EFFFFF1000000000000000000000001C0000007400000061F0FFFF1A00000000450E108602430D06510C070800000000000000 +  - Name:            .init_array +    Type:            SHT_INIT_ARRAY +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x3E10 +    AddressAlign:    0x8 +    EntSize:         0x8 +    Offset:          0x2E10 +    Content:         '1011000000000000' +  - Name:            .fini_array +    Type:            SHT_FINI_ARRAY +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x3E18 +    AddressAlign:    0x8 +    EntSize:         0x8 +    Content:         D010000000000000 +  - Name:            .dynamic +    Type:            SHT_DYNAMIC +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x3E20 +    Link:            .dynstr +    AddressAlign:    0x8 +    Entries: +      - Tag:             DT_NEEDED +        Value:           0x5F +      - Tag:             DT_INIT +        Value:           0x1000 +      - Tag:             DT_FINI +        Value:           0x1134 +      - Tag:             DT_INIT_ARRAY +        Value:           0x3E10 +      - Tag:             DT_INIT_ARRAYSZ +        Value:           0x8 +      - Tag:             DT_FINI_ARRAY +        Value:           0x3E18 +      - Tag:             DT_FINI_ARRAYSZ +        Value:           0x8 +      - Tag:             DT_GNU_HASH +        Value:           0x2F0 +      - Tag:             DT_STRTAB +        Value:           0x3C0 +      - Tag:             DT_SYMTAB +        Value:           0x318 +      - Tag:             DT_STRSZ +        Value:           0x75 +      - Tag:             DT_SYMENT +        Value:           0x18 +      - Tag:             DT_PLTGOT +        Value:           0x4000 +      - Tag:             DT_PLTRELSZ +        Value:           0x18 +      - Tag:             DT_PLTREL +        Value:           0x7 +      - Tag:             DT_JMPREL +        Value:           0x510 +      - Tag:             DT_RELA +        Value:           0x468 +      - Tag:             DT_RELASZ +        Value:           0xA8 +      - Tag:             DT_RELAENT +        Value:           0x18 +      - Tag:             DT_VERNEED +        Value:           0x448 +      - Tag:             DT_VERNEEDNUM +        Value:           0x1 +      - Tag:             DT_VERSYM +        Value:           0x436 +      - Tag:             DT_RELACOUNT +        Value:           0x3 +      - Tag:             DT_NULL +        Value:           0x0 +      - Tag:             DT_NULL +        Value:           0x0 +      - Tag:             DT_NULL +        Value:           0x0 +      - Tag:             DT_NULL +        Value:           0x0 +      - Tag:             DT_NULL +        Value:           0x0 +  - Name:            .got +    Type:            SHT_PROGBITS +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x3FE0 +    AddressAlign:    0x8 +    EntSize:         0x8 +    Content:         '0000000000000000000000000000000000000000000000000000000000000000' +  - Name:            .got.plt +    Type:            SHT_PROGBITS +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x4000 +    AddressAlign:    0x8 +    EntSize:         0x8 +    Content:         '203E000000000000000000000000000000000000000000003010000000000000' +  - Name:            .data +    Type:            SHT_PROGBITS +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x4020 +    AddressAlign:    0x8 +    Content:         '2040000000000000' +  - Name:            .bss +    Type:            SHT_NOBITS +    Flags:           [ SHF_WRITE, SHF_ALLOC ] +    Address:         0x4028 +    AddressAlign:    0x1 +    Size:            0x8 +  - Name:            .comment +    Type:            SHT_PROGBITS +    Flags:           [ SHF_MERGE, SHF_STRINGS ] +    AddressAlign:    0x1 +    EntSize:         0x1 +    Content:         4743433A20285562756E74752031312E342E302D317562756E7475317E32322E30342E32292031312E342E3000 +Symbols: +  - Name:            crtstuff.c +    Type:            STT_FILE +    Index:           SHN_ABS +  - Name:            deregister_tm_clones +    Type:            STT_FUNC +    Section:         .text +    Value:           0x1060 +  - Name:            register_tm_clones +    Type:            STT_FUNC +    Section:         .text +    Value:           0x1090 +  - Name:            __do_global_dtors_aux +    Type:            STT_FUNC +    Section:         .text +    Value:           0x10D0 +  - Name:            completed.0 +    Type:            STT_OBJECT +    Section:         .bss +    Value:           0x4028 +    Size:            0x1 +  - Name:            __do_global_dtors_aux_fini_array_entry +    Type:            STT_OBJECT +    Section:         .fini_array +    Value:           0x3E18 +  - Name:            frame_dummy +    Type:            STT_FUNC +    Section:         .text +    Value:           0x1110 +  - Name:            __frame_dummy_init_array_entry +    Type:            STT_OBJECT +    Section:         .init_array +    Value:           0x3E10 +  - Name:            libZ.c +    Type:            STT_FILE +    Index:           SHN_ABS +  - Name:            'crtstuff.c (1)' +    Type:            STT_FILE +    Index:           SHN_ABS +  - Name:            __FRAME_END__ +    Type:            STT_OBJECT +    Section:         .eh_frame +    Value:           0x20D0 +  - Type:            STT_FILE +    Index:           SHN_ABS +  - Name:            _fini +    Type:            STT_FUNC +    Section:         .fini +    Value:           0x1134 +  - Name:            __dso_handle +    Type:            STT_OBJECT +    Section:         .data +    Value:           0x4020 +  - Name:            _DYNAMIC +    Type:            STT_OBJECT +    Section:         .dynamic +    Value:           0x3E20 +  - Name:            __GNU_EH_FRAME_HDR +    Section:         .eh_frame_hdr +    Value:           0x2010 +  - Name:            __TMC_END__ +    Type:            STT_OBJECT +    Section:         .data +    Value:           0x4028 +  - Name:            _GLOBAL_OFFSET_TABLE_ +    Type:            STT_OBJECT +    Section:         .got.plt +    Value:           0x4000 +  - Name:            _init +    Type:            STT_FUNC +    Section:         .init +    Value:           0x1000 +  - Name:            _ITM_deregisterTMCloneTable +    Binding:         STB_WEAK +  - Name:            'puts@GLIBC_2.2.5' +    Type:            STT_FUNC +    Binding:         STB_GLOBAL +  - Name:            __gmon_start__ +    Binding:         STB_WEAK +  - Name:            sayZ +    Type:            STT_FUNC +    Section:         .text +    Binding:         STB_GLOBAL +    Value:           0x1119 +    Size:            0x1A +  - Name:            _ITM_registerTMCloneTable +    Binding:         STB_WEAK +  - Name:            '__cxa_finalize@GLIBC_2.2.5' +    Type:            STT_FUNC +    Binding:         STB_WEAK +DynamicSymbols: +  - Name:            _ITM_deregisterTMCloneTable +    Binding:         STB_WEAK +  - Name:            puts +    Type:            STT_FUNC +    Binding:         STB_GLOBAL +  - Name:            __gmon_start__ +    Binding:         STB_WEAK +  - Name:            _ITM_registerTMCloneTable +    Binding:         STB_WEAK +  - Name:            __cxa_finalize +    Type:            STT_FUNC +    Binding:         STB_WEAK +  - Name:            sayZ +    Type:            STT_FUNC +    Section:         .text +    Binding:         STB_GLOBAL +    Value:           0x1119 +    Size:            0x1A +... diff --git a/llvm/unittests/ExecutionEngine/Orc/Inputs/Z/Z_macho.yaml b/llvm/unittests/ExecutionEngine/Orc/Inputs/Z/Z_macho.yaml new file mode 100644 index 0000000..c0c1826 --- /dev/null +++ b/llvm/unittests/ExecutionEngine/Orc/Inputs/Z/Z_macho.yaml @@ -0,0 +1,723 @@ +--- !fat-mach-o +FatHeader: +  magic:           0xCAFEBABE +  nfat_arch:       3 +FatArchs: +  - cputype:         0x1000007 +    cpusubtype:      0x3 +    offset:          0x1000 +    size:            8376 +    align:           12 +  - cputype:         0x100000C +    cpusubtype:      0x0 +    offset:          0x4000 +    size:            33376 +    align:           14 +  - cputype:         0x100000C +    cpusubtype:      0x80000002 +    offset:          0x10000 +    size:            33376 +    align:           14 +Slices: +  - !mach-o +    FileHeader: +      magic:           0xFEEDFACF +      cputype:         0x1000007 +      cpusubtype:      0x3 +      filetype:        0x6 +      ncmds:           14 +      sizeofcmds:      960 +      flags:           0x100085 +      reserved:        0x0 +    LoadCommands: +      - cmd:             LC_SEGMENT_64 +        cmdsize:         392 +        segname:         __TEXT +        vmaddr:          0 +        vmsize:          4096 +        fileoff:         0 +        filesize:        4096 +        maxprot:         5 +        initprot:        5 +        nsects:          4 +        flags:           0 +        Sections: +          - sectname:        __text +            segname:         __TEXT +            addr:            0xF80 +            size:            20 +            offset:          0xF80 +            align:           4 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000400 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         554889E5488D3D0F000000B000E8020000005DC3 +          - sectname:        __stubs +            segname:         __TEXT +            addr:            0xF94 +            size:            6 +            offset:          0xF94 +            align:           1 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000408 +            reserved1:       0x0 +            reserved2:       0x6 +            reserved3:       0x0 +            content:         FF2566000000 +          - sectname:        __cstring +            segname:         __TEXT +            addr:            0xF9A +            size:            14 +            offset:          0xF9A +            align:           0 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x2 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         48656C6C6F2066726F6D205A0A00 +          - sectname:        __unwind_info +            segname:         __TEXT +            addr:            0xFA8 +            size:            88 +            offset:          0xFA8 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x0 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         010000001C000000000000001C000000000000001C00000002000000800F00004000000040000000940F00000000000040000000000000000000000000000000030000000C00010010000100000000000000000100000000 +      - cmd:             LC_SEGMENT_64 +        cmdsize:         152 +        segname:         __DATA_CONST +        vmaddr:          4096 +        vmsize:          4096 +        fileoff:         4096 +        filesize:        4096 +        maxprot:         3 +        initprot:        3 +        nsects:          1 +        flags:           16 +        Sections: +          - sectname:        __got +            segname:         __DATA_CONST +            addr:            0x1000 +            size:            8 +            offset:          0x1000 +            align:           3 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x6 +            reserved1:       0x1 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         '0000000000000080' +      - cmd:             LC_SEGMENT_64 +        cmdsize:         72 +        segname:         __LINKEDIT +        vmaddr:          8192 +        vmsize:          4096 +        fileoff:         8192 +        filesize:        184 +        maxprot:         1 +        initprot:        1 +        nsects:          0 +        flags:           0 +      - cmd:             LC_ID_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       1 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libZ.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_DYLD_CHAINED_FIXUPS +        cmdsize:         16 +        dataoff:         8192 +        datasize:        96 +      - cmd:             LC_DYLD_EXPORTS_TRIE +        cmdsize:         16 +        dataoff:         8288 +        datasize:        24 +      - cmd:             LC_SYMTAB +        cmdsize:         24 +        symoff:          8320 +        nsyms:           2 +        stroff:          8360 +        strsize:         16 +      - cmd:             LC_DYSYMTAB +        cmdsize:         80 +        ilocalsym:       0 +        nlocalsym:       0 +        iextdefsym:      0 +        nextdefsym:      1 +        iundefsym:       1 +        nundefsym:       1 +        tocoff:          0 +        ntoc:            0 +        modtaboff:       0 +        nmodtab:         0 +        extrefsymoff:    0 +        nextrefsyms:     0 +        indirectsymoff:  8352 +        nindirectsyms:   2 +        extreloff:       0 +        nextrel:         0 +        locreloff:       0 +        nlocrel:         0 +      - cmd:             LC_UUID +        cmdsize:         24 +        uuid:            399E203C-FF9A-3B80-872C-85F3A759A78B +      - cmd:             LC_BUILD_VERSION +        cmdsize:         32 +        platform:        1 +        minos:           983040 +        sdk:             983552 +        ntools:          1 +        Tools: +          - tool:            3 +            version:         73074435 +      - cmd:             LC_SOURCE_VERSION +        cmdsize:         16 +        version:         0 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         56 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 88539136 +          compatibility_version: 65536 +        Content:         '/usr/lib/libSystem.B.dylib' +        ZeroPadBytes:    6 +      - cmd:             LC_FUNCTION_STARTS +        cmdsize:         16 +        dataoff:         8312 +        datasize:        8 +      - cmd:             LC_DATA_IN_CODE +        cmdsize:         16 +        dataoff:         8320 +        datasize:        0 +    LinkEditData: +      ExportTrie: +        TerminalSize:    0 +        NodeOffset:      0 +        Name:            '' +        Flags:           0x0 +        Address:         0x0 +        Other:           0x0 +        ImportName:      '' +        Children: +          - TerminalSize:    3 +            NodeOffset:      13 +            Name:            _sayZ +            Flags:           0x0 +            Address:         0xF80 +            Other:           0x0 +            ImportName:      '' +      NameList: +        - n_strx:          2 +          n_type:          0xF +          n_sect:          1 +          n_desc:          0 +          n_value:         3968 +        - n_strx:          8 +          n_type:          0x1 +          n_sect:          0 +          n_desc:          256 +          n_value:         0 +      StringTable: +        - ' ' +        - _sayZ +        - _printf +      IndirectSymbols: [ 0x1, 0x1 ] +      FunctionStarts:  [ 0xF80 ] +      ChainedFixups:   [ 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x48,  +                         0x0, 0x0, 0x0, 0x50, 0x0, 0x0, 0x0, 0x1, 0x0,  +                         0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x18, 0x0, 0x0, 0x0, 0x0, 0x10, 0x6, 0x0,  +                         0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x2, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5F, 0x70, 0x72,  +                         0x69, 0x6E, 0x74, 0x66, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0 ] +  - !mach-o +    FileHeader: +      magic:           0xFEEDFACF +      cputype:         0x100000C +      cpusubtype:      0x0 +      filetype:        0x6 +      ncmds:           15 +      sizeofcmds:      976 +      flags:           0x100085 +      reserved:        0x0 +    LoadCommands: +      - cmd:             LC_SEGMENT_64 +        cmdsize:         392 +        segname:         __TEXT +        vmaddr:          0 +        vmsize:          16384 +        fileoff:         0 +        filesize:        16384 +        maxprot:         5 +        initprot:        5 +        nsects:          4 +        flags:           0 +        Sections: +          - sectname:        __text +            segname:         __TEXT +            addr:            0x3F70 +            size:            28 +            offset:          0x3F70 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000400 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         FD7BBFA9FD0300910000009000603E9103000094FD7BC1A8C0035FD6 +          - sectname:        __stubs +            segname:         __TEXT +            addr:            0x3F8C +            size:            12 +            offset:          0x3F8C +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000408 +            reserved1:       0x0 +            reserved2:       0xC +            reserved3:       0x0 +            content:         100000B0100240F900021FD6 +          - sectname:        __cstring +            segname:         __TEXT +            addr:            0x3F98 +            size:            14 +            offset:          0x3F98 +            align:           0 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x2 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         48656C6C6F2066726F6D205A0A00 +          - sectname:        __unwind_info +            segname:         __TEXT +            addr:            0x3FA8 +            size:            88 +            offset:          0x3FA8 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x0 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         010000001C000000000000001C000000000000001C00000002000000703F000040000000400000008C3F00000000000040000000000000000000000000000000030000000C00010010000100000000000000000400000000 +      - cmd:             LC_SEGMENT_64 +        cmdsize:         152 +        segname:         __DATA_CONST +        vmaddr:          16384 +        vmsize:          16384 +        fileoff:         16384 +        filesize:        16384 +        maxprot:         3 +        initprot:        3 +        nsects:          1 +        flags:           16 +        Sections: +          - sectname:        __got +            segname:         __DATA_CONST +            addr:            0x4000 +            size:            8 +            offset:          0x4000 +            align:           3 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x6 +            reserved1:       0x1 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         '0000000000000080' +      - cmd:             LC_SEGMENT_64 +        cmdsize:         72 +        segname:         __LINKEDIT +        vmaddr:          32768 +        vmsize:          16384 +        fileoff:         32768 +        filesize:        608 +        maxprot:         1 +        initprot:        1 +        nsects:          0 +        flags:           0 +      - cmd:             LC_ID_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       1 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libZ.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_DYLD_CHAINED_FIXUPS +        cmdsize:         16 +        dataoff:         32768 +        datasize:        96 +      - cmd:             LC_DYLD_EXPORTS_TRIE +        cmdsize:         16 +        dataoff:         32864 +        datasize:        24 +      - cmd:             LC_SYMTAB +        cmdsize:         24 +        symoff:          32896 +        nsyms:           2 +        stroff:          32936 +        strsize:         16 +      - cmd:             LC_DYSYMTAB +        cmdsize:         80 +        ilocalsym:       0 +        nlocalsym:       0 +        iextdefsym:      0 +        nextdefsym:      1 +        iundefsym:       1 +        nundefsym:       1 +        tocoff:          0 +        ntoc:            0 +        modtaboff:       0 +        nmodtab:         0 +        extrefsymoff:    0 +        nextrefsyms:     0 +        indirectsymoff:  32928 +        nindirectsyms:   2 +        extreloff:       0 +        nextrel:         0 +        locreloff:       0 +        nlocrel:         0 +      - cmd:             LC_UUID +        cmdsize:         24 +        uuid:            6E8E78AF-EDB2-3830-BE1E-013390302CC5 +      - cmd:             LC_BUILD_VERSION +        cmdsize:         32 +        platform:        1 +        minos:           983040 +        sdk:             983552 +        ntools:          1 +        Tools: +          - tool:            3 +            version:         73074435 +      - cmd:             LC_SOURCE_VERSION +        cmdsize:         16 +        version:         0 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         56 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 88539136 +          compatibility_version: 65536 +        Content:         '/usr/lib/libSystem.B.dylib' +        ZeroPadBytes:    6 +      - cmd:             LC_FUNCTION_STARTS +        cmdsize:         16 +        dataoff:         32888 +        datasize:        8 +      - cmd:             LC_DATA_IN_CODE +        cmdsize:         16 +        dataoff:         32896 +        datasize:        0 +      - cmd:             LC_CODE_SIGNATURE +        cmdsize:         16 +        dataoff:         32960 +        datasize:        416 +    LinkEditData: +      ExportTrie: +        TerminalSize:    0 +        NodeOffset:      0 +        Name:            '' +        Flags:           0x0 +        Address:         0x0 +        Other:           0x0 +        ImportName:      '' +        Children: +          - TerminalSize:    3 +            NodeOffset:      13 +            Name:            _sayZ +            Flags:           0x0 +            Address:         0x3F70 +            Other:           0x0 +            ImportName:      '' +      NameList: +        - n_strx:          2 +          n_type:          0xF +          n_sect:          1 +          n_desc:          0 +          n_value:         16240 +        - n_strx:          8 +          n_type:          0x1 +          n_sect:          0 +          n_desc:          256 +          n_value:         0 +      StringTable: +        - ' ' +        - _sayZ +        - _printf +      IndirectSymbols: [ 0x1, 0x1 ] +      FunctionStarts:  [ 0x3F70 ] +      ChainedFixups:   [ 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x48,  +                         0x0, 0x0, 0x0, 0x50, 0x0, 0x0, 0x0, 0x1, 0x0,  +                         0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x18, 0x0, 0x0, 0x0, 0x0, 0x40, 0x6, 0x0,  +                         0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x2, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5F, 0x70, 0x72,  +                         0x69, 0x6E, 0x74, 0x66, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0 ] +  - !mach-o +    FileHeader: +      magic:           0xFEEDFACF +      cputype:         0x100000C +      cpusubtype:      0x80000002 +      filetype:        0x6 +      ncmds:           15 +      sizeofcmds:      976 +      flags:           0x100085 +      reserved:        0x0 +    LoadCommands: +      - cmd:             LC_SEGMENT_64 +        cmdsize:         392 +        segname:         __TEXT +        vmaddr:          0 +        vmsize:          16384 +        fileoff:         0 +        filesize:        16384 +        maxprot:         5 +        initprot:        5 +        nsects:          4 +        flags:           0 +        Sections: +          - sectname:        __text +            segname:         __TEXT +            addr:            0x3F68 +            size:            32 +            offset:          0x3F68 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000400 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         7F2303D5FD7BBFA9FD0300910000009000603E9103000094FD7BC1A8FF0F5FD6 +          - sectname:        __auth_stubs +            segname:         __TEXT +            addr:            0x3F88 +            size:            16 +            offset:          0x3F88 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x80000408 +            reserved1:       0x0 +            reserved2:       0x10 +            reserved3:       0x0 +            content:         110000B031020091300240F9110A1FD7 +          - sectname:        __cstring +            segname:         __TEXT +            addr:            0x3F98 +            size:            14 +            offset:          0x3F98 +            align:           0 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x2 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         48656C6C6F2066726F6D205A0A00 +          - sectname:        __unwind_info +            segname:         __TEXT +            addr:            0x3FA8 +            size:            88 +            offset:          0x3FA8 +            align:           2 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x0 +            reserved1:       0x0 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         010000001C000000000000001C000000000000001C00000002000000683F00004000000040000000883F00000000000040000000000000000000000000000000030000000C00010010000100000000000000000400000000 +      - cmd:             LC_SEGMENT_64 +        cmdsize:         152 +        segname:         __DATA_CONST +        vmaddr:          16384 +        vmsize:          16384 +        fileoff:         16384 +        filesize:        16384 +        maxprot:         3 +        initprot:        3 +        nsects:          1 +        flags:           16 +        Sections: +          - sectname:        __auth_got +            segname:         __DATA_CONST +            addr:            0x4000 +            size:            8 +            offset:          0x4000 +            align:           3 +            reloff:          0x0 +            nreloc:          0 +            flags:           0x6 +            reserved1:       0x1 +            reserved2:       0x0 +            reserved3:       0x0 +            content:         00000000000001C0 +      - cmd:             LC_SEGMENT_64 +        cmdsize:         72 +        segname:         __LINKEDIT +        vmaddr:          32768 +        vmsize:          16384 +        fileoff:         32768 +        filesize:        608 +        maxprot:         1 +        initprot:        1 +        nsects:          0 +        flags:           0 +      - cmd:             LC_ID_DYLIB +        cmdsize:         48 +        dylib: +          name:            24 +          timestamp:       1 +          current_version: 0 +          compatibility_version: 0 +        Content:         '@rpath/libZ.dylib' +        ZeroPadBytes:    7 +      - cmd:             LC_DYLD_CHAINED_FIXUPS +        cmdsize:         16 +        dataoff:         32768 +        datasize:        96 +      - cmd:             LC_DYLD_EXPORTS_TRIE +        cmdsize:         16 +        dataoff:         32864 +        datasize:        24 +      - cmd:             LC_SYMTAB +        cmdsize:         24 +        symoff:          32896 +        nsyms:           2 +        stroff:          32936 +        strsize:         16 +      - cmd:             LC_DYSYMTAB +        cmdsize:         80 +        ilocalsym:       0 +        nlocalsym:       0 +        iextdefsym:      0 +        nextdefsym:      1 +        iundefsym:       1 +        nundefsym:       1 +        tocoff:          0 +        ntoc:            0 +        modtaboff:       0 +        nmodtab:         0 +        extrefsymoff:    0 +        nextrefsyms:     0 +        indirectsymoff:  32928 +        nindirectsyms:   2 +        extreloff:       0 +        nextrel:         0 +        locreloff:       0 +        nlocrel:         0 +      - cmd:             LC_UUID +        cmdsize:         24 +        uuid:            E74F368D-238F-31FA-BF40-FA2964FED986 +      - cmd:             LC_BUILD_VERSION +        cmdsize:         32 +        platform:        1 +        minos:           983040 +        sdk:             983552 +        ntools:          1 +        Tools: +          - tool:            3 +            version:         73074435 +      - cmd:             LC_SOURCE_VERSION +        cmdsize:         16 +        version:         0 +      - cmd:             LC_LOAD_DYLIB +        cmdsize:         56 +        dylib: +          name:            24 +          timestamp:       2 +          current_version: 88539136 +          compatibility_version: 65536 +        Content:         '/usr/lib/libSystem.B.dylib' +        ZeroPadBytes:    6 +      - cmd:             LC_FUNCTION_STARTS +        cmdsize:         16 +        dataoff:         32888 +        datasize:        8 +      - cmd:             LC_DATA_IN_CODE +        cmdsize:         16 +        dataoff:         32896 +        datasize:        0 +      - cmd:             LC_CODE_SIGNATURE +        cmdsize:         16 +        dataoff:         32960 +        datasize:        416 +    LinkEditData: +      ExportTrie: +        TerminalSize:    0 +        NodeOffset:      0 +        Name:            '' +        Flags:           0x0 +        Address:         0x0 +        Other:           0x0 +        ImportName:      '' +        Children: +          - TerminalSize:    3 +            NodeOffset:      13 +            Name:            _sayZ +            Flags:           0x0 +            Address:         0x3F68 +            Other:           0x0 +            ImportName:      '' +      NameList: +        - n_strx:          2 +          n_type:          0xF +          n_sect:          1 +          n_desc:          0 +          n_value:         16232 +        - n_strx:          8 +          n_type:          0x1 +          n_sect:          0 +          n_desc:          256 +          n_value:         0 +      StringTable: +        - ' ' +        - _sayZ +        - _printf +      IndirectSymbols: [ 0x1, 0x1 ] +      FunctionStarts:  [ 0x3F68 ] +      ChainedFixups:   [ 0x0, 0x0, 0x0, 0x0, 0x20, 0x0, 0x0, 0x0, 0x48,  +                         0x0, 0x0, 0x0, 0x50, 0x0, 0x0, 0x0, 0x1, 0x0,  +                         0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x10, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x18, 0x0, 0x0, 0x0, 0x0, 0x40, 0xC, 0x0,  +                         0x0, 0x40, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0, 0x1, 0x0, 0x0, 0x0, 0x1, 0x2, 0x0,  +                         0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x5F, 0x70, 0x72,  +                         0x69, 0x6E, 0x74, 0x66, 0x0, 0x0, 0x0, 0x0, 0x0,  +                         0x0, 0x0, 0x0 ] +... diff --git a/llvm/unittests/ExecutionEngine/Orc/LibraryResolverTest.cpp b/llvm/unittests/ExecutionEngine/Orc/LibraryResolverTest.cpp new file mode 100644 index 0000000..2a396da --- /dev/null +++ b/llvm/unittests/ExecutionEngine/Orc/LibraryResolverTest.cpp @@ -0,0 +1,764 @@ +//===- LibraryResolverTest.cpp - Unit tests for LibraryResolver -===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "llvm/ExecutionEngine/Orc/TargetProcess/LibraryResolver.h" +#include "llvm/ExecutionEngine/Orc/JITTargetMachineBuilder.h" +#include "llvm/ExecutionEngine/Orc/TargetProcess/LibraryScanner.h" +#include "llvm/ObjectYAML/MachOYAML.h" +#include "llvm/ObjectYAML/yaml2obj.h" +#include "llvm/Support/FileSystem.h" +#include "llvm/Support/MemoryBuffer.h" +#include "llvm/Support/Path.h" +#include "llvm/Support/YAMLParser.h" +#include "llvm/Support/YAMLTraits.h" +#include "llvm/Support/raw_ostream.h" + +#include "llvm/Testing/Support/SupportHelpers.h" + +#include "gtest/gtest.h" + +#include <algorithm> +#include <optional> +#include <string> +#include <vector> + +using namespace llvm; +using namespace llvm::orc; + +// Disabled due to test setup issue — YAML to shared library creation seems +// invalid on some build bots. (PR #165360) Not related to code logic. +#if 0 +// TODO: Add COFF (Windows) support for these tests. +// this facility also works correctly on Windows (COFF), +// so we should eventually enable and run these tests for that platform as well. +namespace { + +#if defined(__APPLE__) +constexpr const char *ext = ".dylib"; +#elif defined(_WIN32) +constexpr const char *ext = ".dll"; +#else +constexpr const char *ext = ".so"; +#endif + +bool EnvReady = false; + +Triple getTargetTriple() { +  auto JTMB = JITTargetMachineBuilder::detectHost(); +  if (!JTMB) { +    consumeError(JTMB.takeError()); +    return Triple(); +  } +  return JTMB->getTargetTriple(); +} + +static bool CheckHostSupport() { +  auto Triple = getTargetTriple(); +  // TODO: Extend support to COFF (Windows) once test setup and YAML conversion +  // are verified. +  if (!Triple.isOSBinFormatMachO() && +      !(Triple.isOSBinFormatELF() && Triple.getArch() == Triple::x86_64)) +    return false; + +  return true; +} + +std::string getYamlFilePlatformExt() { +  auto Triple = getTargetTriple(); +  if (Triple.isOSBinFormatMachO()) +    return "_macho"; +  else if (Triple.isOSBinFormatELF()) +    return "_linux"; + +  return ""; +} + +unsigned getYamlDocNum() { +  // auto Triple = getTargetTriple(); +  // if (Triple.isOSBinFormatELF()) +  //   return 1; + +  return 1; +} + +class LibraryTestEnvironment : public ::testing::Environment { +  std::vector<std::string> CreatedDylibsDir; +  std::vector<std::string> CreatedDylibs; +  SmallVector<char, 128> DirPath; + +public: +  void SetUp() override { +    if (!CheckHostSupport()) { +      EnvReady = false; +      return; +    } + +    StringRef ThisFile = __FILE__; +    SmallVector<char, 128> InputDirPath(ThisFile.begin(), ThisFile.end()); +    sys::path::remove_filename(InputDirPath); +    sys::path::append(InputDirPath, "Inputs"); +    if (!sys::fs::exists(InputDirPath)) +      return; + +    SmallString<128> UniqueDir; +    sys::path::append(UniqueDir, InputDirPath); +    std::error_code EC = sys::fs::createUniqueDirectory(UniqueDir, DirPath); + +    if (EC) +      return; + +    // given yamlPath + DylibPath, validate + convert +    auto processYamlToDylib = [&](const SmallVector<char, 128> &YamlPath, +                                  const SmallVector<char, 128> &DylibPath, +                                  unsigned DocNum) -> bool { +      if (!sys::fs::exists(YamlPath)) { +        errs() << "YAML file missing: " +               << StringRef(YamlPath.data(), YamlPath.size()) << "\n"; +        EnvReady = false; +        return false; +      } + +      auto BufOrErr = MemoryBuffer::getFile(YamlPath); +      if (!BufOrErr) { +        errs() << "Failed to read " +               << StringRef(YamlPath.data(), YamlPath.size()) << ": " +               << BufOrErr.getError().message() << "\n"; +        EnvReady = false; +        return false; +      } + +      yaml::Input yin(BufOrErr->get()->getBuffer()); +      std::error_code EC; +      raw_fd_ostream outFile(StringRef(DylibPath.data(), DylibPath.size()), EC, +                             sys::fs::OF_None); + +      if (EC) { +        errs() << "Failed to open " +               << StringRef(DylibPath.data(), DylibPath.size()) +               << " for writing: " << EC.message() << "\n"; +        EnvReady = false; +        return false; +      } + +      if (!yaml::convertYAML( +              yin, outFile, +              [](const Twine &M) { +                // Handle or ignore errors here +                errs() << "Yaml Error :" << M << "\n"; +              }, +              DocNum)) { +        errs() << "Failed to convert " +               << StringRef(YamlPath.data(), YamlPath.size()) << " to " +               << StringRef(DylibPath.data(), DylibPath.size()) << "\n"; +        EnvReady = false; +        return false; +      } + +      CreatedDylibsDir.push_back(std::string(sys::path::parent_path( +          StringRef(DylibPath.data(), DylibPath.size())))); +      CreatedDylibs.push_back(std::string(DylibPath.begin(), DylibPath.end())); +      return true; +    }; + +    std::vector<const char *> LibDirs = {"Z", "A", "B", "C"}; + +    unsigned DocNum = getYamlDocNum(); +    std::string YamlPltExt = getYamlFilePlatformExt(); +    for (const auto &LibdirName : LibDirs) { +      // YAML path +      SmallVector<char, 128> YamlPath(InputDirPath.begin(), InputDirPath.end()); +      SmallVector<char, 128> YamlFileName; +      YamlFileName.append(LibdirName, LibdirName + strlen(LibdirName)); +      YamlFileName.append(YamlPltExt.begin(), YamlPltExt.end()); +      sys::path::append(YamlPath, LibdirName, YamlFileName); +      sys::path::replace_extension(YamlPath, ".yaml"); + +      // dylib path +      SmallVector<char, 128> DylibPath(DirPath.begin(), DirPath.end()); +      SmallVector<char, 128> DylibFileName; +      StringRef prefix("lib"); +      DylibFileName.append(prefix.begin(), prefix.end()); +      DylibFileName.append(LibdirName, LibdirName + strlen(LibdirName)); + +      sys::path::append(DylibPath, LibdirName); +      if (!sys::fs::exists(DylibPath)) { +        auto EC = sys::fs::create_directory(DylibPath); +        if (EC) +          return; +      } +      sys::path::append(DylibPath, DylibFileName); +      sys::path::replace_extension(DylibPath, ext); +      if (!processYamlToDylib(YamlPath, DylibPath, DocNum)) +        return; +    } + +    EnvReady = true; +  } + +  void TearDown() override { sys::fs::remove_directories(DirPath); } + +  std::string getBaseDir() const { +    return std::string(DirPath.begin(), DirPath.end()); +  } + +  std::vector<std::string> getDylibPaths() const { return CreatedDylibs; } +}; + +static LibraryTestEnvironment *GlobalEnv = +    static_cast<LibraryTestEnvironment *>( +        ::testing::AddGlobalTestEnvironment(new LibraryTestEnvironment())); + +inline std::string libPath(const std::string &BaseDir, +                           const std::string &name) { +#if defined(__APPLE__) +  return BaseDir + "/" + name + ".dylib"; +#elif defined(_WIN32) +  return BaseDir + "/" + name + ".dll"; +#else +  return BaseDir + "/" + name + ".so"; +#endif +} + +inline std::string withext(const std::string &lib) { +  SmallString<128> P(lib); +  sys::path::replace_extension(P, ext); +  return P.str().str(); +} + +inline std::string platformSymbolName(const std::string &name) { +#if defined(__APPLE__) +  return "_" + name; // macOS prepends underscore +#else +  return name; +#endif +} + +struct TestLibrary { +  std::string path; +  std::vector<std::string> Syms; +}; + +class LibraryResolverIT : public ::testing::Test { +protected: +  std::string BaseDir; +  std::unordered_map<std::string, TestLibrary> libs; + +  void addLib(const std::string &name) { +    SmallString<512> path; +    std::error_code EC = +        sys::fs::real_path(libPath(BaseDir, name + "/lib" + name), path); +    if (EC || path.empty() || !sys::fs::exists(path)) +      GTEST_SKIP(); +    libs[name] = {path.str().str(), {platformSymbolName("say" + name)}}; +  } + +  void SetUp() override { +    if (!EnvReady || GlobalEnv == nullptr) +      GTEST_SKIP() << "Skipping test: environment setup failed."; + +    { +      SmallString<512> path; +      std::error_code EC = sys::fs::real_path(GlobalEnv->getBaseDir(), path); +      if (path.empty() || EC) +        GTEST_SKIP() << "Base directory resolution failed: " << EC.message(); +      BaseDir = path.str().str(); +    } + +    for (const auto &P : GlobalEnv->getDylibPaths()) { +      if (!sys::fs::exists(P)) +        GTEST_SKIP() << "Missing dylib path: " << P; +    } + +    const std::vector<std::string> libNames = {"A", "B", "C", "Z"}; +    for (const auto &name : libNames) +      addLib(name); + +    if (!EnvReady) +      GTEST_SKIP() << "Skipping test: environment setup failed."; +  } + +  const std::vector<std::string> &sym(const std::string &key) { +    return libs[key].Syms; +  } +  const std::string &lib(const std::string &key) { return libs[key].path; } +  const std::string libdir(const std::string &key) { +    SmallString<512> P(libs[key].path); +    sys::path::remove_filename(P); +    return P.str().str(); +  } +  const std::string libname(const std::string &key) { +    return sys::path::filename(libs[key].path).str(); +  } +}; + +// Helper: allow either "sayA" or "_sayA" depending on how your +// SymbolEnumerator reports. +static bool matchesEitherUnderscore(const std::string &got, +                                    const std::string &bare) { +  return got == bare || got == ("_" + bare); +} + +// Helper: normalize path ending check (we only care that it resolved to the +// right dylib) +static bool endsWith(const std::string &s, const std::string &suffix) { +  if (s.size() < suffix.size()) +    return false; +  return std::equal(suffix.rbegin(), suffix.rend(), s.rbegin()); +} + +TEST_F(LibraryResolverIT, EnumerateSymbols_ExportsOnly_DefaultFlags) { +  const std::string libC = lib("C"); +  SymbolEnumeratorOptions Opts = SymbolEnumeratorOptions::defaultOptions(); + +  std::vector<std::string> seen; +  auto onEach = [&](llvm::StringRef sym) -> EnumerateResult { +    seen.emplace_back(sym.str()); +    return EnumerateResult::Continue; +  }; + +  ASSERT_TRUE(SymbolEnumerator::enumerateSymbols(libC, onEach, Opts)); + +  // sayC is exported, others are undefined → only sayC expected +  EXPECT_TRUE(any_of(seen, [&](const std::string &s) { +    return matchesEitherUnderscore(s, "sayC"); +  })); +  EXPECT_FALSE(any_of(seen, [&](const std::string &s) { +    return matchesEitherUnderscore(s, "sayA"); +  })); +  EXPECT_FALSE(any_of(seen, [&](const std::string &s) { +    return matchesEitherUnderscore(s, "sayB"); +  })); +} + +TEST_F(LibraryResolverIT, EnumerateSymbols_IncludesUndefineds) { +  const std::string libC = lib("C"); + +  SymbolEnumeratorOptions Opts; +  Opts.FilterFlags = +      SymbolEnumeratorOptions::IgnoreWeak | +      SymbolEnumeratorOptions::IgnoreIndirect; // no IgnoreUndefined + +  std::vector<std::string> seen; +  auto onEach = [&](llvm::StringRef sym) -> EnumerateResult { +    seen.emplace_back(sym.str()); +    return EnumerateResult::Continue; +  }; + +  ASSERT_TRUE(SymbolEnumerator::enumerateSymbols(libC, onEach, Opts)); + +  // Now we should see both sayC (export) and the undefined refs sayA, sayB, +  // sayZ +  EXPECT_TRUE(any_of(seen, [&](const std::string &s) { +    return matchesEitherUnderscore(s, "sayC"); +  })); +  EXPECT_TRUE(any_of(seen, [&](const std::string &s) { +    return matchesEitherUnderscore(s, "sayA"); +  })); +  EXPECT_TRUE(any_of(seen, [&](const std::string &s) { +    return matchesEitherUnderscore(s, "sayB"); +  })); +} + +// Full resolution via LibraryResolutionDriver/LibraryResolver --- +TEST_F(LibraryResolverIT, DriverResolvesSymbolsToCorrectLibraries) { +  // Create the resolver from real base paths (our fixtures dir) +  auto Stup = LibraryResolver::Setup::create({BaseDir}); + +  // Full system behavior: no mocks +  auto Driver = LibraryResolutionDriver::create(Stup); +  ASSERT_NE(Driver, nullptr); + +  // Tell the Driver about the scan path kinds (User/System) as your +  // production code expects. +  Driver->addScanPath(libdir("A"), PathType::User); +  Driver->addScanPath(libdir("B"), PathType::User); +  Driver->addScanPath(libdir("Z"), PathType::User); + +  // Symbols to resolve (bare names; class handles underscore differences +  // internally) +  std::vector<std::string> Syms = {platformSymbolName("sayA"), +                                   platformSymbolName("sayB"), +                                   platformSymbolName("sayZ")}; + +  bool CallbackRan = false; +  Driver->resolveSymbols(Syms, [&](SymbolQuery &Q) { +    CallbackRan = true; + +    // sayA should resolve to A.dylib +    { +      auto lib = Q.getResolvedLib(platformSymbolName("sayA")); +      ASSERT_TRUE(lib.has_value()) << "sayA should be resolved"; +      EXPECT_TRUE(endsWith(lib->str(), libname("A"))) +          << "sayA resolved to: " << lib->str(); +    } + +    // sayB should resolve to B.dylib +    { +      auto lib = Q.getResolvedLib(platformSymbolName("sayB")); +      ASSERT_TRUE(lib.has_value()) << "sayB should be resolved"; +      EXPECT_TRUE(endsWith(lib->str(), libname("B"))) +          << "sayB resolved to: " << lib->str(); +    } + +    // sayZ should resolve to B.dylib +    { +      auto lib = Q.getResolvedLib(platformSymbolName("sayZ")); +      ASSERT_TRUE(lib.has_value()) << "sayZ should be resolved"; +      EXPECT_TRUE(endsWith(lib->str(), libname("Z"))) +          << "sayZ resolved to: " << lib->str(); +    } + +    EXPECT_TRUE(Q.allResolved()); +  }); + +  EXPECT_TRUE(CallbackRan); +} + +// stress SymbolQuery with the real resolve flow +// And resolve libC dependency libA, libB, libZ --- +TEST_F(LibraryResolverIT, ResolveManySymbols) { +  auto Stup = LibraryResolver::Setup::create({BaseDir}); +  auto Driver = LibraryResolutionDriver::create(Stup); +  ASSERT_NE(Driver, nullptr); +  Driver->addScanPath(libdir("C"), PathType::User); + +  // Many duplicates to provoke concurrent updates inside SymbolQuery +  std::vector<std::string> Syms = { +      platformSymbolName("sayA"), platformSymbolName("sayB"), +      platformSymbolName("sayA"), platformSymbolName("sayB"), +      platformSymbolName("sayZ"), platformSymbolName("sayZ"), +      platformSymbolName("sayZ"), platformSymbolName("sayZ"), +      platformSymbolName("sayA"), platformSymbolName("sayB"), +      platformSymbolName("sayA"), platformSymbolName("sayB")}; + +  bool CallbackRan = false; +  Driver->resolveSymbols(Syms, [&](SymbolQuery &Q) { +    CallbackRan = true; +    EXPECT_TRUE(Q.isResolved(platformSymbolName("sayA"))); +    EXPECT_TRUE(Q.isResolved(platformSymbolName("sayB"))); +    EXPECT_TRUE(Q.isResolved(platformSymbolName("sayZ"))); + +    auto A = Q.getResolvedLib(platformSymbolName("sayA")); +    auto B = Q.getResolvedLib(platformSymbolName("sayB")); +    auto Z = Q.getResolvedLib(platformSymbolName("sayZ")); +    ASSERT_TRUE(A.has_value()); +    ASSERT_TRUE(B.has_value()); +    ASSERT_TRUE(Z.has_value()); +    EXPECT_TRUE(endsWith(A->str(), libname("A"))); +    EXPECT_TRUE(endsWith(B->str(), libname("B"))); +    EXPECT_TRUE(endsWith(Z->str(), libname("Z"))); +    EXPECT_TRUE(Q.allResolved()); +  }); + +  EXPECT_TRUE(CallbackRan); +} + +TEST_F(LibraryResolverIT, ScanAndResolveDependencyGraph) { +  auto LibPathCache = std::make_shared<LibraryPathCache>(); +  auto PResolver = std::make_shared<PathResolver>(LibPathCache); +  LibraryScanHelper ScanH({}, LibPathCache, PResolver); + +  ScanH.addBasePath(libdir("C"), PathType::User); + +  LibraryManager LibMgr; +  LibraryScanner Scanner(ScanH, LibMgr); + +  Scanner.scanNext(PathType::User, 0); + +  size_t numLibs = 0; +  LibMgr.forEachLibrary([&](const LibraryInfo &L) { +    numLibs++; +    return true; +  }); + +  EXPECT_GT(numLibs, 0u) << "Expected at least one library scanned"; + +  // Validate that each scanned library path is resolvable +  std::error_code EC; +  LibMgr.forEachLibrary([&](const LibraryInfo &L) { +    auto R = PResolver->resolve(L.getFullPath(), EC); +    EXPECT_TRUE(R.has_value()); +    EXPECT_FALSE(EC); +    return true; +  }); +} + +TEST_F(LibraryResolverIT, ScanEmptyPath) { +  auto LibPathCache = std::make_shared<LibraryPathCache>(); +  auto PResolver = std::make_shared<PathResolver>(LibPathCache); +  LibraryScanHelper ScanH({}, LibPathCache, PResolver); + +  ScanH.addBasePath("/tmp/empty", PathType::User); + +  LibraryManager LibMgr; +  LibraryScanner Scanner(ScanH, LibMgr); + +  Scanner.scanNext(PathType::User, 0); + +  size_t count = 0; +  LibMgr.forEachLibrary([&](const LibraryInfo &) { +    count++; +    return true; +  }); +  EXPECT_EQ(count, 0u); +} + +TEST_F(LibraryResolverIT, PathResolverResolvesKnownPaths) { +  auto LibPathCache = std::make_shared<LibraryPathCache>(); +  auto PResolver = std::make_shared<PathResolver>(LibPathCache); + +  std::error_code EC; +  auto Missing = PResolver->resolve("temp/foo/bar", EC); +  EXPECT_FALSE(Missing.has_value()) << "Unexpectedly resolved a bogus path"; +  EXPECT_TRUE(EC) << "Expected error resolving path"; + +  auto DirPath = PResolver->resolve(BaseDir, EC); +  ASSERT_TRUE(DirPath.has_value()); +  EXPECT_FALSE(EC) << "Expected no error resolving path"; +  EXPECT_EQ(*DirPath, BaseDir); + +  auto DylibPath = PResolver->resolve(lib("C"), EC); +  ASSERT_TRUE(DylibPath.has_value()); +  EXPECT_FALSE(EC) << "Expected no error resolving path"; +  EXPECT_EQ(*DylibPath, lib("C")); +} + +TEST_F(LibraryResolverIT, PathResolverNormalizesDotAndDotDot) { +  auto LibPathCache = std::make_shared<LibraryPathCache>(); +  auto PResolver = std::make_shared<PathResolver>(LibPathCache); + +  std::error_code EC; + +  // e.g. BaseDir + "/./C/../C/C.dylib" → BaseDir + "/C.dylib" +  std::string Messy = BaseDir + "/C/./../C/./libC" + ext; +  auto Resolved = PResolver->resolve(Messy, EC); +  ASSERT_TRUE(Resolved.has_value()); +  EXPECT_FALSE(EC); +  EXPECT_EQ(*Resolved, lib("C")) << "Expected realpath to collapse . and .."; +} + +#if !defined(_WIN32) +TEST_F(LibraryResolverIT, PathResolverFollowsSymlinks) { +  auto LibPathCache = std::make_shared<LibraryPathCache>(); +  auto PResolver = std::make_shared<PathResolver>(LibPathCache); + +  std::error_code EC; + +  // Create a symlink temp -> BaseDir (only if filesystem allows it) +  std::string linkName = BaseDir + withext("/link_to_C"); +  std::string target = lib("C"); +  if (::symlink(target.c_str(), linkName.c_str()) != 0) +    GTEST_SKIP() << "Failed to create symlink: " << strerror(errno); + +  auto resolved = PResolver->resolve(linkName, EC); +  ASSERT_TRUE(resolved.has_value()); +  EXPECT_FALSE(EC); +  EXPECT_EQ(*resolved, target); + +  (void)::unlink(linkName.c_str()); // cleanup +} + +TEST_F(LibraryResolverIT, PathResolverCachesResults) { +  auto LibPathCache = std::make_shared<LibraryPathCache>(); +  auto PResolver = std::make_shared<PathResolver>(LibPathCache); + +  SmallString<128> TmpDylib; +  std::error_code EC; +  EC = sys::fs::createUniqueFile(withext("A-copy"), TmpDylib); +  if (EC) +    GTEST_SKIP() << "Failed to create temp dylib" << EC.message(); + +  EC = sys::fs::copy_file(lib("A"), TmpDylib); +  if (EC) +    GTEST_SKIP() << "Failed to copy libA: " << EC.message(); +  EC.clear(); + +  // First resolve -> should populate LibPathCache +  auto first = PResolver->resolve(TmpDylib, EC); +  ASSERT_TRUE(first.has_value()); + +  // Forcefully remove the file from disk +  (void)::unlink(TmpDylib.c_str()); + +  // Second resolve -> should still succeed from LibPathCache +  auto second = PResolver->resolve(TmpDylib, EC); +  EXPECT_TRUE(second.has_value()); +  EXPECT_EQ(*second, *first); +} +#endif + +TEST_F(LibraryResolverIT, LoaderPathSubstitutionAndResolve) { +  auto LibPathCache = std::make_shared<LibraryPathCache>(); +  auto PResolver = std::make_shared<PathResolver>(LibPathCache); + +  DylibSubstitutor substitutor; +  substitutor.configure(libdir("C")); +#if defined(__APPLE__) +  // Substitute @loader_path with BaseDir +  std::string substituted = +      substitutor.substitute(withext("@loader_path/libC")); +#elif defined(__linux__) +  // Substitute $origin with BaseDir +  std::string substituted = substitutor.substitute(withext("$ORIGIN/libC")); +#endif +  ASSERT_FALSE(substituted.empty()); +  EXPECT_EQ(substituted, lib("C")); + +  // Now try resolving the substituted path +  std::error_code EC; +  auto resolved = PResolver->resolve(substituted, EC); +  ASSERT_TRUE(resolved.has_value()) << "Expected to resolve substituted dylib"; +  EXPECT_EQ(*resolved, lib("C")); +  EXPECT_FALSE(EC) << "Expected no error resolving substituted dylib"; +} + +TEST_F(LibraryResolverIT, ResolveFromUsrOrSystemPaths) { +  auto LibPathCache = std::make_shared<LibraryPathCache>(); +  auto PResolver = std::make_shared<PathResolver>(LibPathCache); + +  DylibPathValidator validator(*PResolver); + +  std::vector<std::string> Paths = {"/foo/bar/", "temp/foo",  libdir("C"), +                                    libdir("A"), libdir("B"), libdir("Z")}; + +  SmallVector<StringRef> P(Paths.begin(), Paths.end()); + +  DylibResolver Resolver(validator); +  Resolver.configure("", {{P, SearchPathType::UsrOrSys}}); + +  // Check "C" +  auto ValOptC = Resolver.resolve("libC", true); +  EXPECT_TRUE(ValOptC.has_value()); +  EXPECT_EQ(*ValOptC, lib("C")); + +  auto ValOptCdylib = Resolver.resolve(withext("libC")); +  EXPECT_TRUE(ValOptCdylib.has_value()); +  EXPECT_EQ(*ValOptCdylib, lib("C")); + +  // Check "A" +  auto ValOptA = Resolver.resolve("libA", true); +  EXPECT_TRUE(ValOptA.has_value()); +  EXPECT_EQ(*ValOptA, lib("A")); + +  auto ValOptAdylib = Resolver.resolve(withext("libA")); +  EXPECT_TRUE(ValOptAdylib.has_value()); +  EXPECT_EQ(*ValOptAdylib, lib("A")); + +  // Check "B" +  auto ValOptB = Resolver.resolve("libB", true); +  EXPECT_TRUE(ValOptB.has_value()); +  EXPECT_EQ(*ValOptB, lib("B")); + +  auto ValOptBdylib = Resolver.resolve(withext("libB")); +  EXPECT_TRUE(ValOptBdylib.has_value()); +  EXPECT_EQ(*ValOptBdylib, lib("B")); + +  // Check "Z" +  auto ValOptZ = Resolver.resolve("libZ", true); +  EXPECT_TRUE(ValOptZ.has_value()); +  EXPECT_EQ(*ValOptZ, lib("Z")); + +  auto ValOptZdylib = Resolver.resolve(withext("libZ")); +  EXPECT_TRUE(ValOptZdylib.has_value()); +  EXPECT_EQ(*ValOptZdylib, lib("Z")); +} + +#if defined(__APPLE__) +TEST_F(LibraryResolverIT, ResolveViaLoaderPathAndRPathSubstitution) { +  auto LibPathCache = std::make_shared<LibraryPathCache>(); +  auto PResolver = std::make_shared<PathResolver>(LibPathCache); + +  DylibPathValidator validator(*PResolver); + +  std::vector<std::string> Paths = {"@loader_path/../A", "@loader_path/../B", +                                    "@loader_path/../C", "@loader_path/../Z"}; + +  SmallVector<StringRef> P(Paths.begin(), Paths.end()); + +  DylibResolver Resolver(validator); + +  // Use only RPath config +  Resolver.configure(lib("C"), {{P, SearchPathType::RPath}}); + +  // --- Check A --- +  auto ValOptA = Resolver.resolve("@rpath/libA", true); +  EXPECT_TRUE(ValOptA.has_value()); +  EXPECT_EQ(*ValOptA, lib("A")); + +  auto ValOptAdylib = Resolver.resolve(withext("@rpath/libA")); +  EXPECT_TRUE(ValOptAdylib.has_value()); +  EXPECT_EQ(*ValOptAdylib, lib("A")); + +  // --- Check B --- +  auto ValOptB = Resolver.resolve("@rpath/libB", true); +  EXPECT_TRUE(ValOptB.has_value()); +  EXPECT_EQ(*ValOptB, lib("B")); + +  auto ValOptBdylib = Resolver.resolve(withext("@rpath/libB")); +  EXPECT_TRUE(ValOptBdylib.has_value()); +  EXPECT_EQ(*ValOptBdylib, lib("B")); + +  // --- Check Z --- +  auto ValOptZ = Resolver.resolve("@rpath/libZ", true); +  EXPECT_TRUE(ValOptZ.has_value()); +  EXPECT_EQ(*ValOptZ, lib("Z")); + +  auto ValOptZdylib = Resolver.resolve(withext("@rpath/libZ")); +  EXPECT_TRUE(ValOptZdylib.has_value()); +  EXPECT_EQ(*ValOptZdylib, lib("Z")); +} +#endif + +#if defined(__linux__) +TEST_F(LibraryResolverIT, ResolveViaOriginAndRPathSubstitution) { +  auto LibPathCache = std::make_shared<LibraryPathCache>(); +  auto PResolver = std::make_shared<PathResolver>(LibPathCache); + +  DylibPathValidator validator(*PResolver); + +  // On Linux, $ORIGIN works like @loader_path +  std::vector<std::string> Paths = {"$ORIGIN/../A", "$ORIGIN/../B", +                                    "$ORIGIN/../C", "$ORIGIN/../Z"}; + +  SmallVector<StringRef> P(Paths.begin(), Paths.end()); + +  DylibResolver Resolver(validator); + +  // Use only RPath config +  Resolver.configure(lib("C"), {{P, SearchPathType::RunPath}}); + +  // --- Check A --- +  auto ValOptA = Resolver.resolve("libA", true); +  EXPECT_TRUE(ValOptA.has_value()); +  EXPECT_EQ(*ValOptA, lib("A")); + +  auto valOptASO = Resolver.resolve(withext("libA")); +  EXPECT_TRUE(valOptASO.has_value()); +  EXPECT_EQ(*valOptASO, lib("A")); + +  // --- Check B --- +  auto ValOptB = Resolver.resolve("libB", true); +  EXPECT_TRUE(ValOptB.has_value()); +  EXPECT_EQ(*ValOptB, lib("B")); + +  auto valOptBSO = Resolver.resolve(withext("libB")); +  EXPECT_TRUE(valOptBSO.has_value()); +  EXPECT_EQ(*valOptBSO, lib("B")); + +  // --- Check Z --- +  auto ValOptZ = Resolver.resolve("libZ", true); +  EXPECT_TRUE(ValOptZ.has_value()); +  EXPECT_EQ(*ValOptZ, lib("Z")); + +  auto valOptZSO = Resolver.resolve(withext("libZ")); +  EXPECT_TRUE(valOptZSO.has_value()); +  EXPECT_EQ(*valOptZSO, lib("Z")); +} +#endif +} // namespace +#endif // defined(__APPLE__)  | 
