Index: lld/trunk/test/COFF/Inputs/delayimporttables-dll1.yaml =================================================================== --- lld/trunk/test/COFF/Inputs/delayimporttables-dll1.yaml +++ lld/trunk/test/COFF/Inputs/delayimporttables-dll1.yaml @@ -0,0 +1,57 @@ +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [ ] +sections: + - Name: .drectve + Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: 2020202F44454641554C544C49423A224C4942434D5422202F44454641554C544C49423A224F4C444E414D455322202F4558504F52543A6F6E65202F4558504F52543A74776F20 + - Name: '.text$mn' + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: C20000CCCCCCCCCCCCCCCCCCCCCCCCCCC20000CCCCCCCCCCCCCCCCCCCCCCCCCC4C894424188954241048894C240833C0C3 +symbols: + - Name: .drectve + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 71 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 4081356488 + Number: 0 + - Name: '.text$mn' + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 49 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 405845281 + Number: 0 + - Name: one + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: two + Value: 16 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: DllMain + Value: 32 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... Index: lld/trunk/test/COFF/Inputs/delayimporttables-dll2.yaml =================================================================== --- lld/trunk/test/COFF/Inputs/delayimporttables-dll2.yaml +++ lld/trunk/test/COFF/Inputs/delayimporttables-dll2.yaml @@ -0,0 +1,57 @@ +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [ ] +sections: + - Name: .drectve + Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: 2020202F44454641554C544C49423A224C4942434D5422202F44454641554C544C49423A224F4C444E414D455322202F4558504F52543A6C656674202F4558504F52543A726967687420 + - Name: '.text$mn' + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: C20000CCCCCCCCCCCCCCCCCCCCCCCCCCC20000CCCCCCCCCCCCCCCCCCCCCCCCCC4C894424188954241048894C240833C0C3 +symbols: + - Name: .drectve + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 74 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 127731413 + Number: 0 + - Name: '.text$mn' + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 49 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 405845281 + Number: 0 + - Name: left + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: right + Value: 16 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: DllMain + Value: 32 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... Index: lld/trunk/test/COFF/delayimporttables.yaml =================================================================== --- lld/trunk/test/COFF/delayimporttables.yaml +++ lld/trunk/test/COFF/delayimporttables.yaml @@ -0,0 +1,122 @@ +# RUN: yaml2obj %p/Inputs/delayimporttables-dll1.yaml > %t1.obj +# RUN: yaml2obj %p/Inputs/delayimporttables-dll2.yaml > %t2.obj +# RUN: yaml2obj %s > %t.obj +# RUN: lld-link /nodefaultlib /entry:DllMain /out:%T/delayimporttables-dll1.dll /dll /implib:%t-dll1.lib %t1.obj +# RUN: lld-link /nodefaultlib /entry:DllMain /out:%T/delayimporttables-dll2.dll /dll /implib:%t-dll2.lib %t2.obj +# RUN: lld-link /nodefaultlib /entry:main /out:%t.exe /delayload:delayimporttables-dll1.dll /delayload:delayimporttables-dll2.dll %t.obj %t-dll1.lib %t-dll2.lib +# RUN: llvm-readobj --coff-imports %t.exe |FileCheck %s + +# CHECK: Format: COFF-x86-64 +# CHECK-NEXT: Arch: x86_64 +# CHECK-NEXT: AddressSize: 64bit +# CHECK-NEXT: DelayImport { +# CHECK-NEXT: Name: delayimporttables-dll1.dll +# CHECK-NEXT: Attributes: 0x1 +# CHECK-NEXT: ModuleHandle: 0x3000 +# CHECK-NEXT: ImportAddressTable: 0x3010 +# CHECK-NEXT: ImportNameTable: 0x2060 +# CHECK-NEXT: BoundDelayImportTable: 0x0 +# CHECK-NEXT: UnloadDelayImportTable: 0x0 +# CHECK-NEXT: Import { +# CHECK-NEXT: Symbol: one (0) +# CHECK-NEXT: Address: 0x14000104D +# CHECK-NEXT: } +# CHECK-NEXT: Import { +# CHECK-NEXT: Symbol: two (0) +# CHECK-NEXT: Address: 0x1400010A4 +# CHECK-NEXT: } +# CHECK-NEXT: } +# CHECK-NEXT: DelayImport { +# CHECK-NEXT: Name: delayimporttables-dll2.dll +# CHECK-NEXT: Attributes: 0x1 +# CHECK-NEXT: ModuleHandle: 0x3008 +# CHECK-NEXT: ImportAddressTable: 0x3028 +# CHECK-NEXT: ImportNameTable: 0x2078 +# CHECK-NEXT: BoundDelayImportTable: 0x0 +# CHECK-NEXT: UnloadDelayImportTable: 0x0 +# CHECK-NEXT: Import { +# CHECK-NEXT: Symbol: left (0) +# CHECK-NEXT: Address: 0x1400010FB +# CHECK-NEXT: } +# CHECK-NEXT: Import { +# CHECK-NEXT: Symbol: right (0) +# CHECK-NEXT: Address: 0x140001152 +# CHECK-NEXT: } +# CHECK-NEXT: } + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [ ] +sections: + - Name: .drectve + Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: 2020202F44454641554C544C49423A224C4942434D5422202F44454641554C544C49423A224F4C444E414D45532220 + - Name: '.text$mn' + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: 4889542410894C24084883EC28FF1500000000FF1500000000FF1500000000FF150000000033C04883C428C3CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC488954241048894C240833C0C3 + Relocations: + - VirtualAddress: 15 + SymbolName: __imp_one + Type: IMAGE_REL_AMD64_REL32 + - VirtualAddress: 21 + SymbolName: __imp_two + Type: IMAGE_REL_AMD64_REL32 + - VirtualAddress: 27 + SymbolName: __imp_left + Type: IMAGE_REL_AMD64_REL32 + - VirtualAddress: 33 + SymbolName: __imp_right + Type: IMAGE_REL_AMD64_REL32 +symbols: + - Name: .drectve + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 47 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: __imp_one + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: __imp_two + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: __imp_left + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: __imp_right + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: main + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: __delayLoadHelper2 + Value: 64 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... Index: llvm/trunk/lib/Object/COFFObjectFile.cpp =================================================================== --- llvm/trunk/lib/Object/COFFObjectFile.cpp +++ llvm/trunk/lib/Object/COFFObjectFile.cpp @@ -1457,7 +1457,7 @@ std::error_code DelayImportDirectoryEntryRef:: getDelayImportTable(const delay_import_directory_table_entry *&Result) const { - Result = Table; + Result = &Table[Index]; return std::error_code(); }