diff options
Diffstat (limited to 'test')
626 files changed, 21099 insertions, 1723 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 1dbd1b7699ea..eb8475881de8 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -17,18 +17,23 @@ llvm_canonicalize_cmake_booleans( HAVE_LIBZ) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg) + ${CMAKE_CURRENT_SOURCE_DIR}/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/lit.site.cfg.py + MAIN_CONFIG + ${CMAKE_CURRENT_SOURCE_DIR}/lit.cfg.py + ) configure_lit_site_cfg( - ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.in - ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg + ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.site.cfg.py.in + ${CMAKE_CURRENT_BINARY_DIR}/Unit/lit.site.cfg.py + MAIN_CONFIG + ${CMAKE_CURRENT_SOURCE_DIR}/Unit/lit.cfg.py ) set(LLD_TEST_DEPS lld) if (NOT LLD_BUILT_STANDALONE) list(APPEND LLD_TEST_DEPS FileCheck count not llvm-ar llvm-as llvm-dis llvm-dwarfdump llvm-nm - llc llvm-config llvm-objdump llvm-readobj yaml2obj obj2yaml + llc llvm-config llvm-objdump llvm-readelf llvm-readobj yaml2obj obj2yaml llvm-mc llvm-lib llvm-pdbutil opt ) endif() diff --git a/test/COFF/Inputs/alpha.ll b/test/COFF/Inputs/alpha.ll new file mode 100644 index 000000000000..53fc36beee68 --- /dev/null +++ b/test/COFF/Inputs/alpha.ll @@ -0,0 +1,9 @@ +define void @_DllMainCRTStartup() { +entry: + ret void +} + +define dllexport void @f() local_unnamed_addr { +entry: + ret void +} diff --git a/test/COFF/Inputs/beta.ll b/test/COFF/Inputs/beta.ll new file mode 100644 index 000000000000..ff98618d884f --- /dev/null +++ b/test/COFF/Inputs/beta.ll @@ -0,0 +1,7 @@ +declare dllimport void @f() local_unnamed_addr + +define void @g() local_unnamed_addr { +entry: + tail call void @f() + ret void +} diff --git a/test/COFF/Inputs/except_handler3.lib b/test/COFF/Inputs/except_handler3.lib Binary files differnew file mode 100644 index 000000000000..fdc51ed73285 --- /dev/null +++ b/test/COFF/Inputs/except_handler3.lib diff --git a/test/COFF/Inputs/far-arm-thumb-abs20.s b/test/COFF/Inputs/far-arm-thumb-abs20.s new file mode 100644 index 000000000000..8483e32dc7f0 --- /dev/null +++ b/test/COFF/Inputs/far-arm-thumb-abs20.s @@ -0,0 +1,2 @@ +.global too_far20 +too_far20 = 0x501004 diff --git a/test/COFF/Inputs/gamma.ll b/test/COFF/Inputs/gamma.ll new file mode 100644 index 000000000000..1c78fff2909d --- /dev/null +++ b/test/COFF/Inputs/gamma.ll @@ -0,0 +1,14 @@ + +declare void @f() local_unnamed_addr + +define void @__imp_f() local_unnamed_addr { +entry: + ret void +} + +define void @mainCRTStartup() local_unnamed_addr { +entry: + tail call void @f() + ret void +} + diff --git a/test/COFF/Inputs/library2-arm64.lib b/test/COFF/Inputs/library2-arm64.lib Binary files differnew file mode 100644 index 000000000000..6fedf06f7be5 --- /dev/null +++ b/test/COFF/Inputs/library2-arm64.lib diff --git a/test/COFF/Inputs/library2.def b/test/COFF/Inputs/library2.def new file mode 100644 index 000000000000..d1906010cd30 --- /dev/null +++ b/test/COFF/Inputs/library2.def @@ -0,0 +1,3 @@ +LIBRARY library2 +EXPORTS + function2 diff --git a/test/COFF/Inputs/locally-imported-def.s b/test/COFF/Inputs/locally-imported-def.s new file mode 100644 index 000000000000..60a0970e9702 --- /dev/null +++ b/test/COFF/Inputs/locally-imported-def.s @@ -0,0 +1,4 @@ +.text +.globl f +f: + ret diff --git a/test/COFF/Inputs/locally-imported-imp.s b/test/COFF/Inputs/locally-imported-imp.s new file mode 100644 index 000000000000..33f2d54f617f --- /dev/null +++ b/test/COFF/Inputs/locally-imported-imp.s @@ -0,0 +1,2 @@ +.text + call __imp_f diff --git a/test/COFF/Inputs/lto-cache.ll b/test/COFF/Inputs/lto-cache.ll new file mode 100644 index 000000000000..acbee7be0144 --- /dev/null +++ b/test/COFF/Inputs/lto-cache.ll @@ -0,0 +1,10 @@ +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc" + +define i32 @main() { +entry: + call void (...) @globalfunc() + ret i32 0 +} + +declare void @globalfunc(...) diff --git a/test/COFF/Inputs/pdb-globals.yaml b/test/COFF/Inputs/pdb-globals.yaml new file mode 100644 index 000000000000..98ef914d9041 --- /dev/null +++ b/test/COFF/Inputs/pdb-globals.yaml @@ -0,0 +1,593 @@ +# // YAML Generated from the following source code: +# // Compile with clang-cl /Z7 /GS- /c t.obj pdb-globals.cpp +# +# void *__purecall = 0; +# +# struct HelloPoint { +# int X = 3; +# int Y = 4; +# int Z = 5; +# }; +# +# // S_LPROCREF +# static int LocalFunc() { return 42; } +# +# // S_PROCREF +# int GlobalFunc() { return 43; } +# +# // S_LDATA32 +# const int ConstantVar = 17; +# +# // S_GDATA32 +# const int *GlobalVar = &ConstantVar; +# +# // S_CONSTANT +# constexpr int ConstexprVar = 18; +# +# // S_UDT +# typedef HelloPoint HelloPointTypedef; +# +# int main(int argc, char **argv) { +# HelloPointTypedef P; +# int N = P.X + P.Y + P.Z; +# N += LocalFunc() + GlobalFunc(); +# N += *GlobalVar; +# N += ConstexprVar; +# } + + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_I386 + Characteristics: [ ] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: 5589E5B82B0000005DC3660F1F4400005589E583EC208B450C8B4D088D55F4894DEC89D18945E8E8000000008B4DF4034DF8034DFC894DF08945E4E8000000008945E0E80000000031C98B55E001C20355F08955F0A1000000008B000345F08945F08B45F083C0128945F089C883C4205DC366666666662E0F1F8400000000005589E5B82A0000005DC3 + Relocations: + - VirtualAddress: 40 + SymbolName: '??0HelloPoint@@QAE@XZ' + Type: IMAGE_REL_I386_REL32 + - VirtualAddress: 60 + SymbolName: '?LocalFunc@@YAHXZ' + Type: IMAGE_REL_I386_REL32 + - VirtualAddress: 68 + SymbolName: '?GlobalFunc@@YAHXZ' + Type: IMAGE_REL_I386_REL32 + - VirtualAddress: 86 + SymbolName: '?GlobalVar@@3PBHB' + Type: IMAGE_REL_I386_DIR32 + - Name: .data + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: '00000000' + Relocations: + - VirtualAddress: 0 + SymbolName: _ConstantVar + Type: IMAGE_REL_I386_DIR32 + - Name: .bss + Characteristics: [ IMAGE_SCN_CNT_UNINITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: '' + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: 5589E550894DFC8B4DFCC70103000000C7410404000000C741080500000089C883C4045DC3 + - Name: .rdata + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: '11000000' + - Name: .drectve + Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: 202F44454641554C544C49423A6C6962636D742E6C6962202F44454641554C544C49423A6F6C646E616D65732E6C6962 + - Name: '.debug$S' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 04000000F10000002F0000002D003C1101000000070006000000000000007017000000000000636C616E672076657273696F6E20362E302E30200000F100000036000000300047110000000000000000000000000A00000000000000000000000210000000000000000000476C6F62616C46756E630002004F110000F20000002000000000000000000000000A0000000000000001000000140000000000000010000000F1000000B60000002A00471100000000000000000000000062000000000000000000000006100000000000000000006D61696E000D003E1174000000010061726763001200451116000000080000001F000000000053000D003E11031000000100617267760012004511160000000C0000001F000000000053000A003E1107100000000050001200451116000000F4FFFFFF1F000000000053000A003E117400000000004E001200451116000000F0FFFFFF1F0000000000530002004F110000F200000050000000000000000000000062000000000000000700000044000000000000001E0000000F0000001F0000001C000000200000002800000021000000450000002200000052000000230000005B00000024000000F1000000350000002F0046110000000000000000000000000A00000000000000000000000F100000000000000000004C6F63616C46756E630002004F11000000F20000002000000000000000000000000A000000000000000100000014000000000000000D000000F10000004B00000017000D11030400000000000000005F5F7075726563616C6C0016000D1111100000000000000000476C6F62616C5661720018000C1110100000000000000000436F6E7374616E745661720000F10000002D000000180008110710000048656C6C6F506F696E745479706564656600110008110910000048656C6C6F506F696E7400000000F4000000080000000100000000000000F30000003800000000643A5C7372635C6C6C766D2D6D6F6E6F5C6C6C645C746573745C636F66665C696E707574735C7064622D676C6F62616C732E6370700000 + Subsections: + - !Symbols + Records: + - Kind: S_COMPILE3 + Compile3Sym: + Flags: [ ] + Machine: Pentium3 + FrontendMajor: 6 + FrontendMinor: 0 + FrontendBuild: 0 + FrontendQFE: 0 + BackendMajor: 6000 + BackendMinor: 0 + BackendBuild: 0 + BackendQFE: 0 + Version: 'clang version 6.0.0 ' + - Kind: S_GPROC32_ID + ProcSym: + CodeSize: 10 + DbgStart: 0 + DbgEnd: 0 + FunctionType: 4098 + Flags: [ ] + DisplayName: GlobalFunc + - Kind: S_PROC_ID_END + ScopeEndSym: + - Kind: S_GPROC32_ID + ProcSym: + CodeSize: 98 + DbgStart: 0 + DbgEnd: 0 + FunctionType: 4102 + Flags: [ ] + DisplayName: main + - Kind: S_LOCAL + LocalSym: + Type: 116 + Flags: [ IsParameter ] + VarName: argc + - Kind: S_DEFRANGE_REGISTER_REL + DefRangeRegisterRelSym: + - Kind: S_LOCAL + LocalSym: + Type: 4099 + Flags: [ IsParameter ] + VarName: argv + - Kind: S_DEFRANGE_REGISTER_REL + DefRangeRegisterRelSym: + - Kind: S_LOCAL + LocalSym: + Type: 4103 + Flags: [ ] + VarName: P + - Kind: S_DEFRANGE_REGISTER_REL + DefRangeRegisterRelSym: + - Kind: S_LOCAL + LocalSym: + Type: 116 + Flags: [ ] + VarName: N + - Kind: S_DEFRANGE_REGISTER_REL + DefRangeRegisterRelSym: + - Kind: S_PROC_ID_END + ScopeEndSym: + - Kind: S_LPROC32_ID + ProcSym: + CodeSize: 10 + DbgStart: 0 + DbgEnd: 0 + FunctionType: 4111 + Flags: [ ] + DisplayName: LocalFunc + - Kind: S_PROC_ID_END + ScopeEndSym: + - Kind: S_GDATA32 + DataSym: + Type: 1027 + DisplayName: __purecall + - Kind: S_GDATA32 + DataSym: + Type: 4113 + DisplayName: GlobalVar + - Kind: S_LDATA32 + DataSym: + Type: 4112 + DisplayName: ConstantVar + - Kind: S_UDT + UDTSym: + Type: 4103 + UDTName: HelloPointTypedef + - Kind: S_UDT + UDTSym: + Type: 4105 + UDTName: HelloPoint + - !FileChecksums + Checksums: + - FileName: 'd:\src\llvm-mono\lld\test\coff\inputs\pdb-globals.cpp' + Kind: None + Checksum: '' + - !StringTable + Strings: + - 'd:\src\llvm-mono\lld\test\coff\inputs\pdb-globals.cpp' + - '' + Relocations: + - VirtualAddress: 100 + SymbolName: '?GlobalFunc@@YAHXZ' + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 104 + SymbolName: '?GlobalFunc@@YAHXZ' + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 132 + SymbolName: '?GlobalFunc@@YAHXZ' + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 136 + SymbolName: '?GlobalFunc@@YAHXZ' + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 204 + SymbolName: _main + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 208 + SymbolName: _main + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 243 + SymbolName: .text + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 247 + SymbolName: .text + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 278 + SymbolName: .text + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 282 + SymbolName: .text + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 310 + SymbolName: .text + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 314 + SymbolName: .text + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 342 + SymbolName: .text + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 346 + SymbolName: .text + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 364 + SymbolName: _main + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 368 + SymbolName: _main + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 484 + SymbolName: '?LocalFunc@@YAHXZ' + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 488 + SymbolName: '?LocalFunc@@YAHXZ' + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 516 + SymbolName: '?LocalFunc@@YAHXZ' + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 520 + SymbolName: '?LocalFunc@@YAHXZ' + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 564 + SymbolName: '?__purecall@@3PAXA' + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 568 + SymbolName: '?__purecall@@3PAXA' + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 589 + SymbolName: '?GlobalVar@@3PBHB' + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 593 + SymbolName: '?GlobalVar@@3PBHB' + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 613 + SymbolName: _ConstantVar + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 617 + SymbolName: _ConstantVar + Type: IMAGE_REL_I386_SECTION + - Name: '.debug$T' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 0400000006000112000000000E000810740000000000000000100000160001160000000001100000476C6F62616C46756E6300F10A000210700400000A8000000E0001120200000074000000031000000E0008107400000000000200041000001200011600000000051000006D61696E00F3F2F13200051500008002000000000000000000000000000048656C6C6F506F696E74002E3F415548656C6C6F506F696E74404000F2F1260003120D15030074000000000058000D15030074000000040059000D1503007400000008005A0032000515030000020810000000000000000000000C0048656C6C6F506F696E74002E3F415548656C6C6F506F696E74404000F2F13E00051600000000643A5C7372635C6C6C766D2D6D6F6E6F5C6C6C645C746573745C636F66665C696E707574735C7064622D676C6F62616C732E63707000F2F10E000616091000000A100000060000000A000210071000000A8000001A00091003000000071000000C1000000B000000001000000000000016000216071000000D10000048656C6C6F506F696E7400F11600011600000000011000004C6F63616C46756E6300F2F10A000110740000000100F2F10A000210101000000A800000 + Types: + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ ] + - Kind: LF_PROCEDURE + Procedure: + ReturnType: 116 + CallConv: NearC + Options: [ None ] + ParameterCount: 0 + ArgumentList: 4096 + - Kind: LF_FUNC_ID + FuncId: + ParentScope: 0 + FunctionType: 4097 + Name: GlobalFunc + - Kind: LF_POINTER + Pointer: + ReferentType: 1136 + Attrs: 32778 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 116, 4099 ] + - Kind: LF_PROCEDURE + Procedure: + ReturnType: 116 + CallConv: NearC + Options: [ None ] + ParameterCount: 2 + ArgumentList: 4100 + - Kind: LF_FUNC_ID + FuncId: + ParentScope: 0 + FunctionType: 4101 + Name: main + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: HelloPoint + UniqueName: '.?AUHelloPoint@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 116 + FieldOffset: 0 + Name: X + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 116 + FieldOffset: 4 + Name: Y + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 116 + FieldOffset: 8 + Name: Z + - Kind: LF_STRUCTURE + Class: + MemberCount: 3 + Options: [ None, HasUniqueName ] + FieldList: 4104 + Name: HelloPoint + UniqueName: '.?AUHelloPoint@@' + DerivationList: 0 + VTableShape: 0 + Size: 12 + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: 'd:\src\llvm-mono\lld\test\coff\inputs\pdb-globals.cpp' + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4105 + SourceFile: 4106 + LineNumber: 6 + - Kind: LF_POINTER + Pointer: + ReferentType: 4103 + Attrs: 32778 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4103 + ThisType: 4108 + CallConv: ThisCall + Options: [ None ] + ParameterCount: 0 + ArgumentList: 4096 + ThisPointerAdjustment: 0 + - Kind: LF_MFUNC_ID + MemberFuncId: + ClassType: 4103 + FunctionType: 4109 + Name: HelloPoint + - Kind: LF_FUNC_ID + FuncId: + ParentScope: 0 + FunctionType: 4097 + Name: LocalFunc + - Kind: LF_MODIFIER + Modifier: + ModifiedType: 116 + Modifiers: [ None, Const ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4112 + Attrs: 32778 + - Name: '.debug$S' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 04000000F1000000650000003C0047110000000000000000000000002500000000000000000000000E1000000000000000000048656C6C6F506F696E743A3A48656C6C6F506F696E74000D003E110C100000010074686973001200451116000000FCFFFFFF0A00000000001B0002004F11000000F20000004000000000000000000000002500000000000000050000003400000000000000060000000A00000007000000100000000800000017000000090000001E00000006000000 + Subsections: + - !Symbols + Records: + - Kind: S_GPROC32_ID + ProcSym: + CodeSize: 37 + DbgStart: 0 + DbgEnd: 0 + FunctionType: 4110 + Flags: [ ] + DisplayName: 'HelloPoint::HelloPoint' + - Kind: S_LOCAL + LocalSym: + Type: 4108 + Flags: [ IsParameter ] + VarName: this + - Kind: S_DEFRANGE_REGISTER_REL + DefRangeRegisterRelSym: + - Kind: S_PROC_ID_END + ScopeEndSym: + Relocations: + - VirtualAddress: 44 + SymbolName: '??0HelloPoint@@QAE@XZ' + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 48 + SymbolName: '??0HelloPoint@@QAE@XZ' + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 101 + SymbolName: .text + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 105 + SymbolName: .text + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 124 + SymbolName: '??0HelloPoint@@QAE@XZ' + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 128 + SymbolName: '??0HelloPoint@@QAE@XZ' + Type: IMAGE_REL_I386_SECTION +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 138 + NumberOfRelocations: 4 + NumberOfLinenumbers: 0 + CheckSum: 3215092891 + Number: 1 + - Name: .data + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 4 + NumberOfRelocations: 1 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 2 + - Name: .bss + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 4 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 3 + - Name: .text + Value: 0 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 37 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 77530982 + Number: 4 + Selection: IMAGE_COMDAT_SELECT_ANY + - Name: '??0HelloPoint@@QAE@XZ' + Value: 0 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: .rdata + Value: 0 + SectionNumber: 5 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 4 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 3903140090 + Number: 5 + - Name: .drectve + Value: 0 + SectionNumber: 6 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 48 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 149686238 + Number: 6 + - Name: '.debug$S' + Value: 0 + SectionNumber: 7 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 768 + NumberOfRelocations: 26 + NumberOfLinenumbers: 0 + CheckSum: 2940884584 + Number: 7 + - Name: '.debug$S' + Value: 0 + SectionNumber: 9 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 188 + NumberOfRelocations: 6 + NumberOfLinenumbers: 0 + CheckSum: 1246640575 + Number: 4 + Selection: IMAGE_COMDAT_SELECT_ASSOCIATIVE + - Name: '.debug$T' + Value: 0 + SectionNumber: 8 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 452 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 2561906059 + Number: 8 + - Name: '@feat.00' + Value: 1 + SectionNumber: -1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: '?GlobalFunc@@YAHXZ' + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: _main + Value: 16 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: '?LocalFunc@@YAHXZ' + Value: 128 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: '?GlobalVar@@3PBHB' + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: '?__purecall@@3PAXA' + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: _ConstantVar + Value: 0 + SectionNumber: 5 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC +... diff --git a/test/COFF/Inputs/pdb-hashes-1.yaml b/test/COFF/Inputs/pdb-hashes-1.yaml new file mode 100644 index 000000000000..ad9e69188f51 --- /dev/null +++ b/test/COFF/Inputs/pdb-hashes-1.yaml @@ -0,0 +1,540 @@ +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_I386 + Characteristics: [ ] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: 5589E55683EC188B450C8B4D088D55F4C745F8000000008B7508894DF089D18934248945ECE80000000083EC048D4DF4890C248945E8E80000000083C4185E5DC3 + Relocations: + - VirtualAddress: 38 + SymbolName: '??0Foo@NS@@QAE@H@Z' + Type: IMAGE_REL_I386_REL32 + - VirtualAddress: 55 + SymbolName: '?func@NS@@YAHABUFoo@1@@Z' + Type: IMAGE_REL_I386_REL32 + - Name: .data + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: '' + - Name: .bss + Characteristics: [ IMAGE_SCN_CNT_UNINITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: '' + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: 5589E583EC088B4508894DFC8B4DFC8B550889118945F889C883C4085DC20400 + - Name: .drectve + Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: 202F44454641554C544C49423A6C6962636D742E6C6962202F44454641554C544C49423A6F6C646E616D65732E6C6962 + - Name: '.debug$S' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 04000000F10000002F0000002D003C1101000000070006000000000000007017000000000000636C616E672076657273696F6E20362E302E30200000F50000008400000000000000000000004100000000000000080000000000000052000000070000000400000001000000400000000000000008000000000000007F0000000600040000000000030000003E000000000000000800000000000000BD0000000400040000000000040000003D000000000000000800000000000000FA0000000300080000000000F1000000960000002A00471100000000000000000000000041000000000000000000000003100000000000000000006D61696E000D003E1174000000010061726763001200451116000000080000001700000000002A000D003E11001000000100617267760012004511160000000C0000001700000000002A000A003E1109100000000066001200451116000000F4FFFFFF1700000000002A0002004F110000F200000030000000000000000000000041000000000000000300000024000000000000000300000017000000040000003000000005000000F1000000100000000E000811091000004E533A3A466F6F00F40000003000000001000000100165C9E387F88362A8EB2B49539DD5A65500002B00000010019303CF100D518DAF59C31DA01FEF4AFC0000F30000004801000000443A5C7372635C6C6C766D6275696C645C636C616E675C44656275675C7838365C6F626A312E63707000443A5C7372635C6C6C766D6275696C645C636C616E675C44656275675C7838365C6F626A2E6800245430202E7261536561726368203D202465697020245430205E203D2024657370202454302034202B203D2000245430202E7261536561726368203D202465697020245430205E203D2024657370202454302034202B203D2024656270202454302034202D205E203D200024543020246562702034202B203D202465697020245430205E203D2024657370202454302034202B203D2024656270202454302034202D205E203D200024543020246562702034202B203D202465697020245430205E203D2024657370202454302034202B203D2024656270202454302034202D205E203D2024657369202454302038202D205E203D2000 + Subsections: + - !Symbols + Records: + - Kind: S_COMPILE3 + Compile3Sym: + Flags: [ ] + Machine: Pentium3 + FrontendMajor: 6 + FrontendMinor: 0 + FrontendBuild: 0 + FrontendQFE: 0 + BackendMajor: 6000 + BackendMinor: 0 + BackendBuild: 0 + BackendQFE: 0 + Version: 'clang version 6.0.0 ' + - !FrameData + Frames: + - CodeSize: 65 + FrameFunc: '$T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = ' + LocalSize: 0 + MaxStackSize: 0 + ParamsSize: 8 + PrologSize: 7 + RvaStart: 0 + SavedRegsSize: 0 + - CodeSize: 64 + FrameFunc: '$T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = ' + LocalSize: 0 + MaxStackSize: 0 + ParamsSize: 8 + PrologSize: 6 + RvaStart: 1 + SavedRegsSize: 4 + - CodeSize: 62 + FrameFunc: '$T0 $ebp 4 + = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = ' + LocalSize: 0 + MaxStackSize: 0 + ParamsSize: 8 + PrologSize: 4 + RvaStart: 3 + SavedRegsSize: 4 + - CodeSize: 61 + FrameFunc: '$T0 $ebp 4 + = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = $esi $T0 8 - ^ = ' + LocalSize: 0 + MaxStackSize: 0 + ParamsSize: 8 + PrologSize: 3 + RvaStart: 4 + SavedRegsSize: 8 + - !Symbols + Records: + - Kind: S_GPROC32_ID + ProcSym: + CodeSize: 65 + DbgStart: 0 + DbgEnd: 0 + FunctionType: 4099 + Flags: [ ] + DisplayName: main + - Kind: S_LOCAL + LocalSym: + Type: 116 + Flags: [ IsParameter ] + VarName: argc + - Kind: S_DEFRANGE_REGISTER_REL + DefRangeRegisterRelSym: + - Kind: S_LOCAL + LocalSym: + Type: 4096 + Flags: [ IsParameter ] + VarName: argv + - Kind: S_DEFRANGE_REGISTER_REL + DefRangeRegisterRelSym: + - Kind: S_LOCAL + LocalSym: + Type: 4105 + Flags: [ ] + VarName: f + - Kind: S_DEFRANGE_REGISTER_REL + DefRangeRegisterRelSym: + - Kind: S_PROC_ID_END + ScopeEndSym: + - !Lines + CodeSize: 65 + Flags: [ ] + RelocOffset: 0 + RelocSegment: 0 + Blocks: + - FileName: 'D:\src\llvmbuild\clang\Debug\x86\obj1.cpp' + Lines: + - Offset: 0 + LineStart: 3 + IsStatement: false + EndDelta: 0 + - Offset: 23 + LineStart: 4 + IsStatement: false + EndDelta: 0 + - Offset: 48 + LineStart: 5 + IsStatement: false + EndDelta: 0 + Columns: + - !Symbols + Records: + - Kind: S_UDT + UDTSym: + Type: 4105 + UDTName: 'NS::Foo' + - !FileChecksums + Checksums: + - FileName: 'D:\src\llvmbuild\clang\Debug\x86\obj1.cpp' + Kind: MD5 + Checksum: 65C9E387F88362A8EB2B49539DD5A655 + - FileName: 'D:\src\llvmbuild\clang\Debug\x86\obj.h' + Kind: MD5 + Checksum: 9303CF100D518DAF59C31DA01FEF4AFC + - !StringTable + Strings: + - 'D:\src\llvmbuild\clang\Debug\x86\obj1.cpp' + - 'D:\src\llvmbuild\clang\Debug\x86\obj.h' + - '$T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = ' + - '$T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = ' + - '$T0 $ebp 4 + = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = ' + - '$T0 $ebp 4 + = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = $esi $T0 8 - ^ = ' + Relocations: + - VirtualAddress: 68 + SymbolName: _main + Type: IMAGE_REL_I386_DIR32NB + - VirtualAddress: 240 + SymbolName: _main + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 244 + SymbolName: _main + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 279 + SymbolName: .text + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 283 + SymbolName: .text + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 314 + SymbolName: .text + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 318 + SymbolName: .text + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 346 + SymbolName: .text + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 350 + SymbolName: .text + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 368 + SymbolName: _main + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 372 + SymbolName: _main + Type: IMAGE_REL_I386_SECTION + - Name: '.debug$T' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 040000000A000210700400000A8000000E0001120200000074000000001000000E0008107400000000000200011000001200011600000000021000006D61696E00F3F2F12A0005150000800200000000000000000000000000004E533A3A466F6F002E3F4155466F6F404E53404000F10A000210041000000A8000000A00011201000000740000001A0009100300000004100000051000000B00010006100000000000001A0003120D15030074000000000058001115030007100000466F6F002A0005150200000208100000000000000000000004004E533A3A466F6F002E3F4155466F6F404E53404000F12E00051600000000443A5C7372635C6C6C766D6275696C645C636C616E675C44656275675C7838365C6F626A2E6800F10E000616091000000A100000020000000E0002160410000007100000466F6F00 + Types: + - Kind: LF_POINTER + Pointer: + ReferentType: 1136 + Attrs: 32778 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 116, 4096 ] + - Kind: LF_PROCEDURE + Procedure: + ReturnType: 116 + CallConv: NearC + Options: [ None ] + ParameterCount: 2 + ArgumentList: 4097 + - Kind: LF_FUNC_ID + FuncId: + ParentScope: 0 + FunctionType: 4098 + Name: main + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: 'NS::Foo' + UniqueName: '.?AUFoo@NS@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_POINTER + Pointer: + ReferentType: 4100 + Attrs: 32778 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 116 ] + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4100 + ThisType: 4101 + CallConv: ThisCall + Options: [ None ] + ParameterCount: 1 + ArgumentList: 4102 + ThisPointerAdjustment: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 116 + FieldOffset: 0 + Name: X + - Kind: LF_ONEMETHOD + OneMethod: + Type: 4103 + Attrs: 3 + VFTableOffset: -1 + Name: Foo + - Kind: LF_STRUCTURE + Class: + MemberCount: 2 + Options: [ None, HasUniqueName ] + FieldList: 4104 + Name: 'NS::Foo' + UniqueName: '.?AUFoo@NS@@' + DerivationList: 0 + VTableShape: 0 + Size: 4 + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: 'D:\src\llvmbuild\clang\Debug\x86\obj.h' + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4105 + SourceFile: 4106 + LineNumber: 2 + - Kind: LF_MFUNC_ID + MemberFuncId: + ClassType: 4100 + FunctionType: 4103 + Name: Foo + - Name: '.debug$H' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: C5C93301000000009E56666824DC4B12E25261D4E09E6E9DA0F4EE31FDEC3D2D96287486127C66070B248ED52E421F55074AE5CC2D68AF9F0A3BEF23993968F7FD82CA84BF0439C1A64C9070C6A6ADB0A34D21DAD0FFC3E99E616EF06A14EA74A2420F9062A1FB04917E5975E3A50EABE5E8FE3945468547C19DC681D0BFB3B797DD91CA4D7F1953C314442D5549419E78044E38A0BF16BFFAA5EE9C0103E7DBFE9941E63379C0B0C0A9021B711ACC4F67008974EBF441031BDD653F6935DFF3112C6A5346EF2AC94B9B7EB56EF55CFA0AF6C1846743F43D846BB19517E12E8873BBA90CC41DD1BEAC89CBA8897AC1BA46762E2557A82D894CEAE81AEF8680D723D403D9A4481F0E28683A98 + GlobalHashes: + Version: 0 + HashAlgorithm: 0 + HashValues: + - 9E56666824DC4B12E25261D4E09E6E9DA0F4EE31 + - FDEC3D2D96287486127C66070B248ED52E421F55 + - 074AE5CC2D68AF9F0A3BEF23993968F7FD82CA84 + - BF0439C1A64C9070C6A6ADB0A34D21DAD0FFC3E9 + - 9E616EF06A14EA74A2420F9062A1FB04917E5975 + - E3A50EABE5E8FE3945468547C19DC681D0BFB3B7 + - 97DD91CA4D7F1953C314442D5549419E78044E38 + - A0BF16BFFAA5EE9C0103E7DBFE9941E63379C0B0 + - C0A9021B711ACC4F67008974EBF441031BDD653F + - 6935DFF3112C6A5346EF2AC94B9B7EB56EF55CFA + - 0AF6C1846743F43D846BB19517E12E8873BBA90C + - C41DD1BEAC89CBA8897AC1BA46762E2557A82D89 + - 4CEAE81AEF8680D723D403D9A4481F0E28683A98 + - Name: '.debug$S' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 04000000F500000064000000000000000000000020000000000000000400000000000000520000000600000004000000010000001F0000000000000004000000000000007F0000000500040000000000030000001D000000000000000400000000000000BD0000000300040000000000F10000007B000000320047110000000000000000000000002000000000000000000000000C100000000000000000004E533A3A466F6F3A3A466F6F000D003E1105100000010074686973001200451116000000FCFFFFFF0F000000000011000A003E1174000000010078001200451116000000080000000F0000000000110002004F1100F2000000200000000000000000000000200000001800000001000000140000000000000003000000 + Subsections: + - !FrameData + Frames: + - CodeSize: 32 + FrameFunc: '$T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = ' + LocalSize: 0 + MaxStackSize: 0 + ParamsSize: 4 + PrologSize: 6 + RvaStart: 0 + SavedRegsSize: 0 + - CodeSize: 31 + FrameFunc: '$T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = ' + LocalSize: 0 + MaxStackSize: 0 + ParamsSize: 4 + PrologSize: 5 + RvaStart: 1 + SavedRegsSize: 4 + - CodeSize: 29 + FrameFunc: '$T0 $ebp 4 + = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = ' + LocalSize: 0 + MaxStackSize: 0 + ParamsSize: 4 + PrologSize: 3 + RvaStart: 3 + SavedRegsSize: 4 + - !Symbols + Records: + - Kind: S_GPROC32_ID + ProcSym: + CodeSize: 32 + DbgStart: 0 + DbgEnd: 0 + FunctionType: 4108 + Flags: [ ] + DisplayName: 'NS::Foo::Foo' + - Kind: S_LOCAL + LocalSym: + Type: 4101 + Flags: [ IsParameter ] + VarName: this + - Kind: S_DEFRANGE_REGISTER_REL + DefRangeRegisterRelSym: + - Kind: S_LOCAL + LocalSym: + Type: 116 + Flags: [ IsParameter ] + VarName: x + - Kind: S_DEFRANGE_REGISTER_REL + DefRangeRegisterRelSym: + - Kind: S_PROC_ID_END + ScopeEndSym: + - !Lines + CodeSize: 32 + Flags: [ ] + RelocOffset: 0 + RelocSegment: 0 + Blocks: + - FileName: 'D:\src\llvmbuild\clang\Debug\x86\obj.h' + Lines: + - Offset: 0 + LineStart: 3 + IsStatement: false + EndDelta: 0 + Columns: + Relocations: + - VirtualAddress: 12 + SymbolName: '??0Foo@NS@@QAE@H@Z' + Type: IMAGE_REL_I386_DIR32NB + - VirtualAddress: 152 + SymbolName: '??0Foo@NS@@QAE@H@Z' + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 156 + SymbolName: '??0Foo@NS@@QAE@H@Z' + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 199 + SymbolName: .text + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 203 + SymbolName: .text + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 231 + SymbolName: .text + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 235 + SymbolName: .text + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 252 + SymbolName: '??0Foo@NS@@QAE@H@Z' + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 256 + SymbolName: '??0Foo@NS@@QAE@H@Z' + Type: IMAGE_REL_I386_SECTION +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 65 + NumberOfRelocations: 2 + NumberOfLinenumbers: 0 + CheckSum: 4176946275 + Number: 1 + - Name: .data + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 0 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 2 + - Name: .bss + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 0 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 3 + - Name: .text + Value: 0 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 32 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 1438182552 + Number: 4 + Selection: IMAGE_COMDAT_SELECT_ANY + - Name: '??0Foo@NS@@QAE@H@Z' + Value: 0 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: .drectve + Value: 0 + SectionNumber: 5 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 48 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 149686238 + Number: 5 + - Name: '.debug$S' + Value: 0 + SectionNumber: 6 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 832 + NumberOfRelocations: 11 + NumberOfLinenumbers: 0 + CheckSum: 4106171226 + Number: 6 + - Name: '.debug$S' + Value: 0 + SectionNumber: 9 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 284 + NumberOfRelocations: 9 + NumberOfLinenumbers: 0 + CheckSum: 1378739251 + Number: 4 + Selection: IMAGE_COMDAT_SELECT_ASSOCIATIVE + - Name: '.debug$T' + Value: 0 + SectionNumber: 7 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 316 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 3343977630 + Number: 7 + - Name: '.debug$H' + Value: 0 + SectionNumber: 8 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 268 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 3965031229 + Number: 8 + - Name: '@feat.00' + Value: 1 + SectionNumber: -1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: _main + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: '?func@NS@@YAHABUFoo@1@@Z' + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/Inputs/pdb-hashes-2-missing.yaml b/test/COFF/Inputs/pdb-hashes-2-missing.yaml new file mode 100644 index 000000000000..74f3a62fcc23 --- /dev/null +++ b/test/COFF/Inputs/pdb-hashes-2-missing.yaml @@ -0,0 +1,321 @@ +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_I386 + Characteristics: [ ] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: 5589E5508B45088B4D088B09C1E1018945FC89C883C4045DC3 + - Name: .data + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: '' + - Name: .bss + Characteristics: [ IMAGE_SCN_CNT_UNINITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: '' + - Name: .drectve + Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: 202F44454641554C544C49423A6C6962636D742E6C6962202F44454641554C544C49423A6F6C646E616D65732E6C6962 + - Name: '.debug$S' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 04000000F10000002F0000002D003C1101000000070006000000000000007017000000000000636C616E672076657273696F6E20362E302E30200000F5000000640000000000000000000000190000000000000004000000000000002B000000040000000400000001000000180000000000000004000000000000005800000003000400000000000300000016000000000000000400000000000000960000000100040000000000F1000000540000002E0047110000000000000000000000001900000000000000000000000D100000000000000000004E533A3A66756E63000A003E110310000001006600120045111600000008000000070000000000120002004F11F20000002800000000000000000000001900000000000000020000001C00000000000000030000000700000004000000F1000000100000000E0008110A1000004E533A3A466F6F00F40000001800000001000000100159DFAC75D18675AED1AD169FE316317E0000F3000000D400000000443A5C7372635C6C6C766D6275696C645C636C616E675C44656275675C7838365C6F626A322E63707000245430202E7261536561726368203D202465697020245430205E203D2024657370202454302034202B203D2000245430202E7261536561726368203D202465697020245430205E203D2024657370202454302034202B203D2024656270202454302034202D205E203D200024543020246562702034202B203D202465697020245430205E203D2024657370202454302034202B203D2024656270202454302034202D205E203D200000 + Subsections: + - !Symbols + Records: + - Kind: S_COMPILE3 + Compile3Sym: + Flags: [ ] + Machine: Pentium3 + FrontendMajor: 6 + FrontendMinor: 0 + FrontendBuild: 0 + FrontendQFE: 0 + BackendMajor: 6000 + BackendMinor: 0 + BackendBuild: 0 + BackendQFE: 0 + Version: 'clang version 6.0.0 ' + - !FrameData + Frames: + - CodeSize: 25 + FrameFunc: '$T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = ' + LocalSize: 0 + MaxStackSize: 0 + ParamsSize: 4 + PrologSize: 4 + RvaStart: 0 + SavedRegsSize: 0 + - CodeSize: 24 + FrameFunc: '$T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = ' + LocalSize: 0 + MaxStackSize: 0 + ParamsSize: 4 + PrologSize: 3 + RvaStart: 1 + SavedRegsSize: 4 + - CodeSize: 22 + FrameFunc: '$T0 $ebp 4 + = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = ' + LocalSize: 0 + MaxStackSize: 0 + ParamsSize: 4 + PrologSize: 1 + RvaStart: 3 + SavedRegsSize: 4 + - !Symbols + Records: + - Kind: S_GPROC32_ID + ProcSym: + CodeSize: 25 + DbgStart: 0 + DbgEnd: 0 + FunctionType: 4109 + Flags: [ ] + DisplayName: 'NS::func' + - Kind: S_LOCAL + LocalSym: + Type: 4099 + Flags: [ IsParameter ] + VarName: f + - Kind: S_DEFRANGE_REGISTER_REL + DefRangeRegisterRelSym: + - Kind: S_PROC_ID_END + ScopeEndSym: + - !Lines + CodeSize: 25 + Flags: [ ] + RelocOffset: 0 + RelocSegment: 0 + Blocks: + - FileName: 'D:\src\llvmbuild\clang\Debug\x86\obj2.cpp' + Lines: + - Offset: 0 + LineStart: 3 + IsStatement: false + EndDelta: 0 + - Offset: 7 + LineStart: 4 + IsStatement: false + EndDelta: 0 + Columns: + - !Symbols + Records: + - Kind: S_UDT + UDTSym: + Type: 4106 + UDTName: 'NS::Foo' + - !FileChecksums + Checksums: + - FileName: 'D:\src\llvmbuild\clang\Debug\x86\obj2.cpp' + Kind: MD5 + Checksum: 59DFAC75D18675AED1AD169FE316317E + - !StringTable + Strings: + - 'D:\src\llvmbuild\clang\Debug\x86\obj2.cpp' + - '$T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = ' + - '$T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = ' + - '$T0 $ebp 4 + = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = ' + - '' + Relocations: + - VirtualAddress: 68 + SymbolName: '?func@NS@@YAHABUFoo@1@@Z' + Type: IMAGE_REL_I386_DIR32NB + - VirtualAddress: 208 + SymbolName: '?func@NS@@YAHABUFoo@1@@Z' + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 212 + SymbolName: '?func@NS@@YAHABUFoo@1@@Z' + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 248 + SymbolName: .text + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 252 + SymbolName: .text + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 268 + SymbolName: '?func@NS@@YAHABUFoo@1@@Z' + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 272 + SymbolName: '?func@NS@@YAHABUFoo@1@@Z' + Type: IMAGE_REL_I386_SECTION + - Name: '.debug$T' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 040000000A000516000000004E5300F12A0005150000800200000000000000000000000000004E533A3A466F6F002E3F4155466F6F404E53404000F10A000110011000000100F2F10A000210021000002A8000000A00011201000000031000000E0008107400000000000100041000000A000210011000000A8000000A00011201000000740000001A0009100300000001100000061000000B00010007100000000000001A0003120D15030074000000000058001115030008100000466F6F002A0005150200000209100000000000000000000004004E533A3A466F6F002E3F4155466F6F404E53404000F12E00051600000000443A5C7372635C6C6C766D6275696C645C636C616E675C44656275675C7838365C6F626A2E6800F10E0006160A1000000B1000000200000012000116001000000510000066756E6300F3F2F1 + Types: + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: NS + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: 'NS::Foo' + UniqueName: '.?AUFoo@NS@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_MODIFIER + Modifier: + ModifiedType: 4097 + Modifiers: [ None, Const ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4098 + Attrs: 32810 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4099 ] + - Kind: LF_PROCEDURE + Procedure: + ReturnType: 116 + CallConv: NearC + Options: [ None ] + ParameterCount: 1 + ArgumentList: 4100 + - Kind: LF_POINTER + Pointer: + ReferentType: 4097 + Attrs: 32778 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 116 ] + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4097 + ThisType: 4102 + CallConv: ThisCall + Options: [ None ] + ParameterCount: 1 + ArgumentList: 4103 + ThisPointerAdjustment: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 116 + FieldOffset: 0 + Name: X + - Kind: LF_ONEMETHOD + OneMethod: + Type: 4104 + Attrs: 3 + VFTableOffset: -1 + Name: Foo + - Kind: LF_STRUCTURE + Class: + MemberCount: 2 + Options: [ None, HasUniqueName ] + FieldList: 4105 + Name: 'NS::Foo' + UniqueName: '.?AUFoo@NS@@' + DerivationList: 0 + VTableShape: 0 + Size: 4 + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: 'D:\src\llvmbuild\clang\Debug\x86\obj.h' + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4106 + SourceFile: 4107 + LineNumber: 2 + - Kind: LF_FUNC_ID + FuncId: + ParentScope: 4096 + FunctionType: 4101 + Name: func +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 25 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 1820185021 + Number: 1 + - Name: .data + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 0 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 2 + - Name: .bss + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 0 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 3 + - Name: .drectve + Value: 0 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 48 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 149686238 + Number: 4 + - Name: '.debug$S' + Value: 0 + SectionNumber: 5 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 584 + NumberOfRelocations: 7 + NumberOfLinenumbers: 0 + CheckSum: 2847177244 + Number: 5 + - Name: '.debug$T' + Value: 0 + SectionNumber: 6 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 320 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 2684556216 + Number: 6 + - Name: '@feat.00' + Value: 1 + SectionNumber: -1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: '?func@NS@@YAHABUFoo@1@@Z' + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/Inputs/pdb-hashes-2.yaml b/test/COFF/Inputs/pdb-hashes-2.yaml new file mode 100644 index 000000000000..63e9fc02ad5a --- /dev/null +++ b/test/COFF/Inputs/pdb-hashes-2.yaml @@ -0,0 +1,355 @@ +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_I386 + Characteristics: [ ] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: 5589E5508B45088B4D088B09C1E1018945FC89C883C4045DC3 + - Name: .data + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: '' + - Name: .bss + Characteristics: [ IMAGE_SCN_CNT_UNINITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: '' + - Name: .drectve + Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: 202F44454641554C544C49423A6C6962636D742E6C6962202F44454641554C544C49423A6F6C646E616D65732E6C6962 + - Name: '.debug$S' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 04000000F10000002F0000002D003C1101000000070006000000000000007017000000000000636C616E672076657273696F6E20362E302E30200000F5000000640000000000000000000000190000000000000004000000000000002B000000040000000400000001000000180000000000000004000000000000005800000003000400000000000300000016000000000000000400000000000000960000000100040000000000F1000000540000002E0047110000000000000000000000001900000000000000000000000D100000000000000000004E533A3A66756E63000A003E110310000001006600120045111600000008000000070000000000120002004F11F20000002800000000000000000000001900000000000000020000001C00000000000000030000000700000004000000F1000000100000000E0008110A1000004E533A3A466F6F00F40000001800000001000000100159DFAC75D18675AED1AD169FE316317E0000F3000000D400000000443A5C7372635C6C6C766D6275696C645C636C616E675C44656275675C7838365C6F626A322E63707000245430202E7261536561726368203D202465697020245430205E203D2024657370202454302034202B203D2000245430202E7261536561726368203D202465697020245430205E203D2024657370202454302034202B203D2024656270202454302034202D205E203D200024543020246562702034202B203D202465697020245430205E203D2024657370202454302034202B203D2024656270202454302034202D205E203D200000 + Subsections: + - !Symbols + Records: + - Kind: S_COMPILE3 + Compile3Sym: + Flags: [ ] + Machine: Pentium3 + FrontendMajor: 6 + FrontendMinor: 0 + FrontendBuild: 0 + FrontendQFE: 0 + BackendMajor: 6000 + BackendMinor: 0 + BackendBuild: 0 + BackendQFE: 0 + Version: 'clang version 6.0.0 ' + - !FrameData + Frames: + - CodeSize: 25 + FrameFunc: '$T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = ' + LocalSize: 0 + MaxStackSize: 0 + ParamsSize: 4 + PrologSize: 4 + RvaStart: 0 + SavedRegsSize: 0 + - CodeSize: 24 + FrameFunc: '$T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = ' + LocalSize: 0 + MaxStackSize: 0 + ParamsSize: 4 + PrologSize: 3 + RvaStart: 1 + SavedRegsSize: 4 + - CodeSize: 22 + FrameFunc: '$T0 $ebp 4 + = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = ' + LocalSize: 0 + MaxStackSize: 0 + ParamsSize: 4 + PrologSize: 1 + RvaStart: 3 + SavedRegsSize: 4 + - !Symbols + Records: + - Kind: S_GPROC32_ID + ProcSym: + CodeSize: 25 + DbgStart: 0 + DbgEnd: 0 + FunctionType: 4109 + Flags: [ ] + DisplayName: 'NS::func' + - Kind: S_LOCAL + LocalSym: + Type: 4099 + Flags: [ IsParameter ] + VarName: f + - Kind: S_DEFRANGE_REGISTER_REL + DefRangeRegisterRelSym: + - Kind: S_PROC_ID_END + ScopeEndSym: + - !Lines + CodeSize: 25 + Flags: [ ] + RelocOffset: 0 + RelocSegment: 0 + Blocks: + - FileName: 'D:\src\llvmbuild\clang\Debug\x86\obj2.cpp' + Lines: + - Offset: 0 + LineStart: 3 + IsStatement: false + EndDelta: 0 + - Offset: 7 + LineStart: 4 + IsStatement: false + EndDelta: 0 + Columns: + - !Symbols + Records: + - Kind: S_UDT + UDTSym: + Type: 4106 + UDTName: 'NS::Foo' + - !FileChecksums + Checksums: + - FileName: 'D:\src\llvmbuild\clang\Debug\x86\obj2.cpp' + Kind: MD5 + Checksum: 59DFAC75D18675AED1AD169FE316317E + - !StringTable + Strings: + - 'D:\src\llvmbuild\clang\Debug\x86\obj2.cpp' + - '$T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = ' + - '$T0 .raSearch = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = ' + - '$T0 $ebp 4 + = $eip $T0 ^ = $esp $T0 4 + = $ebp $T0 4 - ^ = ' + - '' + Relocations: + - VirtualAddress: 68 + SymbolName: '?func@NS@@YAHABUFoo@1@@Z' + Type: IMAGE_REL_I386_DIR32NB + - VirtualAddress: 208 + SymbolName: '?func@NS@@YAHABUFoo@1@@Z' + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 212 + SymbolName: '?func@NS@@YAHABUFoo@1@@Z' + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 248 + SymbolName: .text + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 252 + SymbolName: .text + Type: IMAGE_REL_I386_SECTION + - VirtualAddress: 268 + SymbolName: '?func@NS@@YAHABUFoo@1@@Z' + Type: IMAGE_REL_I386_SECREL + - VirtualAddress: 272 + SymbolName: '?func@NS@@YAHABUFoo@1@@Z' + Type: IMAGE_REL_I386_SECTION + - Name: '.debug$T' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 040000000A000516000000004E5300F12A0005150000800200000000000000000000000000004E533A3A466F6F002E3F4155466F6F404E53404000F10A000110011000000100F2F10A000210021000002A8000000A00011201000000031000000E0008107400000000000100041000000A000210011000000A8000000A00011201000000740000001A0009100300000001100000061000000B00010007100000000000001A0003120D15030074000000000058001115030008100000466F6F002A0005150200000209100000000000000000000004004E533A3A466F6F002E3F4155466F6F404E53404000F12E00051600000000443A5C7372635C6C6C766D6275696C645C636C616E675C44656275675C7838365C6F626A2E6800F10E0006160A1000000B1000000200000012000116001000000510000066756E6300F3F2F1 + Types: + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: NS + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: 'NS::Foo' + UniqueName: '.?AUFoo@NS@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_MODIFIER + Modifier: + ModifiedType: 4097 + Modifiers: [ None, Const ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4098 + Attrs: 32810 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4099 ] + - Kind: LF_PROCEDURE + Procedure: + ReturnType: 116 + CallConv: NearC + Options: [ None ] + ParameterCount: 1 + ArgumentList: 4100 + - Kind: LF_POINTER + Pointer: + ReferentType: 4097 + Attrs: 32778 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 116 ] + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4097 + ThisType: 4102 + CallConv: ThisCall + Options: [ None ] + ParameterCount: 1 + ArgumentList: 4103 + ThisPointerAdjustment: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 116 + FieldOffset: 0 + Name: X + - Kind: LF_ONEMETHOD + OneMethod: + Type: 4104 + Attrs: 3 + VFTableOffset: -1 + Name: Foo + - Kind: LF_STRUCTURE + Class: + MemberCount: 2 + Options: [ None, HasUniqueName ] + FieldList: 4105 + Name: 'NS::Foo' + UniqueName: '.?AUFoo@NS@@' + DerivationList: 0 + VTableShape: 0 + Size: 4 + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: 'D:\src\llvmbuild\clang\Debug\x86\obj.h' + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4106 + SourceFile: 4107 + LineNumber: 2 + - Kind: LF_FUNC_ID + FuncId: + ParentScope: 4096 + FunctionType: 4101 + Name: func + - Name: '.debug$H' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: C5C9330100000000EC145CD76AEFE74E78880D531132B3BB8FFACEF79E616EF06A14EA74A2420F9062A1FB04917E59759949E334BA18509ED692F3C65CE242D8450EBC78B81B63AF8316DC324562EB9F0D4A0D708E8A25C263DB05943C19B84A36719E1E414DDA3EDBDF005322238D70F9058EEDC5C50EF11BC849618B51FD89E3A50EABE5E8FE3945468547C19DC681D0BFB3B797DD91CA4D7F1953C314442D5549419E78044E38A0BF16BFFAA5EE9C0103E7DBFE9941E63379C0B0C0A9021B711ACC4F67008974EBF441031BDD653F6935DFF3112C6A5346EF2AC94B9B7EB56EF55CFA0AF6C1846743F43D846BB19517E12E8873BBA90CC41DD1BEAC89CBA8897AC1BA46762E2557A82D89DCBC783AF285D9DBB672F67A81E36906B2038B57 + GlobalHashes: + Version: 0 + HashAlgorithm: 0 + HashValues: + - EC145CD76AEFE74E78880D531132B3BB8FFACEF7 + - 9E616EF06A14EA74A2420F9062A1FB04917E5975 + - 9949E334BA18509ED692F3C65CE242D8450EBC78 + - B81B63AF8316DC324562EB9F0D4A0D708E8A25C2 + - 63DB05943C19B84A36719E1E414DDA3EDBDF0053 + - 22238D70F9058EEDC5C50EF11BC849618B51FD89 + - E3A50EABE5E8FE3945468547C19DC681D0BFB3B7 + - 97DD91CA4D7F1953C314442D5549419E78044E38 + - A0BF16BFFAA5EE9C0103E7DBFE9941E63379C0B0 + - C0A9021B711ACC4F67008974EBF441031BDD653F + - 6935DFF3112C6A5346EF2AC94B9B7EB56EF55CFA + - 0AF6C1846743F43D846BB19517E12E8873BBA90C + - C41DD1BEAC89CBA8897AC1BA46762E2557A82D89 + - DCBC783AF285D9DBB672F67A81E36906B2038B57 +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 25 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 1820185021 + Number: 1 + - Name: .data + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 0 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 2 + - Name: .bss + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 0 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 3 + - Name: .drectve + Value: 0 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 48 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 149686238 + Number: 4 + - Name: '.debug$S' + Value: 0 + SectionNumber: 5 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 584 + NumberOfRelocations: 7 + NumberOfLinenumbers: 0 + CheckSum: 2847177244 + Number: 5 + - Name: '.debug$T' + Value: 0 + SectionNumber: 6 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 320 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 2684556216 + Number: 6 + - Name: '.debug$H' + Value: 0 + SectionNumber: 7 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 288 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 2348181452 + Number: 7 + - Name: '@feat.00' + Value: 1 + SectionNumber: -1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: '?func@NS@@YAHABUFoo@1@@Z' + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/Inputs/pdb-scopes-a.yaml b/test/COFF/Inputs/pdb-scopes-a.yaml index e9f4484c7060..e422a6241f27 100644 --- a/test/COFF/Inputs/pdb-scopes-a.yaml +++ b/test/COFF/Inputs/pdb-scopes-a.yaml @@ -1,8 +1,8 @@ --- !COFF -header: +header: Machine: IMAGE_FILE_MACHINE_AMD64 Characteristics: [ ] -sections: +sections: - Name: .drectve Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] Alignment: 1 @@ -10,15 +10,15 @@ sections: - Name: '.debug$S' Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] Alignment: 1 - Subsections: + Subsections: - !Symbols - Records: + Records: - Kind: S_OBJNAME - ObjNameSym: + ObjNameSym: Signature: 0 ObjectName: 'C:\src\llvm-project\build\a.obj' - Kind: S_COMPILE3 - Compile3Sym: + Compile3Sym: Flags: [ SecurityChecks, HotPatch ] Machine: X64 FrontendMajor: 19 @@ -31,9 +31,9 @@ sections: BackendQFE: 1 Version: 'Microsoft (R) Optimizing Compiler' - !Symbols - Records: + Records: - Kind: S_GPROC32_ID - ProcSym: + ProcSym: CodeSize: 5 DbgStart: 4 DbgEnd: 4 @@ -41,7 +41,7 @@ sections: Flags: [ ] DisplayName: g - Kind: S_FRAMEPROC - FrameProcSym: + FrameProcSym: TotalFrameBytes: 0 PaddingFrameBytes: 0 OffsetToPadding: 0 @@ -50,30 +50,30 @@ sections: SectionIdOfExceptionHandler: 0 Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ] - Kind: S_REGREL32 - RegRelativeSym: + RegRelativeSym: Offset: 8 Type: 116 Register: RSP VarName: x - Kind: S_PROC_ID_END - ScopeEndSym: + ScopeEndSym: - !Lines CodeSize: 5 Flags: [ ] RelocOffset: 0 RelocSegment: 0 - Blocks: + Blocks: - FileName: 'c:\src\llvm-project\build\a.c' - Lines: + Lines: - Offset: 0 LineStart: 1 IsStatement: true EndDelta: 0 - Columns: + Columns: - !Symbols - Records: + Records: - Kind: S_GPROC32_ID - ProcSym: + ProcSym: CodeSize: 58 DbgStart: 8 DbgEnd: 53 @@ -81,7 +81,7 @@ sections: Flags: [ ] DisplayName: main - Kind: S_FRAMEPROC - FrameProcSym: + FrameProcSym: TotalFrameBytes: 56 PaddingFrameBytes: 0 OffsetToPadding: 0 @@ -90,47 +90,47 @@ sections: SectionIdOfExceptionHandler: 0 Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ] - Kind: S_REGREL32 - RegRelativeSym: + RegRelativeSym: Offset: 64 Type: 116 Register: RSP VarName: argc - Kind: S_BLOCK32 - BlockSym: + BlockSym: CodeSize: 17 Offset: 15 BlockName: '' - Kind: S_REGREL32 - RegRelativeSym: + RegRelativeSym: Offset: 32 Type: 116 Register: RSP VarName: x - Kind: S_END - ScopeEndSym: + ScopeEndSym: - Kind: S_BLOCK32 - BlockSym: + BlockSym: CodeSize: 17 Offset: 34 BlockName: '' - Kind: S_REGREL32 - RegRelativeSym: + RegRelativeSym: Offset: 36 Type: 116 Register: RSP VarName: y - Kind: S_END - ScopeEndSym: + ScopeEndSym: - Kind: S_PROC_ID_END - ScopeEndSym: + ScopeEndSym: - !Lines CodeSize: 58 Flags: [ ] RelocOffset: 0 RelocSegment: 0 - Blocks: + Blocks: - FileName: 'c:\src\llvm-project\build\a.c' - Lines: + Lines: - Offset: 0 LineStart: 3 IsStatement: true @@ -163,21 +163,21 @@ sections: LineStart: 11 IsStatement: true EndDelta: 0 - Columns: + Columns: - !FileChecksums - Checksums: + Checksums: - FileName: 'c:\src\llvm-project\build\a.c' Kind: MD5 Checksum: 7FA72225C3F5630316383BD8BCC3EF72 - !StringTable - Strings: + Strings: - 'c:\src\llvm-project\build\a.c' - !Symbols - Records: + Records: - Kind: S_BUILDINFO - BuildInfoSym: + BuildInfoSym: BuildId: 4110 - Relocations: + Relocations: - VirtualAddress: 152 SymbolName: g Type: IMAGE_REL_AMD64_SECREL @@ -217,78 +217,78 @@ sections: - Name: '.debug$T' Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] Alignment: 1 - Types: + Types: - Kind: LF_ARGLIST - ArgList: + ArgList: ArgIndices: [ 116 ] - Kind: LF_PROCEDURE - Procedure: + Procedure: ReturnType: 3 CallConv: NearC Options: [ None ] ParameterCount: 1 ArgumentList: 4096 - Kind: LF_POINTER - Pointer: + Pointer: ReferentType: 4097 Attrs: 65548 - Kind: LF_FUNC_ID - FuncId: + FuncId: ParentScope: 0 FunctionType: 4097 Name: g - Kind: LF_PROCEDURE - Procedure: + Procedure: ReturnType: 116 CallConv: NearC Options: [ None ] ParameterCount: 1 ArgumentList: 4096 - Kind: LF_FUNC_ID - FuncId: + FuncId: ParentScope: 0 FunctionType: 4100 Name: main - Kind: LF_FUNC_ID - FuncId: + FuncId: ParentScope: 0 FunctionType: 4097 Name: f - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: 'C:\src\llvm-project\build' - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: 'C:\PROGRA~2\MICROS~1.0\VC\Bin\amd64\cl.exe' - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: '-c -Z7 -MT -IC:\PROGRA~2\MICROS~1.0\VC\include -IC:\PROGRA~2\MICROS~1.0\VC\atlmfc\include -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\ucrt -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\shared -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\um' - Kind: LF_SUBSTR_LIST - StringList: + StringList: StringIndices: [ 4105 ] - Kind: LF_STRING_ID - StringId: + StringId: Id: 4106 String: ' -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\winrt -TC -X' - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: a.c - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: 'C:\src\llvm-project\build\vc140.pdb' - Kind: LF_BUILDINFO - BuildInfo: + BuildInfo: ArgIndices: [ 4103, 4104, 4108, 4109, 4107 ] - Name: '.text$mn' Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] Alignment: 16 SectionData: 894C2408C3CCCCCCCCCCCCCCCCCCCCCC894C24084883EC38837C2440007413C74424202A0000008B4C2420E800000000EB11C74424240D0000008B4C2424E80000000033C04883C438C3 - Relocations: + Relocations: - VirtualAddress: 44 SymbolName: f Type: IMAGE_REL_AMD64_REL32 @@ -303,7 +303,7 @@ sections: Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] Alignment: 4 SectionData: 000000003A00000000000000 - Relocations: + Relocations: - VirtualAddress: 0 SymbolName: '$LN5' Type: IMAGE_REL_AMD64_ADDR32NB @@ -313,14 +313,14 @@ sections: - VirtualAddress: 8 SymbolName: '$unwind$main' Type: IMAGE_REL_AMD64_ADDR32NB -symbols: +symbols: - Name: .drectve Value: 0 SectionNumber: 1 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 47 NumberOfRelocations: 0 NumberOfLinenumbers: 0 @@ -332,7 +332,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 628 NumberOfRelocations: 12 NumberOfLinenumbers: 0 @@ -344,7 +344,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 624 NumberOfRelocations: 0 NumberOfLinenumbers: 0 @@ -356,7 +356,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 74 NumberOfRelocations: 2 NumberOfLinenumbers: 0 @@ -392,7 +392,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 8 NumberOfRelocations: 0 NumberOfLinenumbers: 0 @@ -410,7 +410,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 12 NumberOfRelocations: 3 NumberOfLinenumbers: 0 diff --git a/test/COFF/Inputs/pdb-scopes-b.yaml b/test/COFF/Inputs/pdb-scopes-b.yaml index 2839bf7e3538..b1c602143c3f 100644 --- a/test/COFF/Inputs/pdb-scopes-b.yaml +++ b/test/COFF/Inputs/pdb-scopes-b.yaml @@ -1,8 +1,8 @@ --- !COFF -header: +header: Machine: IMAGE_FILE_MACHINE_AMD64 Characteristics: [ ] -sections: +sections: - Name: .drectve Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] Alignment: 1 @@ -10,15 +10,15 @@ sections: - Name: '.debug$S' Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] Alignment: 1 - Subsections: + Subsections: - !Symbols - Records: + Records: - Kind: S_OBJNAME - ObjNameSym: + ObjNameSym: Signature: 0 ObjectName: 'C:\src\llvm-project\build\b.obj' - Kind: S_COMPILE3 - Compile3Sym: + Compile3Sym: Flags: [ SecurityChecks, HotPatch ] Machine: X64 FrontendMajor: 19 @@ -31,9 +31,9 @@ sections: BackendQFE: 1 Version: 'Microsoft (R) Optimizing Compiler' - !Symbols - Records: + Records: - Kind: S_GPROC32_ID - ProcSym: + ProcSym: CodeSize: 62 DbgStart: 8 DbgEnd: 57 @@ -41,7 +41,7 @@ sections: Flags: [ ] DisplayName: f - Kind: S_FRAMEPROC - FrameProcSym: + FrameProcSym: TotalFrameBytes: 56 PaddingFrameBytes: 0 OffsetToPadding: 0 @@ -50,47 +50,47 @@ sections: SectionIdOfExceptionHandler: 0 Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ] - Kind: S_REGREL32 - RegRelativeSym: + RegRelativeSym: Offset: 64 Type: 116 Register: RSP VarName: x - Kind: S_BLOCK32 - BlockSym: + BlockSym: CodeSize: 20 Offset: 15 BlockName: '' - Kind: S_REGREL32 - RegRelativeSym: + RegRelativeSym: Offset: 32 Type: 116 Register: RSP VarName: y - Kind: S_END - ScopeEndSym: + ScopeEndSym: - Kind: S_BLOCK32 - BlockSym: + BlockSym: CodeSize: 20 Offset: 37 BlockName: '' - Kind: S_REGREL32 - RegRelativeSym: + RegRelativeSym: Offset: 36 Type: 116 Register: RSP VarName: w - Kind: S_END - ScopeEndSym: + ScopeEndSym: - Kind: S_PROC_ID_END - ScopeEndSym: + ScopeEndSym: - !Lines CodeSize: 62 Flags: [ ] RelocOffset: 0 RelocSegment: 0 - Blocks: + Blocks: - FileName: 'c:\src\llvm-project\build\b.c' - Lines: + Lines: - Offset: 0 LineStart: 2 IsStatement: true @@ -123,21 +123,21 @@ sections: LineStart: 10 IsStatement: true EndDelta: 0 - Columns: + Columns: - !FileChecksums - Checksums: + Checksums: - FileName: 'c:\src\llvm-project\build\b.c' Kind: MD5 Checksum: 8E8C92DB46478902EBEAEBFCFF15A6E0 - !StringTable - Strings: + Strings: - 'c:\src\llvm-project\build\b.c' - !Symbols - Records: + Records: - Kind: S_BUILDINFO - BuildInfoSym: + BuildInfoSym: BuildId: 4110 - Relocations: + Relocations: - VirtualAddress: 152 SymbolName: f Type: IMAGE_REL_AMD64_SECREL @@ -165,76 +165,76 @@ sections: - Name: '.debug$T' Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] Alignment: 1 - Types: + Types: - Kind: LF_ARGLIST - ArgList: + ArgList: ArgIndices: [ 0 ] - Kind: LF_PROCEDURE - Procedure: + Procedure: ReturnType: 3 CallConv: NearC Options: [ None ] ParameterCount: 0 ArgumentList: 4096 - Kind: LF_POINTER - Pointer: + Pointer: ReferentType: 4097 Attrs: 65548 - Kind: LF_ARGLIST - ArgList: + ArgList: ArgIndices: [ 116 ] - Kind: LF_PROCEDURE - Procedure: + Procedure: ReturnType: 3 CallConv: NearC Options: [ None ] ParameterCount: 1 ArgumentList: 4099 - Kind: LF_FUNC_ID - FuncId: + FuncId: ParentScope: 0 FunctionType: 4100 Name: f - Kind: LF_FUNC_ID - FuncId: + FuncId: ParentScope: 0 FunctionType: 4097 Name: g - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: 'C:\src\llvm-project\build' - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: 'C:\PROGRA~2\MICROS~1.0\VC\Bin\amd64\cl.exe' - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: '-c -Z7 -MT -IC:\PROGRA~2\MICROS~1.0\VC\include -IC:\PROGRA~2\MICROS~1.0\VC\atlmfc\include -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\ucrt -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\shared -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\um' - Kind: LF_SUBSTR_LIST - StringList: + StringList: StringIndices: [ 4105 ] - Kind: LF_STRING_ID - StringId: + StringId: Id: 4106 String: ' -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\winrt -TC -X' - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: b.c - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: 'C:\src\llvm-project\build\vc140.pdb' - Kind: LF_BUILDINFO - BuildInfo: + BuildInfo: ArgIndices: [ 4103, 4104, 4108, 4109, 4107 ] - Name: '.text$mn' Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] Alignment: 16 SectionData: 894C24084883EC38837C24400074168B44244083C003894424208B4C2420E800000000EB148B44244083C004894424248B4C2424E8000000004883C438C3 - Relocations: + Relocations: - VirtualAddress: 31 SymbolName: g Type: IMAGE_REL_AMD64_REL32 @@ -249,7 +249,7 @@ sections: Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] Alignment: 4 SectionData: '000000003E00000000000000' - Relocations: + Relocations: - VirtualAddress: 0 SymbolName: '$LN5' Type: IMAGE_REL_AMD64_ADDR32NB @@ -259,14 +259,14 @@ sections: - VirtualAddress: 8 SymbolName: '$unwind$f' Type: IMAGE_REL_AMD64_ADDR32NB -symbols: +symbols: - Name: .drectve Value: 0 SectionNumber: 1 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 47 NumberOfRelocations: 0 NumberOfLinenumbers: 0 @@ -278,7 +278,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 484 NumberOfRelocations: 8 NumberOfLinenumbers: 0 @@ -290,7 +290,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 616 NumberOfRelocations: 0 NumberOfLinenumbers: 0 @@ -302,7 +302,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 62 NumberOfRelocations: 2 NumberOfLinenumbers: 0 @@ -332,7 +332,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 8 NumberOfRelocations: 0 NumberOfLinenumbers: 0 @@ -350,7 +350,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 12 NumberOfRelocations: 3 NumberOfLinenumbers: 0 diff --git a/test/COFF/Inputs/pdb_comdat_bar.yaml b/test/COFF/Inputs/pdb_comdat_bar.yaml index 71a9535c50b7..796e71379c47 100644 --- a/test/COFF/Inputs/pdb_comdat_bar.yaml +++ b/test/COFF/Inputs/pdb_comdat_bar.yaml @@ -1,8 +1,8 @@ --- !COFF -header: +header: Machine: IMAGE_FILE_MACHINE_AMD64 Characteristics: [ ] -sections: +sections: - Name: .drectve Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] Alignment: 1 @@ -10,15 +10,15 @@ sections: - Name: '.debug$S' Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] Alignment: 1 - Subsections: + Subsections: - !Symbols - Records: + Records: - Kind: S_OBJNAME - ObjNameSym: + ObjNameSym: Signature: 0 ObjectName: 'C:\src\llvm-project\build\pdb_comdat_bar.obj' - Kind: S_COMPILE3 - Compile3Sym: + Compile3Sym: Flags: [ SecurityChecks, HotPatch ] Machine: X64 FrontendMajor: 19 @@ -31,9 +31,9 @@ sections: BackendQFE: 1 Version: 'Microsoft (R) Optimizing Compiler' - !Symbols - Records: + Records: - Kind: S_GPROC32_ID - ProcSym: + ProcSym: PtrParent: 0 PtrEnd: 0 PtrNext: 0 @@ -45,7 +45,7 @@ sections: Flags: [ ] DisplayName: bar - Kind: S_FRAMEPROC - FrameProcSym: + FrameProcSym: TotalFrameBytes: 40 PaddingFrameBytes: 0 OffsetToPadding: 0 @@ -54,15 +54,15 @@ sections: SectionIdOfExceptionHandler: 0 Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ] - Kind: S_PROC_ID_END - ScopeEndSym: + ScopeEndSym: - !Lines CodeSize: 14 Flags: [ ] RelocOffset: 0 RelocSegment: 0 - Blocks: + Blocks: - FileName: 'c:\src\llvm-project\build\pdb_comdat_bar.c' - Lines: + Lines: - Offset: 0 LineStart: 3 IsStatement: true @@ -75,15 +75,15 @@ sections: LineStart: 5 IsStatement: true EndDelta: 0 - Columns: + Columns: - !Symbols - Records: + Records: - Kind: S_GDATA32 - DataSym: + DataSym: Type: 116 DisplayName: global - !FileChecksums - Checksums: + Checksums: - FileName: 'c:\src\llvm-project\build\pdb_comdat_bar.c' Kind: MD5 Checksum: 365279DB4FCBEDD721BBFC3B14A953C2 @@ -91,15 +91,15 @@ sections: Kind: MD5 Checksum: D74D834EFAC3AE2B45E606A8320B1D5C - !StringTable - Strings: + Strings: - 'c:\src\llvm-project\build\pdb_comdat_bar.c' - 'c:\src\llvm-project\build\foo.h' - !Symbols - Records: + Records: - Kind: S_BUILDINFO - BuildInfoSym: + BuildInfoSym: BuildId: 4110 - Relocations: + Relocations: - VirtualAddress: 168 SymbolName: bar Type: IMAGE_REL_AMD64_SECREL @@ -121,70 +121,70 @@ sections: - Name: '.debug$T' Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] Alignment: 1 - Types: + Types: - Kind: LF_ARGLIST - ArgList: + ArgList: ArgIndices: [ 0 ] - Kind: LF_PROCEDURE - Procedure: + Procedure: ReturnType: 3 CallConv: NearC Options: [ None ] ParameterCount: 0 ArgumentList: 4096 - Kind: LF_POINTER - Pointer: + Pointer: ReferentType: 4097 Attrs: 65548 - Kind: LF_FUNC_ID - FuncId: + FuncId: ParentScope: 0 FunctionType: 4097 Name: foo - Kind: LF_ARGLIST - ArgList: + ArgList: ArgIndices: [ ] - Kind: LF_PROCEDURE - Procedure: + Procedure: ReturnType: 3 CallConv: NearC Options: [ None ] ParameterCount: 0 ArgumentList: 4100 - Kind: LF_FUNC_ID - FuncId: + FuncId: ParentScope: 0 FunctionType: 4101 Name: bar - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: 'C:\src\llvm-project\build' - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: 'C:\PROGRA~2\MICROS~1.0\VC\Bin\amd64\cl.exe' - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: '-c -Z7 -MT -IC:\PROGRA~2\MICROS~1.0\VC\include -IC:\PROGRA~2\MICROS~1.0\VC\atlmfc\include -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\ucrt -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\shared -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\um' - Kind: LF_SUBSTR_LIST - StringList: + StringList: StringIndices: [ 4105 ] - Kind: LF_STRING_ID - StringId: + StringId: Id: 4106 String: ' -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\winrt -TC -X' - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: pdb_comdat_bar.c - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: 'C:\src\llvm-project\build\vc140.pdb' - Kind: LF_BUILDINFO - BuildInfo: + BuildInfo: ArgIndices: [ 4103, 4104, 4108, 4109, 4107 ] - Name: .bss Characteristics: [ IMAGE_SCN_CNT_UNINITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] @@ -194,7 +194,7 @@ sections: Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] Alignment: 16 SectionData: 4883EC28E8000000004883C428C3 - Relocations: + Relocations: - VirtualAddress: 5 SymbolName: foo Type: IMAGE_REL_AMD64_REL32 @@ -202,7 +202,7 @@ sections: Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] Alignment: 16 SectionData: 8B0500000000FFC0890500000000C3 - Relocations: + Relocations: - VirtualAddress: 2 SymbolName: global Type: IMAGE_REL_AMD64_REL32 @@ -212,11 +212,11 @@ sections: - Name: '.debug$S' Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] Alignment: 1 - Subsections: + Subsections: - !Symbols - Records: + Records: - Kind: S_GPROC32_ID - ProcSym: + ProcSym: PtrParent: 0 PtrEnd: 0 PtrNext: 0 @@ -228,7 +228,7 @@ sections: Flags: [ ] DisplayName: foo - Kind: S_FRAMEPROC - FrameProcSym: + FrameProcSym: TotalFrameBytes: 0 PaddingFrameBytes: 0 OffsetToPadding: 0 @@ -237,15 +237,15 @@ sections: SectionIdOfExceptionHandler: 0 Flags: [ MarkedInline, AsynchronousExceptionHandling, OptimizedForSpeed ] - Kind: S_PROC_ID_END - ScopeEndSym: + ScopeEndSym: - !Lines CodeSize: 15 Flags: [ ] RelocOffset: 0 RelocSegment: 0 - Blocks: + Blocks: - FileName: 'c:\src\llvm-project\build\foo.h' - Lines: + Lines: - Offset: 0 LineStart: 2 IsStatement: true @@ -258,8 +258,8 @@ sections: LineStart: 4 IsStatement: true EndDelta: 0 - Columns: - Relocations: + Columns: + Relocations: - VirtualAddress: 44 SymbolName: foo Type: IMAGE_REL_AMD64_SECREL @@ -280,7 +280,7 @@ sections: Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] Alignment: 4 SectionData: '000000000E00000000000000' - Relocations: + Relocations: - VirtualAddress: 0 SymbolName: '$LN3' Type: IMAGE_REL_AMD64_ADDR32NB @@ -290,14 +290,14 @@ sections: - VirtualAddress: 8 SymbolName: '$unwind$bar' Type: IMAGE_REL_AMD64_ADDR32NB -symbols: +symbols: - Name: .drectve Value: 0 SectionNumber: 1 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 47 NumberOfRelocations: 0 NumberOfLinenumbers: 0 @@ -309,7 +309,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 460 NumberOfRelocations: 6 NumberOfLinenumbers: 0 @@ -321,7 +321,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 628 NumberOfRelocations: 0 NumberOfLinenumbers: 0 @@ -333,7 +333,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 4 NumberOfRelocations: 0 NumberOfLinenumbers: 0 @@ -351,7 +351,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 14 NumberOfRelocations: 1 NumberOfLinenumbers: 0 @@ -363,7 +363,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 15 NumberOfRelocations: 2 NumberOfLinenumbers: 0 @@ -376,7 +376,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 148 NumberOfRelocations: 4 NumberOfLinenumbers: 0 @@ -407,7 +407,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 8 NumberOfRelocations: 0 NumberOfLinenumbers: 0 @@ -425,7 +425,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 12 NumberOfRelocations: 3 NumberOfLinenumbers: 0 diff --git a/test/COFF/Inputs/pdb_comdat_main.yaml b/test/COFF/Inputs/pdb_comdat_main.yaml index d9019d633415..637ac21abc5c 100644 --- a/test/COFF/Inputs/pdb_comdat_main.yaml +++ b/test/COFF/Inputs/pdb_comdat_main.yaml @@ -1,8 +1,8 @@ --- !COFF -header: +header: Machine: IMAGE_FILE_MACHINE_AMD64 Characteristics: [ ] -sections: +sections: - Name: .drectve Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] Alignment: 1 @@ -10,15 +10,15 @@ sections: - Name: '.debug$S' Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] Alignment: 1 - Subsections: + Subsections: - !Symbols - Records: + Records: - Kind: S_OBJNAME - ObjNameSym: + ObjNameSym: Signature: 0 ObjectName: 'C:\src\llvm-project\build\pdb_comdat_main.obj' - Kind: S_COMPILE3 - Compile3Sym: + Compile3Sym: Flags: [ SecurityChecks, HotPatch ] Machine: X64 FrontendMajor: 19 @@ -31,9 +31,9 @@ sections: BackendQFE: 1 Version: 'Microsoft (R) Optimizing Compiler' - !Symbols - Records: + Records: - Kind: S_GPROC32_ID - ProcSym: + ProcSym: PtrParent: 0 PtrEnd: 0 PtrNext: 0 @@ -45,7 +45,7 @@ sections: Flags: [ ] DisplayName: main - Kind: S_FRAMEPROC - FrameProcSym: + FrameProcSym: TotalFrameBytes: 40 PaddingFrameBytes: 0 OffsetToPadding: 0 @@ -54,15 +54,15 @@ sections: SectionIdOfExceptionHandler: 0 Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ] - Kind: S_PROC_ID_END - ScopeEndSym: + ScopeEndSym: - !Lines CodeSize: 24 Flags: [ ] RelocOffset: 0 RelocSegment: 0 - Blocks: + Blocks: - FileName: 'c:\src\llvm-project\build\pdb_comdat_main.c' - Lines: + Lines: - Offset: 0 LineStart: 2 IsStatement: true @@ -83,15 +83,15 @@ sections: LineStart: 6 IsStatement: true EndDelta: 0 - Columns: + Columns: - !Symbols - Records: + Records: - Kind: S_GDATA32 - DataSym: + DataSym: Type: 116 DisplayName: global - !FileChecksums - Checksums: + Checksums: - FileName: 'c:\src\llvm-project\build\pdb_comdat_main.c' Kind: MD5 Checksum: F969E51BBE373436D81492EB61387F36 @@ -99,15 +99,15 @@ sections: Kind: MD5 Checksum: D74D834EFAC3AE2B45E606A8320B1D5C - !StringTable - Strings: + Strings: - 'c:\src\llvm-project\build\pdb_comdat_main.c' - 'c:\src\llvm-project\build\foo.h' - !Symbols - Records: + Records: - Kind: S_BUILDINFO - BuildInfoSym: + BuildInfoSym: BuildId: 4111 - Relocations: + Relocations: - VirtualAddress: 168 SymbolName: main Type: IMAGE_REL_AMD64_SECREL @@ -129,81 +129,81 @@ sections: - Name: '.debug$T' Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] Alignment: 1 - Types: + Types: - Kind: LF_ARGLIST - ArgList: + ArgList: ArgIndices: [ 0 ] - Kind: LF_PROCEDURE - Procedure: + Procedure: ReturnType: 3 CallConv: NearC Options: [ None ] ParameterCount: 0 ArgumentList: 4096 - Kind: LF_POINTER - Pointer: + Pointer: ReferentType: 4097 Attrs: 65548 - Kind: LF_FUNC_ID - FuncId: + FuncId: ParentScope: 0 FunctionType: 4097 Name: foo - Kind: LF_ARGLIST - ArgList: + ArgList: ArgIndices: [ ] - Kind: LF_PROCEDURE - Procedure: + Procedure: ReturnType: 116 CallConv: NearC Options: [ None ] ParameterCount: 0 ArgumentList: 4100 - Kind: LF_FUNC_ID - FuncId: + FuncId: ParentScope: 0 FunctionType: 4101 Name: main - Kind: LF_FUNC_ID - FuncId: + FuncId: ParentScope: 0 FunctionType: 4097 Name: bar - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: 'C:\src\llvm-project\build' - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: 'C:\PROGRA~2\MICROS~1.0\VC\Bin\amd64\cl.exe' - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: '-c -Z7 -MT -IC:\PROGRA~2\MICROS~1.0\VC\include -IC:\PROGRA~2\MICROS~1.0\VC\atlmfc\include -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\ucrt -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\shared -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\um' - Kind: LF_SUBSTR_LIST - StringList: + StringList: StringIndices: [ 4106 ] - Kind: LF_STRING_ID - StringId: + StringId: Id: 4107 String: ' -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\winrt -TC -X' - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: pdb_comdat_main.c - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: 'C:\src\llvm-project\build\vc140.pdb' - Kind: LF_BUILDINFO - BuildInfo: + BuildInfo: ArgIndices: [ 4104, 4105, 4109, 4110, 4108 ] - Name: '.text$mn' Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] Alignment: 16 SectionData: 4883EC28E800000000E800000000B82A0000004883C428C3 - Relocations: + Relocations: - VirtualAddress: 5 SymbolName: foo Type: IMAGE_REL_AMD64_REL32 @@ -214,7 +214,7 @@ sections: Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] Alignment: 16 SectionData: 8B0500000000FFC0890500000000C3 - Relocations: + Relocations: - VirtualAddress: 2 SymbolName: global Type: IMAGE_REL_AMD64_REL32 @@ -224,11 +224,11 @@ sections: - Name: '.debug$S' Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] Alignment: 1 - Subsections: + Subsections: - !Symbols - Records: + Records: - Kind: S_GPROC32_ID - ProcSym: + ProcSym: PtrParent: 0 PtrEnd: 0 PtrNext: 0 @@ -240,7 +240,7 @@ sections: Flags: [ ] DisplayName: foo - Kind: S_FRAMEPROC - FrameProcSym: + FrameProcSym: TotalFrameBytes: 0 PaddingFrameBytes: 0 OffsetToPadding: 0 @@ -249,15 +249,15 @@ sections: SectionIdOfExceptionHandler: 0 Flags: [ MarkedInline, AsynchronousExceptionHandling, OptimizedForSpeed ] - Kind: S_PROC_ID_END - ScopeEndSym: + ScopeEndSym: - !Lines CodeSize: 15 Flags: [ ] RelocOffset: 0 RelocSegment: 0 - Blocks: + Blocks: - FileName: 'c:\src\llvm-project\build\foo.h' - Lines: + Lines: - Offset: 0 LineStart: 2 IsStatement: true @@ -270,8 +270,8 @@ sections: LineStart: 4 IsStatement: true EndDelta: 0 - Columns: - Relocations: + Columns: + Relocations: - VirtualAddress: 44 SymbolName: foo Type: IMAGE_REL_AMD64_SECREL @@ -292,7 +292,7 @@ sections: Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] Alignment: 4 SectionData: '000000001800000000000000' - Relocations: + Relocations: - VirtualAddress: 0 SymbolName: '$LN3' Type: IMAGE_REL_AMD64_ADDR32NB @@ -302,14 +302,14 @@ sections: - VirtualAddress: 8 SymbolName: '$unwind$main' Type: IMAGE_REL_AMD64_ADDR32NB -symbols: +symbols: - Name: .drectve Value: 0 SectionNumber: 1 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 47 NumberOfRelocations: 0 NumberOfLinenumbers: 0 @@ -321,7 +321,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 480 NumberOfRelocations: 6 NumberOfLinenumbers: 0 @@ -333,7 +333,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 648 NumberOfRelocations: 0 NumberOfLinenumbers: 0 @@ -345,7 +345,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 24 NumberOfRelocations: 2 NumberOfLinenumbers: 0 @@ -357,7 +357,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 15 NumberOfRelocations: 2 NumberOfLinenumbers: 0 @@ -370,7 +370,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 148 NumberOfRelocations: 4 NumberOfLinenumbers: 0 @@ -407,7 +407,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 8 NumberOfRelocations: 0 NumberOfLinenumbers: 0 @@ -425,7 +425,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 12 NumberOfRelocations: 3 NumberOfLinenumbers: 0 diff --git a/test/COFF/Inputs/pdb_lines_1.yaml b/test/COFF/Inputs/pdb_lines_1.yaml index 3fbb2a94d45f..b52ed97c93c7 100644 --- a/test/COFF/Inputs/pdb_lines_1.yaml +++ b/test/COFF/Inputs/pdb_lines_1.yaml @@ -1,8 +1,8 @@ --- !COFF -header: +header: Machine: IMAGE_FILE_MACHINE_AMD64 Characteristics: [ ] -sections: +sections: - Name: .drectve Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] Alignment: 1 @@ -10,15 +10,15 @@ sections: - Name: '.debug$S' Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] Alignment: 1 - Subsections: + Subsections: - !Symbols - Records: + Records: - Kind: S_OBJNAME - ObjNameSym: + ObjNameSym: Signature: 0 ObjectName: 'C:\src\llvm-project\build\pdb_lines_1.obj' - Kind: S_COMPILE3 - Compile3Sym: + Compile3Sym: Flags: [ SecurityChecks, HotPatch ] Machine: X64 FrontendMajor: 19 @@ -31,9 +31,9 @@ sections: BackendQFE: 1 Version: 'Microsoft (R) Optimizing Compiler' - !Symbols - Records: + Records: - Kind: S_GPROC32_ID - ProcSym: + ProcSym: PtrParent: 0 PtrEnd: 0 PtrNext: 0 @@ -45,7 +45,7 @@ sections: Flags: [ ] DisplayName: main - Kind: S_FRAMEPROC - FrameProcSym: + FrameProcSym: TotalFrameBytes: 40 PaddingFrameBytes: 0 OffsetToPadding: 0 @@ -54,15 +54,15 @@ sections: SectionIdOfExceptionHandler: 0 Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ] - Kind: S_PROC_ID_END - ScopeEndSym: + ScopeEndSym: - !Lines CodeSize: 19 Flags: [ ] RelocOffset: 0 RelocSegment: 0 - Blocks: + Blocks: - FileName: 'c:\src\llvm-project\build\pdb_lines_1.c' - Lines: + Lines: - Offset: 0 LineStart: 2 IsStatement: true @@ -79,9 +79,9 @@ sections: LineStart: 5 IsStatement: true EndDelta: 0 - Columns: + Columns: - !FileChecksums - Checksums: + Checksums: - FileName: 'c:\src\llvm-project\build\pdb_lines_1.c' Kind: MD5 Checksum: 4EB19DCD86C3BA2238A255C718572E7B @@ -89,15 +89,15 @@ sections: Kind: MD5 Checksum: 061EB73ABB642532857A4F1D9CBAC323 - !StringTable - Strings: + Strings: - 'c:\src\llvm-project\build\pdb_lines_1.c' - 'c:\src\llvm-project\build\foo.h' - !Symbols - Records: + Records: - Kind: S_BUILDINFO - BuildInfoSym: + BuildInfoSym: BuildId: 4111 - Relocations: + Relocations: - VirtualAddress: 164 SymbolName: main Type: IMAGE_REL_AMD64_SECREL @@ -113,81 +113,81 @@ sections: - Name: '.debug$T' Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] Alignment: 1 - Types: + Types: - Kind: LF_ARGLIST - ArgList: + ArgList: ArgIndices: [ ] - Kind: LF_PROCEDURE - Procedure: + Procedure: ReturnType: 3 CallConv: NearC Options: [ None ] ParameterCount: 0 ArgumentList: 4096 - Kind: LF_POINTER - Pointer: + Pointer: ReferentType: 4097 Attrs: 65548 - Kind: LF_FUNC_ID - FuncId: + FuncId: ParentScope: 0 FunctionType: 4097 Name: foo - Kind: LF_ARGLIST - ArgList: + ArgList: ArgIndices: [ 0 ] - Kind: LF_PROCEDURE - Procedure: + Procedure: ReturnType: 116 CallConv: NearC Options: [ None ] ParameterCount: 0 ArgumentList: 4100 - Kind: LF_FUNC_ID - FuncId: + FuncId: ParentScope: 0 FunctionType: 4101 Name: main - Kind: LF_FUNC_ID - FuncId: + FuncId: ParentScope: 0 FunctionType: 4097 Name: bar - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: 'C:\src\llvm-project\build' - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: 'C:\PROGRA~2\MICROS~1.0\VC\Bin\amd64\cl.exe' - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: '-c -Z7 -MT -IC:\PROGRA~2\MICROS~1.0\VC\include -IC:\PROGRA~2\MICROS~1.0\VC\atlmfc\include -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\ucrt -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\shared -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\um' - Kind: LF_SUBSTR_LIST - StringList: + StringList: StringIndices: [ 4106 ] - Kind: LF_STRING_ID - StringId: + StringId: Id: 4107 String: ' -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\winrt -TC -X' - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: pdb_lines_1.c - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: 'C:\src\llvm-project\build\vc140.pdb' - Kind: LF_BUILDINFO - BuildInfo: + BuildInfo: ArgIndices: [ 4104, 4105, 4109, 4110, 4108 ] - Name: '.text$mn' Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] Alignment: 16 SectionData: 4883EC28E800000000B82A0000004883C428C3 - Relocations: + Relocations: - VirtualAddress: 5 SymbolName: foo Type: IMAGE_REL_AMD64_REL32 @@ -195,18 +195,18 @@ sections: Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] Alignment: 16 SectionData: 4883EC28E8000000004883C428C3 - Relocations: + Relocations: - VirtualAddress: 5 SymbolName: bar Type: IMAGE_REL_AMD64_REL32 - Name: '.debug$S' Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] Alignment: 1 - Subsections: + Subsections: - !Symbols - Records: + Records: - Kind: S_GPROC32_ID - ProcSym: + ProcSym: PtrParent: 0 PtrEnd: 0 PtrNext: 0 @@ -218,7 +218,7 @@ sections: Flags: [ ] DisplayName: foo - Kind: S_FRAMEPROC - FrameProcSym: + FrameProcSym: TotalFrameBytes: 40 PaddingFrameBytes: 0 OffsetToPadding: 0 @@ -227,15 +227,15 @@ sections: SectionIdOfExceptionHandler: 0 Flags: [ MarkedInline, AsynchronousExceptionHandling, OptimizedForSpeed ] - Kind: S_PROC_ID_END - ScopeEndSym: + ScopeEndSym: - !Lines CodeSize: 14 Flags: [ ] RelocOffset: 0 RelocSegment: 0 - Blocks: + Blocks: - FileName: 'c:\src\llvm-project\build\foo.h' - Lines: + Lines: - Offset: 0 LineStart: 2 IsStatement: true @@ -248,8 +248,8 @@ sections: LineStart: 4 IsStatement: true EndDelta: 0 - Columns: - Relocations: + Columns: + Relocations: - VirtualAddress: 44 SymbolName: foo Type: IMAGE_REL_AMD64_SECREL @@ -270,7 +270,7 @@ sections: Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_READ ] Alignment: 4 SectionData: '000000000E00000000000000' - Relocations: + Relocations: - VirtualAddress: 0 SymbolName: '$LN3' Type: IMAGE_REL_AMD64_ADDR32NB @@ -288,7 +288,7 @@ sections: Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] Alignment: 4 SectionData: '000000001300000000000000' - Relocations: + Relocations: - VirtualAddress: 0 SymbolName: '$LN3' Type: IMAGE_REL_AMD64_ADDR32NB @@ -298,14 +298,14 @@ sections: - VirtualAddress: 8 SymbolName: '$unwind$main' Type: IMAGE_REL_AMD64_ADDR32NB -symbols: +symbols: - Name: .drectve Value: 0 SectionNumber: 1 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 47 NumberOfRelocations: 0 NumberOfLinenumbers: 0 @@ -317,7 +317,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 432 NumberOfRelocations: 4 NumberOfLinenumbers: 0 @@ -329,7 +329,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 644 NumberOfRelocations: 0 NumberOfLinenumbers: 0 @@ -341,7 +341,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 19 NumberOfRelocations: 1 NumberOfLinenumbers: 0 @@ -353,7 +353,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 14 NumberOfRelocations: 1 NumberOfLinenumbers: 0 @@ -366,7 +366,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 148 NumberOfRelocations: 4 NumberOfLinenumbers: 0 @@ -409,7 +409,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 8 NumberOfRelocations: 0 NumberOfLinenumbers: 0 @@ -428,7 +428,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 12 NumberOfRelocations: 3 NumberOfLinenumbers: 0 @@ -447,7 +447,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 8 NumberOfRelocations: 0 NumberOfLinenumbers: 0 @@ -465,7 +465,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 12 NumberOfRelocations: 3 NumberOfLinenumbers: 0 diff --git a/test/COFF/Inputs/pdb_lines_2.yaml b/test/COFF/Inputs/pdb_lines_2.yaml index 8ad8d062db58..8026c19c91d4 100644 --- a/test/COFF/Inputs/pdb_lines_2.yaml +++ b/test/COFF/Inputs/pdb_lines_2.yaml @@ -1,8 +1,8 @@ --- !COFF -header: +header: Machine: IMAGE_FILE_MACHINE_AMD64 Characteristics: [ ] -sections: +sections: - Name: .drectve Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] Alignment: 1 @@ -10,15 +10,15 @@ sections: - Name: '.debug$S' Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] Alignment: 1 - Subsections: + Subsections: - !Symbols - Records: + Records: - Kind: S_OBJNAME - ObjNameSym: + ObjNameSym: Signature: 0 ObjectName: 'C:\src\llvm-project\build\pdb_lines_2.obj' - Kind: S_COMPILE3 - Compile3Sym: + Compile3Sym: Flags: [ SecurityChecks, HotPatch ] Machine: X64 FrontendMajor: 19 @@ -31,9 +31,9 @@ sections: BackendQFE: 1 Version: 'Microsoft (R) Optimizing Compiler' - !Symbols - Records: + Records: - Kind: S_GPROC32_ID - ProcSym: + ProcSym: PtrParent: 0 PtrEnd: 0 PtrNext: 0 @@ -45,7 +45,7 @@ sections: Flags: [ ] DisplayName: bar - Kind: S_FRAMEPROC - FrameProcSym: + FrameProcSym: TotalFrameBytes: 0 PaddingFrameBytes: 0 OffsetToPadding: 0 @@ -54,15 +54,15 @@ sections: SectionIdOfExceptionHandler: 0 Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ] - Kind: S_PROC_ID_END - ScopeEndSym: + ScopeEndSym: - !Lines CodeSize: 1 Flags: [ ] RelocOffset: 0 RelocSegment: 0 - Blocks: + Blocks: - FileName: 'c:\src\llvm-project\build\pdb_lines_2.c' - Lines: + Lines: - Offset: 0 LineStart: 1 IsStatement: true @@ -71,21 +71,21 @@ sections: LineStart: 2 IsStatement: true EndDelta: 0 - Columns: + Columns: - !FileChecksums - Checksums: + Checksums: - FileName: 'c:\src\llvm-project\build\pdb_lines_2.c' Kind: MD5 Checksum: DF91CB3A2B8D917486574BB50CAC4CC7 - !StringTable - Strings: + Strings: - 'c:\src\llvm-project\build\pdb_lines_2.c' - !Symbols - Records: + Records: - Kind: S_BUILDINFO - BuildInfoSym: + BuildInfoSym: BuildId: 4106 - Relocations: + Relocations: - VirtualAddress: 164 SymbolName: bar Type: IMAGE_REL_AMD64_SECREL @@ -101,64 +101,64 @@ sections: - Name: '.debug$T' Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] Alignment: 1 - Types: + Types: - Kind: LF_ARGLIST - ArgList: + ArgList: ArgIndices: [ ] - Kind: LF_PROCEDURE - Procedure: + Procedure: ReturnType: 3 CallConv: NearC Options: [ None ] ParameterCount: 0 ArgumentList: 4096 - Kind: LF_FUNC_ID - FuncId: + FuncId: ParentScope: 0 FunctionType: 4097 Name: bar - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: 'C:\src\llvm-project\build' - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: 'C:\PROGRA~2\MICROS~1.0\VC\Bin\amd64\cl.exe' - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: '-c -Z7 -MT -IC:\PROGRA~2\MICROS~1.0\VC\include -IC:\PROGRA~2\MICROS~1.0\VC\atlmfc\include -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\ucrt -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\shared -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\um' - Kind: LF_SUBSTR_LIST - StringList: + StringList: StringIndices: [ 4101 ] - Kind: LF_STRING_ID - StringId: + StringId: Id: 4102 String: ' -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.14393.0\winrt -TC -X' - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: pdb_lines_2.c - Kind: LF_STRING_ID - StringId: + StringId: Id: 0 String: 'C:\src\llvm-project\build\vc140.pdb' - Kind: LF_BUILDINFO - BuildInfo: + BuildInfo: ArgIndices: [ 4099, 4100, 4104, 4105, 4103 ] - Name: '.text$mn' Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] Alignment: 16 SectionData: C3 -symbols: +symbols: - Name: .drectve Value: 0 SectionNumber: 1 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 47 NumberOfRelocations: 0 NumberOfLinenumbers: 0 @@ -170,7 +170,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 360 NumberOfRelocations: 4 NumberOfLinenumbers: 0 @@ -182,7 +182,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 568 NumberOfRelocations: 0 NumberOfLinenumbers: 0 @@ -194,7 +194,7 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: + SectionDefinition: Length: 1 NumberOfRelocations: 0 NumberOfLinenumbers: 0 diff --git a/test/COFF/arm-thumb-branch20-error.s b/test/COFF/arm-thumb-branch20-error.s new file mode 100644 index 000000000000..ec7d23b05329 --- /dev/null +++ b/test/COFF/arm-thumb-branch20-error.s @@ -0,0 +1,10 @@ +// REQUIRES: arm +// RUN: llvm-mc -filetype=obj -triple=thumbv7a-windows-gnu %s -o %t.obj +// RUN: llvm-mc -filetype=obj -triple=thumbv7a-windows-gnu %S/Inputs/far-arm-thumb-abs20.s -o %t.far.obj +// RUN: not lld-link -entry:_start -subsystem:console %t.obj %t.far.obj -out:%t.exe 2>&1 | FileCheck %s + .syntax unified + .globl _start +_start: + bne too_far20 + +// CHECK: relocation out of range diff --git a/test/COFF/arm64-dynamicbase.s b/test/COFF/arm64-dynamicbase.s new file mode 100644 index 000000000000..d4cb12c1c8ff --- /dev/null +++ b/test/COFF/arm64-dynamicbase.s @@ -0,0 +1,8 @@ +// REQUIRES: aarch64 +// RUN: llvm-mc -filetype=obj -triple=aarch64-windows %s -o %t.obj +// RUN: not lld-link -entry:_start -subsystem:console %t.obj -out:%t.exe -dynamicbase:no 2>&1 | FileCheck %s + .globl _start +_start: + ret + +# CHECK: dynamicbase:no is not compatible with arm64 diff --git a/test/COFF/arm64-import2.test b/test/COFF/arm64-import2.test new file mode 100644 index 000000000000..3119e73e1d54 --- /dev/null +++ b/test/COFF/arm64-import2.test @@ -0,0 +1,85 @@ +# REQUIRES: aarch64 + +# RUN: yaml2obj < %s > %t.obj +# RUN: llvm-objdump -d %t.obj | FileCheck %s -check-prefix BEFORE +# RUN: lld-link /entry:main /subsystem:console /out:%t.exe %t.obj %p/Inputs/library-arm64.lib %p/Inputs/library2-arm64.lib +# RUN: llvm-objdump -d %t.exe | FileCheck %s -check-prefix AFTER +# RUN: llvm-readobj -coff-imports %t.exe | FileCheck %s -check-prefix IMPORTS + +# BEFORE: Disassembly of section .text: +# BEFORE: 0: 00 00 00 94 bl #0 +# BEFORE: 4: 00 00 00 94 bl #0 +# BEFORE: 8: c0 03 5f d6 ret + +# AFTER: Disassembly of section .text: +# AFTER: 140001000: 03 00 00 94 bl #12 +# AFTER: 140001004: 05 00 00 94 bl #20 +# AFTER: 140001008: c0 03 5f d6 ret +# AFTER: 14000100c: 10 00 00 b0 adrp x16, #4096 +# AFTER: 140001010: 10 32 40 f9 ldr x16, [x16, #96] +# AFTER: 140001014: 00 02 1f d6 br x16 +# AFTER: 140001018: 10 00 00 b0 adrp x16, #4096 +# AFTER: 14000101c: 10 3a 40 f9 ldr x16, [x16, #112] +# AFTER: 140001020: 00 02 1f d6 br x16 + +# IMPORTS: Import { +# IMPORTS: Name: library.dll +# IMPORTS: ImportLookupTableRVA: 0x2040 +# IMPORTS: ImportAddressTableRVA: 0x2060 +# IMPORTS: Symbol: function (2) +# IMPORTS: } +# IMPORTS: Import { +# IMPORTS: Name: library2.dll +# IMPORTS: ImportLookupTableRVA: 0x2050 +# IMPORTS: ImportAddressTableRVA: 0x2070 +# IMPORTS: Symbol: function2 (0) +# IMPORTS: } + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_ARM64 + Characteristics: [ ] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 0000009400000094C0035FD6 + Relocations: + - VirtualAddress: 0 + SymbolName: function + Type: IMAGE_REL_ARM64_BRANCH26 + - VirtualAddress: 4 + SymbolName: function2 + Type: IMAGE_REL_ARM64_BRANCH26 +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 12 + NumberOfRelocations: 2 + NumberOfLinenumbers: 0 + CheckSum: 1438860354 + Number: 1 + - Name: main + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: function + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: function2 + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/arm64-relocs-imports.test b/test/COFF/arm64-relocs-imports.test index 3d252aaa2801..57590dcf733a 100644 --- a/test/COFF/arm64-relocs-imports.test +++ b/test/COFF/arm64-relocs-imports.test @@ -14,29 +14,67 @@ # BEFORE: 14: 00 01 40 79 ldrh w0, [x8] # BEFORE: 18: 00 01 40 b9 ldr w0, [x8] # BEFORE: 1c: 00 01 40 f9 ldr x0, [x8] -# BEFORE: 20: e0 03 1f 2a mov w0, wzr -# BEFORE: 24: fe 07 41 f8 ldr x30, [sp], #16 -# BEFORE: 28: c0 03 5f d6 ret -# BEFORE: 2c: 08 00 00 00 <unknown> -# BEFORE: 30: 00 00 00 00 <unknown> +# BEFORE: 20: 00 01 00 39 strb w0, [x8] +# BEFORE: 24: 00 01 00 79 strh w0, [x8] +# BEFORE: 28: 00 01 00 b9 str w0, [x8] +# BEFORE: 2c: 00 01 00 f9 str x0, [x8] +# BEFORE: 30: 00 01 40 3d ldr b0, [x8] +# BEFORE: 34: 00 01 40 7d ldr h0, [x8] +# BEFORE: 38: 00 01 40 bd ldr s0, [x8] +# BEFORE: 3c: 00 01 40 fd ldr d0, [x8] +# BEFORE: 40: 00 01 c0 3d ldr q0, [x8] +# BEFORE: 44: 00 01 00 3d str b0, [x8] +# BEFORE: 48: 00 01 00 7d str h0, [x8] +# BEFORE: 4c: 00 01 00 bd str s0, [x8] +# BEFORE: 50: 00 01 00 fd str d0, [x8] +# BEFORE: 54: 00 01 80 3d str q0, [x8] +# BEFORE: 58: 00 05 40 f9 ldr x0, [x8, #8] +# BEFORE: 5c: 20 1a 01 b0 adrp x0, #36982784 +# BEFORE: 60: 00 fc 4f f9 ldr x0, [x0, #8184] +# BEFORE: 64: e0 03 1f 2a mov w0, wzr +# BEFORE: 68: fe 07 41 f8 ldr x30, [sp], #16 +# BEFORE: 6c: c0 03 5f d6 ret +# BEFORE: 70: 08 00 00 00 <unknown> +# BEFORE: 74: 00 00 00 00 <unknown> +# BEFORE: 78: 01 00 00 00 <unknown> +# BEFORE: 7c: 01 00 00 00 <unknown> # AFTER: Disassembly of section .text: # AFTER: 140002000: fe 0f 1f f8 str x30, [sp, #-16]! # AFTER: 140002004: e0 ff ff f0 adrp x0, #-4096 # AFTER: 140002008: 00 18 00 91 add x0, x0, #6 -# AFTER: 14000200c: 0a 00 00 94 bl #40 +# AFTER: 14000200c: 1d 00 00 94 bl #116 # AFTER: 140002010: 00 21 40 39 ldrb w0, [x8, #8] # AFTER: 140002014: 00 11 40 79 ldrh w0, [x8, #8] # AFTER: 140002018: 00 09 40 b9 ldr w0, [x8, #8] # AFTER: 14000201c: 00 05 40 f9 ldr x0, [x8, #8] -# AFTER: 140002020: e0 03 1f 2a mov w0, wzr -# AFTER: 140002024: fe 07 41 f8 ldr x30, [sp], #16 -# AFTER: 140002028: c0 03 5f d6 ret -# AFTER: 14000202c: 10 10 00 40 <unknown> -# AFTER: 140002030: 01 00 00 00 <unknown> -# AFTER: 140002034: 10 00 00 b0 adrp x16, #4096 -# AFTER: 140002038: 10 1e 40 f9 ldr x16, [x16, #56] -# AFTER: 14000203c: 00 02 1f d6 br x16 +# AFTER: 140002020: 00 21 00 39 strb w0, [x8, #8] +# AFTER: 140002024: 00 11 00 79 strh w0, [x8, #8] +# AFTER: 140002028: 00 09 00 b9 str w0, [x8, #8] +# AFTER: 14000202c: 00 05 00 f9 str x0, [x8, #8] +# AFTER: 140002030: 00 41 40 3d ldr b0, [x8, #16] +# AFTER: 140002034: 00 21 40 7d ldr h0, [x8, #16] +# AFTER: 140002038: 00 11 40 bd ldr s0, [x8, #16] +# AFTER: 14000203c: 00 09 40 fd ldr d0, [x8, #16] +# AFTER: 140002040: 00 05 c0 3d ldr q0, [x8, #16] +# AFTER: 140002044: 00 41 00 3d str b0, [x8, #16] +# AFTER: 140002048: 00 21 00 7d str h0, [x8, #16] +# AFTER: 14000204c: 00 11 00 bd str s0, [x8, #16] +# AFTER: 140002050: 00 09 00 fd str d0, [x8, #16] +# AFTER: 140002054: 00 05 80 3d str q0, [x8, #16] +# AFTER: 140002058: 00 09 40 f9 ldr x0, [x8, #16] +# AFTER: 14000205c: 00 00 00 b0 adrp x0, #4096 +# AFTER: 140002060: 00 fc 47 f9 ldr x0, [x0, #4088] +# AFTER: 140002064: e0 03 1f 2a mov w0, wzr +# AFTER: 140002068: fe 07 41 f8 ldr x30, [sp], #16 +# AFTER: 14000206c: c0 03 5f d6 ret +# AFTER: 140002070: 10 10 00 40 <unknown> +# AFTER: 140002074: 01 00 00 00 <unknown> +# AFTER: 140002078: 09 10 00 00 <unknown> +# AFTER: 14000207c: 09 00 00 00 <unknown> +# AFTER: 140002080: 10 00 00 b0 adrp x16, #4096 +# AFTER: 140002084: 10 1e 40 f9 ldr x16, [x16, #56] +# AFTER: 140002088: 00 02 1f d6 br x16 --- !COFF header: @@ -46,32 +84,89 @@ sections: - Name: .text Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] Alignment: 4 - SectionData: FE0F1FF80000009000080091000000940001403900014079000140B9000140F9E0031F2AFE0741F8C0035FD60800000000000000 + SectionData: FE0F1FF80000009000080091000000940001403900014079000140B9000140F90001003900010079000100B9000100F90001403D0001407D000140BD000140FD0001C03D0001003D0001007D000100BD000100FD0001803D000540F9201A01B000FC4FF9E0031F2AFE0741F8C0035FD608000000000000000100000001000000 Relocations: - VirtualAddress: 4 SymbolName: .Lstr - Type: 4 + Type: IMAGE_REL_ARM64_PAGEBASE_REL21 - VirtualAddress: 8 SymbolName: .Lstr - Type: 6 + Type: IMAGE_REL_ARM64_PAGEOFFSET_12A - VirtualAddress: 12 SymbolName: function - Type: 3 + Type: IMAGE_REL_ARM64_BRANCH26 - VirtualAddress: 16 SymbolName: .Lglobal - Type: 7 + Type: IMAGE_REL_ARM64_PAGEOFFSET_12L - VirtualAddress: 20 SymbolName: .Lglobal - Type: 7 + Type: IMAGE_REL_ARM64_PAGEOFFSET_12L - VirtualAddress: 24 SymbolName: .Lglobal - Type: 7 + Type: IMAGE_REL_ARM64_PAGEOFFSET_12L - VirtualAddress: 28 SymbolName: .Lglobal - Type: 7 + Type: IMAGE_REL_ARM64_PAGEOFFSET_12L + - VirtualAddress: 32 + SymbolName: .Lglobal + Type: IMAGE_REL_ARM64_PAGEOFFSET_12L + - VirtualAddress: 36 + SymbolName: .Lglobal + Type: IMAGE_REL_ARM64_PAGEOFFSET_12L + - VirtualAddress: 40 + SymbolName: .Lglobal + Type: IMAGE_REL_ARM64_PAGEOFFSET_12L - VirtualAddress: 44 SymbolName: .Lglobal - Type: 14 + Type: IMAGE_REL_ARM64_PAGEOFFSET_12L + - VirtualAddress: 48 + SymbolName: .Lglobal16 + Type: IMAGE_REL_ARM64_PAGEOFFSET_12L + - VirtualAddress: 52 + SymbolName: .Lglobal16 + Type: IMAGE_REL_ARM64_PAGEOFFSET_12L + - VirtualAddress: 56 + SymbolName: .Lglobal16 + Type: IMAGE_REL_ARM64_PAGEOFFSET_12L + - VirtualAddress: 60 + SymbolName: .Lglobal16 + Type: IMAGE_REL_ARM64_PAGEOFFSET_12L + - VirtualAddress: 64 + SymbolName: .Lglobal16 + Type: IMAGE_REL_ARM64_PAGEOFFSET_12L + - VirtualAddress: 68 + SymbolName: .Lglobal16 + Type: IMAGE_REL_ARM64_PAGEOFFSET_12L + - VirtualAddress: 72 + SymbolName: .Lglobal16 + Type: IMAGE_REL_ARM64_PAGEOFFSET_12L + - VirtualAddress: 76 + SymbolName: .Lglobal16 + Type: IMAGE_REL_ARM64_PAGEOFFSET_12L + - VirtualAddress: 80 + SymbolName: .Lglobal16 + Type: IMAGE_REL_ARM64_PAGEOFFSET_12L + - VirtualAddress: 84 + SymbolName: .Lglobal16 + Type: IMAGE_REL_ARM64_PAGEOFFSET_12L + - VirtualAddress: 88 + SymbolName: .Lglobal + Type: IMAGE_REL_ARM64_PAGEOFFSET_12L + - VirtualAddress: 92 + SymbolName: .Lglobal16 + Type: IMAGE_REL_ARM64_PAGEBASE_REL21 + - VirtualAddress: 96 + SymbolName: .Lglobal0 + Type: IMAGE_REL_ARM64_PAGEOFFSET_12L + - VirtualAddress: 112 + SymbolName: .Lglobal + Type: IMAGE_REL_ARM64_ADDR64 + - VirtualAddress: 120 + SymbolName: .Lglobal + Type: IMAGE_REL_ARM64_ADDR32NB + - VirtualAddress: 124 + SymbolName: .Lglobal + Type: IMAGE_REL_ARM64_SECREL - Name: .data Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] Alignment: 4 @@ -127,6 +222,18 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: .Lglobal16 + Value: 16 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: .Lglobal0 + Value: 0 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC - Name: function Value: 0 SectionNumber: 0 diff --git a/test/COFF/armnt-blx23t.test b/test/COFF/armnt-blx23t.test index 5caf6ebaa127..ec36225e4332 100644 --- a/test/COFF/armnt-blx23t.test +++ b/test/COFF/armnt-blx23t.test @@ -37,7 +37,7 @@ sections: Relocations: - VirtualAddress: 12 SymbolName: identity - Type: 21 + Type: IMAGE_REL_ARM_BLX23T symbols: - Name: .text Value: 0 diff --git a/test/COFF/armnt-branch24t.test b/test/COFF/armnt-branch24t.test index 6e1114c94a18..88d17e445b1e 100644 --- a/test/COFF/armnt-branch24t.test +++ b/test/COFF/armnt-branch24t.test @@ -30,7 +30,7 @@ sections: Relocations: - VirtualAddress: 6 SymbolName: identity - Type: 20 + Type: IMAGE_REL_ARM_BRANCH24T symbols: - Name: .text Value: 0 diff --git a/test/COFF/armnt-dynamicbase.test b/test/COFF/armnt-dynamicbase.test new file mode 100644 index 000000000000..50d3bea54fd3 --- /dev/null +++ b/test/COFF/armnt-dynamicbase.test @@ -0,0 +1,3 @@ +# RUN: yaml2obj < %p/Inputs/armnt-executable.obj.yaml > %t.obj +# RUN: not lld-link /out:%t.exe /entry:mainCRTStartup /subsystem:console %t.obj /dynamicbase:no 2>&1 | FileCheck %s +# CHECK: dynamicbase:no is not compatible with arm diff --git a/test/COFF/armnt-imports.test b/test/COFF/armnt-imports.test index 519886eb0c06..7d3612a0df7e 100644 --- a/test/COFF/armnt-imports.test +++ b/test/COFF/armnt-imports.test @@ -22,7 +22,7 @@ sections: Relocations: - VirtualAddress: 0 SymbolName: __imp_function - Type: 17 + Type: IMAGE_REL_ARM_MOV32T symbols: - Name: .text Value: 0 diff --git a/test/COFF/armnt-mov32t-exec.test b/test/COFF/armnt-mov32t-exec.test index 629f0620730d..abc78c7fcc5b 100644 --- a/test/COFF/armnt-mov32t-exec.test +++ b/test/COFF/armnt-mov32t-exec.test @@ -31,7 +31,7 @@ sections: Relocations: - VirtualAddress: 4 SymbolName: function - Type: 17 + Type: IMAGE_REL_ARM_MOV32T symbols: - Name: .text Value: 0 diff --git a/test/COFF/armnt-movt32t.test b/test/COFF/armnt-movt32t.test index 6a9bf256e335..7c6965efed6a 100644 --- a/test/COFF/armnt-movt32t.test +++ b/test/COFF/armnt-movt32t.test @@ -27,7 +27,7 @@ sections: Relocations: - VirtualAddress: 0 SymbolName: buffer - Type: 17 + Type: IMAGE_REL_ARM_MOV32T - Name: .rdata Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] Alignment: 1 diff --git a/test/COFF/common-alignment.test b/test/COFF/common-alignment.test new file mode 100644 index 000000000000..a4ee15729107 --- /dev/null +++ b/test/COFF/common-alignment.test @@ -0,0 +1,78 @@ +# REQUIRES: x86 +# RUN: yaml2obj %s > %t.obj +# RUN: lld-link /out:%t.exe /entry:main %t.obj %t.obj +# RUN: llvm-objdump -d %t.exe | FileCheck %s + +# Operands of B8 (MOV EAX) are common symbols +# CHECK: 3000: b8 00 10 00 40 +# CHECK: 3005: b8 10 10 00 40 + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: b800000000b800000000 + Relocations: + - VirtualAddress: 1 + SymbolName: bssdata4 + Type: IMAGE_REL_AMD64_ADDR32 + - VirtualAddress: 6 + SymbolName: bssdata4_align16 + Type: IMAGE_REL_AMD64_ADDR32 + - Name: .data + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] + Alignment: 4 + SectionData: 03000000 + - Name: .drectve + Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: 202d616c69676e636f6d6d3a62737364617461345f616c69676e31362c340a # -aligncomm:bssdata4_align16,4 + +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 0 + NumberOfRelocations: 5 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: .data + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 4 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: main + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: bssdata4 + Value: 4 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: bssdata4_align16 + Value: 4 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/ctors_dtors_priority.s b/test/COFF/ctors_dtors_priority.s new file mode 100644 index 000000000000..60562ba57a52 --- /dev/null +++ b/test/COFF/ctors_dtors_priority.s @@ -0,0 +1,30 @@ +# REQUIRES: x86 +# RUN: llvm-mc -triple=x86_64-windows-gnu -filetype=obj -o %t.obj %s +# RUN: lld-link -entry:main %t.obj -out:%t.exe +# RUN: llvm-objdump -s %t.exe | FileCheck %s + +.globl main +main: + nop + +.section .ctors.00005, "w" + .quad 2 +.section .ctors, "w" + .quad 1 +.section .ctors.00100, "w" + .quad 3 + +.section .dtors, "w" + .quad 1 +.section .dtors.00100, "w" + .quad 3 +.section .dtors.00005, "w" + .quad 2 + +# CHECK: Contents of section .ctors: +# CHECK-NEXT: 140001000 01000000 00000000 02000000 00000000 +# CHECK-NEXT: 140001010 03000000 00000000 + +# CHECK: Contents of section .dtors: +# CHECK-NEXT: 140002000 01000000 00000000 02000000 00000000 +# CHECK-NEXT: 140002010 03000000 00000000 diff --git a/test/COFF/debug-dwarf.test b/test/COFF/debug-dwarf.test new file mode 100644 index 000000000000..156b2f58f64e --- /dev/null +++ b/test/COFF/debug-dwarf.test @@ -0,0 +1,19 @@ +# Check that /debug creates %t.pdb. +# RUN: rm -f %t.pdb +# RUN: lld-link /debug /entry:main /out:%t.exe %p/Inputs/ret42.obj +# RUN: ls %t.pdb + +# Check that /debug:dwarf does not create %t.pdb. +# RUN: rm -f %t.pdb +# RUN: lld-link /debug:dwarf /entry:main /out:%t.exe %p/Inputs/ret42.obj +# RUN: not ls %t.pdb + +# Check that /debug:dwarf /debug creates %t.pdb. +# RUN: rm -f %t.pdb +# RUN: lld-link /debug:dwarf /debug /entry:main /out:%t.exe %p/Inputs/ret42.obj +# RUN: ls %t.pdb + +# Check that /debug:dwarf /pdb:%t.pdb does not create %t.pdb. +# RUN: rm -f %t.pdb +# RUN: lld-link /debug:dwarf /pdb:%t.pdb /entry:main /out:%t.exe %p/Inputs/ret42.obj +# RUN: not ls %t.pdb diff --git a/test/COFF/def-export-stdcall.s b/test/COFF/def-export-stdcall.s index 17473f7f9761..851ac6d975b9 100644 --- a/test/COFF/def-export-stdcall.s +++ b/test/COFF/def-export-stdcall.s @@ -1,21 +1,89 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=i686-windows-msvc %s -o %t.obj -# RUN: echo -e "LIBRARY foo\nEXPORTS\n stdcall" > %t.def +# RUN: echo -e "LIBRARY foo\nEXPORTS\n stdcall\n fastcall\n vectorcall\n _underscored" > %t.def # RUN: lld-link -entry:dllmain -dll -def:%t.def %t.obj -out:%t.dll -implib:%t.lib -# RUN: llvm-readobj %t.lib | FileCheck %s -# CHECK: Name type: undecorate -# CHECK: __imp__stdcall@8 -# CHECK: _stdcall@8 +# RUN: llvm-readobj %t.lib | FileCheck -check-prefix UNDECORATED-IMPLIB %s +# RUN: llvm-readobj -coff-exports %t.dll | FileCheck -check-prefix UNDECORATED-EXPORTS %s + +# UNDECORATED-IMPLIB: Name type: noprefix +# UNDECORATED-IMPLIB-NEXT: __imp___underscored +# UNDECORATED-IMPLIB-NEXT: __underscored +# UNDECORATED-IMPLIB: Name type: undecorate +# UNDECORATED-IMPLIB-NEXT: __imp_@fastcall@8 +# UNDECORATED-IMPLIB-NEXT: fastcall@8 +# UNDECORATED-IMPLIB: Name type: undecorate +# UNDECORATED-IMPLIB-NEXT: __imp__stdcall@8 +# UNDECORATED-IMPLIB-NEXT: _stdcall@8 +# UNDECORATED-IMPLIB: Name type: undecorate +# UNDECORATED-IMPLIB-NEXT: __imp_vectorcall@@8 +# UNDECORATED-IMPLIB-NEXT: vectorcall@@8 + +# UNDECORATED-EXPORTS: Name: _underscored +# UNDECORATED-EXPORTS: Name: fastcall +# UNDECORATED-EXPORTS: Name: stdcall +# UNDECORATED-EXPORTS: Name: vectorcall + + +# RUN: echo -e "LIBRARY foo\nEXPORTS\n _stdcall@8\n @fastcall@8\n vectorcall@@8" > %t.def +# RUN: lld-link -entry:dllmain -dll -def:%t.def %t.obj -out:%t.dll -implib:%t.lib +# RUN: llvm-readobj %t.lib | FileCheck -check-prefix DECORATED-IMPLIB %s +# RUN: llvm-readobj -coff-exports %t.dll | FileCheck -check-prefix DECORATED-EXPORTS %s + +# DECORATED-IMPLIB: Name type: name +# DECORATED-IMPLIB-NEXT: __imp_@fastcall@8 +# DECORATED-IMPLIB-NEXT: @fastcall@8 +# TODO: To match link.exe, this one should also be Name type: name. +# DECORATED-IMPLIB: Name type: noprefix +# DECORATED-IMPLIB-NEXT: __imp__stdcall@8 +# DECORATED-IMPLIB-NEXT: _stdcall@8 +# DECORATED-IMPLIB: Name type: name +# DECORATED-IMPLIB-NEXT: __imp_vectorcall@@8 +# DECORATED-IMPLIB-NEXT: vectorcall@@8 + +# DECORATED-EXPORTS: Name: @fastcall@8 +# TODO: To match link.exe, this one should actually be _stdcall@8 +# DECORATED-EXPORTS: Name: stdcall@8 +# DECORATED-EXPORTS: Name: vectorcall@@8 + + +# RUN: echo -e "LIBRARY foo\nEXPORTS\n stdcall@8\n @fastcall@8" > %t.def +# RUN: lld-link -lldmingw -entry:dllmain -dll -def:%t.def %t.obj -out:%t.dll -implib:%t.lib +# RUN: llvm-readobj %t.lib | FileCheck -check-prefix DECORATED-MINGW-IMPLIB %s +# RUN: llvm-readobj -coff-exports %t.dll | FileCheck -check-prefix DECORATED-MINGW-EXPORTS %s + +# DECORATED-MINGW-IMPLIB: Name type: name +# DECORATED-MINGW-IMPLIB-NEXT: __imp_@fastcall@8 +# DECORATED-MINGW-IMPLIB-NEXT: fastcall@8 +# DECORATED-MINGW-IMPLIB: Name type: noprefix +# DECORATED-MINGW-IMPLIB-NEXT: __imp__stdcall@8 +# DECORATED-MINGW-IMPLIB-NEXT: _stdcall@8 + +# DECORATED-MINGW-EXPORTS: Name: @fastcall@8 +# DECORATED-MINGW-EXPORTS: Name: stdcall@8 + .def _stdcall@8; .scl 2; .type 32; .endef .globl _stdcall@8 + .globl @fastcall@8 + .globl vectorcall@@8 + .globl __underscored _stdcall@8: movl 8(%esp), %eax addl 4(%esp), %eax retl $8 +@fastcall@8: + movl 8(%esp), %eax + addl 4(%esp), %eax + retl $8 +vectorcall@@8: + movl 8(%esp), %eax + addl 4(%esp), %eax + retl $8 +__underscored: + ret .def _dllmain; .scl 2; diff --git a/test/COFF/delayimports-armnt.yaml b/test/COFF/delayimports-armnt.yaml new file mode 100644 index 000000000000..231b4bc5c1f1 --- /dev/null +++ b/test/COFF/delayimports-armnt.yaml @@ -0,0 +1,106 @@ +# REQUIRES: arm +# RUN: yaml2obj < %s > %t.obj +# RUN: lld-link %t.obj %p/Inputs/library.lib /subsystem:console \ +# RUN: /entry:mainCRTStartup /alternatename:__delayLoadHelper2=mainCRTStartup \ +# RUN: /delayload:library.dll /out:%t.exe +# RUN: llvm-readobj -coff-imports %t.exe | FileCheck -check-prefix=IMPORT %s +# RUN: llvm-readobj -coff-basereloc %t.exe | FileCheck -check-prefix=BASEREL %s +# RUN: llvm-objdump -d %t.exe | FileCheck -check-prefix=DISASM %s + +# IMPORT: Format: COFF-ARM +# IMPORT-NEXT: Arch: thumb +# IMPORT-NEXT: AddressSize: 32bit +# IMPORT-NEXT: DelayImport { +# IMPORT-NEXT: Name: library.dll +# IMPORT-NEXT: Attributes: 0x1 +# IMPORT-NEXT: ModuleHandle: 0x3000 +# IMPORT-NEXT: ImportAddressTable: 0x3008 +# IMPORT-NEXT: ImportNameTable: 0x2040 +# IMPORT-NEXT: BoundDelayImportTable: 0x0 +# IMPORT-NEXT: UnloadDelayImportTable: 0x0 +# IMPORT-NEXT: Import { +# IMPORT-NEXT: Symbol: function (0) +# IMPORT-NEXT: Address: 0x401019 +# IMPORT-NEXT: } +# IMPORT-NEXT: } +# +# BASEREL: BaseReloc [ +# BASEREL-NEXT: Entry { +# BASEREL-NEXT: Type: ARM_MOV32(T) +# BASEREL-NEXT: Address: 0x1000 +# BASEREL-NEXT: } +# BASEREL-NEXT: Entry { +# BASEREL-NEXT: Type: ARM_MOV32(T) +# BASEREL-NEXT: Address: 0x100C +# BASEREL-NEXT: } +# BASEREL-NEXT: Entry { +# BASEREL-NEXT: Type: ARM_MOV32(T) +# BASEREL-NEXT: Address: 0x1018 +# BASEREL-NEXT: } +# BASEREL-NEXT: Entry { +# BASEREL-NEXT: Type: ARM_MOV32(T) +# BASEREL-NEXT: Address: 0x102E +# BASEREL-NEXT: } +# BASEREL-NEXT: Entry { +# BASEREL-NEXT: Type: HIGHLOW +# BASEREL-NEXT: Address: 0x3008 +# BASEREL-NEXT: } +# BASEREL-NEXT: Entry { +# BASEREL-NEXT: Type: ABSOLUTE +# BASEREL-NEXT: Address: 0x3000 +# BASEREL-NEXT: } +# BASEREL-NEXT: ] +# +# DISASM: 401018: 43 f2 08 0c movw r12, #12296 +# DISASM-NEXT: 40101c: c0 f2 40 0c movt r12, #64 +# DISASM-NEXT: 401020: 2d e9 0f 48 push.w {r0, r1, r2, r3, r11, lr} +# DISASM-NEXT: 401024: 0d f2 10 0b addw r11, sp, #16 +# DISASM-NEXT: 401028: 2d ed 10 0b vpush {d0, d1, d2, d3, d4, d5, d6, d7} +# DISASM-NEXT: 40102c: 61 46 mov r1, r12 +# DISASM-NEXT: 40102e: 42 f2 00 00 movw r0, #8192 +# DISASM-NEXT: 401032: c0 f2 40 00 movt r0, #64 +# DISASM-NEXT: 401036: ff f7 e3 ff bl #-58 +# DISASM-NEXT: 40103a: 84 46 mov r12, r0 +# DISASM-NEXT: 40103c: bd ec 10 0b vpop {d0, d1, d2, d3, d4, d5, d6, d7} +# DISASM-NEXT: 401040: bd e8 0f 48 pop.w {r0, r1, r2, r3, r11, lr} +# DISASM-NEXT: 401044: 60 47 bx r12 + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_ARMNT + Characteristics: [ ] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_PURGEABLE, IMAGE_SCN_MEM_16BIT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 40F20000C0F2000000680047 + Relocations: + - VirtualAddress: 0 + SymbolName: __imp_function + Type: IMAGE_REL_ARM_MOV32T +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 12 + NumberOfRelocations: 1 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 1 + - Name: mainCRTStartup + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: __imp_function + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/delayimports32.test b/test/COFF/delayimports32.test index 53aadbb6a185..006eecff4d95 100644 --- a/test/COFF/delayimports32.test +++ b/test/COFF/delayimports32.test @@ -73,7 +73,7 @@ BASEREL-NEXT: ] DISASM: 202b: 68 20 10 40 00 pushl $4198432 DISASM-NEXT: 2030: 68 00 40 40 00 pushl $4210688 -DISASM-NEXT: 2035: e8 c6 ff ff ff calll -58 <_main@0> +DISASM-NEXT: 2035: e8 c6 ff ff ff calll -58 <.text> DISASM-NEXT: 203a: 5a popl %edx DISASM-NEXT: 203b: 59 popl %ecx DISASM-NEXT: 203c: ff e0 jmpl *%eax @@ -81,7 +81,7 @@ DISASM-NEXT: 203e: 51 pushl %ecx DISASM-NEXT: 203f: 52 pushl %edx DISASM-NEXT: 2040: 68 24 10 40 00 pushl $4198436 DISASM-NEXT: 2045: 68 00 40 40 00 pushl $4210688 -DISASM-NEXT: 204a: e8 b1 ff ff ff calll -79 <_main@0> +DISASM-NEXT: 204a: e8 b1 ff ff ff calll -79 <.text> DISASM-NEXT: 204f: 5a popl %edx DISASM-NEXT: 2050: 59 popl %ecx DISASM-NEXT: 2051: ff e0 jmpl *%eax diff --git a/test/COFF/dllexport-mingw.s b/test/COFF/dllexport-mingw.s new file mode 100644 index 000000000000..8bf035b36dcf --- /dev/null +++ b/test/COFF/dllexport-mingw.s @@ -0,0 +1,24 @@ +# REQEUIRES: x86 + +# RUN: llvm-mc -triple=i686-windows-gnu %s -filetype=obj -o %t.obj + +# RUN: lld-link -lldmingw -dll -out:%t.dll -entry:main %t.obj -implib:%t.lib +# RUN: llvm-readobj %t.lib | FileCheck %s + +# CHECK: Symbol: __imp___underscoredFunc +# CHECK: Symbol: __underscoredFunc +# CHECK: Symbol: __imp__func +# CHECK: Symbol: _func + +.global _main +.global _func +.global __underscoredFunc +.text +_main: + ret +_func: + ret +__underscoredFunc: + ret +.section .drectve +.ascii "-export:func -export:_underscoredFunc" diff --git a/test/COFF/driver.test b/test/COFF/driver.test index 0832350a4f30..36de6c200cb1 100644 --- a/test/COFF/driver.test +++ b/test/COFF/driver.test @@ -1,3 +1,6 @@ # RUN: not lld-link nosuchfile.obj >& %t.log # RUN: FileCheck -check-prefix=MISSING %s < %t.log MISSING: nosuchfile.obj: {{[Nn]}}o such file or directory + +# RUN: lld-link --version | FileCheck -check-prefix=VERSION %s +VERSION: {{LLD [0-9]+\.[0-9]+}} diff --git a/test/COFF/duplicate.test b/test/COFF/duplicate.test new file mode 100644 index 000000000000..c2f743ebc28f --- /dev/null +++ b/test/COFF/duplicate.test @@ -0,0 +1,12 @@ +RUN: llc -mtriple x86_64-windows-msvc -filetype obj -o alpha.obj %S/Inputs/alpha.ll +RUN: llc -mtriple x86_64-windows-msvc -filetype obj -o beta.obj %S/Inputs/beta.ll +RUN: lld-link /out:alpha.dll /dll alpha.obj /implib:alpha.lib +RUN: not lld-link /out:beta.dll /dll alpha.obj beta.obj alpha.lib 2>&1 | FileCheck %s -check-prefix CHECK-ALPHA + +CHECK-ALPHA: error: duplicate symbol: f in {{.*}}alpha.obj and in alpha.dll + +RUN: llc -mtriple x86_64-windows-msvc -filetype obj -o gamma.obj %S/Inputs/gamma.ll +RUN: not lld-link /out:gamma.exe /subsystem:console /entry:mainCRTStartup gamma.obj alpha.lib 2>&1 | FileCheck %s -check-prefix CHECK-GAMMA + +CHECK-GAMMA: error: duplicate symbol: __imp_f in {{.*}}gamma.obj and in alpha.dll + diff --git a/test/COFF/entry-drectve.test b/test/COFF/entry-drectve.test new file mode 100644 index 000000000000..e51e7cb201f3 --- /dev/null +++ b/test/COFF/entry-drectve.test @@ -0,0 +1,24 @@ +# RUN: yaml2obj < %s > %t.obj +# RUN: lld-link /subsystem:console /out:%t.exe %t.obj + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_I386 + Characteristics: [] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: B800000000506800000000680000000050E80000000050E800000000 + - Name: .drectve + Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: 2f656e7472793a437573746f6d456e74727900 # /entry:CustomEntry +symbols: + - Name: _CustomEntry + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/entry-inference.test b/test/COFF/entry-inference.test index 2eb9a6863983..294870bf4185 100644 --- a/test/COFF/entry-inference.test +++ b/test/COFF/entry-inference.test @@ -14,10 +14,10 @@ # RUN: not lld-link /out:%t.exe %t.obj > %t.log 2>&1 # RUN: FileCheck -check-prefix=WWINMAIN %s < %t.log -# MAIN: <root>: undefined symbol: mainCRTStartup -# WMAIN: <root>: undefined symbol: wmainCRTStartup -# WINMAIN: <root>: undefined symbol: WinMainCRTStartup -# WWINMAIN: <root>: undefined symbol: wWinMainCRTStartup +# MAIN: error: <root>: undefined symbol: mainCRTStartup +# WMAIN: error: <root>: undefined symbol: wmainCRTStartup +# WINMAIN: error: <root>: undefined symbol: WinMainCRTStartup +# WWINMAIN: error: <root>: undefined symbol: wWinMainCRTStartup --- !COFF header: diff --git a/test/COFF/export-all.s b/test/COFF/export-all.s new file mode 100644 index 000000000000..96c7dca5df29 --- /dev/null +++ b/test/COFF/export-all.s @@ -0,0 +1,86 @@ +# REQEUIRES: x86 + +# RUN: llvm-mc -triple=i686-windows-gnu %s -filetype=obj -o %t.obj + +# RUN: lld-link -lldmingw -dll -out:%t.dll -entry:DllMainCRTStartup@12 %t.obj -implib:%t.lib +# RUN: llvm-readobj -coff-exports %t.dll | FileCheck %s +# RUN: llvm-readobj %t.lib | FileCheck -check-prefix=IMPLIB %s + +# CHECK-NOT: Name: DllMainCRTStartup +# CHECK-NOT: Name: _imp__unexported +# CHECK: Name: dataSym +# CHECK: Name: foobar +# CHECK-NOT: Name: unexported + +# IMPLIB: Symbol: __imp__dataSym +# IMPLIB-NOT: Symbol: _dataSym +# IMPLIB: Symbol: __imp__foobar +# IMPLIB: Symbol: _foobar + +.global _foobar +.global _DllMainCRTStartup@12 +.global _dataSym +.global _unexported +.global __imp__unexported +.text +_DllMainCRTStartup@12: + ret +_foobar: + ret +_unexported: + ret +.data +_dataSym: + .int 4 +__imp__unexported: + .int _unexported + +# Test specifying -export-all-symbols, on an object file that contains +# dllexport directive for some of the symbols. + +# RUN: yaml2obj < %p/Inputs/export.yaml > %t.obj +# +# RUN: lld-link -out:%t.dll -dll %t.obj -lldmingw -export-all-symbols -output-def:%t.def +# RUN: llvm-readobj -coff-exports %t.dll | FileCheck -check-prefix=CHECK2 %s +# RUN: cat %t.def | FileCheck -check-prefix=CHECK2-DEF %s + +# Note, this will actually export _DllMainCRTStartup as well, since +# it uses the standard spelling in this object file, not the MinGW one. + +# CHECK2: Name: exportfn1 +# CHECK2: Name: exportfn2 +# CHECK2: Name: exportfn3 + +# CHECK2-DEF: EXPORTS +# CHECK2-DEF: exportfn1 @3 +# CHECK2-DEF: exportfn2 @4 +# CHECK2-DEF: exportfn3 @5 + +# Test ignoring certain object files and libs. + +# RUN: echo -e ".global foobar\n.global DllMainCRTStartup\n.text\nDllMainCRTStartup:\nret\nfoobar:\ncall mingwfunc\ncall crtfunc\nret\n" > %t.main.s +# RUN: llvm-mc -triple=x86_64-windows-gnu %t.main.s -filetype=obj -o %t.main.obj +# RUN: mkdir -p %T/libs +# RUN: echo -e ".global mingwfunc\n.text\nmingwfunc:\nret\n" > %T/libs/mingwfunc.s +# RUN: llvm-mc -triple=x86_64-windows-gnu %T/libs/mingwfunc.s -filetype=obj -o %T/libs/mingwfunc.o +# RUN: llvm-ar rcs %T/libs/libmingwex.a %T/libs/mingwfunc.o +# RUN: echo -e ".global crtfunc\n.text\ncrtfunc:\nret\n" > %T/libs/crtfunc.s +# RUN: llvm-mc -triple=x86_64-windows-gnu %T/libs/crtfunc.s -filetype=obj -o %T/libs/crt2.o +# RUN: lld-link -out:%t.dll -dll -entry:DllMainCRTStartup %t.main.obj -lldmingw %T/libs/crt2.o %T/libs/libmingwex.a -output-def:%t.def +# RUN: echo "EOF" >> %t.def +# RUN: cat %t.def | FileCheck -check-prefix=CHECK-EXCLUDE %s + +# CHECK-EXCLUDE: EXPORTS +# CHECK-EXCLUDE-NEXT: foobar @1 +# CHECK-EXCLUDE-NEXT: EOF + +# Test that we handle import libraries together with -opt:noref. + +# RUN: yaml2obj < %p/Inputs/hello32.yaml > %t.obj +# RUN: lld-link -lldmingw -dll -out:%t.dll -entry:main@0 %t.obj -implib:%t.lib -opt:noref %p/Inputs/std32.lib -output-def:%t.def +# RUN: echo "EOF" >> %t.def +# RUN: cat %t.def | FileCheck -check-prefix=CHECK-IMPLIB %s + +# CHECK-IMPLIB: EXPORTS +# CHECK-IMPLIB-NEXT: main@0 @1 +# CHECK-IMPLIB-NEXT: EOF diff --git a/test/COFF/export-arm64.yaml b/test/COFF/export-arm64.yaml new file mode 100644 index 000000000000..ad9a96db4100 --- /dev/null +++ b/test/COFF/export-arm64.yaml @@ -0,0 +1,70 @@ +# REQUIRES: aarch64 + +# RUN: yaml2obj < %s > %t.obj +# RUN: lld-link /out:%t.dll /dll %t.obj /export:exportfn1 /export:exportfn2 /implib:%t.lib +# RUN: llvm-objdump -p %t.dll | FileCheck %s +# RUN: llvm-objdump -r %t.lib | FileCheck %s -check-prefix=RELOCS + +# CHECK: Export Table: +# CHECK: DLL name: export-arm64.yaml.tmp.dll +# CHECK: Ordinal RVA Name +# CHECK-NEXT: 0 0 +# CHECK-NEXT: 1 0x1008 exportfn1 +# CHECK-NEXT: 2 0x1010 exportfn2 +# CHECK-NEXT: 3 0x1018 exportfn3 + +# RELOCS: IMAGE_REL_ARM64_ADDR32NB .idata$6 +# RELOCS: IMAGE_REL_ARM64_ADDR32NB .idata$4 +# RELOCS: IMAGE_REL_ARM64_ADDR32NB .idata$5 + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_ARM64 + Characteristics: [] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_PURGEABLE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: e0031f2ac0035fd6e0031f2ac0035fd6e0031f2ac0035fd6e0031f2ac0035fd6 + - Name: .drectve + Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: 2f6578706f72743a6578706f7274666e3300 # /export:exportfn3 +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 32 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 1 + - Name: _DllMainCRTStartup + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: exportfn1 + Value: 8 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: exportfn2 + Value: 16 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: exportfn3 + Value: 24 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/export-armnt.yaml b/test/COFF/export-armnt.yaml new file mode 100644 index 000000000000..461d5a033fe2 --- /dev/null +++ b/test/COFF/export-armnt.yaml @@ -0,0 +1,72 @@ +# REQUIRES: arm + +# RUN: yaml2obj < %s > %t.obj +# +# RUN: lld-link /out:%t.dll /dll %t.obj /export:exportfn1 /export:exportfn2 +# RUN: llvm-objdump -p %t.dll | FileCheck %s + +# CHECK: Export Table: +# CHECK: DLL name: export-armnt.yaml.tmp.dll +# CHECK: Ordinal RVA Name +# CHECK-NEXT: 0 0 +# CHECK-NEXT: 1 0x1005 exportfn1 +# CHECK-NEXT: 2 0x1009 exportfn2 +# CHECK-NEXT: 3 0x1009 exportfn3 + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_ARMNT + Characteristics: [] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 704700bf704700bf704700bf + - Name: .drectve + Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: 2f6578706f72743a6578706f7274666e3300 # /export:exportfn3 +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 12 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: _DllMainCRTStartup + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: exportfn1 + Value: 4 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: exportfn2 + Value: 8 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: exportfn3 + Value: 8 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: '?mangled@@YAHXZ' + Value: 8 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/export32.test b/test/COFF/export32.test index 83de18b11624..34cd1a73319e 100644 --- a/test/COFF/export32.test +++ b/test/COFF/export32.test @@ -57,6 +57,11 @@ # RUN: lld-link /out:%t.dll /dll %t.obj /def:%t.def # RUN: llvm-objdump -p %t.dll | FileCheck -check-prefix=CHECK5 %s +# RUN: echo "EXPORTS exportfn1 @ 3" > %t.def +# RUN: echo "fn2=exportfn2 @ 2" >> %t.def +# RUN: lld-link /out:%t.dll /dll %t.obj /def:%t.def +# RUN: llvm-objdump -p %t.dll | FileCheck -check-prefix=CHECK5 %s + # CHECK5: Export Table: # CHECK5: DLL name: export32.test.tmp.dll # CHECK5: Ordinal RVA Name diff --git a/test/COFF/filename-casing.s b/test/COFF/filename-casing.s new file mode 100644 index 000000000000..e210aea9358a --- /dev/null +++ b/test/COFF/filename-casing.s @@ -0,0 +1,14 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-windows-msvc -o %T/MixedCase.obj %s +# RUN: not lld-link /entry:main %T/MixedCase.obj 2>&1 | FileCheck -check-prefix=OBJECT %s + +# RUN: llvm-lib /out:%T/MixedCase.lib %T/MixedCase.obj +# RUN: not lld-link /machine:x64 /entry:main %T/MixedCase.lib 2>&1 | FileCheck -check-prefix=ARCHIVE %s + +# OBJECT: MixedCase.obj: undefined symbol: f +# ARCHIVE: MixedCase.lib(MixedCase.obj): undefined symbol: f + +.globl main +main: + callq f diff --git a/test/COFF/force.test b/test/COFF/force.test index 80bd275558f6..b96c1f84cd44 100644 --- a/test/COFF/force.test +++ b/test/COFF/force.test @@ -1,10 +1,11 @@ # RUN: yaml2obj < %s > %t.obj # RUN: not lld-link /out:%t.exe /entry:main %t.obj >& %t.log -# RUN: FileCheck %s < %t.log +# RUN: FileCheck -check-prefix=ERROR %s < %t.log # RUN: lld-link /out:%t.exe /entry:main %t.obj /force >& %t.log -# RUN: FileCheck %s < %t.log +# RUN: FileCheck -check-prefix=WARN %s < %t.log -# CHECK: .obj: undefined symbol: foo +# ERROR: error: {{.*}}.obj: undefined symbol: foo +# WARN: warning: {{.*}}.obj: undefined symbol: foo --- !COFF header: diff --git a/test/COFF/guardcf.test b/test/COFF/guardcf.test index 4f99d705301c..57dca5870d0f 100644 --- a/test/COFF/guardcf.test +++ b/test/COFF/guardcf.test @@ -71,4 +71,10 @@ symbols: SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: __enclave_config + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL ... diff --git a/test/COFF/hello32.test b/test/COFF/hello32.test index e987bb953890..2399193da6a1 100644 --- a/test/COFF/hello32.test +++ b/test/COFF/hello32.test @@ -39,13 +39,13 @@ HEADER-NEXT: MajorImageVersion: 0 HEADER-NEXT: MinorImageVersion: 0 HEADER-NEXT: MajorSubsystemVersion: 6 HEADER-NEXT: MinorSubsystemVersion: 0 -HEADER-NEXT: SizeOfImage: 16896 +HEADER-NEXT: SizeOfImage: 20480 HEADER-NEXT: SizeOfHeaders: 512 HEADER-NEXT: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI (0x3) -HEADER-NEXT: Characteristics [ (0x9940) +HEADER-NEXT: Characteristics [ (0x9540) HEADER-NEXT: IMAGE_DLL_CHARACTERISTICS_APPCONTAINER (0x1000) HEADER-NEXT: IMAGE_DLL_CHARACTERISTICS_DYNAMIC_BASE (0x40) -HEADER-NEXT: IMAGE_DLL_CHARACTERISTICS_NO_BIND (0x800) +HEADER-NEXT: IMAGE_DLL_CHARACTERISTICS_NO_SEH (0x400) HEADER-NEXT: IMAGE_DLL_CHARACTERISTICS_NX_COMPAT (0x100) HEADER-NEXT: IMAGE_DLL_CHARACTERISTICS_TERMINAL_SERVER_AWARE (0x8000) HEADER-NEXT: ] diff --git a/test/COFF/icf-associative.test b/test/COFF/icf-associative.test index bfaeabb4d41a..3b2aa5de41b1 100644 --- a/test/COFF/icf-associative.test +++ b/test/COFF/icf-associative.test @@ -1,5 +1,5 @@ # RUN: yaml2obj < %s > %t.obj -# RUN: lld-link /entry:foo /out:%t.exe /subsystem:console /include:bar \ +# RUN: lld-link /opt:icf /entry:foo /out:%t.exe /subsystem:console /include:bar \ # RUN: /debug /verbose %t.obj > %t.log 2>&1 # RUN: FileCheck %s < %t.log diff --git a/test/COFF/icf-executable.s b/test/COFF/icf-executable.s new file mode 100644 index 000000000000..7f923d25ca45 --- /dev/null +++ b/test/COFF/icf-executable.s @@ -0,0 +1,18 @@ +# RUN: llvm-mc -triple=x86_64-windows-msvc %s -filetype=obj -o %t.obj +# RUN: lld-link -entry:main %t.obj -out:%t.exe -verbose 2>&1 | FileCheck %s + +# CHECK: Selected internal +# CHECK: Removed f2 + +.section .text,"xr",one_only,internal +internal: +.globl main +main: +call f2 +ret + +.section .text,"xr",one_only,f2 +.globl f2 +f2: +call main +ret diff --git a/test/COFF/icf-simple.test b/test/COFF/icf-simple.test index c302c8796a95..ead7e7679ce6 100644 --- a/test/COFF/icf-simple.test +++ b/test/COFF/icf-simple.test @@ -1,5 +1,5 @@ # RUN: yaml2obj < %s > %t.obj -# RUN: lld-link /entry:foo /out:%t.exe /subsystem:console /include:bar \ +# RUN: lld-link /opt:icf /entry:foo /out:%t.exe /subsystem:console /include:bar \ # RUN: /verbose %t.obj > %t.log 2>&1 # RUN: FileCheck -check-prefix=ICF %s < %t.log @@ -13,6 +13,31 @@ # RUN: /verbose /opt:noref,noicf %t.obj > %t.log 2>&1 # RUN: FileCheck -check-prefix=NOICF %s < %t.log +# ICF is on by default (no /opt: flags). +# RUN: lld-link /entry:foo /out:%t.exe /subsystem:console \ +# RUN: /include:bar /verbose %t.obj > %t.log 2>&1 +# RUN: FileCheck -check-prefix=ICF %s < %t.log + +# /debug disables ICF. +# RUN: lld-link /debug /entry:foo /out:%t.exe /subsystem:console \ +# RUN: /include:bar /verbose %t.obj > %t.log 2>&1 +# RUN: FileCheck -check-prefix=NOICF %s < %t.log + +# /opt:noref disables ICF. +# RUN: lld-link /opt:noref /entry:foo /out:%t.exe /subsystem:console \ +# RUN: /include:bar /verbose %t.obj > %t.log 2>&1 +# RUN: FileCheck -check-prefix=NOICF %s < %t.log + +# /debug /opt:ref enables ICF. +# RUN: lld-link /debug /opt:ref /entry:foo /out:%t.exe /subsystem:console \ +# RUN: /include:bar /verbose %t.obj > %t.log 2>&1 +# RUN: FileCheck -check-prefix=ICF %s < %t.log + +# /debug /opt:noicf,ref disables ICF. +# RUN: lld-link /debug /opt:noicf,ref /entry:foo /out:%t.exe /subsystem:console \ +# RUN: /include:bar /verbose %t.obj > %t.log 2>&1 +# RUN: FileCheck -check-prefix=NOICF %s < %t.log + # NOICF-NOT: Removed foo # NOICF-NOT: Removed bar diff --git a/test/COFF/icf-xdata.s b/test/COFF/icf-xdata.s new file mode 100644 index 000000000000..8fb4bad057bd --- /dev/null +++ b/test/COFF/icf-xdata.s @@ -0,0 +1,86 @@ +# RUN: llvm-mc %s -triple x86_64-windows-msvc -filetype=obj -o %t.obj +# RUN: lld-link %t.obj -dll -noentry -out:%t.dll +# RUN: llvm-readobj -sections %t.dll | FileCheck %s + +# There shouldn't be much xdata, because all three .pdata entries (12 bytes +# each) should use the same .xdata unwind info. +# CHECK: Name: .pdata +# CHECK-NEXT: VirtualSize: 0x24 +# CHECK: Name: .xdata +# CHECK-NEXT: VirtualSize: 0x8 + + .text +callee: + ret + + .def xdata1; + .scl 2; + .type 32; + .endef + .section .text,"xr",one_only,xdata1 + .globl xdata1 # -- Begin function xdata1 + .p2align 4, 0x90 +xdata1: # @xdata1 +.seh_proc xdata1 +# BB#0: # %entry + subq $40, %rsp + .seh_stackalloc 40 + .seh_endprologue + callq callee + nop + addq $40, %rsp + jmp callee # TAILCALL + .seh_handlerdata + .section .text,"xr",one_only,xdata1 + .seh_endproc + # -- End function + .def xdata2; + .scl 2; + .type 32; + .endef + .section .text,"xr",one_only,xdata2 + .globl xdata2 # -- Begin function xdata2 + .p2align 4, 0x90 +xdata2: # @xdata2 +.seh_proc xdata2 +# BB#0: # %entry + subq $40, %rsp + .seh_stackalloc 40 + .seh_endprologue + callq callee + callq callee + nop + addq $40, %rsp + jmp callee # TAILCALL + .seh_handlerdata + .section .text,"xr",one_only,xdata2 + .seh_endproc + # -- End function + .def xdata3; + .scl 2; + .type 32; + .endef + .section .text,"xr",one_only,xdata3 + .globl xdata3 # -- Begin function xdata3 + .p2align 4, 0x90 +xdata3: # @xdata3 +.seh_proc xdata3 +# BB#0: # %entry + subq $40, %rsp + .seh_stackalloc 40 + .seh_endprologue + callq callee + callq callee + callq callee + nop + addq $40, %rsp + jmp callee # TAILCALL + .seh_handlerdata + .section .text,"xr",one_only,xdata3 + .seh_endproc + # -- End function + .section .drectve,"yn" + .ascii " -export:xdata1" + .ascii " -export:xdata2" + .ascii " -export:xdata3" + diff --git a/test/COFF/include.test b/test/COFF/include.test index e7b0c58d5a19..e7e9095cff8b 100644 --- a/test/COFF/include.test +++ b/test/COFF/include.test @@ -62,6 +62,19 @@ symbols: CheckSum: 0 Number: 0 Selection: IMAGE_COMDAT_SELECT_ANY + - Name: '.text$mn' + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 6 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + Selection: IMAGE_COMDAT_SELECT_ANY - Name: main Value: 0 SectionNumber: 1 diff --git a/test/COFF/libpath.test b/test/COFF/libpath.test index da465bc556bc..77b4c546c992 100644 --- a/test/COFF/libpath.test +++ b/test/COFF/libpath.test @@ -5,14 +5,22 @@ # RUN: env LIB=%t/a lld-link /out:%t.exe /entry:main /verbose \ # RUN: std64.lib /subsystem:console %p/Inputs/hello64.obj \ -# RUN: /libpath:%t/b /libpath:%t/c > %t.log +# RUN: /libpath:%t/b /libpath:%t/c 2> %t.log # RUN: FileCheck -check-prefix=CHECK1 %s < %t.log CHECK1: b{{[/\\]}}std64.lib # RUN: lld-link /out:%t.exe /entry:main /verbose \ # RUN: std64.lib /subsystem:console %p/Inputs/hello64.obj \ -# RUN: /libpath:%t/a /libpath:%t/b /libpath:%t/c > %t.log +# RUN: /libpath:%t/a /libpath:%t/b /libpath:%t/c 2> %t.log # RUN: FileCheck -check-prefix=CHECK2 %s < %t.log CHECK2: a{{[/\\]}}std64.lib + +# RUN: lld-link /out:%t.exe /entry:main /verbose \ +# RUN: %t/a/std64.lib /subsystem:console %p/Inputs/hello64.obj \ +# RUN: /libpath:%t/b /verbose > %t.log 2>&1 +# RUN: FileCheck -check-prefix=CHECK3 %s < %t.log + +CHECK3: Reading {{.*}}a/std64.lib +CHECK3-NOT: Reading {{.*}}b/std64.lib diff --git a/test/COFF/linkrepro-manifest.test b/test/COFF/linkrepro-manifest.test new file mode 100644 index 000000000000..a938ab590b2e --- /dev/null +++ b/test/COFF/linkrepro-manifest.test @@ -0,0 +1,12 @@ +REQUIRES: x86, gnutar, manifest_tool + +RUN: rm -rf %t && mkdir %t && cd %t +RUN: lld-link -entry:__ImageBase -nodefaultlib -linkrepro:%t -manifest:embed %p/Inputs/std32.lib -subsystem:console +RUN: tar tf repro.tar | FileCheck --check-prefix=LIST %s +RUN: tar xOf repro.tar repro/response.txt | FileCheck %s + +LIST: manifest.res + +CHECK-NOT: -manifest: +CHECK: .manifest.res +CHECK-NOT: -manifest: diff --git a/test/COFF/linkrepro-pdb.test b/test/COFF/linkrepro-pdb.test new file mode 100644 index 000000000000..33aa0bc4a90e --- /dev/null +++ b/test/COFF/linkrepro-pdb.test @@ -0,0 +1,9 @@ +REQUIRES: x86, gnutar + +RUN: rm -rf %t && mkdir -p %t && cd %t +RUN: yaml2obj %S/Inputs/pdb-type-server-simple-a.yaml -o a.obj +RUN: yaml2obj %S/Inputs/pdb-type-server-simple-b.yaml -o b.obj +RUN: llvm-pdbutil yaml2pdb %S/Inputs/pdb-type-server-simple-ts.yaml -pdb ts.pdb +RUN: lld-link a.obj b.obj -entry:main -debug -out:t.exe -pdb:t.pdb -nodefaultlib -linkrepro:. +RUN: tar xOf repro.tar repro/%:t/ts.pdb > repro-ts.pdb +RUN: diff ts.pdb repro-ts.pdb diff --git a/test/COFF/linkrepro-res.test b/test/COFF/linkrepro-res.test new file mode 100644 index 000000000000..cf0aa1636ce2 --- /dev/null +++ b/test/COFF/linkrepro-res.test @@ -0,0 +1,12 @@ +# REQUIRES: x86, shell + +# RUN: rm -rf %t.dir +# RUN: mkdir -p %t.dir/build +# RUN: cd %t.dir/build +# RUN: lld-link %p/Inputs/resource.res /subsystem:console /machine:x64 \ +# RUN: /entry:__ImageBase /linkrepro:. /out:%t.exe +# RUN: tar xf repro.tar +# RUN: diff %p/Inputs/resource.res repro/%:p/Inputs/resource.res +# RUN: FileCheck %s --check-prefix=RSP < repro/response.txt + +# RSP: resource.res diff --git a/test/COFF/loadcfg.test b/test/COFF/loadcfg.test index b74917f15707..072ee6b1edb8 100644 --- a/test/COFF/loadcfg.test +++ b/test/COFF/loadcfg.test @@ -14,10 +14,6 @@ sections: Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] Alignment: 4 SectionData: B82A000000C3 - - Name: .text - Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] - Alignment: 4 - SectionData: B82A000000C3 - Name: .rdata Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] Alignment: 16 @@ -35,19 +31,6 @@ symbols: NumberOfLinenumbers: 0 CheckSum: 0 Number: 0 - - Name: .text - Value: 0 - SectionNumber: 2 - SimpleType: IMAGE_SYM_TYPE_NULL - ComplexType: IMAGE_SYM_DTYPE_NULL - StorageClass: IMAGE_SYM_CLASS_STATIC - SectionDefinition: - Length: 6 - NumberOfRelocations: 0 - NumberOfLinenumbers: 0 - CheckSum: 0 - Number: 0 - Selection: IMAGE_COMDAT_SELECT_ANY - Name: main Value: 0 SectionNumber: 1 @@ -56,7 +39,7 @@ symbols: StorageClass: IMAGE_SYM_CLASS_EXTERNAL - Name: .rdata Value: 0 - SectionNumber: 3 + SectionNumber: 2 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_STATIC @@ -68,7 +51,7 @@ symbols: Number: 3 - Name: _load_config_used Value: 0 - SectionNumber: 3 + SectionNumber: 2 SimpleType: IMAGE_SYM_TYPE_NULL ComplexType: IMAGE_SYM_DTYPE_NULL StorageClass: IMAGE_SYM_CLASS_EXTERNAL diff --git a/test/COFF/locally-imported-arm64.test b/test/COFF/locally-imported-arm64.test new file mode 100644 index 000000000000..35200ffc1e8d --- /dev/null +++ b/test/COFF/locally-imported-arm64.test @@ -0,0 +1,61 @@ +# RUN: yaml2obj < %s > %t.obj +# RUN: lld-link /out:%t.exe /entry:main %t.obj +# RUN: llvm-objdump -s %t.exe | FileCheck %s +# RUN: llvm-readobj -coff-basereloc %t.exe | FileCheck -check-prefix=BASEREL %s + +# CHECK: Contents of section .text: +# CHECK-NEXT: 1000 00200000 +# CHECK: Contents of section .rdata: +# CHECK-NEXT: 2000 04100040 01000000 + +# BASEREL: BaseReloc [ +# BASEREL-NEXT: Entry { +# BASEREL-NEXT: Type: DIR64 +# BASEREL-NEXT: Address: 0x2000 +# BASEREL-NEXT: } +# BASEREL-NEXT: Entry { +# BASEREL-NEXT: Type: ABSOLUTE +# BASEREL-NEXT: Address: 0x2000 +# BASEREL-NEXT: } +# BASEREL-NEXT: ] + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_ARM64 + Characteristics: [] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 00000000 + Relocations: + - VirtualAddress: 0 + SymbolName: __imp_main + Type: IMAGE_REL_ARM64_ADDR32NB +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 4 + NumberOfRelocations: 1 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + Selection: IMAGE_COMDAT_SELECT_ANY + - Name: main + Value: 4 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: __imp_main + Value: 0 + SectionNumber: 0 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/locally-imported-warn-multiple.s b/test/COFF/locally-imported-warn-multiple.s new file mode 100644 index 000000000000..247ec58b0fdb --- /dev/null +++ b/test/COFF/locally-imported-warn-multiple.s @@ -0,0 +1,14 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-windows-msvc -o %T/locally-imported-def.obj %S/Inputs/locally-imported-def.s +# RUN: llvm-mc -filetype=obj -triple=x86_64-windows-msvc -o %T/locally-imported-imp1.obj %S/Inputs/locally-imported-imp.s +# RUN: llvm-mc -filetype=obj -triple=x86_64-windows-msvc -o %T/locally-imported-imp2.obj %S/Inputs/locally-imported-imp.s +# RUN: llvm-mc -filetype=obj -triple=x86_64-windows-msvc -o %t.obj %s +# RUN: lld-link /entry:main %T/locally-imported-def.obj %T/locally-imported-imp1.obj %T/locally-imported-imp2.obj %t.obj 2>&1 | FileCheck %s + +# CHECK: warning: [[TESTDIR:.+]]locally-imported-imp1.obj: locally defined symbol imported: f (defined in [[TESTDIR]]locally-imported-def.obj) +# CHECK-NEXT: warning: [[TESTDIR:.+]]locally-imported-imp2.obj: locally defined symbol imported: f (defined in [[TESTDIR]]locally-imported-def.obj) + +.globl main +main: + ret diff --git a/test/COFF/locally-imported.test b/test/COFF/locally-imported.test index a10da4b11bcb..b269cecf00b7 100644 --- a/test/COFF/locally-imported.test +++ b/test/COFF/locally-imported.test @@ -1,8 +1,10 @@ # RUN: yaml2obj < %s > %t.obj -# RUN: lld-link /out:%t.exe /entry:main %t.obj +# RUN: lld-link /out:%t.exe /entry:main %t.obj 2>&1 | FileCheck -check-prefix=WARN %s # RUN: llvm-objdump -s %t.exe | FileCheck %s # RUN: llvm-readobj -coff-basereloc %t.exe | FileCheck -check-prefix=BASEREL %s +# WARN: warning: [[INPUT:.+]]: locally defined symbol imported: main (defined in [[INPUT]]) + # CHECK: Contents of section .text: # CHECK-NEXT: 1000 00200000 # CHECK: Contents of section .rdata: diff --git a/test/COFF/long-section-name.test b/test/COFF/long-section-name.test index 1de329db0296..bad7876c888f 100644 --- a/test/COFF/long-section-name.test +++ b/test/COFF/long-section-name.test @@ -1,7 +1,10 @@ # RUN: yaml2obj < %s > %t.obj -# RUN: lld-link /debug /out:%t.exe /entry:main %t.obj +# RUN: lld-link /out:%t.exe /entry:main %t.obj # RUN: llvm-readobj -sections %t.exe | FileCheck %s +# RUN: lld-link /debug /out:%t2.exe /entry:main %t.obj +# RUN: llvm-readobj -sections %t2.exe | FileCheck %s +# CHECK: Name: .eh_fram ( # CHECK: Name: .data_long_section_name # CHECK: Name: .text_long_section_name @@ -11,10 +14,14 @@ header: Characteristics: [ ] sections: - Name: .text_long_section_name - Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_DISCARDABLE ] Alignment: 4 SectionData: B82A000000C3 - Name: .data_long_section_name + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE, IMAGE_SCN_MEM_DISCARDABLE ] + Alignment: 4 + SectionData: "00" + - Name: .eh_frame Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ] Alignment: 4 SectionData: "00" @@ -49,6 +56,18 @@ symbols: NumberOfLinenumbers: 0 CheckSum: 0 Number: 0 + - Name: .eh_frame + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 0 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 - Name: main Value: 0 SectionNumber: 1 diff --git a/test/COFF/lto-cache.ll b/test/COFF/lto-cache.ll new file mode 100644 index 000000000000..ad1a3b71f19a --- /dev/null +++ b/test/COFF/lto-cache.ll @@ -0,0 +1,21 @@ +; REQUIRES: x86 + +; RUN: opt -module-hash -module-summary %s -o %t.o +; RUN: opt -module-hash -module-summary %p/Inputs/lto-cache.ll -o %t2.o + +; RUN: rm -Rf %t.cache && mkdir %t.cache +; Create two files that would be removed by cache pruning due to age. +; We should only remove files matching the pattern "llvmcache-*". +; RUN: touch -t 197001011200 %t.cache/llvmcache-foo %t.cache/foo +; RUN: lld-link /lldltocache:%t.cache /lldltocachepolicy:prune_after=1h /out:%t3 /entry:main %t2.o %t.o + +; Two cached objects, plus a timestamp file and "foo", minus the file we removed. +; RUN: ls %t.cache | count 4 + +target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-pc-windows-msvc" + +define void @globalfunc() #0 { +entry: + ret void +} diff --git a/test/COFF/lto-opt-level.ll b/test/COFF/lto-opt-level.ll index 674b6cc0f934..cacd0637731a 100644 --- a/test/COFF/lto-opt-level.ll +++ b/test/COFF/lto-opt-level.ll @@ -1,10 +1,10 @@ ; RUN: llvm-as -o %t.obj %s -; RUN: lld-link /out:%t0.exe /entry:main /subsystem:console /opt:lldlto=0 /debug %t.obj -; RUN: llvm-nm %t0.exe | FileCheck --check-prefix=CHECK-O0 %s -; RUN: lld-link /out:%t2.exe /entry:main /subsystem:console /opt:lldlto=2 /debug %t.obj -; RUN: llvm-nm %t2.exe | FileCheck --check-prefix=CHECK-O2 %s -; RUN: lld-link /out:%t2a.exe /entry:main /subsystem:console /debug %t.obj -; RUN: llvm-nm %t2a.exe | FileCheck --check-prefix=CHECK-O2 %s +; RUN: lld-link /out:%t0.exe /entry:main /subsystem:console /opt:lldlto=0 /lldmap:%t0.map %t.obj +; RUN: FileCheck --check-prefix=CHECK-O0 %s < %t0.map +; RUN: lld-link /out:%t2.exe /entry:main /subsystem:console /opt:lldlto=2 /lldmap:%t2.map %t.obj +; RUN: FileCheck --check-prefix=CHECK-O2 %s < %t2.map +; RUN: lld-link /out:%t2a.exe /entry:main /subsystem:console /lldmap:%t2a.map %t.obj +; RUN: FileCheck --check-prefix=CHECK-O2 %s < %t2a.map target datalayout = "e-m:w-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-pc-windows-msvc" diff --git a/test/COFF/lto-reloc-model.ll b/test/COFF/lto-reloc-model.ll new file mode 100644 index 000000000000..bea19e9ce3e9 --- /dev/null +++ b/test/COFF/lto-reloc-model.ll @@ -0,0 +1,19 @@ +; RUN: llvm-as -o %t %s +; RUN: lld-link /entry:main /subsystem:console /out:%t.exe %t +; RUN: llvm-objdump -d %t.exe | FileCheck %s + +target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32" +target triple = "i686-pc-windows-msvc" + +@foo = thread_local global i8 0 + +module asm "__tls_index = 1" +module asm "__tls_array = 2" + +define i8* @main() { + ; CHECK: movl 1, %eax + ; CHECK: movl %fs:2, %ecx + ; CHECK: movl (%ecx,%eax,4), %eax + ; CHECK: leal (%eax), %eax + ret i8* @foo +} diff --git a/test/COFF/manifest.test b/test/COFF/manifest.test index accec48d6866..31587b43e2e9 100644 --- a/test/COFF/manifest.test +++ b/test/COFF/manifest.test @@ -57,10 +57,24 @@ DEPENDENCY: </dependentAssembly> DEPENDENCY: </dependency> DEPENDENCY: </assembly> -# RUN: lld-link /manifest /out:%t.exe /entry:main /manifestuac:no %t.obj +# RUN: lld-link /manifest /out:%t.exe /entry:main /manifestuac:no \ +# RUN: /manifestdependency:"foo='bar'" %t.obj # RUN: FileCheck -check-prefix=NOUAC %s < %t.exe.manifest NOUAC: <?xml version="1.0" standalone="yes"?> NOUAC: <assembly xmlns="urn:schemas-microsoft-com:asm.v1" NOUAC: manifestVersion="1.0"> +NOUAC: <dependency> +NOUAC: <dependentAssembly> +NOUAC: <assemblyIdentity foo='bar' /> +NOUAC: </dependentAssembly> +NOUAC: </dependency> NOUAC: </assembly> + +# RUN: lld-link /manifest /out:%t.exe /entry:main /manifestuac:no %t.obj +# RUN: FileCheck -check-prefix=NOUACNODEP %s < %t.exe.manifest + +NOUACNODEP: <?xml version="1.0" standalone="yes"?> +NOUACNODEP: <assembly xmlns="urn:schemas-microsoft-com:asm.v1" +NOUACNODEP: manifestVersion="1.0"> +NOUACNODEP: </assembly> diff --git a/test/COFF/manifestinput-error.test b/test/COFF/manifestinput-error.test new file mode 100644 index 000000000000..eca7d0d03927 --- /dev/null +++ b/test/COFF/manifestinput-error.test @@ -0,0 +1,10 @@ +# UNSUPPORTED: manifest_tool +# UNSUPPORTED: libxml2 + +# RUN: yaml2obj %p/Inputs/ret42.yaml > %t.obj +# RUN: not lld-link /out:%t.exe /entry:main \ +# RUN: /manifest:embed \ +# RUN: /manifestuac:"level='requireAdministrator'" \ +# RUN: /manifestinput:%p/Inputs/manifestinput.test %t.obj 2>&1 | FileCheck %s + +# CHECK: error: unable to find mt.exe in PATH: No such file or directory diff --git a/test/COFF/manifestinput-nowarning.test b/test/COFF/manifestinput-nowarning.test new file mode 100644 index 000000000000..d8dd864d533f --- /dev/null +++ b/test/COFF/manifestinput-nowarning.test @@ -0,0 +1,11 @@ +# UNSUPPORTED: libxml2 +# REQUIRES: manifest_tool + +# RUN: yaml2obj %p/Inputs/ret42.yaml > %t.obj +# RUN: lld-link /out:%t.exe /entry:main \ +# RUN: /manifest:embed \ +# RUN: /manifestuac:"level='requireAdministrator'" \ +# RUN: /manifestinput:%p/Inputs/manifestinput.test %t.obj | \ +# RUN: FileCheck -allow-empty %s + +# CHECK-NOT: warning: error with internal manifest tool: no libxml2 diff --git a/test/COFF/manifestinput.test b/test/COFF/manifestinput.test index 95ebc22f7410..51c189098261 100644 --- a/test/COFF/manifestinput.test +++ b/test/COFF/manifestinput.test @@ -1,4 +1,4 @@ -# REQUIRES: win_mt +# REQUIRES: manifest_tool # RUN: yaml2obj %p/Inputs/ret42.yaml > %t.obj # RUN: lld-link /out:%t.exe /entry:main \ @@ -11,7 +11,7 @@ TEST_EMBED: ResourceTableRVA: 0x1000 TEST_EMBED-NEXT: ResourceTableSize: 0x298 TEST_EMBED-DAG: Resources [ -TEST_EMBED-NEXT: Total Number of Resources: 1 +TEST_EMBED-NEXT: Total Number of Resources: 1 TEST_EMBED-DAG: Number of String Entries: 0 TEST_EMBED-NEXT: Number of ID Entries: 1 TEST_EMBED-NEXT: Type: kRT_MANIFEST (ID 24) [ diff --git a/test/COFF/msvclto-archive.ll b/test/COFF/msvclto-archive.ll index 334565a1bef7..f09532721024 100644 --- a/test/COFF/msvclto-archive.ll +++ b/test/COFF/msvclto-archive.ll @@ -9,14 +9,14 @@ ; RUN: mkdir -p %t.dir ; RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o %t.dir/bitcode.obj %p/Inputs/msvclto.s ; RUN: lld-link %t-main1.a %t.dir/bitcode.obj /msvclto /out:%t.exe /opt:lldlto=1 /opt:icf \ -; RUN: /entry:main /verbose > %t.log || true +; RUN: /entry:main /verbose 2> %t.log || true ; RUN: FileCheck -check-prefix=BC %s < %t.log ; BC-NOT: Creating a temporary archive for ; RUN: rm -f %t-main2.a ; RUN: llvm-ar cru %t-main2.a %t.dir/bitcode.obj ; RUN: lld-link %t.obj %t-main2.a /msvclto /out:%t.exe /opt:lldlto=1 /opt:icf \ -; RUN: /entry:main /verbose > %t.log || true +; RUN: /entry:main /verbose 2> %t.log || true ; RUN: FileCheck -check-prefix=OBJ %s < %t.log ; OBJ-NOT: Creating a temporary archive @@ -25,7 +25,7 @@ ; RUN: rm -f %t-main3.a ; RUN: llvm-ar cruT %t-main3.a %t.dir/bitcode.obj ; RUN: lld-link %t.obj %t-main3.a /msvclto /out:%t.exe /opt:lldlto=1 /opt:icf \ -; RUN: /entry:main /verbose > %t.log || true +; RUN: /entry:main /verbose 2> %t.log || true ; RUN: FileCheck -check-prefix=THIN %s < %t.log ; THIN: Creating a temporary archive diff --git a/test/COFF/msvclto-order.ll b/test/COFF/msvclto-order.ll index 6f569af4af0c..1758077fe748 100644 --- a/test/COFF/msvclto-order.ll +++ b/test/COFF/msvclto-order.ll @@ -5,7 +5,7 @@ ; RUN: llc -filetype=obj %S/Inputs/msvclto-order-b.ll -o %T/msvclto-order-b.obj ; RUN: llvm-ar crs %T/msvclto-order-b.lib %T/msvclto-order-b.obj ; RUN: lld-link /verbose /msvclto /out:%t.exe /entry:main %t.obj \ -; RUN: %T/msvclto-order-a.lib %T/msvclto-order-b.lib > %t.log || true +; RUN: %T/msvclto-order-a.lib %T/msvclto-order-b.lib 2> %t.log || true ; RUN: FileCheck %s < %t.log ; CHECK: : link.exe diff --git a/test/COFF/msvclto.ll b/test/COFF/msvclto.ll index 66fabeb80c74..b29982737f14 100644 --- a/test/COFF/msvclto.ll +++ b/test/COFF/msvclto.ll @@ -3,7 +3,7 @@ ; RUN: mkdir -p %t.dir ; RUN: llvm-mc -triple=x86_64-pc-windows-msvc -filetype=obj -o %t.dir/bitcode.obj %p/Inputs/msvclto.s ; RUN: lld-link %t.obj %t.dir/bitcode.obj /msvclto /out:%t.exe /opt:lldlto=1 /opt:icf \ -; RUN: /entry:main /verbose > %t.log || true +; RUN: /entry:main /verbose 2> %t.log || true ; RUN: FileCheck %s < %t.log ; CHECK: /opt:icf /entry:main diff --git a/test/COFF/nodefaultlib.test b/test/COFF/nodefaultlib.test index 867dc8f18e78..c0f8d50fc7ed 100644 --- a/test/COFF/nodefaultlib.test +++ b/test/COFF/nodefaultlib.test @@ -19,9 +19,9 @@ # RUN: /nodefaultlib:std64.lib >& %t.log || true # RUN: FileCheck -check-prefix=CHECK3 %s < %t.log -CHECK1: hello64.obj: {{[Nn]}}o such file or directory -CHECK2: hello64: {{[Nn]}}o such file or directory -CHECK3: hello64.obj: undefined symbol: MessageBoxA +CHECK1: error: could not open hello64.obj: {{[Nn]}}o such file or directory +CHECK2: error: could not open hello64: {{[Nn]}}o such file or directory +CHECK3: error: {{.*}}hello64.obj: undefined symbol: MessageBoxA # RUN: lld-link /libpath:%T /out:%t.exe /entry:main \ # RUN: /subsystem:console hello64.obj /defaultlib:std64.lib diff --git a/test/COFF/nopdb.test b/test/COFF/nopdb.test deleted file mode 100644 index 29797bbf9310..000000000000 --- a/test/COFF/nopdb.test +++ /dev/null @@ -1,14 +0,0 @@ -# Check that /debug creates %t.pdb. -# RUN: rm -f %t.pdb -# RUN: lld-link /debug /entry:main /out:%t.exe %p/Inputs/ret42.obj -# RUN: ls %t.pdb - -# Check that /debug /nopdb does not create %t.pdb. -# RUN: rm -f %t.pdb -# RUN: lld-link /debug /nopdb /entry:main /out:%t.exe %p/Inputs/ret42.obj -# RUN: not ls %t.pdb - -# Check that /debug /nopdb /pdb:%t.pdb does not create %t.pdb. -# RUN: rm -f %t.pdb -# RUN: lld-link /debug /nopdb /pdb:%t.pdb /entry:main /out:%t.exe %p/Inputs/ret42.obj -# RUN: not ls %t.pdb diff --git a/test/COFF/options.test b/test/COFF/options.test index a23da1971d15..39f944beddbc 100644 --- a/test/COFF/options.test +++ b/test/COFF/options.test @@ -2,7 +2,13 @@ # RUN: lld-link /out:%t.exe /entry:main %t.obj # RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=BIND %s -BIND: IMAGE_DLL_CHARACTERISTICS_NO_BIND +# RUN: lld-link /allowbind /out:%t.exe /entry:main %t.obj +# RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=BIND %s +BIND-NOT: IMAGE_DLL_CHARACTERISTICS_NO_BIND + +# RUN: lld-link /allowbind:no /out:%t.exe /entry:main %t.obj +# RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=NOBIND %s +NOBIND: IMAGE_DLL_CHARACTERISTICS_NO_BIND # RUN: lld-link /out:%t.exe /entry:main %t.obj # RUN: llvm-readobj -file-headers %t.exe | FileCheck -check-prefix=ISO %s diff --git a/test/COFF/pdata-arm64.yaml b/test/COFF/pdata-arm64.yaml new file mode 100644 index 000000000000..f21749b9253f --- /dev/null +++ b/test/COFF/pdata-arm64.yaml @@ -0,0 +1,87 @@ +# RUN: yaml2obj < %s > %t.obj +# +# RUN: lld-link /out:%t.exe /entry:func1 /subsystem:console %t.obj +# RUN: llvm-objdump -s -section=.pdata %t.exe | FileCheck -check-prefix=PDATA %s + +# PDATA: 00200000 2500a100 24200000 31002201 + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_ARM64 + Characteristics: [ ] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: ff4300d1f37b00a9f303012a00000094e003132a00000094f37b40a9ff430091c0035fd6f353bea9fe0b00f9f303012af403022a00000094e003132a00000094e003142a00000094fe0b40f9f353c2a8c0035fd6c0035fd6 + Relocations: + - VirtualAddress: 12 + SymbolName: func3 + Type: IMAGE_REL_ARM64_BRANCH26 + - VirtualAddress: 20 + SymbolName: func3 + Type: IMAGE_REL_ARM64_BRANCH26 + - VirtualAddress: 52 + SymbolName: func3 + Type: IMAGE_REL_ARM64_BRANCH26 + - VirtualAddress: 60 + SymbolName: func3 + Type: IMAGE_REL_ARM64_BRANCH26 + - VirtualAddress: 68 + SymbolName: func3 + Type: IMAGE_REL_ARM64_BRANCH26 + - Name: .pdata + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 0000000031002201000000002500a100 + Relocations: + - VirtualAddress: 0 + SymbolName: func2 + Type: IMAGE_REL_ARM64_ADDR32NB + - VirtualAddress: 8 + SymbolName: func1 + Type: IMAGE_REL_ARM64_ADDR32NB +symbols: + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 57 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 1 + - Name: .pdata + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 16 + NumberOfRelocations: 2 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 2 + - Name: func1 + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: func2 + Value: 36 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: func3 + Value: 84 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/pdb-comdat.test b/test/COFF/pdb-comdat.test index f85dacdbf4bb..655f215e0199 100644 --- a/test/COFF/pdb-comdat.test +++ b/test/COFF/pdb-comdat.test @@ -25,8 +25,8 @@ pdb_comdat_main.obj should be included in the PDB. RUN: rm -rf %t && mkdir -p %t && cd %t RUN: yaml2obj %S/Inputs/pdb_comdat_main.yaml -o pdb_comdat_main.obj RUN: yaml2obj %S/Inputs/pdb_comdat_bar.yaml -o pdb_comdat_bar.obj -RUN: lld-link pdb_comdat_main.obj pdb_comdat_bar.obj -out:t.exe -debug -pdb:t.pdb -nodefaultlib -entry:main -RUN: llvm-pdbutil dump -l -symbols t.pdb | FileCheck %s +RUN: lld-link pdb_comdat_main.obj pdb_comdat_bar.obj -out:%t.exe -debug -pdb:%t.pdb -nodefaultlib -entry:main +RUN: llvm-pdbutil dump -l -symbols -globals %t.pdb | FileCheck %s CHECK: Lines CHECK: ============================================================ @@ -38,6 +38,20 @@ CHECK: c:\src\llvm-project\build\pdb_comdat_bar.c (MD5: 365279DB4FCBEDD721 CHECK-NOT: c:\src\llvm-project\build\foo.h CHECK-LABEL: Mod 0002 | `* Linker *`: +CHECK-LABEL: Global Symbols +CHECK-NEXT: ============================================================ +CHECK-NEXT: Records +CHECK-NEXT: 84 | S_PROCREF [size = 20] `main` +CHECK-NEXT: module = 1, sum name = 0, offset = 120 +CHECK-NEXT: 128 | S_PROCREF [size = 20] `foo` +CHECK-NEXT: module = 1, sum name = 0, offset = 208 +CHECK-NEXT: 148 | S_PROCREF [size = 20] `bar` +CHECK-NEXT: module = 2, sum name = 0, offset = 120 +CHECK-NEXT: 104 | S_GDATA32 [size = 24] `global` +CHECK-NEXT: type = 0x0074 (int), addr = 0000:0000 +CHECK-NEXT: 168 | S_GDATA32 [size = 24] `global` +CHECK-NEXT: type = 0x0074 (int), addr = 0000:0000 + CHECK: Symbols CHECK: ============================================================ CHECK-LABEL: Mod 0000 | `{{.*}}pdb_comdat_main.obj`: @@ -46,7 +60,7 @@ CHECK: 60 | S_COMPILE3 [size = 60] CHECK: machine = intel x86-x64, Ver = Microsoft (R) Optimizing Compiler, language = c CHECK: frontend = 19.0.24215.1, backend = 19.0.24215.1 CHECK: flags = security checks | hot patchable -CHECK: 120 | S_GPROC32_ID [size = 44] `main` +CHECK: 120 | S_GPROC32 [size = 44] `main` CHECK: parent = 0, end = 196, addr = 0002:0000, code size = 24 CHECK: debug start = 4, debug end = 19, flags = none CHECK: 164 | S_FRAMEPROC [size = 32] @@ -54,24 +68,22 @@ CHECK: size = 40, padding size = 0, offset to padding = 0 CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000 CHECK: flags = has async eh | opt speed CHECK: 196 | S_END [size = 4] -CHECK: 200 | S_GDATA32 [size = 24] `global` -CHECK: type = 0x0074 (int), addr = 0000:0000 -CHECK: 224 | S_BUILDINFO [size = 8] BuildId = `0x100A` -CHECK: 232 | S_GPROC32_ID [size = 44] `foo` -CHECK: parent = 0, end = 308, addr = 0002:0032, code size = 15 +CHECK: 200 | S_BUILDINFO [size = 8] BuildId = `0x100A` +CHECK: 208 | S_GPROC32 [size = 44] `foo` +CHECK: parent = 0, end = 284, addr = 0002:0032, code size = 15 CHECK: debug start = 0, debug end = 14, flags = none -CHECK: 276 | S_FRAMEPROC [size = 32] +CHECK: 252 | S_FRAMEPROC [size = 32] CHECK: size = 0, padding size = 0, offset to padding = 0 CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000 CHECK: flags = marked inline | has async eh | opt speed -CHECK: 308 | S_END [size = 4] +CHECK: 284 | S_END [size = 4] CHECK-LABEL: Mod 0001 | `{{.*}}pdb_comdat_bar.obj`: CHECK: 4 | S_OBJNAME [size = 56] sig=0, `C:\src\llvm-project\build\pdb_comdat_bar.obj` CHECK: 60 | S_COMPILE3 [size = 60] CHECK: machine = intel x86-x64, Ver = Microsoft (R) Optimizing Compiler, language = c CHECK: frontend = 19.0.24215.1, backend = 19.0.24215.1 CHECK: flags = security checks | hot patchable -CHECK: 120 | S_GPROC32_ID [size = 44] `bar` +CHECK: 120 | S_GPROC32 [size = 44] `bar` CHECK: parent = 0, end = 196, addr = 0002:0048, code size = 14 CHECK: debug start = 4, debug end = 9, flags = none CHECK: 164 | S_FRAMEPROC [size = 32] @@ -79,10 +91,8 @@ CHECK: size = 40, padding size = 0, offset to padding = 0 CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000 CHECK: flags = has async eh | opt speed CHECK: 196 | S_END [size = 4] -CHECK: 200 | S_GDATA32 [size = 24] `global` -CHECK: type = 0x0074 (int), addr = 0000:0000 -CHECK: 224 | S_BUILDINFO [size = 8] BuildId = `0x100D` -CHECK-NOT: S_GPROC32_ID {{.*}} `foo` +CHECK: 200 | S_BUILDINFO [size = 8] BuildId = `0x100D` +CHECK-NOT: S_GPROC32 {{.*}} `foo` CHECK-LABEL: Mod 0002 | `* Linker *`: Reorder the object files and verify that the other table is selected. @@ -97,3 +107,6 @@ REORDER-LABEL: Mod 0001 | `{{.*}}pdb_comdat_main.obj`: REORDER: c:\src\llvm-project\build\pdb_comdat_main.c REORDER-NOT: c:\src\llvm-project\build\foo.h REORDER-LABEL: Mod 0002 | `* Linker *`: + +Make sure that we don't crash on non-prevailing debug sections if -debug is not enabled. +RUN: lld-link pdb_comdat_main.obj pdb_comdat_bar.obj -out:%t.exe -nodefaultlib -entry:main diff --git a/test/COFF/pdb-diff.test b/test/COFF/pdb-diff.test index 79b23a5c026d..17d26b60353e 100644 --- a/test/COFF/pdb-diff.test +++ b/test/COFF/pdb-diff.test @@ -4,8 +4,11 @@ as the "baseline" for us to measure against. Then we link the same object file with LLD and compare the two PDBs. Since the baseline object file and PDB are already checked in, we just run LLD on the object file. -RUN: lld-link /debug /pdb:%T/pdb-diff-lld.pdb /nodefaultlib /entry:main %S/Inputs/pdb-diff.obj -RUN: llvm-pdbutil diff -result -values=false -left-bin-root=%S -right-bin-root=D:/src/llvm-mono/lld/test/COFF/ %T/pdb-diff-lld.pdb %S/Inputs/pdb-diff-cl.pdb | FileCheck %s +RUN: rm -f %T/pdb-diff-lld.pdb %T/pdb-diff-lld.exe +RUN: lld-link /debug /pdb:%T/pdb-diff-lld.pdb /out:%T/pdb-diff-lld.exe /nodefaultlib \ +RUN: /entry:main %S/Inputs/pdb-diff.obj +RUN: llvm-pdbutil diff -result -values=false -left-bin-root=%S -right-bin-root=D:/src/llvm-mono/lld/test/COFF/ \ +RUN: %T/pdb-diff-lld.pdb %S/Inputs/pdb-diff-cl.pdb | FileCheck %s CHECK: ---------------------- CHECK-NEXT: | MSF Super Block | @@ -25,7 +28,7 @@ CHECK-NEXT: | Stream Directory | CHECK-NEXT: |------------------------------+---| CHECK-NEXT: | File | | CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | Stream Count | D | +CHECK-NEXT: | Stream Count | I | CHECK-NEXT: |------------------------------+---| CHECK-NEXT: | Old MSF Directory | I | CHECK-NEXT: |------------------------------+---| @@ -55,9 +58,9 @@ CHECK-NEXT: | IPI Hash | {{[EI]}} | CHECK-NEXT: |------------------------------+---| CHECK-NEXT: | Public Symbol Hash | {{[EI]}} | CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | Public Symbol Records | {{[EI]}} | +CHECK-NEXT: | Global Symbol Hash | {{[EI]}} | CHECK-NEXT: |------------------------------+---| -CHECK-NEXT: | Global Symbol Hash | D | +CHECK-NEXT: | Symbol Records | {{[EI]}} | CHECK-NEXT: |------------------------------+---| CHECK-NEXT: ------------------------------------ CHECK-NEXT: | String Table | @@ -152,7 +155,7 @@ CHECK-NEXT: | DBG (NewFPO) | {{[EI]}} | CHECK-NEXT: |----------------------------------------+---| CHECK-NEXT: | DBG (SectionHdrOrig) | I | CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | Globals Stream | D | +CHECK-NEXT: | Globals Stream | {{[EI]}} | CHECK-NEXT: |----------------------------------------+---| CHECK-NEXT: | Publics Stream | {{[EI]}} | CHECK-NEXT: |----------------------------------------+---| @@ -186,7 +189,7 @@ CHECK-NEXT: | - Pdb File Path Index | I | CHECK-NEXT: |----------------------------------------+---| CHECK-NEXT: | - Source File Name Index | I | CHECK-NEXT: |----------------------------------------+---| -CHECK-NEXT: | - Symbol Byte Size | D | +CHECK-NEXT: | - Symbol Byte Size | CHECK-NEXT: |----------------------------------------+---| CHECK-NEXT: | Module "* Linker *" | CHECK-NEXT: |----------------------------------------+---| diff --git a/test/COFF/pdb-global-gc.yaml b/test/COFF/pdb-global-gc.yaml index b66b3f2ca7b8..f2c4450809b0 100644 --- a/test/COFF/pdb-global-gc.yaml +++ b/test/COFF/pdb-global-gc.yaml @@ -1,8 +1,8 @@ # RUN: yaml2obj %s -o %t.obj # RUN: llvm-mc %S/Inputs/pdb-global-gc.s -triple x86_64-windows-msvc -filetype=obj -o %t2.obj # RUN: lld-link %t.obj %t2.obj -debug -entry:main \ -# RUN: -nodefaultlib -debug -out:%t.exe -pdb:%t.pdb -verbose -# RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck %s +# RUN: -nodefaultlib -opt:ref -out:%t.exe -pdb:%t.pdb -verbose +# RUN: llvm-pdbutil dump -symbols -globals %t.pdb | FileCheck %s # This tests the case where an __imp_ chunk is discarded by linker GC. The debug # info may refer to the __imp_ symbol still. @@ -12,13 +12,17 @@ # int discarded() { return __wc_mb_cur; } # int main() { return g2; } -# CHECK: Symbols -# CHECK: ============================================================ -# CHECK: Mod 0000 | `{{.*}}pdb-global-gc.yaml.tmp.obj`: -# CHECK: 4 | S_GDATA32 [size = 28] `__wc_mb_cur` -# CHECK-NEXT: type = 0x0070 (char), addr = 0000:0000 -# CHECK: Mod 0001 | `{{.*}}pdb-global-gc.yaml.tmp2.obj`: -# CHECK: Mod 0002 | `* Linker *`: +# CHECK: Global Symbols +# CHECK-NEXT: ============================================================ +# CHECK-NEXT: Records +# CHECK-NEXT: 20 | S_GDATA32 [size = 28] `__wc_mb_cur` +# CHECK-NEXT: type = 0x0070 (char), addr = 0000:0000 + +# CHECK: Symbols +# CHECK: ============================================================ +# CHECK-NEXT: Mod 0000 | `{{.*}}pdb-global-gc.yaml.tmp.obj`: +# CHECK-NEXT: Mod 0001 | `{{.*}}pdb-global-gc.yaml.tmp2.obj`: +# CHECK-NEXT: Mod 0002 | `* Linker *`: --- !COFF header: diff --git a/test/COFF/pdb-global-hashes.test b/test/COFF/pdb-global-hashes.test new file mode 100644 index 000000000000..b47e43826537 --- /dev/null +++ b/test/COFF/pdb-global-hashes.test @@ -0,0 +1,93 @@ +RUN: yaml2obj %p/Inputs/pdb-hashes-1.yaml > %t.1.obj +RUN: yaml2obj %p/Inputs/pdb-hashes-2.yaml > %t.2.obj +RUN: yaml2obj %p/Inputs/pdb-hashes-2-missing.yaml > %t.2.missing.obj +RUN: lld-link /debug %t.1.obj %t.2.obj /entry:main /nodefaultlib /PDB:%t.nohash.pdb +RUN: lld-link /debug:ghash %t.1.obj %t.2.obj /entry:main /nodefaultlib /PDB:%t.hash.pdb +RUN: lld-link /debug:ghash %t.1.obj %t.2.missing.obj /entry:main /nodefaultlib /PDB:%t.mixed.pdb +RUN: llvm-pdbutil dump -types -ids %t.nohash.pdb | FileCheck %s +RUN: llvm-pdbutil dump -types -ids %t.hash.pdb | FileCheck %s +RUN: llvm-pdbutil dump -types -ids %t.mixed.pdb | FileCheck %s + +; These object files were generated via the following inputs and commands: +; ---------------------------------------------- +; // obj.h +; namespace NS { +; struct Foo { +; explicit Foo(int x) : X(x) {} +; int X; +; }; +; +; int func(const Foo &f); +; } +; ---------------------------------------------- +; // obj1.cpp +; #include "obj.h" +; +; int main(int argc, char **argv) { +; NS::Foo f(argc); +; return NS::func(f); +; } +; ---------------------------------------------- +; // obj2.cpp +; #include "obj.h" +; +; int NS::func(const Foo &f) { +; return 2 * f.X; +; } +; ---------------------------------------------- +; $ clang-cl /Z7 /GS- obj1.cpp /c /o obj1.obj +; $ clang-cl /Z7 /GS- obj2.cpp /c /o obj2.obj + +CHECK: Types (TPI Stream) +CHECK-NEXT: ============================================================ +CHECK-NEXT: Showing 13 records +CHECK-NEXT: 0x1000 | LF_POINTER [size = 12] +CHECK-NEXT: referent = 0x0470 (char*), mode = pointer, opts = None, kind = ptr32 +CHECK-NEXT: 0x1001 | LF_ARGLIST [size = 16] +CHECK-NEXT: 0x0074 (int): `int` +CHECK-NEXT: 0x1000: `char**` +CHECK-NEXT: 0x1002 | LF_PROCEDURE [size = 16] +CHECK-NEXT: return type = 0x0074 (int), # args = 2, param list = 0x1001 +CHECK-NEXT: calling conv = cdecl, options = None +CHECK-NEXT: 0x1003 | LF_STRUCTURE [size = 44] `NS::Foo` +CHECK-NEXT: unique name: `.?AUFoo@NS@@` +CHECK-NEXT: vtable: <no type>, base list: <no type>, field list: <no type> +CHECK-NEXT: options: forward ref | has unique name +CHECK-NEXT: 0x1004 | LF_POINTER [size = 12] +CHECK-NEXT: referent = 0x1003, mode = pointer, opts = None, kind = ptr32 +CHECK-NEXT: 0x1005 | LF_ARGLIST [size = 12] +CHECK-NEXT: 0x0074 (int): `int` +CHECK-NEXT: 0x1006 | LF_MFUNCTION [size = 28] +CHECK-NEXT: return type = 0x0003 (void), # args = 1, param list = 0x1005 +CHECK-NEXT: class type = 0x1003, this type = 0x1004, this adjust = 0 +CHECK-NEXT: calling conv = thiscall, options = None +CHECK-NEXT: 0x1007 | LF_FIELDLIST [size = 28] +CHECK-NEXT: - LF_MEMBER [name = `X`, Type = 0x0074 (int), offset = 0, attrs = public] +CHECK-NEXT: - LF_ONEMETHOD [name = `Foo`] +CHECK-NEXT: type = 0x1006, vftable offset = -1, attrs = public +CHECK-NEXT: 0x1008 | LF_STRUCTURE [size = 44] `NS::Foo` +CHECK-NEXT: unique name: `.?AUFoo@NS@@` +CHECK-NEXT: vtable: <no type>, base list: <no type>, field list: 0x1007 +CHECK-NEXT: options: has unique name +CHECK-NEXT: 0x1009 | LF_MODIFIER [size = 12] +CHECK-NEXT: referent = 0x1003, modifiers = const +CHECK-NEXT: 0x100A | LF_POINTER [size = 12] +CHECK-NEXT: referent = 0x1009, mode = ref, opts = None, kind = ptr32 +CHECK-NEXT: 0x100B | LF_ARGLIST [size = 12] +CHECK-NEXT: 0x100A: `const NS::Foo&` +CHECK-NEXT: 0x100C | LF_PROCEDURE [size = 16] +CHECK-NEXT: return type = 0x0074 (int), # args = 1, param list = 0x100B +CHECK-NEXT: calling conv = cdecl, options = None +CHECK: Types (IPI Stream) +CHECK-NEXT: ============================================================ +CHECK-NEXT: Showing 6 records +CHECK-NEXT: 0x1000 | LF_FUNC_ID [size = 20] +CHECK-NEXT: name = main, type = 0x1002, parent scope = <no type> +CHECK-NEXT: 0x1001 | LF_STRING_ID [size = 48] ID: <no type>, String: D:\src\llvmbuild\clang\Debug\x86\obj.h +CHECK-NEXT: 0x1002 | LF_UDT_SRC_LINE [size = 16] +CHECK-NEXT: udt = 0x1008, file = 4097, line = 2 +CHECK-NEXT: 0x1003 | LF_MFUNC_ID [size = 16] +CHECK-NEXT: name = Foo, type = 0x1006, class type = 0x1003 +CHECK-NEXT: 0x1004 | LF_STRING_ID [size = 12] ID: <no type>, String: NS +CHECK-NEXT: 0x1005 | LF_FUNC_ID [size = 20] +CHECK-NEXT: name = func, type = 0x100C, parent scope = 0x1004 diff --git a/test/COFF/pdb-globals.test b/test/COFF/pdb-globals.test new file mode 100644 index 000000000000..b5e4f49cb458 --- /dev/null +++ b/test/COFF/pdb-globals.test @@ -0,0 +1,42 @@ +RUN: yaml2obj %S/Inputs/pdb-globals.yaml > %t.obj +RUN: lld-link /debug /nodefaultlib /entry:main /out:%t.exe /pdb:%t.pdb %t.obj +RUN: llvm-pdbutil dump -symbols -globals %t.pdb | FileCheck %s + +# Test that we correctly distribute symbols between the globals and module +# symbol streams. Specifically: +# * S_UDT, S_GDATA32, and S_CONSTANT end up in the globals stream, and are +# omitted from the module stream. +# * S_GPROC32 and S_LPROC32 end up in the symbols stream, but S_PROCREF and +# S_LPROCREF are added to the globals stream that refer to the module +# stream. +# * S_LDATA32 is copied byte for byte into both streams. + + +CHECK-LABEL: Global Symbols +CHECK-NEXT: ============================================================ +CHECK-NEXT: Records +CHECK-NEXT: 160 | S_PROCREF [size = 28] `GlobalFunc` +CHECK-NEXT: module = 1, sum name = 0, offset = 52 +CHECK-NEXT: 188 | S_PROCREF [size = 20] `main` +CHECK-NEXT: module = 1, sum name = 0, offset = 108 +CHECK-NEXT: 208 | S_LPROCREF [size = 24] `LocalFunc` +CHECK-NEXT: module = 1, sum name = 0, offset = 292 +CHECK-NEXT: 312 | S_PROCREF [size = 40] `HelloPoint::HelloPoint` +CHECK-NEXT: module = 1, sum name = 0, offset = 376 +CHECK-NEXT: 232 | S_GDATA32 [size = 28] `__purecall` +CHECK-NEXT: type = 0x0403 (void*), addr = 0000:0000 +CHECK-NEXT: 260 | S_GDATA32 [size = 24] `GlobalVar` +CHECK-NEXT: type = 0x100B (const int*), addr = 0001:0000 +CHECK-NEXT: 284 | S_LDATA32 [size = 28] `ConstantVar` +CHECK-NEXT: type = 0x100A (const int), addr = 0002:0000 + +CHECK-LABEL: Symbols +CHECK-NEXT: ============================================================ +CHECK-NEXT: Mod 0000 +CHECK-NOT: | S_GDATA32 +CHECK-NOT: | S_UDT +CHECK: 52 | S_GPROC32 [size = 52] `GlobalFunc` +CHECK: 108 | S_GPROC32 [size = 44] `main` +CHECK: 292 | S_LPROC32 [size = 52] `LocalFunc` +CHECK: 348 | S_LDATA32 [size = 28] `ConstantVar` +CHECK: 376 | S_GPROC32 [size = 64] `HelloPoint::HelloPoint` diff --git a/test/COFF/pdb-heapsite.yaml b/test/COFF/pdb-heapsite.yaml new file mode 100644 index 000000000000..966ae4284890 --- /dev/null +++ b/test/COFF/pdb-heapsite.yaml @@ -0,0 +1,1561 @@ +# RUN: yaml2obj %s -o %t.obj +# RUN: lld-link %t.obj -dll -debug -noentry -nodefaultlib -debug -out:%t.exe -pdb:%t.pdb +# RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck %s + +# This object generated from this C++ source: +# // t.cpp +# void *operator new(size_t) { return nullptr; } +# struct Foo { int x; }; +# extern "C" __declspec(dllexport) Foo *f() { return new Foo; } + +# Compile as: +# $ cl -c -Z7 t.cpp + +# CHECK: S_HEAPALLOCSITE [size = 16] +# CHECK-NEXT: type = 0x1000 (Foo), addr = {{.*}} call size = 5 + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [ ] +sections: + - Name: .drectve + Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: 2020202F44454641554C544C49423A224C4942434D5422202F44454641554C544C49423A224F4C444E414D455322202F4558504F52543A6620 + - Name: '.debug$S' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 1 + Subsections: + - !Symbols + Records: + - Kind: S_OBJNAME + ObjNameSym: + Signature: 0 + ObjectName: 'C:\src\llvm-project\build\t.obj' + - Kind: S_COMPILE3 + Compile3Sym: + Flags: [ SecurityChecks, HotPatch ] + Machine: X64 + FrontendMajor: 19 + FrontendMinor: 11 + FrontendBuild: 25508 + FrontendQFE: 2 + BackendMajor: 19 + BackendMinor: 11 + BackendBuild: 25508 + BackendQFE: 2 + Version: 'Microsoft (R) Optimizing Compiler' + - !Symbols + Records: + - Kind: S_GPROC32_ID + ProcSym: + CodeSize: 8 + DbgStart: 5 + DbgEnd: 7 + FunctionType: 4104 + Flags: [ ] + DisplayName: operator new + - Kind: S_FRAMEPROC + FrameProcSym: + TotalFrameBytes: 0 + PaddingFrameBytes: 0 + OffsetToPadding: 0 + BytesOfCalleeSavedRegisters: 0 + OffsetOfExceptionHandler: 0 + SectionIdOfExceptionHandler: 0 + Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ] + - Kind: S_REGREL32 + RegRelativeSym: + Offset: 8 + Type: 35 + Register: RSP + VarName: __formal + - Kind: S_PROC_ID_END + ScopeEndSym: + - !Lines + CodeSize: 8 + Flags: [ ] + RelocOffset: 0 + RelocSegment: 0 + Blocks: + - FileName: 'c:\src\llvm-project\build\t.cpp' + Lines: + - Offset: 0 + LineStart: 1 + IsStatement: true + EndDelta: 0 + Columns: + - !Symbols + Records: + - Kind: S_GPROC32_ID + ProcSym: + CodeSize: 29 + DbgStart: 4 + DbgEnd: 24 + FunctionType: 4107 + Flags: [ ] + DisplayName: f + - Kind: S_FRAMEPROC + FrameProcSym: + TotalFrameBytes: 56 + PaddingFrameBytes: 0 + OffsetToPadding: 0 + BytesOfCalleeSavedRegisters: 0 + OffsetOfExceptionHandler: 0 + SectionIdOfExceptionHandler: 0 + Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ] + - Kind: S_HEAPALLOCSITE + HeapAllocationSiteSym: + Offset: 9 + CallInstructionSize: 5 + Type: 4096 + - Kind: S_PROC_ID_END + ScopeEndSym: + - !Lines + CodeSize: 29 + Flags: [ ] + RelocOffset: 0 + RelocSegment: 0 + Blocks: + - FileName: 'c:\src\llvm-project\build\t.cpp' + Lines: + - Offset: 0 + LineStart: 3 + IsStatement: true + EndDelta: 0 + Columns: + - !Symbols + Records: + - Kind: S_UDT + UDTSym: + Type: 4098 + UDTName: Foo + - Kind: S_UDT + UDTSym: + Type: 4196 + UDTName: '__vc_attributes::event_sourceAttribute' + - Kind: S_UDT + UDTSym: + Type: 4188 + UDTName: '__vc_attributes::event_sourceAttribute::optimize_e' + - Kind: S_UDT + UDTSym: + Type: 4185 + UDTName: '__vc_attributes::event_sourceAttribute::type_e' + - Kind: S_UDT + UDTSym: + Type: 4181 + UDTName: '__vc_attributes::helper_attributes::v1_alttypeAttribute' + - Kind: S_UDT + UDTSym: + Type: 4175 + UDTName: '__vc_attributes::helper_attributes::v1_alttypeAttribute::type_e' + - Kind: S_UDT + UDTSym: + Type: 4171 + UDTName: '__vc_attributes::helper_attributes::usageAttribute' + - Kind: S_UDT + UDTSym: + Type: 4165 + UDTName: '__vc_attributes::helper_attributes::usageAttribute::usage_e' + - Kind: S_UDT + UDTSym: + Type: 4161 + UDTName: '__vc_attributes::threadingAttribute' + - Kind: S_UDT + UDTSym: + Type: 4153 + UDTName: '__vc_attributes::threadingAttribute::threading_e' + - Kind: S_UDT + UDTSym: + Type: 4149 + UDTName: '__vc_attributes::aggregatableAttribute' + - Kind: S_UDT + UDTSym: + Type: 4141 + UDTName: '__vc_attributes::aggregatableAttribute::type_e' + - Kind: S_UDT + UDTSym: + Type: 4137 + UDTName: '__vc_attributes::event_receiverAttribute' + - Kind: S_UDT + UDTSym: + Type: 4127 + UDTName: '__vc_attributes::event_receiverAttribute::type_e' + - Kind: S_UDT + UDTSym: + Type: 4123 + UDTName: '__vc_attributes::moduleAttribute' + - Kind: S_UDT + UDTSym: + Type: 4110 + UDTName: '__vc_attributes::moduleAttribute::type_e' + - Kind: S_UDT + UDTSym: + Type: 35 + UDTName: size_t + - !FileChecksums + Checksums: + - FileName: 'c:\src\llvm-project\build\t.cpp' + Kind: MD5 + Checksum: 3C4D132707FA572FA0869E4E4DAA7F85 + - !StringTable + Strings: + - 'c:\src\llvm-project\build\t.cpp' + - !Symbols + Records: + - Kind: S_BUILDINFO + BuildInfoSym: + BuildId: 4205 + Relocations: + - VirtualAddress: 152 + SymbolName: '??2@YAPEAX_K@Z' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 156 + SymbolName: '??2@YAPEAX_K@Z' + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 240 + SymbolName: '??2@YAPEAX_K@Z' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 244 + SymbolName: '??2@YAPEAX_K@Z' + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 312 + SymbolName: f + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 316 + SymbolName: f + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 355 + SymbolName: f + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 359 + SymbolName: f + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 380 + SymbolName: f + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 384 + SymbolName: f + Type: IMAGE_REL_AMD64_SECTION + - Name: '.debug$T' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 1 + Types: + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: Foo + UniqueName: '.?AUFoo@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 116 + FieldOffset: 0 + Name: x + - Kind: LF_STRUCTURE + Class: + MemberCount: 1 + Options: [ None, HasUniqueName ] + FieldList: 4097 + Name: Foo + UniqueName: '.?AUFoo@@' + DerivationList: 0 + VTableShape: 0 + Size: 4 + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: 'c:\src\llvm-project\build\t.cpp' + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4098 + SourceFile: 4099 + LineNumber: 2 + - Kind: LF_POINTER + Pointer: + ReferentType: 4096 + Attrs: 65548 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 35 ] + - Kind: LF_PROCEDURE + Procedure: + ReturnType: 1539 + CallConv: NearC + Options: [ None ] + ParameterCount: 1 + ArgumentList: 4102 + - Kind: LF_FUNC_ID + FuncId: + ParentScope: 0 + FunctionType: 4103 + Name: operator new + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ ] + - Kind: LF_PROCEDURE + Procedure: + ReturnType: 4101 + CallConv: NearC + Options: [ None ] + ParameterCount: 0 + ArgumentList: 4105 + - Kind: LF_FUNC_ID + FuncId: + ParentScope: 0 + FunctionType: 4106 + Name: f + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: '__vc_attributes::moduleAttribute' + UniqueName: '.?AUmoduleAttribute@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 1 + Name: dll + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 2 + Name: exe + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 3 + Name: service + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 4 + Name: unspecified + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 2 + Name: EXE + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 3 + Name: SERVICE + - Kind: LF_ENUM + Enum: + NumEnumerators: 6 + Options: [ None, Nested, HasUniqueName ] + FieldList: 4109 + Name: '__vc_attributes::moduleAttribute::type_e' + UniqueName: '.?AW4type_e@moduleAttribute@__vc_attributes@@' + UnderlyingType: 116 + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: 'c:\src\llvm-project\build\predefined c++ attributes (compiler internal)' + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4110 + SourceFile: 4111 + LineNumber: 482 + - Kind: LF_MODIFIER + Modifier: + ModifiedType: 112 + Modifiers: [ None, Const ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4113 + Attrs: 65548 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4110, 4114, 4114, 4114, 116, 48, 4114, 116, + 4114, 4114, 116, 48, 48, 4114, 4114 ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4108 + Attrs: 66572 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4108 + ThisType: 4116 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 15 + ArgumentList: 4115 + ThisPointerAdjustment: 0 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4110 ] + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4108 + ThisType: 4116 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 1 + ArgumentList: 4118 + ThisPointerAdjustment: 0 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4108 + ThisType: 4116 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 0 + ArgumentList: 4105 + ThisPointerAdjustment: 0 + - Kind: LF_METHODLIST + MethodOverloadList: + Methods: + - Type: 4117 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Type: 4119 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Type: 4120 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_NESTTYPE + NestedType: + Type: 4110 + Name: type_e + - Kind: LF_METHOD + OverloadedMethod: + NumOverloads: 3 + MethodList: 4121 + Name: moduleAttribute + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4110 + FieldOffset: 0 + Name: type + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4114 + FieldOffset: 8 + Name: name + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4114 + FieldOffset: 16 + Name: version + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4114 + FieldOffset: 24 + Name: uuid + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 116 + FieldOffset: 32 + Name: lcid + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 48 + FieldOffset: 36 + Name: control + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4114 + FieldOffset: 40 + Name: helpstring + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 116 + FieldOffset: 48 + Name: helpstringcontext + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4114 + FieldOffset: 56 + Name: helpstringdll + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4114 + FieldOffset: 64 + Name: helpfile + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 116 + FieldOffset: 72 + Name: helpcontext + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 48 + FieldOffset: 76 + Name: hidden + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 48 + FieldOffset: 77 + Name: restricted + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4114 + FieldOffset: 80 + Name: custom + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4114 + FieldOffset: 88 + Name: resource_name + - Kind: LF_STRUCTURE + Class: + MemberCount: 19 + Options: [ None, HasConstructorOrDestructor, ContainsNestedClass, HasUniqueName ] + FieldList: 4122 + Name: '__vc_attributes::moduleAttribute' + UniqueName: '.?AUmoduleAttribute@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 96 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4123 + SourceFile: 4111 + LineNumber: 481 + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: '__vc_attributes::event_receiverAttribute' + UniqueName: '.?AUevent_receiverAttribute@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 0 + Name: native + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 1 + Name: com + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 2 + Name: managed + - Kind: LF_ENUM + Enum: + NumEnumerators: 3 + Options: [ None, Nested, HasUniqueName ] + FieldList: 4126 + Name: '__vc_attributes::event_receiverAttribute::type_e' + UniqueName: '.?AW4type_e@event_receiverAttribute@__vc_attributes@@' + UnderlyingType: 116 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4127 + SourceFile: 4111 + LineNumber: 136 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4127, 48 ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4125 + Attrs: 66572 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4125 + ThisType: 4130 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 2 + ArgumentList: 4129 + ThisPointerAdjustment: 0 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4127 ] + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4125 + ThisType: 4130 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 1 + ArgumentList: 4132 + ThisPointerAdjustment: 0 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4125 + ThisType: 4130 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 0 + ArgumentList: 4105 + ThisPointerAdjustment: 0 + - Kind: LF_METHODLIST + MethodOverloadList: + Methods: + - Type: 4131 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Type: 4133 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Type: 4134 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_NESTTYPE + NestedType: + Type: 4127 + Name: type_e + - Kind: LF_METHOD + OverloadedMethod: + NumOverloads: 3 + MethodList: 4135 + Name: event_receiverAttribute + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4127 + FieldOffset: 0 + Name: type + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 48 + FieldOffset: 4 + Name: layout_dependent + - Kind: LF_STRUCTURE + Class: + MemberCount: 6 + Options: [ None, HasConstructorOrDestructor, ContainsNestedClass, HasUniqueName ] + FieldList: 4136 + Name: '__vc_attributes::event_receiverAttribute' + UniqueName: '.?AUevent_receiverAttribute@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 8 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4137 + SourceFile: 4111 + LineNumber: 135 + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: '__vc_attributes::aggregatableAttribute' + UniqueName: '.?AUaggregatableAttribute@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 0 + Name: never + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 1 + Name: allowed + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 2 + Name: always + - Kind: LF_ENUM + Enum: + NumEnumerators: 3 + Options: [ None, Nested, HasUniqueName ] + FieldList: 4140 + Name: '__vc_attributes::aggregatableAttribute::type_e' + UniqueName: '.?AW4type_e@aggregatableAttribute@__vc_attributes@@' + UnderlyingType: 116 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4141 + SourceFile: 4111 + LineNumber: 545 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4141 ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4139 + Attrs: 66572 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4139 + ThisType: 4144 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 1 + ArgumentList: 4143 + ThisPointerAdjustment: 0 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4139 + ThisType: 4144 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 0 + ArgumentList: 4105 + ThisPointerAdjustment: 0 + - Kind: LF_METHODLIST + MethodOverloadList: + Methods: + - Type: 4145 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Type: 4146 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_NESTTYPE + NestedType: + Type: 4141 + Name: type_e + - Kind: LF_METHOD + OverloadedMethod: + NumOverloads: 2 + MethodList: 4147 + Name: aggregatableAttribute + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4141 + FieldOffset: 0 + Name: type + - Kind: LF_STRUCTURE + Class: + MemberCount: 4 + Options: [ None, HasConstructorOrDestructor, ContainsNestedClass, HasUniqueName ] + FieldList: 4148 + Name: '__vc_attributes::aggregatableAttribute' + UniqueName: '.?AUaggregatableAttribute@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 4 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4149 + SourceFile: 4111 + LineNumber: 544 + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: '__vc_attributes::threadingAttribute' + UniqueName: '.?AUthreadingAttribute@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 1 + Name: apartment + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 2 + Name: single + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 3 + Name: free + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 4 + Name: neutral + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 5 + Name: both + - Kind: LF_ENUM + Enum: + NumEnumerators: 5 + Options: [ None, Nested, HasUniqueName ] + FieldList: 4152 + Name: '__vc_attributes::threadingAttribute::threading_e' + UniqueName: '.?AW4threading_e@threadingAttribute@__vc_attributes@@' + UnderlyingType: 116 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4153 + SourceFile: 4111 + LineNumber: 423 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4153 ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4151 + Attrs: 66572 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4151 + ThisType: 4156 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 1 + ArgumentList: 4155 + ThisPointerAdjustment: 0 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4151 + ThisType: 4156 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 0 + ArgumentList: 4105 + ThisPointerAdjustment: 0 + - Kind: LF_METHODLIST + MethodOverloadList: + Methods: + - Type: 4157 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Type: 4158 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_NESTTYPE + NestedType: + Type: 4153 + Name: threading_e + - Kind: LF_METHOD + OverloadedMethod: + NumOverloads: 2 + MethodList: 4159 + Name: threadingAttribute + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4153 + FieldOffset: 0 + Name: value + - Kind: LF_STRUCTURE + Class: + MemberCount: 4 + Options: [ None, HasConstructorOrDestructor, ContainsNestedClass, HasUniqueName ] + FieldList: 4160 + Name: '__vc_attributes::threadingAttribute' + UniqueName: '.?AUthreadingAttribute@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 4 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4161 + SourceFile: 4111 + LineNumber: 422 + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: '__vc_attributes::helper_attributes::usageAttribute' + UniqueName: '.?AUusageAttribute@helper_attributes@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 0 + Name: eAnyUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 1 + Name: eCoClassUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 2 + Name: eCOMInterfaceUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 6 + Name: eInterfaceUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 8 + Name: eMemberUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 16 + Name: eMethodUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 32 + Name: eInterfaceMethodUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 64 + Name: eInterfaceMemberUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 128 + Name: eCoClassMemberUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 256 + Name: eCoClassMethodUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 768 + Name: eGlobalMethodUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 1024 + Name: eGlobalDataUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 2048 + Name: eClassUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 4096 + Name: eInterfaceParameterUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 12288 + Name: eMethodParameterUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 16384 + Name: eIDLModuleUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 32768 + Name: eAnonymousUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 65536 + Name: eTypedefUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 131072 + Name: eUnionUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 262144 + Name: eEnumUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 524288 + Name: eDefineTagUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 1048576 + Name: eStructUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 2097152 + Name: eLocalUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 4194304 + Name: ePropertyUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 8388608 + Name: eEventUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 16777216 + Name: eTemplateUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 16777216 + Name: eModuleUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 33554432 + Name: eIllegalUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 67108864 + Name: eAsynchronousUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 4161535 + Name: eAnyIDLUsage + - Kind: LF_ENUM + Enum: + NumEnumerators: 30 + Options: [ None, Nested, HasUniqueName ] + FieldList: 4164 + Name: '__vc_attributes::helper_attributes::usageAttribute::usage_e' + UniqueName: '.?AW4usage_e@usageAttribute@helper_attributes@__vc_attributes@@' + UnderlyingType: 116 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4165 + SourceFile: 4111 + LineNumber: 51 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 117 ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4163 + Attrs: 66572 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4163 + ThisType: 4168 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 1 + ArgumentList: 4167 + ThisPointerAdjustment: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_NESTTYPE + NestedType: + Type: 4165 + Name: usage_e + - Kind: LF_ONEMETHOD + OneMethod: + Type: 4169 + Attrs: 3 + VFTableOffset: -1 + Name: usageAttribute + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 117 + FieldOffset: 0 + Name: value + - Kind: LF_STRUCTURE + Class: + MemberCount: 3 + Options: [ None, HasConstructorOrDestructor, ContainsNestedClass, HasUniqueName ] + FieldList: 4170 + Name: '__vc_attributes::helper_attributes::usageAttribute' + UniqueName: '.?AUusageAttribute@helper_attributes@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 4 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4171 + SourceFile: 4111 + LineNumber: 49 + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: '__vc_attributes::helper_attributes::v1_alttypeAttribute' + UniqueName: '.?AUv1_alttypeAttribute@helper_attributes@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 0 + Name: eBoolean + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 1 + Name: eInteger + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 2 + Name: eFloat + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 3 + Name: eDouble + - Kind: LF_ENUM + Enum: + NumEnumerators: 4 + Options: [ None, Nested, HasUniqueName ] + FieldList: 4174 + Name: '__vc_attributes::helper_attributes::v1_alttypeAttribute::type_e' + UniqueName: '.?AW4type_e@v1_alttypeAttribute@helper_attributes@__vc_attributes@@' + UnderlyingType: 116 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4175 + SourceFile: 4111 + LineNumber: 38 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4175 ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4173 + Attrs: 66572 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4173 + ThisType: 4178 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 1 + ArgumentList: 4177 + ThisPointerAdjustment: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_NESTTYPE + NestedType: + Type: 4175 + Name: type_e + - Kind: LF_ONEMETHOD + OneMethod: + Type: 4179 + Attrs: 3 + VFTableOffset: -1 + Name: v1_alttypeAttribute + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4175 + FieldOffset: 0 + Name: type + - Kind: LF_STRUCTURE + Class: + MemberCount: 3 + Options: [ None, HasConstructorOrDestructor, ContainsNestedClass, HasUniqueName ] + FieldList: 4180 + Name: '__vc_attributes::helper_attributes::v1_alttypeAttribute' + UniqueName: '.?AUv1_alttypeAttribute@helper_attributes@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 4 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4181 + SourceFile: 4111 + LineNumber: 37 + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: '__vc_attributes::event_sourceAttribute' + UniqueName: '.?AUevent_sourceAttribute@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 0 + Name: native + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 1 + Name: com + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 2 + Name: managed + - Kind: LF_ENUM + Enum: + NumEnumerators: 3 + Options: [ None, Nested, HasUniqueName ] + FieldList: 4184 + Name: '__vc_attributes::event_sourceAttribute::type_e' + UniqueName: '.?AW4type_e@event_sourceAttribute@__vc_attributes@@' + UnderlyingType: 116 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4185 + SourceFile: 4111 + LineNumber: 1142 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 0 + Name: speed + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 1 + Name: size + - Kind: LF_ENUM + Enum: + NumEnumerators: 2 + Options: [ None, Nested, HasUniqueName ] + FieldList: 4187 + Name: '__vc_attributes::event_sourceAttribute::optimize_e' + UniqueName: '.?AW4optimize_e@event_sourceAttribute@__vc_attributes@@' + UnderlyingType: 116 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4188 + SourceFile: 4111 + LineNumber: 1145 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4185 ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4183 + Attrs: 66572 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4183 + ThisType: 4191 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 1 + ArgumentList: 4190 + ThisPointerAdjustment: 0 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4183 + ThisType: 4191 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 0 + ArgumentList: 4105 + ThisPointerAdjustment: 0 + - Kind: LF_METHODLIST + MethodOverloadList: + Methods: + - Type: 4192 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Type: 4193 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_NESTTYPE + NestedType: + Type: 4185 + Name: type_e + - Kind: LF_NESTTYPE + NestedType: + Type: 4188 + Name: optimize_e + - Kind: LF_METHOD + OverloadedMethod: + NumOverloads: 2 + MethodList: 4194 + Name: event_sourceAttribute + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4185 + FieldOffset: 0 + Name: type + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4188 + FieldOffset: 4 + Name: optimize + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 48 + FieldOffset: 8 + Name: decorate + - Kind: LF_STRUCTURE + Class: + MemberCount: 7 + Options: [ None, HasConstructorOrDestructor, ContainsNestedClass, HasUniqueName ] + FieldList: 4195 + Name: '__vc_attributes::event_sourceAttribute' + UniqueName: '.?AUevent_sourceAttribute@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 12 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4196 + SourceFile: 4111 + LineNumber: 1141 + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: 'C:\src\llvm-project\build' + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: 'C:\PROGRA~2\MICROS~1\2017\PROFES~1\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\cl.exe' + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: '-c -Z7 -MT -IC:\PROGRA~2\MICROS~1\2017\PROFES~1\VC\Tools\MSVC\14.11.25503\ATLMFC\include -IC:\PROGRA~2\MICROS~1\2017\PROFES~1\VC\Tools\MSVC\14.11.25503\include -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.16299.0\ucrt -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.16299.0\' + - Kind: LF_SUBSTR_LIST + StringList: + StringIndices: [ 4200 ] + - Kind: LF_STRING_ID + StringId: + Id: 4201 + String: 'shared -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.16299.0\um -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.16299.0\winrt -TP -X' + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: t.cpp + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: 'C:\src\llvm-project\build\vc140.pdb' + - Kind: LF_BUILDINFO + BuildInfo: + ArgIndices: [ 4198, 4199, 4203, 4204, 4202 ] + - Name: '.text$mn' + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: 48894C240833C0C3CCCCCCCCCCCCCCCC4883EC38B904000000E8000000004889442420488B4424204883C438C3 + Relocations: + - VirtualAddress: 26 + SymbolName: '??2@YAPEAX_K@Z' + Type: IMAGE_REL_AMD64_REL32 + - Name: .xdata + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: '0104010004620000' + - Name: .pdata + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 000000001D00000000000000 + Relocations: + - VirtualAddress: 0 + SymbolName: '$LN3' + Type: IMAGE_REL_AMD64_ADDR32NB + - VirtualAddress: 4 + SymbolName: '$LN3' + Type: IMAGE_REL_AMD64_ADDR32NB + - VirtualAddress: 8 + SymbolName: '$unwind$f' + Type: IMAGE_REL_AMD64_ADDR32NB +symbols: + - Name: '@comp.id' + Value: 17130404 + SectionNumber: -1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: '@feat.00' + Value: 2147484048 + SectionNumber: -1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: .drectve + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 57 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 1455566745 + Number: 0 + - Name: '.debug$S' + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 1364 + NumberOfRelocations: 10 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: '.debug$T' + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 6560 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: '.text$mn' + Value: 0 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 45 + NumberOfRelocations: 1 + NumberOfLinenumbers: 0 + CheckSum: 1509507051 + Number: 0 + - Name: '??2@YAPEAX_K@Z' + Value: 0 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: f + Value: 16 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: '$LN3' + Value: 16 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_LABEL + - Name: .xdata + Value: 0 + SectionNumber: 5 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 8 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 931692337 + Number: 0 + - Name: '$unwind$f' + Value: 0 + SectionNumber: 5 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: .pdata + Value: 0 + SectionNumber: 6 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 12 + NumberOfRelocations: 3 + NumberOfLinenumbers: 0 + CheckSum: 3887998202 + Number: 0 + - Name: '$pdata$f' + Value: 0 + SectionNumber: 6 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC +... diff --git a/test/COFF/pdb-import-gc.yaml b/test/COFF/pdb-import-gc.yaml index 80484cb75f4f..8f50a111411c 100644 --- a/test/COFF/pdb-import-gc.yaml +++ b/test/COFF/pdb-import-gc.yaml @@ -1,7 +1,7 @@ # RUN: yaml2obj %s -o %t.obj # RUN: lld-link %t.obj %S/Inputs/pdb-import-gc.lib -debug -entry:main \ -# RUN: -nodefaultlib -debug -out:%t.exe -pdb:%t.pdb -# RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck %s +# RUN: -nodefaultlib -opt:ref -out:%t.exe -pdb:%t.pdb +# RUN: llvm-pdbutil dump -globals -symbols %t.pdb | FileCheck %s # This tests the case where an __imp_ chunk is discarded by linker GC. The debug # info may refer to the __imp_ symbol still. @@ -11,12 +11,16 @@ # int discarded() { return __wc_mb_cur; } # int main() { return g2; } -# CHECK: Symbols -# CHECK: ============================================================ -# CHECK: Mod 0000 | `{{.*}}pdb-import-gc.yaml.tmp.obj`: -# CHECK: 4 | S_GDATA32 [size = 32] `__imp___wc_mb_cur` -# CHECK-NEXT: type = 0x0070 (char), addr = 0000:0000 -# CHECK: Mod 0001 | `* Linker *`: +# CHECK: Global Symbols +# CHECK-NEXT: ============================================================ +# CHECK-NEXT: Records +# CHECK-NEXT: 20 | S_GDATA32 [size = 32] `__imp___wc_mb_cur` +# CHECK-NEXT: type = 0x0070 (char), addr = 0000:0000 + +# CHECK: Symbols +# CHECK-NEXT: ============================================================ +# CHECK-NEXT: Mod 0000 | `{{.*}}pdb-import-gc.yaml.tmp.obj`: +# CHECK-NEXT: Mod 0001 | `* Linker *`: --- !COFF header: diff --git a/test/COFF/pdb-invalid-func-type.yaml b/test/COFF/pdb-invalid-func-type.yaml index 686079e7d8e4..219dd424c718 100644 --- a/test/COFF/pdb-invalid-func-type.yaml +++ b/test/COFF/pdb-invalid-func-type.yaml @@ -7,7 +7,7 @@ # RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck %s # CHECK: Mod 0000 | `{{.*}}pdb-invalid-func-type.yaml.tmp.obj`: -# CHECK: 4 | S_GPROC32_ID [size = 44] `main` +# CHECK: 4 | S_GPROC32 [size = 44] `main` # CHECK: parent = 0, end = 80, addr = 0001:0000, code size = 3 # CHECK: 48 | S_FRAMEPROC [size = 32] # CHECK: 80 | S_END [size = 4] diff --git a/test/COFF/pdb-lib.s b/test/COFF/pdb-lib.s index 74d987eac814..319d4bc0fb80 100644 --- a/test/COFF/pdb-lib.s +++ b/test/COFF/pdb-lib.s @@ -11,15 +11,15 @@ # CHECK: Modules # CHECK-NEXT: ============================================================ -# CHECK-NEXT: Mod 0000 | Name: `{{.*pdb-lib.s.tmp[/\\]foo.obj}}`: +# CHECK-NEXT: Mod 0000 | `{{.*pdb-lib.s.tmp[/\\]foo.obj}}`: # CHECK-NEXT: Obj: `{{.*pdb-lib.s.tmp[/\\]foo.obj}}`: # CHECK-NEXT: debug stream: 9, # files: 0, has ec info: false # CHECK-NEXT: pdb file ni: 0 ``, src file ni: 0 `` -# CHECK-NEXT: Mod 0001 | Name: `bar.obj`: +# CHECK-NEXT: Mod 0001 | `bar.obj`: # CHECK-NEXT: Obj: `{{.*pdb-lib.s.tmp[/\\]bar.lib}}`: # CHECK-NEXT: debug stream: 10, # files: 0, has ec info: false # CHECK-NEXT: pdb file ni: 0 ``, src file ni: 0 `` -# CHECK-NEXT: Mod 0002 | Name: `* Linker *`: +# CHECK-NEXT: Mod 0002 | `* Linker *`: # CHECK-NEXT: Obj: ``: # CHECK-NEXT: debug stream: 11, # files: 0, has ec info: false # CHECK-NEXT: pdb file ni: 1 `{{.*foo.pdb}}`, src file ni: 0 `` diff --git a/test/COFF/pdb-linker-module.test b/test/COFF/pdb-linker-module.test index ce366b6d6482..1bb57298f96e 100644 --- a/test/COFF/pdb-linker-module.test +++ b/test/COFF/pdb-linker-module.test @@ -1,18 +1,24 @@ RUN: lld-link /debug /pdb:%t.pdb /nodefaultlib /entry:main %S/Inputs/pdb-diff.obj -RUN: llvm-pdbutil dump -modules -symbols %t.pdb | FileCheck %s +RUN: llvm-pdbutil dump -modules %t.pdb | FileCheck --check-prefix=MODS %s +RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck --check-prefix=SYMS %s -CHECK: Mod 0001 | `* Linker *`: -CHECK-NEXT: 4 | S_OBJNAME [size = 20] sig=0, `* Linker *` -CHECK-NEXT: 24 | S_COMPILE3 [size = 40] -CHECK-NEXT: machine = intel 80386, Ver = LLVM Linker, language = link -CHECK-NEXT: frontend = 0.0.0.0, backend = 0.0.0.0 -CHECK-NEXT: flags = none -CHECK-NEXT: 64 | S_ENVBLOCK -CHECK-NEXT: - cwd -CHECK-NEXT: - -CHECK-NEXT: - exe -CHECK-NEXT: - {{.*}}lld-link -CHECK-NEXT: - pdb -CHECK-NEXT: - {{.*}}pdb-linker-module{{.*}}pdb -CHECK-NEXT: - cmd -CHECK-NEXT: - /debug /pdb:{{.*}}pdb-linker-module{{.*}}pdb /nodefaultlib /entry:main {{.*}}pdb-diff.obj +MODS: Mod 0001 | `* Linker *` +MODS-NEXT: Obj: ``: +MODS-NEXT: debug stream: 10, # files: 0, has ec info: false +MODS-NEXT: pdb file ni: 1 `{{.*}}pdb-linker-module.test.tmp.pdb`, src file ni: 0 `` + +SYMS: Mod 0001 | `* Linker *` +SYMS-NEXT: 4 | S_OBJNAME [size = 20] sig=0, `* Linker *` +SYMS-NEXT: 24 | S_COMPILE3 [size = 40] +SYMS-NEXT: machine = intel 80386, Ver = LLVM Linker, language = link +SYMS-NEXT: frontend = 0.0.0.0, backend = 14.10.25019.0 +SYMS-NEXT: flags = none +SYMS-NEXT: 64 | S_ENVBLOCK +SYMS-NEXT: - cwd +SYMS-NEXT: - +SYMS-NEXT: - exe +SYMS-NEXT: - {{.*}}lld-link +SYMS-NEXT: - pdb +SYMS-NEXT: - {{.*}}pdb-linker-module{{.*}}pdb +SYMS-NEXT: - cmd +SYMS-NEXT: - /debug /pdb:{{.*}}pdb-linker-module{{.*}}pdb /nodefaultlib /entry:main {{.*}}pdb-diff.obj diff --git a/test/COFF/pdb-none.test b/test/COFF/pdb-none.test index c1becbad7a3b..4f5ba0ebb4df 100644 --- a/test/COFF/pdb-none.test +++ b/test/COFF/pdb-none.test @@ -1,12 +1,13 @@ # RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1.obj # RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2.obj +# RUN: rm -f %t.pdb %t.dll # RUN: lld-link /debug /debugtype:pdata /pdb:%t.pdb /dll /out:%t.dll /entry:main /nodefaultlib \ # RUN: %t1.obj %t2.obj # RUN: llvm-pdbutil pdb2yaml -pdb-stream %t.pdb | FileCheck %s # CHECK: PdbStream: -# CHECK-NEXT: Age: 0 +# CHECK-NEXT: Age: 1 # CHECK-NEXT: Guid: # CHECK-NEXT: Signature: # CHECK-NEXT: Features: [ VC140 ] diff --git a/test/COFF/pdb-options.test b/test/COFF/pdb-options.test index 1468c4f1cc65..2bd1d920ee48 100644 --- a/test/COFF/pdb-options.test +++ b/test/COFF/pdb-options.test @@ -18,4 +18,4 @@ # RUN: lld-link /DEBUG /entry:main /nodefaultlib %t1.obj %t2.obj # RUN: ls %t1.pdb # RUN: rm %t* -# RUN: cd %T/..
+# RUN: cd %T/.. diff --git a/test/COFF/pdb-procid-remapping.test b/test/COFF/pdb-procid-remapping.test new file mode 100644 index 000000000000..cb612400a650 --- /dev/null +++ b/test/COFF/pdb-procid-remapping.test @@ -0,0 +1,29 @@ +# RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1.obj +# RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2.obj +# RUN: lld-link /debug /pdb:%t.pdb /dll /out:%t.dll /entry:main /nodefaultlib \ +# RUN: %t1.obj %t2.obj + +# RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck %s + +CHECK: Symbols +CHECK-NEXT: ============================================================ +CHECK-LABEL: Mod 0000 | +CHECK: 92 | S_GPROC32 [size = 44] `main` +CHECK-NEXT: parent = 0, end = 168, addr = 0002:0000, code size = 14 +CHECK-NEXT: type = `0x1004 (int (<no type>))`, debug start = 4, debug end = 9, flags = none +CHECK-NEXT: 136 | S_FRAMEPROC [size = 32] +CHECK-NEXT: size = 40, padding size = 0, offset to padding = 0 +CHECK-NEXT: bytes of callee saved registers = 0, exception handler addr = 0000:0000 +CHECK-NEXT: flags = has async eh | opt speed +CHECK-NEXT: 168 | S_END [size = 4] +CHECK-LABEL: Mod 0001 | +CHECK: 92 | S_GPROC32 [size = 44] `foo` +CHECK-NEXT: parent = 0, end = 168, addr = 0002:0016, code size = 6 +CHECK-NEXT: type = `0x1001 (int ())`, debug start = 0, debug end = 5, flags = none +CHECK-NEXT: 136 | S_FRAMEPROC [size = 32] +CHECK-NEXT: size = 0, padding size = 0, offset to padding = 0 +CHECK-NEXT: bytes of callee saved registers = 0, exception handler addr = 0000:0000 +CHECK-NEXT: flags = has async eh | opt speed +CHECK-NEXT: 168 | S_END [size = 4] +CHECK-LABEL: Mod 0002 | +CHECK: 4 | S_OBJNAME [size = 20] sig=0, `* Linker *` diff --git a/test/COFF/pdb-publics-import.test b/test/COFF/pdb-publics-import.test new file mode 100644 index 000000000000..1c75e905ed46 --- /dev/null +++ b/test/COFF/pdb-publics-import.test @@ -0,0 +1,42 @@ +Make a DLL that exports a few functions, then make a DLL with PDBs that imports +them. Check that the __imp_ pointer and the generated thunks appear in the +publics stream. + +RUN: yaml2obj < %p/Inputs/export.yaml > %t1.obj +RUN: lld-link /out:%t1.dll /dll %t1.obj /implib:%t1.lib \ +RUN: /export:exportfn1 /export:exportfn2 +RUN: yaml2obj < %p/Inputs/import.yaml > %t2.obj +RUN: lld-link /out:%t2.exe /pdb:%t2.pdb /debug /entry:main %t2.obj %t1.lib +RUN: llvm-pdbutil dump %t2.pdb -publics -section-contribs | FileCheck %s + +CHECK: Public Symbols +CHECK-NEXT: ============================================================ +CHECK-NEXT: Records +CHECK-NEXT: 112 | S_PUB32 [size = 20] `main` +CHECK-NEXT: flags = function, addr = 0001:0000 +CHECK-NEXT: 64 | S_PUB32 [size = 24] `exportfn1` +CHECK-NEXT: flags = function, addr = 0001:0016 +CHECK-NEXT: 88 | S_PUB32 [size = 24] `exportfn2` +CHECK-NEXT: flags = function, addr = 0001:0032 +CHECK-NEXT: 32 | S_PUB32 [size = 32] `__imp_exportfn2` +CHECK-NEXT: flags = none, addr = 0003:0072 +CHECK-NEXT: 0 | S_PUB32 [size = 32] `__imp_exportfn1` +CHECK-NEXT: flags = none, addr = 0003:0064 + +CHECK: Section Contributions +CHECK-NEXT: ============================================================ + main +CHECK-NEXT: SC[.text] | mod = 0, 0001:0000, size = 8, data crc = 0, reloc crc = 0 +CHECK-NEXT: IMAGE_SCN_CNT_CODE | IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_MEM_EXECUTE | +CHECK-NEXT: IMAGE_SCN_MEM_READ + exportfn1 thunk +CHECK-NEXT: SC[.text] | mod = 1, 0001:0016, size = 6, data crc = 0, reloc crc = 0 +CHECK-NEXT: IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ + exportfn2 thunk +CHECK-NEXT: SC[.text] | mod = 1, 0001:0032, size = 6, data crc = 0, reloc crc = 0 +CHECK-NEXT: IMAGE_SCN_CNT_CODE | IMAGE_SCN_MEM_EXECUTE | IMAGE_SCN_MEM_READ + .rdata debug directory data chunks +CHECK-NEXT: SC[.rdata] | mod = 1, 0002:0000, size = 28, data crc = 0, reloc crc = 0 +CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ +CHECK-NEXT: SC[.rdata] | mod = 1, 0002:0028, size = {{.*}}, data crc = 0, reloc crc = 0 +CHECK-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ diff --git a/test/COFF/pdb-safeseh.yaml b/test/COFF/pdb-safeseh.yaml index 24215bd11dbe..27948e38d3d3 100644 --- a/test/COFF/pdb-safeseh.yaml +++ b/test/COFF/pdb-safeseh.yaml @@ -1,16 +1,17 @@ # RUN: yaml2obj %s -o %t.obj # RUN: lld-link -debug -entry:main -out:%t.exe -pdb:%t.pdb %t.obj -# RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck %s +# RUN: llvm-pdbutil dump -globals %t.pdb | FileCheck %s # There is an S_GDATA32 symbol record with .secrel32 and .secidx relocations in # it in this debug info. This is similar to the relocations in the loadcfg.obj # file in the MSVC CRT. We need to make sure that our relocation logic matches # MSVC's for these absolute, linker-provided symbols. -# CHECK: Mod 0000 | -# CHECK-NEXT: 4 | S_GDATA32 [size = 40] `___safe_se_handler_table` -# CHECK-NEXT: type = 0x0022 (unsigned long), addr = 0003:0000 -# CHECK-NEXT: Mod 0001 | `* Linker *`: +# CHECK: Global Symbols +# CHECK-NEXT: ============================================================ +# CHECK-NEXT: Records +# CHECK-NEXT: 20 | S_GDATA32 [size = 40] `___safe_se_handler_table` +# CHECK-NEXT: type = 0x0022 (unsigned long), addr = 0003:0000 --- !COFF header: diff --git a/test/COFF/pdb-same-name.test b/test/COFF/pdb-same-name.test new file mode 100644 index 000000000000..76db69fabbd6 --- /dev/null +++ b/test/COFF/pdb-same-name.test @@ -0,0 +1,23 @@ +# RUN: rm -rf %t1 %t2 +# RUN: mkdir %t1 %t2 +# RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1/foo.obj +# RUN: llvm-ar cru %t1/foo.lib %t1/foo.obj +# RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2/foo.obj +# RUN: llvm-ar cru %t2/foo.lib %t2/foo.obj + +# RUN: rm -f %t.dll %t.pdb +# RUN: lld-link /debug /pdb:%t.pdb /dll /out:%t.dll /entry:main /nodefaultlib \ +# RUN: %t1/foo.lib %t2/foo.lib + +# RUN: llvm-pdbutil dump -modules %t.pdb | FileCheck -check-prefix RAW %s + +RAW: Modules +RAW-NEXT: ============================================================ +RAW-NEXT: Mod 0000 | `foo.obj`: +RAW-NEXT: Obj: `{{.*}}1\foo.lib`: +RAW-NEXT: debug stream: 9, # files: 1, has ec info: false +RAW-NEXT: pdb file ni: 0 ``, src file ni: 0 `` +RAW-NEXT: Mod 0001 | `foo.obj`: +RAW-NEXT: Obj: `{{.*}}2\foo.lib`: +RAW-NEXT: debug stream: 10, # files: 1, has ec info: false +RAW-NEXT: pdb file ni: 0 ``, src file ni: 0 `` diff --git a/test/COFF/pdb-scopes.test b/test/COFF/pdb-scopes.test index 7beb59766cc5..2649167e900f 100644 --- a/test/COFF/pdb-scopes.test +++ b/test/COFF/pdb-scopes.test @@ -34,12 +34,12 @@ RUN: lld-link %t-a.obj %t-b.obj -debug -entry:main -nodefaultlib -out:%t.exe -pd RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck %s CHECK-LABEL: Mod 0000 | `{{.*}}pdb-scopes.test.tmp-a.obj`: -CHECK: 104 | S_GPROC32_ID [size = 44] `g` +CHECK: 104 | S_GPROC32 [size = 44] `g` CHECK: parent = 0, end = 196, addr = 0002:0000, code size = 5 CHECK: debug start = 4, debug end = 4, flags = none CHECK: 180 | S_REGREL32 [size = 16] `x` CHECK: 196 | S_END [size = 4] -CHECK: 200 | S_GPROC32_ID [size = 44] `main` +CHECK: 200 | S_GPROC32 [size = 44] `main` CHECK: parent = 0, end = 384, addr = 0002:0016, code size = 58 CHECK: debug start = 8, debug end = 53, flags = none CHECK: 276 | S_REGREL32 [size = 20] `argc` @@ -56,7 +56,7 @@ CHECK: 380 | S_END [size = 4] CHECK: 384 | S_END [size = 4] CHECK-LABEL: Mod 0001 | `{{.*}}pdb-scopes.test.tmp-b.obj`: -CHECK: 104 | S_GPROC32_ID [size = 44] `f` +CHECK: 104 | S_GPROC32 [size = 44] `f` CHECK: parent = 0, end = 284, addr = 0002:0080, code size = 62 CHECK: debug start = 8, debug end = 57, flags = none CHECK: 180 | S_REGREL32 [size = 16] `x` diff --git a/test/COFF/pdb-secrel-absolute.yaml b/test/COFF/pdb-secrel-absolute.yaml index c514e54e99f1..330106b3bbed 100644 --- a/test/COFF/pdb-secrel-absolute.yaml +++ b/test/COFF/pdb-secrel-absolute.yaml @@ -1,16 +1,17 @@ # RUN: yaml2obj %s -o %t.obj # RUN: lld-link -debug -entry:main -out:%t.exe -pdb:%t.pdb %t.obj -# RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck %s +# RUN: llvm-pdbutil dump -globals %t.pdb | FileCheck %s # There is an S_GDATA32 symbol record with .secrel32 and .secidx relocations in # it in this debug info. This is similar to the relocations in the loadcfg.obj # file in the MSVC CRT. We need to make sure that our relocation logic matches # MSVC's for these absolute, linker-provided symbols. -# CHECK: Mod 0000 | -# CHECK-NEXT: 4 | S_GDATA32 [size = 36] `__guard_fids_table` -# CHECK-NEXT: type = 0x0022 (unsigned long), addr = 0003:0000 -# CHECK-NEXT: Mod 0001 | `* Linker *`: +# CHECK: Global Symbols +# CHECK-NEXT: ============================================================ +# CHECK-NEXT: Records +# CHECK-NEXT: 20 | S_GDATA32 [size = 36] `__guard_fids_table` +# CHECK-NEXT: type = 0x0022 (unsigned long), addr = 0003:0000 --- !COFF header: diff --git a/test/COFF/pdb-source-lines.test b/test/COFF/pdb-source-lines.test index f9e0e5c7487f..389d91f20efb 100644 --- a/test/COFF/pdb-source-lines.test +++ b/test/COFF/pdb-source-lines.test @@ -19,10 +19,11 @@ $ cl -c -Z7 pdb_lines*.c RUN: yaml2obj %S/Inputs/pdb_lines_1.yaml -o %t.pdb_lines_1.obj RUN: yaml2obj %S/Inputs/pdb_lines_2.yaml -o %t.pdb_lines_2.obj +RUN: rm -f %t.exe %t.pdb RUN: lld-link -debug -entry:main -nodefaultlib -out:%t.exe -pdb:%t.pdb %t.pdb_lines_1.obj %t.pdb_lines_2.obj RUN: llvm-pdbutil pdb2yaml -modules -module-files -subsections=lines,fc %t.pdb | FileCheck %s -CHECK-LABEL: DbiStream: +CHECK-LABEL: DbiStream: CHECK-NEXT: VerHeader: V70 CHECK-NEXT: Age: 1 CHECK-NEXT: BuildNumber: 0 @@ -30,22 +31,22 @@ CHECK-NEXT: PdbDllVersion: 0 CHECK-NEXT: PdbDllRbld: 0 CHECK-NEXT: Flags: 0 CHECK-NEXT: MachineType: x86 -CHECK-NEXT: Modules: +CHECK-NEXT: Modules: CHECK-LABEL: - Module: {{.*}}pdb_lines_1.obj CHECK-NEXT: ObjFile: {{.*}}pdb_lines_1.obj -CHECK-NEXT: SourceFiles: +CHECK-NEXT: SourceFiles: CHECK-NEXT: - '{{.*}}pdb_lines_1.c' CHECK-NEXT: - '{{.*}}foo.h' -CHECK-NEXT: Subsections: +CHECK-NEXT: Subsections: CHECK-NEXT: - !Lines CHECK-NEXT: CodeSize: 19 CHECK-NEXT: Flags: [ ] CHECK-NEXT: RelocOffset: 0 CHECK-NEXT: RelocSegment: 2 -CHECK-NEXT: Blocks: +CHECK-NEXT: Blocks: CHECK-NEXT: - FileName: '{{.*}}pdb_lines_1.c' -CHECK-NEXT: Lines: +CHECK-NEXT: Lines: CHECK-NEXT: - Offset: 0 CHECK-NEXT: LineStart: 2 CHECK-NEXT: IsStatement: true @@ -62,9 +63,9 @@ CHECK-NEXT: - Offset: 14 CHECK-NEXT: LineStart: 5 CHECK-NEXT: IsStatement: true CHECK-NEXT: EndDelta: 0 -CHECK-NEXT: Columns: +CHECK-NEXT: Columns: CHECK-NEXT: - !FileChecksums -CHECK-NEXT: Checksums: +CHECK-NEXT: Checksums: CHECK-NEXT: - FileName: '{{.*}}pdb_lines_1.c' CHECK-NEXT: Kind: MD5 CHECK-NEXT: Checksum: 4EB19DCD86C3BA2238A255C718572E7B @@ -76,9 +77,9 @@ CHECK-NEXT: CodeSize: 14 CHECK-NEXT: Flags: [ ] CHECK-NEXT: RelocOffset: 32 CHECK-NEXT: RelocSegment: 2 -CHECK-NEXT: Blocks: +CHECK-NEXT: Blocks: CHECK-NEXT: - FileName: '{{.*}}foo.h' -CHECK-NEXT: Lines: +CHECK-NEXT: Lines: CHECK-NEXT: - Offset: 0 CHECK-NEXT: LineStart: 2 CHECK-NEXT: IsStatement: true @@ -91,21 +92,21 @@ CHECK-NEXT: - Offset: 9 CHECK-NEXT: LineStart: 4 CHECK-NEXT: IsStatement: true CHECK-NEXT: EndDelta: 0 -CHECK-NEXT: Columns: +CHECK-NEXT: Columns: CHECK-LABEL: - Module: {{.*}}pdb_lines_2.obj CHECK-NEXT: ObjFile: {{.*}}pdb_lines_2.obj -CHECK-NEXT: SourceFiles: +CHECK-NEXT: SourceFiles: CHECK-NEXT: - '{{.*}}pdb_lines_2.c' -CHECK-NEXT: Subsections: +CHECK-NEXT: Subsections: CHECK-NEXT: - !Lines CHECK-NEXT: CodeSize: 1 CHECK-NEXT: Flags: [ ] CHECK-NEXT: RelocOffset: 48 CHECK-NEXT: RelocSegment: 2 -CHECK-NEXT: Blocks: +CHECK-NEXT: Blocks: CHECK-NEXT: - FileName: '{{.*}}pdb_lines_2.c' -CHECK-NEXT: Lines: +CHECK-NEXT: Lines: CHECK-NEXT: - Offset: 0 CHECK-NEXT: LineStart: 1 CHECK-NEXT: IsStatement: true @@ -114,9 +115,9 @@ CHECK-NEXT: - Offset: 0 CHECK-NEXT: LineStart: 2 CHECK-NEXT: IsStatement: true CHECK-NEXT: EndDelta: 0 -CHECK-NEXT: Columns: +CHECK-NEXT: Columns: CHECK-NEXT: - !FileChecksums -CHECK-NEXT: Checksums: +CHECK-NEXT: Checksums: CHECK-NEXT: - FileName: '{{.*}}pdb_lines_2.c' CHECK-NEXT: Kind: MD5 CHECK-NEXT: Checksum: DF91CB3A2B8D917486574BB50CAC4CC7 diff --git a/test/COFF/pdb-symbol-types.yaml b/test/COFF/pdb-symbol-types.yaml index 2ad6f5b07bf4..9dad72d3cc2f 100644 --- a/test/COFF/pdb-symbol-types.yaml +++ b/test/COFF/pdb-symbol-types.yaml @@ -1,6 +1,6 @@ # RUN: yaml2obj %s -o %t.obj # RUN: lld-link %t.obj -nodefaultlib -entry:main -debug -out:%t.exe -pdb:%t.pdb -# RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck %s +# RUN: llvm-pdbutil dump -symbols -globals %t.pdb | FileCheck %s # To regenerate the object file: # $ cat symbol-types.c @@ -13,6 +13,14 @@ # Note that the type of 'global' goes from 0x1005 in the object file to 0x1004 # in the PDB because the LF_FUNC_ID is moved to the id stream. +# CHECK-LABEL: Global Symbols +# CHECK-NEXT: ============================================================ +# CHECK-NEXT: Records +# CHECK-NEXT: 48 | S_PROCREF [size = 20] `main` +# CHECK-NEXT: module = 1, sum name = 0, offset = 116 +# CHECK-NEXT: 68 | S_GDATA32 [size = 28] `global_foo` +# CHECK-NEXT: type = 0x1004 (Foo), addr = 0001:0000 + # CHECK: Symbols # CHECK: ============================================================ # CHECK-LABEL: Mod 0000 | `{{.*}}pdb-symbol-types.yaml.tmp.obj`: @@ -21,7 +29,7 @@ # CHECK: machine = intel x86-x64, Ver = Microsoft (R) Optimizing Compiler, language = c # CHECK: frontend = 19.0.24215.1, backend = 19.0.24215.1 # CHECK: flags = security checks | hot patchable -# CHECK: 116 | S_GPROC32_ID [size = 44] `main` +# CHECK: 116 | S_GPROC32 [size = 44] `main` # CHECK: parent = 0, end = 192, addr = 0002:0000, code size = 7 # CHECK: debug start = 0, debug end = 6, flags = none # CHECK: 160 | S_FRAMEPROC [size = 32] @@ -29,13 +37,7 @@ # CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000 # CHECK: flags = has async eh | opt speed # CHECK: 192 | S_END [size = 4] -# CHECK: 196 | S_GDATA32 [size = 28] `global_foo` -# CHECK: type = 0x1004 (Foo), addr = 0001:0000 -# CHECK: 224 | S_UDT [size = 16] `UDT_Foo` -# CHECK: original type = 0x1004 -# CHECK: 240 | S_UDT [size = 12] `Foo` -# CHECK: original type = 0x1004 -# CHECK: 252 | S_BUILDINFO [size = 8] BuildId = `0x100A` +# CHECK: 196 | S_BUILDINFO [size = 8] BuildId = `0x100A` # CHECK-LABEL: Mod 0001 | `* Linker *`: --- !COFF diff --git a/test/COFF/pdb-thunk.yaml b/test/COFF/pdb-thunk.yaml new file mode 100644 index 000000000000..6435a17e8f62 --- /dev/null +++ b/test/COFF/pdb-thunk.yaml @@ -0,0 +1,2747 @@ +# RUN: yaml2obj %s -o %t.obj +# RUN: lld-link %t.obj -dll -debug -noentry -nodefaultlib -debug -out:%t.exe -pdb:%t.pdb +# RUN: llvm-pdbutil dump -symbols %t.pdb | FileCheck %s + +# We used to skip vtable thunk symbol records, leading to symbol scope stack +# imbalances (PR35014). Test that they survive the object file into the PDB. + +# This object generated from this C++ source: +# // t.cpp +# struct A { +# virtual int f(); +# }; +# struct B { +# virtual int f(); +# }; +# struct C : A, B { +# __declspec(dllexport) C(); +# int f() override; +# int c; +# }; +# int A::f() { return 0; } +# int B::f() { return 0; } +# int C::f() { return c; } +# C::C() : c(42) {} + +# Compile as: +# $ cl -GR- -Z7 -c t.cpp + +# CHECK: S_THUNK32 +# CHECK: S_END + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_AMD64 + Characteristics: [ ] +sections: + - Name: .drectve + Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: 2020202F44454641554C544C49423A224C4942434D5422202F44454641554C544C49423A224F4C444E414D455322202F4558504F52543A3F3F304340405145414140585A20 + - Name: '.debug$S' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 1 + Subsections: + - !Symbols + Records: + - Kind: S_OBJNAME + ObjNameSym: + Signature: 0 + ObjectName: 'C:\src\llvm-project\build\t.obj' + - Kind: S_COMPILE3 + Compile3Sym: + Flags: [ SecurityChecks, HotPatch ] + Machine: X64 + FrontendMajor: 19 + FrontendMinor: 11 + FrontendBuild: 25508 + FrontendQFE: 2 + BackendMajor: 19 + BackendMinor: 11 + BackendBuild: 25508 + BackendQFE: 2 + Version: 'Microsoft (R) Optimizing Compiler' + - !Symbols + Records: + - Kind: S_GPROC32_ID + ProcSym: + CodeSize: 8 + DbgStart: 5 + DbgEnd: 7 + FunctionType: 4172 + Flags: [ ] + DisplayName: 'A::f' + - Kind: S_FRAMEPROC + FrameProcSym: + TotalFrameBytes: 0 + PaddingFrameBytes: 0 + OffsetToPadding: 0 + BytesOfCalleeSavedRegisters: 0 + OffsetOfExceptionHandler: 0 + SectionIdOfExceptionHandler: 0 + Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ] + - Kind: S_REGREL32 + RegRelativeSym: + Offset: 8 + Type: 4097 + Register: RSP + VarName: this + - Kind: S_PROC_ID_END + ScopeEndSym: + - !Lines + CodeSize: 8 + Flags: [ ] + RelocOffset: 0 + RelocSegment: 0 + Blocks: + - FileName: 'c:\src\llvm-project\build\t.cpp' + Lines: + - Offset: 0 + LineStart: 12 + IsStatement: true + EndDelta: 0 + Columns: + - !Symbols + Records: + - Kind: S_GPROC32_ID + ProcSym: + CodeSize: 8 + DbgStart: 5 + DbgEnd: 7 + FunctionType: 4173 + Flags: [ ] + DisplayName: 'B::f' + - Kind: S_FRAMEPROC + FrameProcSym: + TotalFrameBytes: 0 + PaddingFrameBytes: 0 + OffsetToPadding: 0 + BytesOfCalleeSavedRegisters: 0 + OffsetOfExceptionHandler: 0 + SectionIdOfExceptionHandler: 0 + Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ] + - Kind: S_REGREL32 + RegRelativeSym: + Offset: 8 + Type: 4121 + Register: RSP + VarName: this + - Kind: S_PROC_ID_END + ScopeEndSym: + - !Lines + CodeSize: 8 + Flags: [ ] + RelocOffset: 0 + RelocSegment: 0 + Blocks: + - FileName: 'c:\src\llvm-project\build\t.cpp' + Lines: + - Offset: 0 + LineStart: 13 + IsStatement: true + EndDelta: 0 + Columns: + - !Symbols + Records: + - Kind: S_GPROC32_ID + ProcSym: + CodeSize: 89 + DbgStart: 9 + DbgEnd: 84 + FunctionType: 4175 + Flags: [ ] + DisplayName: 'C::C' + - Kind: S_FRAMEPROC + FrameProcSym: + TotalFrameBytes: 40 + PaddingFrameBytes: 0 + OffsetToPadding: 0 + BytesOfCalleeSavedRegisters: 0 + OffsetOfExceptionHandler: 0 + SectionIdOfExceptionHandler: 0 + Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ] + - Kind: S_REGREL32 + RegRelativeSym: + Offset: 48 + Type: 4143 + Register: RSP + VarName: this + - Kind: S_PROC_ID_END + ScopeEndSym: + - !Lines + CodeSize: 89 + Flags: [ ] + RelocOffset: 0 + RelocSegment: 0 + Blocks: + - FileName: 'c:\src\llvm-project\build\t.cpp' + Lines: + - Offset: 0 + LineStart: 15 + IsStatement: true + EndDelta: 0 + - Offset: 67 + LineStart: 15 + IsStatement: true + EndDelta: 0 + Columns: + - !Symbols + Records: + - Kind: S_GPROC32_ID + ProcSym: + CodeSize: 14 + DbgStart: 5 + DbgEnd: 13 + FunctionType: 4174 + Flags: [ ] + DisplayName: 'C::f' + - Kind: S_FRAMEPROC + FrameProcSym: + TotalFrameBytes: 0 + PaddingFrameBytes: 0 + OffsetToPadding: 0 + BytesOfCalleeSavedRegisters: 0 + OffsetOfExceptionHandler: 0 + SectionIdOfExceptionHandler: 0 + Flags: [ AsynchronousExceptionHandling, OptimizedForSpeed ] + - Kind: S_REGREL32 + RegRelativeSym: + Offset: 8 + Type: 4143 + Register: RSP + VarName: this + - Kind: S_PROC_ID_END + ScopeEndSym: + - !Lines + CodeSize: 14 + Flags: [ ] + RelocOffset: 0 + RelocSegment: 0 + Blocks: + - FileName: 'c:\src\llvm-project\build\t.cpp' + Lines: + - Offset: 0 + LineStart: 14 + IsStatement: true + EndDelta: 0 + Columns: + - !Symbols + Records: + - Kind: S_UDT + UDTSym: + Type: 4117 + UDTName: A + - Kind: S_UDT + UDTSym: + Type: 4268 + UDTName: '__vc_attributes::event_sourceAttribute' + - Kind: S_UDT + UDTSym: + Type: 4260 + UDTName: '__vc_attributes::event_sourceAttribute::optimize_e' + - Kind: S_UDT + UDTSym: + Type: 4257 + UDTName: '__vc_attributes::event_sourceAttribute::type_e' + - Kind: S_UDT + UDTSym: + Type: 4253 + UDTName: '__vc_attributes::helper_attributes::v1_alttypeAttribute' + - Kind: S_UDT + UDTSym: + Type: 4247 + UDTName: '__vc_attributes::helper_attributes::v1_alttypeAttribute::type_e' + - Kind: S_UDT + UDTSym: + Type: 4243 + UDTName: '__vc_attributes::helper_attributes::usageAttribute' + - Kind: S_UDT + UDTSym: + Type: 4237 + UDTName: '__vc_attributes::helper_attributes::usageAttribute::usage_e' + - Kind: S_UDT + UDTSym: + Type: 4233 + UDTName: '__vc_attributes::threadingAttribute' + - Kind: S_UDT + UDTSym: + Type: 4225 + UDTName: '__vc_attributes::threadingAttribute::threading_e' + - Kind: S_UDT + UDTSym: + Type: 4221 + UDTName: '__vc_attributes::aggregatableAttribute' + - Kind: S_UDT + UDTSym: + Type: 4213 + UDTName: '__vc_attributes::aggregatableAttribute::type_e' + - Kind: S_UDT + UDTSym: + Type: 4209 + UDTName: '__vc_attributes::event_receiverAttribute' + - Kind: S_UDT + UDTSym: + Type: 4199 + UDTName: '__vc_attributes::event_receiverAttribute::type_e' + - Kind: S_UDT + UDTSym: + Type: 4195 + UDTName: '__vc_attributes::moduleAttribute' + - Kind: S_UDT + UDTSym: + Type: 4182 + UDTName: '__vc_attributes::moduleAttribute::type_e' + - Kind: S_UDT + UDTSym: + Type: 4160 + UDTName: C + - Kind: S_UDT + UDTSym: + Type: 4140 + UDTName: B + - !FileChecksums + Checksums: + - FileName: 'c:\src\llvm-project\build\t.cpp' + Kind: MD5 + Checksum: 1E487A6B7D4DB0A502F8E5945CCB70D1 + - !StringTable + Strings: + - 'c:\src\llvm-project\build\t.cpp' + - !Symbols + Records: + - Kind: S_BUILDINFO + BuildInfoSym: + BuildId: 4281 + Relocations: + - VirtualAddress: 152 + SymbolName: '?f@A@@UEAAHXZ' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 156 + SymbolName: '?f@A@@UEAAHXZ' + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 228 + SymbolName: '?f@A@@UEAAHXZ' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 232 + SymbolName: '?f@A@@UEAAHXZ' + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 300 + SymbolName: '?f@B@@UEAAHXZ' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 304 + SymbolName: '?f@B@@UEAAHXZ' + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 376 + SymbolName: '?f@B@@UEAAHXZ' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 380 + SymbolName: '?f@B@@UEAAHXZ' + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 448 + SymbolName: '??0C@@QEAA@XZ' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 452 + SymbolName: '??0C@@QEAA@XZ' + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 524 + SymbolName: '??0C@@QEAA@XZ' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 528 + SymbolName: '??0C@@QEAA@XZ' + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 604 + SymbolName: '?f@C@@UEAAHXZ' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 608 + SymbolName: '?f@C@@UEAAHXZ' + Type: IMAGE_REL_AMD64_SECTION + - VirtualAddress: 680 + SymbolName: '?f@C@@UEAAHXZ' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 684 + SymbolName: '?f@C@@UEAAHXZ' + Type: IMAGE_REL_AMD64_SECTION + - Name: '.debug$T' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 1 + Types: + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: A + UniqueName: '.?AUA@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_POINTER + Pointer: + ReferentType: 4096 + Attrs: 66572 + - Kind: LF_VTSHAPE + VFTableShape: + Slots: + - Near16 + - Kind: LF_POINTER + Pointer: + ReferentType: 4098 + Attrs: 65548 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ ] + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 116 + ClassType: 4096 + ThisType: 4097 + CallConv: NearC + Options: [ None ] + ParameterCount: 0 + ArgumentList: 4100 + ThisPointerAdjustment: 0 + - Kind: LF_POINTER + Pointer: + ReferentType: 4096 + Attrs: 65676 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4102 ] + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4096 + ThisType: 4097 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 1 + ArgumentList: 4103 + ThisPointerAdjustment: 0 + - Kind: LF_MODIFIER + Modifier: + ModifiedType: 4096 + Modifiers: [ None, Const ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4105 + Attrs: 65580 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4106 ] + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4096 + ThisType: 4097 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 1 + ArgumentList: 4107 + ThisPointerAdjustment: 0 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4096 + ThisType: 4097 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 0 + ArgumentList: 4100 + ThisPointerAdjustment: 0 + - Kind: LF_METHODLIST + MethodOverloadList: + Methods: + - Type: 4104 + Attrs: 259 + VFTableOffset: -1 + Name: '' + - Type: 4108 + Attrs: 259 + VFTableOffset: -1 + Name: '' + - Type: 4109 + Attrs: 259 + VFTableOffset: -1 + Name: '' + - Kind: LF_POINTER + Pointer: + ReferentType: 4096 + Attrs: 65580 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 4111 + ClassType: 4096 + ThisType: 4097 + CallConv: NearC + Options: [ None ] + ParameterCount: 1 + ArgumentList: 4103 + ThisPointerAdjustment: 0 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 4111 + ClassType: 4096 + ThisType: 4097 + CallConv: NearC + Options: [ None ] + ParameterCount: 1 + ArgumentList: 4107 + ThisPointerAdjustment: 0 + - Kind: LF_METHODLIST + MethodOverloadList: + Methods: + - Type: 4112 + Attrs: 259 + VFTableOffset: -1 + Name: '' + - Type: 4113 + Attrs: 259 + VFTableOffset: -1 + Name: '' + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_VFUNCTAB + VFPtr: + Type: 4099 + - Kind: LF_ONEMETHOD + OneMethod: + Type: 4101 + Attrs: 19 + VFTableOffset: 0 + Name: f + - Kind: LF_METHOD + OverloadedMethod: + NumOverloads: 3 + MethodList: 4110 + Name: A + - Kind: LF_METHOD + OverloadedMethod: + NumOverloads: 2 + MethodList: 4114 + Name: 'operator=' + - Kind: LF_VTSHAPE + VFTableShape: + Slots: + - Near16 + - Kind: LF_STRUCTURE + Class: + MemberCount: 7 + Options: [ None, HasConstructorOrDestructor, HasOverloadedOperator, HasOverloadedAssignmentOperator, HasUniqueName ] + FieldList: 4115 + Name: A + UniqueName: '.?AUA@@' + DerivationList: 0 + VTableShape: 4116 + Size: 8 + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: 'c:\src\llvm-project\build\t.cpp' + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4117 + SourceFile: 4118 + LineNumber: 1 + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: B + UniqueName: '.?AUB@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_POINTER + Pointer: + ReferentType: 4120 + Attrs: 66572 + - Kind: LF_VTSHAPE + VFTableShape: + Slots: + - Near16 + - Kind: LF_POINTER + Pointer: + ReferentType: 4122 + Attrs: 65548 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 116 + ClassType: 4120 + ThisType: 4121 + CallConv: NearC + Options: [ None ] + ParameterCount: 0 + ArgumentList: 4100 + ThisPointerAdjustment: 0 + - Kind: LF_POINTER + Pointer: + ReferentType: 4120 + Attrs: 65676 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4125 ] + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4120 + ThisType: 4121 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 1 + ArgumentList: 4126 + ThisPointerAdjustment: 0 + - Kind: LF_MODIFIER + Modifier: + ModifiedType: 4120 + Modifiers: [ None, Const ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4128 + Attrs: 65580 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4129 ] + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4120 + ThisType: 4121 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 1 + ArgumentList: 4130 + ThisPointerAdjustment: 0 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4120 + ThisType: 4121 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 0 + ArgumentList: 4100 + ThisPointerAdjustment: 0 + - Kind: LF_METHODLIST + MethodOverloadList: + Methods: + - Type: 4127 + Attrs: 259 + VFTableOffset: -1 + Name: '' + - Type: 4131 + Attrs: 259 + VFTableOffset: -1 + Name: '' + - Type: 4132 + Attrs: 259 + VFTableOffset: -1 + Name: '' + - Kind: LF_POINTER + Pointer: + ReferentType: 4120 + Attrs: 65580 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 4134 + ClassType: 4120 + ThisType: 4121 + CallConv: NearC + Options: [ None ] + ParameterCount: 1 + ArgumentList: 4126 + ThisPointerAdjustment: 0 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 4134 + ClassType: 4120 + ThisType: 4121 + CallConv: NearC + Options: [ None ] + ParameterCount: 1 + ArgumentList: 4130 + ThisPointerAdjustment: 0 + - Kind: LF_METHODLIST + MethodOverloadList: + Methods: + - Type: 4135 + Attrs: 259 + VFTableOffset: -1 + Name: '' + - Type: 4136 + Attrs: 259 + VFTableOffset: -1 + Name: '' + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_VFUNCTAB + VFPtr: + Type: 4123 + - Kind: LF_ONEMETHOD + OneMethod: + Type: 4124 + Attrs: 19 + VFTableOffset: 0 + Name: f + - Kind: LF_METHOD + OverloadedMethod: + NumOverloads: 3 + MethodList: 4133 + Name: B + - Kind: LF_METHOD + OverloadedMethod: + NumOverloads: 2 + MethodList: 4137 + Name: 'operator=' + - Kind: LF_VTSHAPE + VFTableShape: + Slots: + - Near16 + - Kind: LF_STRUCTURE + Class: + MemberCount: 7 + Options: [ None, HasConstructorOrDestructor, HasOverloadedOperator, HasOverloadedAssignmentOperator, HasUniqueName ] + FieldList: 4138 + Name: B + UniqueName: '.?AUB@@' + DerivationList: 0 + VTableShape: 4139 + Size: 8 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4140 + SourceFile: 4118 + LineNumber: 4 + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: C + UniqueName: '.?AUC@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_POINTER + Pointer: + ReferentType: 4142 + Attrs: 66572 + - Kind: LF_POINTER + Pointer: + ReferentType: 4142 + Attrs: 65676 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4144 ] + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4142 + ThisType: 4143 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 1 + ArgumentList: 4145 + ThisPointerAdjustment: 0 + - Kind: LF_MODIFIER + Modifier: + ModifiedType: 4142 + Modifiers: [ None, Const ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4147 + Attrs: 65580 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4148 ] + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4142 + ThisType: 4143 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 1 + ArgumentList: 4149 + ThisPointerAdjustment: 0 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4142 + ThisType: 4143 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 0 + ArgumentList: 4100 + ThisPointerAdjustment: 0 + - Kind: LF_METHODLIST + MethodOverloadList: + Methods: + - Type: 4146 + Attrs: 259 + VFTableOffset: -1 + Name: '' + - Type: 4150 + Attrs: 259 + VFTableOffset: -1 + Name: '' + - Type: 4151 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 116 + ClassType: 4142 + ThisType: 4143 + CallConv: NearC + Options: [ None ] + ParameterCount: 0 + ArgumentList: 4100 + ThisPointerAdjustment: 0 + - Kind: LF_POINTER + Pointer: + ReferentType: 4142 + Attrs: 65580 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 4154 + ClassType: 4142 + ThisType: 4143 + CallConv: NearC + Options: [ None ] + ParameterCount: 1 + ArgumentList: 4145 + ThisPointerAdjustment: 0 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 4154 + ClassType: 4142 + ThisType: 4143 + CallConv: NearC + Options: [ None ] + ParameterCount: 1 + ArgumentList: 4149 + ThisPointerAdjustment: 0 + - Kind: LF_METHODLIST + MethodOverloadList: + Methods: + - Type: 4155 + Attrs: 259 + VFTableOffset: -1 + Name: '' + - Type: 4156 + Attrs: 259 + VFTableOffset: -1 + Name: '' + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_BCLASS + BaseClass: + Attrs: 3 + Type: 4096 + Offset: 0 + - Kind: LF_BCLASS + BaseClass: + Attrs: 3 + Type: 4120 + Offset: 8 + - Kind: LF_METHOD + OverloadedMethod: + NumOverloads: 3 + MethodList: 4152 + Name: C + - Kind: LF_ONEMETHOD + OneMethod: + Type: 4153 + Attrs: 7 + VFTableOffset: -1 + Name: f + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 116 + FieldOffset: 16 + Name: c + - Kind: LF_METHOD + OverloadedMethod: + NumOverloads: 2 + MethodList: 4157 + Name: 'operator=' + - Kind: LF_VTSHAPE + VFTableShape: + Slots: + - Near16 + - Kind: LF_STRUCTURE + Class: + MemberCount: 9 + Options: [ None, HasConstructorOrDestructor, HasOverloadedOperator, HasOverloadedAssignmentOperator, HasUniqueName ] + FieldList: 4158 + Name: C + UniqueName: '.?AUC@@' + DerivationList: 0 + VTableShape: 4159 + Size: 24 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4160 + SourceFile: 4118 + LineNumber: 7 + - Kind: LF_POINTER + Pointer: + ReferentType: 4142 + Attrs: 65548 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4142 + ThisType: 4143 + CallConv: NearC + Options: [ None ] + ParameterCount: 0 + ArgumentList: 4100 + ThisPointerAdjustment: 0 + - Kind: LF_POINTER + Pointer: + ReferentType: 4096 + Attrs: 65548 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4096 + ThisType: 4097 + CallConv: NearC + Options: [ None ] + ParameterCount: 0 + ArgumentList: 4100 + ThisPointerAdjustment: 0 + - Kind: LF_POINTER + Pointer: + ReferentType: 4120 + Attrs: 65548 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4120 + ThisType: 4121 + CallConv: NearC + Options: [ None ] + ParameterCount: 0 + ArgumentList: 4100 + ThisPointerAdjustment: 0 + - Kind: LF_PROCEDURE + Procedure: + ReturnType: 3 + CallConv: NearC + Options: [ None ] + ParameterCount: 0 + ArgumentList: 4100 + - Kind: LF_POINTER + Pointer: + ReferentType: 4168 + Attrs: 66572 + - Kind: LF_POINTER + Pointer: + ReferentType: 4169 + Attrs: 65548 + - Kind: LF_POINTER + Pointer: + ReferentType: 4170 + Attrs: 65548 + - Kind: LF_MFUNC_ID + MemberFuncId: + ClassType: 4096 + FunctionType: 4101 + Name: f + - Kind: LF_MFUNC_ID + MemberFuncId: + ClassType: 4120 + FunctionType: 4124 + Name: f + - Kind: LF_MFUNC_ID + MemberFuncId: + ClassType: 4142 + FunctionType: 4153 + Name: f + - Kind: LF_MFUNC_ID + MemberFuncId: + ClassType: 4142 + FunctionType: 4151 + Name: '{ctor}' + - Kind: LF_MFUNC_ID + MemberFuncId: + ClassType: 4096 + FunctionType: 4109 + Name: '{ctor}' + - Kind: LF_MFUNC_ID + MemberFuncId: + ClassType: 4120 + FunctionType: 4132 + Name: '{ctor}' + - Kind: LF_MFUNC_ID + MemberFuncId: + ClassType: 4142 + FunctionType: 4153 + Name: f + - Kind: LF_ARRAY + Array: + ElementType: 4169 + IndexType: 35 + Size: 8 + Name: '' + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: '__vc_attributes::moduleAttribute' + UniqueName: '.?AUmoduleAttribute@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 1 + Name: dll + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 2 + Name: exe + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 3 + Name: service + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 4 + Name: unspecified + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 2 + Name: EXE + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 3 + Name: SERVICE + - Kind: LF_ENUM + Enum: + NumEnumerators: 6 + Options: [ None, Nested, HasUniqueName ] + FieldList: 4181 + Name: '__vc_attributes::moduleAttribute::type_e' + UniqueName: '.?AW4type_e@moduleAttribute@__vc_attributes@@' + UnderlyingType: 116 + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: 'c:\src\llvm-project\build\predefined c++ attributes (compiler internal)' + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4182 + SourceFile: 4183 + LineNumber: 482 + - Kind: LF_MODIFIER + Modifier: + ModifiedType: 112 + Modifiers: [ None, Const ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4185 + Attrs: 65548 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4182, 4186, 4186, 4186, 116, 48, 4186, 116, + 4186, 4186, 116, 48, 48, 4186, 4186 ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4180 + Attrs: 66572 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4180 + ThisType: 4188 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 15 + ArgumentList: 4187 + ThisPointerAdjustment: 0 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4182 ] + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4180 + ThisType: 4188 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 1 + ArgumentList: 4190 + ThisPointerAdjustment: 0 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4180 + ThisType: 4188 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 0 + ArgumentList: 4100 + ThisPointerAdjustment: 0 + - Kind: LF_METHODLIST + MethodOverloadList: + Methods: + - Type: 4189 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Type: 4191 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Type: 4192 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_NESTTYPE + NestedType: + Type: 4182 + Name: type_e + - Kind: LF_METHOD + OverloadedMethod: + NumOverloads: 3 + MethodList: 4193 + Name: moduleAttribute + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4182 + FieldOffset: 0 + Name: type + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4186 + FieldOffset: 8 + Name: name + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4186 + FieldOffset: 16 + Name: version + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4186 + FieldOffset: 24 + Name: uuid + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 116 + FieldOffset: 32 + Name: lcid + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 48 + FieldOffset: 36 + Name: control + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4186 + FieldOffset: 40 + Name: helpstring + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 116 + FieldOffset: 48 + Name: helpstringcontext + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4186 + FieldOffset: 56 + Name: helpstringdll + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4186 + FieldOffset: 64 + Name: helpfile + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 116 + FieldOffset: 72 + Name: helpcontext + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 48 + FieldOffset: 76 + Name: hidden + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 48 + FieldOffset: 77 + Name: restricted + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4186 + FieldOffset: 80 + Name: custom + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4186 + FieldOffset: 88 + Name: resource_name + - Kind: LF_STRUCTURE + Class: + MemberCount: 19 + Options: [ None, HasConstructorOrDestructor, ContainsNestedClass, HasUniqueName ] + FieldList: 4194 + Name: '__vc_attributes::moduleAttribute' + UniqueName: '.?AUmoduleAttribute@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 96 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4195 + SourceFile: 4183 + LineNumber: 481 + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: '__vc_attributes::event_receiverAttribute' + UniqueName: '.?AUevent_receiverAttribute@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 0 + Name: native + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 1 + Name: com + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 2 + Name: managed + - Kind: LF_ENUM + Enum: + NumEnumerators: 3 + Options: [ None, Nested, HasUniqueName ] + FieldList: 4198 + Name: '__vc_attributes::event_receiverAttribute::type_e' + UniqueName: '.?AW4type_e@event_receiverAttribute@__vc_attributes@@' + UnderlyingType: 116 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4199 + SourceFile: 4183 + LineNumber: 136 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4199, 48 ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4197 + Attrs: 66572 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4197 + ThisType: 4202 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 2 + ArgumentList: 4201 + ThisPointerAdjustment: 0 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4199 ] + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4197 + ThisType: 4202 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 1 + ArgumentList: 4204 + ThisPointerAdjustment: 0 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4197 + ThisType: 4202 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 0 + ArgumentList: 4100 + ThisPointerAdjustment: 0 + - Kind: LF_METHODLIST + MethodOverloadList: + Methods: + - Type: 4203 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Type: 4205 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Type: 4206 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_NESTTYPE + NestedType: + Type: 4199 + Name: type_e + - Kind: LF_METHOD + OverloadedMethod: + NumOverloads: 3 + MethodList: 4207 + Name: event_receiverAttribute + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4199 + FieldOffset: 0 + Name: type + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 48 + FieldOffset: 4 + Name: layout_dependent + - Kind: LF_STRUCTURE + Class: + MemberCount: 6 + Options: [ None, HasConstructorOrDestructor, ContainsNestedClass, HasUniqueName ] + FieldList: 4208 + Name: '__vc_attributes::event_receiverAttribute' + UniqueName: '.?AUevent_receiverAttribute@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 8 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4209 + SourceFile: 4183 + LineNumber: 135 + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: '__vc_attributes::aggregatableAttribute' + UniqueName: '.?AUaggregatableAttribute@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 0 + Name: never + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 1 + Name: allowed + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 2 + Name: always + - Kind: LF_ENUM + Enum: + NumEnumerators: 3 + Options: [ None, Nested, HasUniqueName ] + FieldList: 4212 + Name: '__vc_attributes::aggregatableAttribute::type_e' + UniqueName: '.?AW4type_e@aggregatableAttribute@__vc_attributes@@' + UnderlyingType: 116 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4213 + SourceFile: 4183 + LineNumber: 545 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4213 ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4211 + Attrs: 66572 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4211 + ThisType: 4216 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 1 + ArgumentList: 4215 + ThisPointerAdjustment: 0 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4211 + ThisType: 4216 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 0 + ArgumentList: 4100 + ThisPointerAdjustment: 0 + - Kind: LF_METHODLIST + MethodOverloadList: + Methods: + - Type: 4217 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Type: 4218 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_NESTTYPE + NestedType: + Type: 4213 + Name: type_e + - Kind: LF_METHOD + OverloadedMethod: + NumOverloads: 2 + MethodList: 4219 + Name: aggregatableAttribute + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4213 + FieldOffset: 0 + Name: type + - Kind: LF_STRUCTURE + Class: + MemberCount: 4 + Options: [ None, HasConstructorOrDestructor, ContainsNestedClass, HasUniqueName ] + FieldList: 4220 + Name: '__vc_attributes::aggregatableAttribute' + UniqueName: '.?AUaggregatableAttribute@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 4 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4221 + SourceFile: 4183 + LineNumber: 544 + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: '__vc_attributes::threadingAttribute' + UniqueName: '.?AUthreadingAttribute@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 1 + Name: apartment + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 2 + Name: single + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 3 + Name: free + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 4 + Name: neutral + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 5 + Name: both + - Kind: LF_ENUM + Enum: + NumEnumerators: 5 + Options: [ None, Nested, HasUniqueName ] + FieldList: 4224 + Name: '__vc_attributes::threadingAttribute::threading_e' + UniqueName: '.?AW4threading_e@threadingAttribute@__vc_attributes@@' + UnderlyingType: 116 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4225 + SourceFile: 4183 + LineNumber: 423 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4225 ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4223 + Attrs: 66572 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4223 + ThisType: 4228 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 1 + ArgumentList: 4227 + ThisPointerAdjustment: 0 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4223 + ThisType: 4228 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 0 + ArgumentList: 4100 + ThisPointerAdjustment: 0 + - Kind: LF_METHODLIST + MethodOverloadList: + Methods: + - Type: 4229 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Type: 4230 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_NESTTYPE + NestedType: + Type: 4225 + Name: threading_e + - Kind: LF_METHOD + OverloadedMethod: + NumOverloads: 2 + MethodList: 4231 + Name: threadingAttribute + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4225 + FieldOffset: 0 + Name: value + - Kind: LF_STRUCTURE + Class: + MemberCount: 4 + Options: [ None, HasConstructorOrDestructor, ContainsNestedClass, HasUniqueName ] + FieldList: 4232 + Name: '__vc_attributes::threadingAttribute' + UniqueName: '.?AUthreadingAttribute@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 4 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4233 + SourceFile: 4183 + LineNumber: 422 + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: '__vc_attributes::helper_attributes::usageAttribute' + UniqueName: '.?AUusageAttribute@helper_attributes@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 0 + Name: eAnyUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 1 + Name: eCoClassUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 2 + Name: eCOMInterfaceUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 6 + Name: eInterfaceUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 8 + Name: eMemberUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 16 + Name: eMethodUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 32 + Name: eInterfaceMethodUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 64 + Name: eInterfaceMemberUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 128 + Name: eCoClassMemberUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 256 + Name: eCoClassMethodUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 768 + Name: eGlobalMethodUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 1024 + Name: eGlobalDataUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 2048 + Name: eClassUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 4096 + Name: eInterfaceParameterUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 12288 + Name: eMethodParameterUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 16384 + Name: eIDLModuleUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 32768 + Name: eAnonymousUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 65536 + Name: eTypedefUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 131072 + Name: eUnionUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 262144 + Name: eEnumUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 524288 + Name: eDefineTagUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 1048576 + Name: eStructUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 2097152 + Name: eLocalUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 4194304 + Name: ePropertyUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 8388608 + Name: eEventUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 16777216 + Name: eTemplateUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 16777216 + Name: eModuleUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 33554432 + Name: eIllegalUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 67108864 + Name: eAsynchronousUsage + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 4161535 + Name: eAnyIDLUsage + - Kind: LF_ENUM + Enum: + NumEnumerators: 30 + Options: [ None, Nested, HasUniqueName ] + FieldList: 4236 + Name: '__vc_attributes::helper_attributes::usageAttribute::usage_e' + UniqueName: '.?AW4usage_e@usageAttribute@helper_attributes@__vc_attributes@@' + UnderlyingType: 116 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4237 + SourceFile: 4183 + LineNumber: 51 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 117 ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4235 + Attrs: 66572 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4235 + ThisType: 4240 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 1 + ArgumentList: 4239 + ThisPointerAdjustment: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_NESTTYPE + NestedType: + Type: 4237 + Name: usage_e + - Kind: LF_ONEMETHOD + OneMethod: + Type: 4241 + Attrs: 3 + VFTableOffset: -1 + Name: usageAttribute + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 117 + FieldOffset: 0 + Name: value + - Kind: LF_STRUCTURE + Class: + MemberCount: 3 + Options: [ None, HasConstructorOrDestructor, ContainsNestedClass, HasUniqueName ] + FieldList: 4242 + Name: '__vc_attributes::helper_attributes::usageAttribute' + UniqueName: '.?AUusageAttribute@helper_attributes@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 4 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4243 + SourceFile: 4183 + LineNumber: 49 + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: '__vc_attributes::helper_attributes::v1_alttypeAttribute' + UniqueName: '.?AUv1_alttypeAttribute@helper_attributes@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 0 + Name: eBoolean + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 1 + Name: eInteger + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 2 + Name: eFloat + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 3 + Name: eDouble + - Kind: LF_ENUM + Enum: + NumEnumerators: 4 + Options: [ None, Nested, HasUniqueName ] + FieldList: 4246 + Name: '__vc_attributes::helper_attributes::v1_alttypeAttribute::type_e' + UniqueName: '.?AW4type_e@v1_alttypeAttribute@helper_attributes@__vc_attributes@@' + UnderlyingType: 116 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4247 + SourceFile: 4183 + LineNumber: 38 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4247 ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4245 + Attrs: 66572 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4245 + ThisType: 4250 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 1 + ArgumentList: 4249 + ThisPointerAdjustment: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_NESTTYPE + NestedType: + Type: 4247 + Name: type_e + - Kind: LF_ONEMETHOD + OneMethod: + Type: 4251 + Attrs: 3 + VFTableOffset: -1 + Name: v1_alttypeAttribute + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4247 + FieldOffset: 0 + Name: type + - Kind: LF_STRUCTURE + Class: + MemberCount: 3 + Options: [ None, HasConstructorOrDestructor, ContainsNestedClass, HasUniqueName ] + FieldList: 4252 + Name: '__vc_attributes::helper_attributes::v1_alttypeAttribute' + UniqueName: '.?AUv1_alttypeAttribute@helper_attributes@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 4 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4253 + SourceFile: 4183 + LineNumber: 37 + - Kind: LF_STRUCTURE + Class: + MemberCount: 0 + Options: [ None, ForwardReference, HasUniqueName ] + FieldList: 0 + Name: '__vc_attributes::event_sourceAttribute' + UniqueName: '.?AUevent_sourceAttribute@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 0 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 0 + Name: native + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 1 + Name: com + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 2 + Name: managed + - Kind: LF_ENUM + Enum: + NumEnumerators: 3 + Options: [ None, Nested, HasUniqueName ] + FieldList: 4256 + Name: '__vc_attributes::event_sourceAttribute::type_e' + UniqueName: '.?AW4type_e@event_sourceAttribute@__vc_attributes@@' + UnderlyingType: 116 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4257 + SourceFile: 4183 + LineNumber: 1142 + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 0 + Name: speed + - Kind: LF_ENUMERATE + Enumerator: + Attrs: 3 + Value: 1 + Name: size + - Kind: LF_ENUM + Enum: + NumEnumerators: 2 + Options: [ None, Nested, HasUniqueName ] + FieldList: 4259 + Name: '__vc_attributes::event_sourceAttribute::optimize_e' + UniqueName: '.?AW4optimize_e@event_sourceAttribute@__vc_attributes@@' + UnderlyingType: 116 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4260 + SourceFile: 4183 + LineNumber: 1145 + - Kind: LF_ARGLIST + ArgList: + ArgIndices: [ 4257 ] + - Kind: LF_POINTER + Pointer: + ReferentType: 4255 + Attrs: 66572 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4255 + ThisType: 4263 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 1 + ArgumentList: 4262 + ThisPointerAdjustment: 0 + - Kind: LF_MFUNCTION + MemberFunction: + ReturnType: 3 + ClassType: 4255 + ThisType: 4263 + CallConv: NearC + Options: [ None, Constructor ] + ParameterCount: 0 + ArgumentList: 4100 + ThisPointerAdjustment: 0 + - Kind: LF_METHODLIST + MethodOverloadList: + Methods: + - Type: 4264 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Type: 4265 + Attrs: 3 + VFTableOffset: -1 + Name: '' + - Kind: LF_FIELDLIST + FieldList: + - Kind: LF_NESTTYPE + NestedType: + Type: 4257 + Name: type_e + - Kind: LF_NESTTYPE + NestedType: + Type: 4260 + Name: optimize_e + - Kind: LF_METHOD + OverloadedMethod: + NumOverloads: 2 + MethodList: 4266 + Name: event_sourceAttribute + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4257 + FieldOffset: 0 + Name: type + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 4260 + FieldOffset: 4 + Name: optimize + - Kind: LF_MEMBER + DataMember: + Attrs: 3 + Type: 48 + FieldOffset: 8 + Name: decorate + - Kind: LF_STRUCTURE + Class: + MemberCount: 7 + Options: [ None, HasConstructorOrDestructor, ContainsNestedClass, HasUniqueName ] + FieldList: 4267 + Name: '__vc_attributes::event_sourceAttribute' + UniqueName: '.?AUevent_sourceAttribute@__vc_attributes@@' + DerivationList: 0 + VTableShape: 0 + Size: 12 + - Kind: LF_UDT_SRC_LINE + UdtSourceLine: + UDT: 4268 + SourceFile: 4183 + LineNumber: 1141 + - Kind: LF_VFTABLE + VFTable: + CompleteClass: 4117 + OverriddenVFTable: 0 + VFPtrOffset: 0 + MethodNames: + - '??_7A@@6B@' + - '?f@A@@UEAAHXZ' + - Kind: LF_VFTABLE + VFTable: + CompleteClass: 4140 + OverriddenVFTable: 0 + VFPtrOffset: 0 + MethodNames: + - '??_7B@@6B@' + - '?f@B@@UEAAHXZ' + - Kind: LF_VFTABLE + VFTable: + CompleteClass: 4160 + OverriddenVFTable: 4270 + VFPtrOffset: 0 + MethodNames: + - '??_7C@@6BA@@@' + - '?f@C@@UEAAHXZ' + - Kind: LF_VFTABLE + VFTable: + CompleteClass: 4160 + OverriddenVFTable: 4271 + VFPtrOffset: 8 + MethodNames: + - '??_7C@@6BB@@@' + - '?f@C@@W7EAAHXZ' + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: 'C:\src\llvm-project\build' + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: 'C:\PROGRA~2\MICROS~1\2017\PROFES~1\VC\Tools\MSVC\14.11.25503\bin\HostX64\x64\cl.exe' + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: '-GR- -Z7 -c -MT -IC:\PROGRA~2\MICROS~1\2017\PROFES~1\VC\Tools\MSVC\14.11.25503\ATLMFC\include -IC:\PROGRA~2\MICROS~1\2017\PROFES~1\VC\Tools\MSVC\14.11.25503\include -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.16299.0\ucrt -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.162' + - Kind: LF_SUBSTR_LIST + StringList: + StringIndices: [ 4276 ] + - Kind: LF_STRING_ID + StringId: + Id: 4277 + String: '99.0\shared -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.16299.0\um -IC:\PROGRA~2\WI3CF2~1\10\include\10.0.16299.0\winrt -TP -X' + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: t.cpp + - Kind: LF_STRING_ID + StringId: + Id: 0 + String: 'C:\src\llvm-project\build\vc140.pdb' + - Kind: LF_BUILDINFO + BuildInfo: + ArgIndices: [ 4274, 4275, 4279, 4280, 4278 ] + - Name: '.text$mn' + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: 48894C240833C0C3CCCCCCCCCCCCCCCC48894C240833C0C3CCCCCCCCCCCCCCCC48894C24084883EC28488B4C2430E800000000488B4424304883C008488BC8E800000000488B442430488D0D00000000488908488B442430488D0D0000000048894808488B442430C740102A000000488B4424304883C428C3CCCCCCCCCCCCCC48894C2408488B4424088B4010C3 + Relocations: + - VirtualAddress: 47 + SymbolName: '??0A@@QEAA@XZ' + Type: IMAGE_REL_AMD64_REL32 + - VirtualAddress: 64 + SymbolName: '??0B@@QEAA@XZ' + Type: IMAGE_REL_AMD64_REL32 + - VirtualAddress: 76 + SymbolName: '??_7C@@6BA@@@' + Type: IMAGE_REL_AMD64_REL32 + - VirtualAddress: 91 + SymbolName: '??_7C@@6BB@@@' + Type: IMAGE_REL_AMD64_REL32 + - Name: '.text$mn' + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: 48894C2408488B442408488D0D00000000488908488B442408C3 + Relocations: + - VirtualAddress: 13 + SymbolName: '??_7A@@6B@' + Type: IMAGE_REL_AMD64_REL32 + - Name: '.debug$S' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 1 + Subsections: + - !Symbols + Records: + - Kind: S_GPROC32_ID + ProcSym: + CodeSize: 26 + DbgStart: 5 + DbgEnd: 25 + FunctionType: 4176 + Flags: [ ] + DisplayName: 'A::A' + - Kind: S_FRAMEPROC + FrameProcSym: + TotalFrameBytes: 0 + PaddingFrameBytes: 0 + OffsetToPadding: 0 + BytesOfCalleeSavedRegisters: 0 + OffsetOfExceptionHandler: 0 + SectionIdOfExceptionHandler: 0 + Flags: [ MarkedInline, AsynchronousExceptionHandling, OptimizedForSpeed ] + - Kind: S_REGREL32 + RegRelativeSym: + Offset: 8 + Type: 4097 + Register: RSP + VarName: this + - Kind: S_PROC_ID_END + ScopeEndSym: + Relocations: + - VirtualAddress: 44 + SymbolName: '??0A@@QEAA@XZ' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 48 + SymbolName: '??0A@@QEAA@XZ' + Type: IMAGE_REL_AMD64_SECTION + - Name: '.text$mn' + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 16 + SectionData: 48894C2408488B442408488D0D00000000488908488B442408C3 + Relocations: + - VirtualAddress: 13 + SymbolName: '??_7B@@6B@' + Type: IMAGE_REL_AMD64_REL32 + - Name: '.debug$S' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 1 + Subsections: + - !Symbols + Records: + - Kind: S_GPROC32_ID + ProcSym: + CodeSize: 26 + DbgStart: 5 + DbgEnd: 25 + FunctionType: 4177 + Flags: [ ] + DisplayName: 'B::B' + - Kind: S_FRAMEPROC + FrameProcSym: + TotalFrameBytes: 0 + PaddingFrameBytes: 0 + OffsetToPadding: 0 + BytesOfCalleeSavedRegisters: 0 + OffsetOfExceptionHandler: 0 + SectionIdOfExceptionHandler: 0 + Flags: [ MarkedInline, AsynchronousExceptionHandling, OptimizedForSpeed ] + - Kind: S_REGREL32 + RegRelativeSym: + Offset: 8 + Type: 4121 + Register: RSP + VarName: this + - Kind: S_PROC_ID_END + ScopeEndSym: + Relocations: + - VirtualAddress: 44 + SymbolName: '??0B@@QEAA@XZ' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 48 + SymbolName: '??0B@@QEAA@XZ' + Type: IMAGE_REL_AMD64_SECTION + - Name: '.text$mn' + Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: 4883E908E900000000 + Relocations: + - VirtualAddress: 5 + SymbolName: '?f@C@@UEAAHXZ' + Type: IMAGE_REL_AMD64_REL32 + - Name: '.debug$S' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 1 + Subsections: + - !Symbols + Records: + - Kind: S_THUNK32 + Thunk32Sym: + Parent: 0 + End: 0 + Next: 0 + Off: 0 + Seg: 0 + Len: 9 + Ordinal: Pcode + - Kind: S_FRAMEPROC + FrameProcSym: + TotalFrameBytes: 0 + PaddingFrameBytes: 0 + OffsetToPadding: 0 + BytesOfCalleeSavedRegisters: 0 + OffsetOfExceptionHandler: 0 + SectionIdOfExceptionHandler: 0 + Flags: [ MarkedInline, Naked, AsynchronousExceptionHandling ] + - Kind: S_PROC_ID_END + ScopeEndSym: + Relocations: + - VirtualAddress: 28 + SymbolName: '?f@C@@W7EAAHXZ' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 32 + SymbolName: '?f@C@@W7EAAHXZ' + Type: IMAGE_REL_AMD64_SECTION + - Name: .xdata + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: '0109010009420000' + - Name: .pdata + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ ] + Alignment: 4 + SectionData: '000000005900000000000000' + Relocations: + - VirtualAddress: 0 + SymbolName: '$LN3' + Type: IMAGE_REL_AMD64_ADDR32NB + - VirtualAddress: 4 + SymbolName: '$LN3' + Type: IMAGE_REL_AMD64_ADDR32NB + - VirtualAddress: 8 + SymbolName: '$unwind$??0C@@QEAA@XZ' + Type: IMAGE_REL_AMD64_ADDR32NB + - Name: .rdata + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_READ ] + Alignment: 8 + SectionData: '0000000000000000' + Relocations: + - VirtualAddress: 0 + SymbolName: '?f@A@@UEAAHXZ' + Type: IMAGE_REL_AMD64_ADDR64 + - Name: .rdata + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_READ ] + Alignment: 8 + SectionData: '0000000000000000' + Relocations: + - VirtualAddress: 0 + SymbolName: '?f@B@@UEAAHXZ' + Type: IMAGE_REL_AMD64_ADDR64 + - Name: .rdata + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_READ ] + Alignment: 8 + SectionData: '0000000000000000' + Relocations: + - VirtualAddress: 0 + SymbolName: '?f@C@@UEAAHXZ' + Type: IMAGE_REL_AMD64_ADDR64 + - Name: .rdata + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_READ ] + Alignment: 8 + SectionData: '0000000000000000' + Relocations: + - VirtualAddress: 0 + SymbolName: '?f@C@@W7EAAHXZ' + Type: IMAGE_REL_AMD64_ADDR64 + - Name: '.debug$S' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 1 + Subsections: + - !Symbols + Records: + - Kind: S_GDATA32 + DataSym: + Type: 4179 + DisplayName: 'A::`vftable''' + Relocations: + - VirtualAddress: 20 + SymbolName: '??_7A@@6B@' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 24 + SymbolName: '??_7A@@6B@' + Type: IMAGE_REL_AMD64_SECTION + - Name: '.debug$S' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 1 + Subsections: + - !Symbols + Records: + - Kind: S_GDATA32 + DataSym: + Type: 4179 + DisplayName: 'B::`vftable''' + Relocations: + - VirtualAddress: 20 + SymbolName: '??_7B@@6B@' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 24 + SymbolName: '??_7B@@6B@' + Type: IMAGE_REL_AMD64_SECTION + - Name: '.debug$S' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 1 + Subsections: + - !Symbols + Records: + - Kind: S_GDATA32 + DataSym: + Type: 4179 + DisplayName: 'C::`vftable''' + Relocations: + - VirtualAddress: 20 + SymbolName: '??_7C@@6BA@@@' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 24 + SymbolName: '??_7C@@6BA@@@' + Type: IMAGE_REL_AMD64_SECTION + - Name: '.debug$S' + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ ] + Alignment: 1 + Subsections: + - !Symbols + Records: + - Kind: S_GDATA32 + DataSym: + Type: 4179 + DisplayName: 'C::`vftable''' + Relocations: + - VirtualAddress: 20 + SymbolName: '??_7C@@6BB@@@' + Type: IMAGE_REL_AMD64_SECREL + - VirtualAddress: 24 + SymbolName: '??_7C@@6BB@@@' + Type: IMAGE_REL_AMD64_SECTION +symbols: + - Name: '@comp.id' + Value: 17130404 + SectionNumber: -1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: '@feat.00' + Value: 2147484048 + SectionNumber: -1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: .drectve + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 69 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 876125206 + Number: 0 + - Name: '.debug$S' + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 1668 + NumberOfRelocations: 16 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: '.debug$T' + Value: 0 + SectionNumber: 3 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 8276 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: '.text$mn' + Value: 0 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 142 + NumberOfRelocations: 4 + NumberOfLinenumbers: 0 + CheckSum: 1906691115 + Number: 0 + - Name: '.text$mn' + Value: 0 + SectionNumber: 5 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 26 + NumberOfRelocations: 1 + NumberOfLinenumbers: 0 + CheckSum: 2299407997 + Number: 0 + Selection: IMAGE_COMDAT_SELECT_ANY + - Name: '.debug$S' + Value: 0 + SectionNumber: 6 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 112 + NumberOfRelocations: 2 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 5 + Selection: IMAGE_COMDAT_SELECT_ASSOCIATIVE + - Name: '.text$mn' + Value: 0 + SectionNumber: 7 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 26 + NumberOfRelocations: 1 + NumberOfLinenumbers: 0 + CheckSum: 2299407997 + Number: 0 + Selection: IMAGE_COMDAT_SELECT_ANY + - Name: '.debug$S' + Value: 0 + SectionNumber: 8 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 112 + NumberOfRelocations: 2 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 7 + Selection: IMAGE_COMDAT_SELECT_ASSOCIATIVE + - Name: '.text$mn' + Value: 0 + SectionNumber: 9 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 9 + NumberOfRelocations: 1 + NumberOfLinenumbers: 0 + CheckSum: 3880904481 + Number: 0 + Selection: IMAGE_COMDAT_SELECT_ANY + - Name: '.debug$S' + Value: 0 + SectionNumber: 10 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 100 + NumberOfRelocations: 2 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 9 + Selection: IMAGE_COMDAT_SELECT_ASSOCIATIVE + - Name: '?f@A@@UEAAHXZ' + Value: 0 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: '??0A@@QEAA@XZ' + Value: 0 + SectionNumber: 5 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: '?f@B@@UEAAHXZ' + Value: 16 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: '??0B@@QEAA@XZ' + Value: 0 + SectionNumber: 7 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: '??0C@@QEAA@XZ' + Value: 32 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: '?f@C@@UEAAHXZ' + Value: 128 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: '?f@C@@W7EAAHXZ' + Value: 0 + SectionNumber: 9 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: '$LN3' + Value: 32 + SectionNumber: 4 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_LABEL + - Name: .xdata + Value: 0 + SectionNumber: 11 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 8 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 2625142988 + Number: 0 + - Name: '$unwind$??0C@@QEAA@XZ' + Value: 0 + SectionNumber: 11 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: .pdata + Value: 0 + SectionNumber: 12 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 12 + NumberOfRelocations: 3 + NumberOfLinenumbers: 0 + CheckSum: 1248454893 + Number: 0 + - Name: '$pdata$??0C@@QEAA@XZ' + Value: 0 + SectionNumber: 12 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: .rdata + Value: 0 + SectionNumber: 13 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 8 + NumberOfRelocations: 1 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + Selection: IMAGE_COMDAT_SELECT_ANY + - Name: '??_7A@@6B@' + Value: 0 + SectionNumber: 13 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: .rdata + Value: 0 + SectionNumber: 14 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 8 + NumberOfRelocations: 1 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + Selection: IMAGE_COMDAT_SELECT_ANY + - Name: '??_7B@@6B@' + Value: 0 + SectionNumber: 14 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: .rdata + Value: 0 + SectionNumber: 15 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 8 + NumberOfRelocations: 1 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + Selection: IMAGE_COMDAT_SELECT_ANY + - Name: '??_7C@@6BA@@@' + Value: 0 + SectionNumber: 15 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: .rdata + Value: 0 + SectionNumber: 16 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 8 + NumberOfRelocations: 1 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + Selection: IMAGE_COMDAT_SELECT_ANY + - Name: '??_7C@@6BB@@@' + Value: 0 + SectionNumber: 16 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_EXTERNAL + - Name: '.debug$S' + Value: 0 + SectionNumber: 17 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 40 + NumberOfRelocations: 2 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 13 + Selection: IMAGE_COMDAT_SELECT_ASSOCIATIVE + - Name: '.debug$S' + Value: 0 + SectionNumber: 18 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 40 + NumberOfRelocations: 2 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 14 + Selection: IMAGE_COMDAT_SELECT_ASSOCIATIVE + - Name: '.debug$S' + Value: 0 + SectionNumber: 19 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 40 + NumberOfRelocations: 2 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 15 + Selection: IMAGE_COMDAT_SELECT_ASSOCIATIVE + - Name: '.debug$S' + Value: 0 + SectionNumber: 20 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 40 + NumberOfRelocations: 2 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 16 + Selection: IMAGE_COMDAT_SELECT_ASSOCIATIVE +... + diff --git a/test/COFF/pdb-type-server-simple.test b/test/COFF/pdb-type-server-simple.test index c0de4e390914..898c5d4aa130 100644 --- a/test/COFF/pdb-type-server-simple.test +++ b/test/COFF/pdb-type-server-simple.test @@ -21,7 +21,7 @@ RUN: yaml2obj %S/Inputs/pdb-type-server-simple-a.yaml -o a.obj RUN: yaml2obj %S/Inputs/pdb-type-server-simple-b.yaml -o b.obj RUN: llvm-pdbutil yaml2pdb %S/Inputs/pdb-type-server-simple-ts.yaml -pdb ts.pdb RUN: lld-link a.obj b.obj -entry:main -debug -out:t.exe -pdb:t.pdb -nodefaultlib -RUN: llvm-pdbutil dump -symbols -types -ids %t/t.pdb | FileCheck %s +RUN: llvm-pdbutil dump -symbols -types -ids -globals %t/t.pdb | FileCheck %s CHECK-LABEL: Types (TPI Stream) @@ -59,23 +59,29 @@ CHECK: {{.*}}: `a.c` CHECK: [[B_BUILD:[^ ]*]] | LF_BUILDINFO [size = 28] CHECK: {{.*}}: `b.c` +CHECK-LABEL: Global Symbols +CHECK: ============================================================ +CHECK-NEXT: Records +CHECK-NEXT: 36 | S_PROCREF [size = 20] `main` +CHECK-NEXT: module = 1, sum name = 0, offset = 104 +CHECK-NEXT: 56 | S_PROCREF [size = 16] `g` +CHECK-NEXT: module = 2, sum name = 0, offset = 104 + CHECK-LABEL: Symbols CHECK: ============================================================ CHECK-LABEL: Mod 0000 | `{{.*}}a.obj`: CHECK: 4 | S_OBJNAME [size = 40] sig=0, `C:\src\llvm-project\build\a.obj` -CHECK: 104 | S_GPROC32_ID [size = 44] `main` +CHECK: 104 | S_GPROC32 [size = 44] `main` CHECK: parent = 0, end = 196, addr = 0002:0000, code size = 27 CHECK: type = {{.*}}, debug start = 4, debug end = 22, flags = none -CHECK: 200 | S_UDT [size = 12] `Foo` -CHECK: original type = [[FOO_COMPLETE]] -CHECK: 212 | S_BUILDINFO [size = 8] BuildId = `[[A_BUILD]]` +CHECK: 200 | S_BUILDINFO [size = 8] BuildId = `[[A_BUILD]]` CHECK-LABEL: Mod 0001 | `{{.*}}b.obj`: CHECK: 4 | S_OBJNAME [size = 40] sig=0, `C:\src\llvm-project\build\b.obj` CHECK: 44 | S_COMPILE3 [size = 60] CHECK: machine = intel x86-x64, Ver = Microsoft (R) Optimizing Compiler, language = c CHECK: frontend = 19.0.24215.1, backend = 19.0.24215.1 CHECK: flags = security checks | hot patchable -CHECK: 104 | S_GPROC32_ID [size = 44] `g` +CHECK: 104 | S_GPROC32 [size = 44] `g` CHECK: parent = 0, end = 196, addr = 0002:0032, code size = 13 CHECK: type = {{.*}}, debug start = 5, debug end = 12, flags = none CHECK: 148 | S_FRAMEPROC [size = 32] @@ -83,9 +89,7 @@ CHECK: size = 0, padding size = 0, offset to padding = 0 CHECK: bytes of callee saved registers = 0, exception handler addr = 0000:0000 CHECK: flags = has async eh | opt speed CHECK: 180 | S_REGREL32 [size = 16] `p` -CHECK: type = [[FOO_PTR]] (Foo*), register = rsp, offset = 8 +CHECK: type = [[FOO_PTR]] (Foo*), register = RSP, offset = 8 CHECK: 196 | S_END [size = 4] -CHECK: 200 | S_UDT [size = 12] `Foo` -CHECK: original type = [[FOO_COMPLETE]] -CHECK: 212 | S_BUILDINFO [size = 8] BuildId = `[[B_BUILD]]` +CHECK: 200 | S_BUILDINFO [size = 8] BuildId = `[[B_BUILD]]` CHECK-LABEL: Mod 0002 | `* Linker *`: diff --git a/test/COFF/pdb.test b/test/COFF/pdb.test index a4cd4f7c35b3..dad6de25db58 100644 --- a/test/COFF/pdb.test +++ b/test/COFF/pdb.test @@ -1,13 +1,15 @@ # RUN: yaml2obj < %p/Inputs/pdb1.yaml > %t1.obj # RUN: yaml2obj < %p/Inputs/pdb2.yaml > %t2.obj +# RUN: rm -f %t.dll %t.pdb # RUN: lld-link /debug /pdb:%t.pdb /dll /out:%t.dll /entry:main /nodefaultlib \ # RUN: %t1.obj %t2.obj # RUN: llvm-pdbutil pdb2yaml -stream-metadata -stream-directory -pdb-stream \ # RUN: -dbi-stream -ipi-stream -tpi-stream %t.pdb | FileCheck %s -# RUN: llvm-pdbutil dump -modules -section-map -section-contribs \ -# RUN: -types -ids %t.pdb | FileCheck -check-prefix RAW %s +# RUN: llvm-pdbutil dump -modules -section-map -section-contribs -section-headers \ +# RUN: -publics -public-extras -types -ids -type-extras -id-extras %t.pdb \ +# RUN: | FileCheck -check-prefix RAW %s # CHECK: MSF: # CHECK-NEXT: SuperBlock: @@ -117,86 +119,170 @@ RAW: Modules RAW-NEXT: ============================================================ -RAW-NEXT: Mod 0000 | Name: `{{.*}}pdb.test.tmp1.obj`: +RAW-NEXT: Mod 0000 | `{{.*}}pdb.test.tmp1.obj`: RAW-NEXT: Obj: `{{.*}}pdb.test.tmp1.obj`: RAW-NEXT: debug stream: 9, # files: 1, has ec info: false RAW-NEXT: pdb file ni: 0 ``, src file ni: 0 `` -RAW-NEXT: Mod 0001 | Name: `{{.*}}pdb.test.tmp2.obj`: +RAW-NEXT: Mod 0001 | `{{.*}}pdb.test.tmp2.obj`: RAW-NEXT: Obj: `{{.*}}pdb.test.tmp2.obj`: RAW-NEXT: debug stream: 10, # files: 1, has ec info: false RAW-NEXT: pdb file ni: 0 ``, src file ni: 0 `` -RAW-NEXT: Mod 0002 | Name: `* Linker *`: +RAW-NEXT: Mod 0002 | `* Linker *`: RAW-NEXT: Obj: ``: RAW-NEXT: debug stream: 11, # files: 0, has ec info: false RAW-NEXT: pdb file ni: 1 `{{.*pdb.test.tmp.pdb}}`, src file ni: 0 `` RAW: Types (TPI Stream) RAW-NEXT: ============================================================ RAW-NEXT: Showing 5 records -RAW-NEXT: 0x1000 | LF_ARGLIST [size = 8] -RAW-NEXT: 0x1001 | LF_PROCEDURE [size = 16] +RAW-NEXT: 0x1000 | LF_ARGLIST [size = 8, hash = 0xEC0] +RAW-NEXT: 0x1001 | LF_PROCEDURE [size = 16, hash = 0x7BC] RAW-NEXT: return type = 0x0074 (int), # args = 0, param list = 0x1000 RAW-NEXT: calling conv = cdecl, options = None -RAW-NEXT: 0x1002 | LF_POINTER [size = 12] +RAW-NEXT: 0x1002 | LF_POINTER [size = 12, hash = 0x884] RAW-NEXT: referent = 0x1001, mode = pointer, opts = None, kind = ptr64 -RAW-NEXT: 0x1003 | LF_ARGLIST [size = 12] +RAW-NEXT: 0x1003 | LF_ARGLIST [size = 12, hash = 0x936] RAW-NEXT: <no type>: `` -RAW-NEXT: 0x1004 | LF_PROCEDURE [size = 16] +RAW-NEXT: 0x1004 | LF_PROCEDURE [size = 16, hash = 0x852] RAW-NEXT: return type = 0x0074 (int), # args = 0, param list = 0x1003 RAW-NEXT: calling conv = cdecl, options = None RAW: Types (IPI Stream) RAW-NEXT: ============================================================ RAW-NEXT: Showing 12 records -RAW-NEXT: 0x1000 | LF_FUNC_ID [size = 20] +RAW-NEXT: 0x1000 | LF_FUNC_ID [size = 20, hash = 0x330] RAW-NEXT: name = main, type = 0x1004, parent scope = <no type> -RAW-NEXT: 0x1001 | LF_FUNC_ID [size = 16] +RAW-NEXT: 0x1001 | LF_FUNC_ID [size = 16, hash = 0x120] RAW-NEXT: name = foo, type = 0x1001, parent scope = <no type> -RAW-NEXT: 0x1002 | LF_STRING_ID [size = 16] ID: <no type>, String: D:\b -RAW-NEXT: 0x1003 | LF_STRING_ID [size = 36] ID: <no type>, String: C:\vs14\VC\BIN\amd64\cl.exe -RAW-NEXT: 0x1004 | LF_STRING_ID [size = 260] ID: <no type>, String: -Z7 -c -MT -IC:\vs14\VC\INCLUDE -IC:\vs14\VC\ATLMFC\INCLUDE -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10150.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\shared" -RAW-NEXT: 0x1005 | LF_SUBSTR_LIST [size = 12] +RAW-NEXT: 0x1002 | LF_STRING_ID [size = 16, hash = 0x757] ID: <no type>, String: D:\b +RAW-NEXT: 0x1003 | LF_STRING_ID [size = 36, hash = 0xC3A] ID: <no type>, String: C:\vs14\VC\BIN\amd64\cl.exe +RAW-NEXT: 0x1004 | LF_STRING_ID [size = 260, hash = 0x433] ID: <no type>, String: -Z7 -c -MT -IC:\vs14\VC\INCLUDE -IC:\vs14\VC\ATLMFC\INCLUDE -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10150.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\shared" +RAW-NEXT: 0x1005 | LF_SUBSTR_LIST [size = 12, hash = 0x759] RAW-NEXT: 0x1004: `-Z7 -c -MT -IC:\vs14\VC\INCLUDE -IC:\vs14\VC\ATLMFC\INCLUDE -I"C:\Program Files (x86)\Windows Kits\10\include\10.0.10150.0\ucrt" -I"C:\Program Files (x86)\Windows Kits\NETFXSDK\4.6\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\shared"` -RAW-NEXT: 0x1006 | LF_STRING_ID [size = 132] ID: 0x1005, String: -I"C:\Program Files (x86)\Windows Kits\8.1\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\winrt" -TC -X -RAW-NEXT: 0x1007 | LF_STRING_ID [size = 24] ID: <no type>, String: ret42-main.c -RAW-NEXT: 0x1008 | LF_STRING_ID [size = 24] ID: <no type>, String: D:\b\vc140.pdb -RAW-NEXT: 0x1009 | LF_BUILDINFO [size = 28] +RAW-NEXT: 0x1006 | LF_STRING_ID [size = 132, hash = 0xF57] ID: 0x1005, String: -I"C:\Program Files (x86)\Windows Kits\8.1\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\winrt" -TC -X +RAW-NEXT: 0x1007 | LF_STRING_ID [size = 24, hash = 0x2D1] ID: <no type>, String: ret42-main.c +RAW-NEXT: 0x1008 | LF_STRING_ID [size = 24, hash = 0xB8B] ID: <no type>, String: D:\b\vc140.pdb +RAW-NEXT: 0x1009 | LF_BUILDINFO [size = 28, hash = 0xA8C] RAW-NEXT: 0x1002: `D:\b` RAW-NEXT: 0x1003: `C:\vs14\VC\BIN\amd64\cl.exe` RAW-NEXT: 0x1007: `ret42-main.c` RAW-NEXT: 0x1008: `D:\b\vc140.pdb` RAW-NEXT: 0x1006: ` -I"C:\Program Files (x86)\Windows Kits\8.1\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\winrt" -TC -X` -RAW-NEXT: 0x100A | LF_STRING_ID [size = 20] ID: <no type>, String: ret42-sub.c -RAW-NEXT: 0x100B | LF_BUILDINFO [size = 28] +RAW-NEXT: 0x100A | LF_STRING_ID [size = 20, hash = 0x39C] ID: <no type>, String: ret42-sub.c +RAW-NEXT: 0x100B | LF_BUILDINFO [size = 28, hash = 0xAD7] RAW-NEXT: 0x1002: `D:\b` RAW-NEXT: 0x1003: `C:\vs14\VC\BIN\amd64\cl.exe` RAW-NEXT: 0x100A: `ret42-sub.c` RAW-NEXT: 0x1008: `D:\b\vc140.pdb` RAW-NEXT: 0x1006: ` -I"C:\Program Files (x86)\Windows Kits\8.1\include\um" -I"C:\Program Files (x86)\Windows Kits\8.1\include\winrt" -TC -X` +RAW: Public Symbols +RAW-NEXT: ============================================================ +RAW-NEXT: Publics Header +RAW-NEXT: sym hash = 556, thunk table addr = 0000:0000 +RAW-NEXT: GSI Header +RAW-NEXT: sig = 0xFFFFFFFF, hdr = 0xF12F091A, hr size = 16, num buckets = 524 +RAW-NEXT: Records +RAW-NEXT: 20 | S_PUB32 [size = 20] `main` +RAW-NEXT: flags = function, addr = 0002:0000 +RAW-NEXT: 0 | S_PUB32 [size = 20] `foo` +RAW-NEXT: flags = function, addr = 0002:0016 +RAW-NOT: S_PUB32 +RAW-NEXT: Hash Entries +RAW-NEXT: off = 21, refcnt = 1 +RAW-NEXT: off = 1, refcnt = 1 +RAW-NEXT: Hash Buckets +RAW-NEXT: 0x00000000 +RAW-NEXT: 0x0000000c +RAW-NEXT: Address Map +RAW-NEXT: off = 20 +RAW-NEXT: off = 0 +RAW: Section Headers +RAW-NEXT: ============================================================ +RAW: SECTION HEADER #1 +RAW-NEXT: .pdata name +RAW-NEXT: virtual size +RAW-NEXT: 1000 virtual address +RAW-NEXT: 200 size of raw data +RAW-NEXT: 400 file pointer to raw data +RAW-NEXT: 0 file pointer to relocation table +RAW-NEXT: 0 file pointer to line numbers +RAW-NEXT: 0 number of relocations +RAW-NEXT: 0 number of line numbers +RAW-NEXT: 40000040 flags +RAW-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA +RAW-NEXT: IMAGE_SCN_MEM_READ +RAW: SECTION HEADER #2 +RAW-NEXT: .text name +RAW-NEXT: virtual size +RAW-NEXT: 2000 virtual address +RAW-NEXT: 200 size of raw data +RAW-NEXT: 600 file pointer to raw data +RAW-NEXT: 0 file pointer to relocation table +RAW-NEXT: 0 file pointer to line numbers +RAW-NEXT: 0 number of relocations +RAW-NEXT: 0 number of line numbers +RAW-NEXT: 60000020 flags +RAW-NEXT: IMAGE_SCN_CNT_CODE +RAW-NEXT: IMAGE_SCN_MEM_EXECUTE +RAW-NEXT: IMAGE_SCN_MEM_READ +RAW: SECTION HEADER #3 +RAW-NEXT: .xdata name +RAW-NEXT: virtual size +RAW-NEXT: 3000 virtual address +RAW-NEXT: 200 size of raw data +RAW-NEXT: 800 file pointer to raw data +RAW-NEXT: 0 file pointer to relocation table +RAW-NEXT: 0 file pointer to line numbers +RAW-NEXT: 0 number of relocations +RAW-NEXT: 0 number of line numbers +RAW-NEXT: 40000040 flags +RAW-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA +RAW-NEXT: IMAGE_SCN_MEM_READ +RAW: SECTION HEADER #4 +RAW-NEXT: .rdata name +RAW-NEXT: virtual size +RAW-NEXT: 4000 virtual address +RAW-NEXT: 200 size of raw data +RAW-NEXT: A00 file pointer to raw data +RAW-NEXT: 0 file pointer to relocation table +RAW-NEXT: 0 file pointer to line numbers +RAW-NEXT: 0 number of relocations +RAW-NEXT: 0 number of line numbers +RAW-NEXT: 40000040 flags +RAW-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA +RAW-NEXT: IMAGE_SCN_MEM_READ +RAW: Original Section Headers +RAW-NEXT: ============================================================ +RAW-NEXT: PDB does not contain the requested image section header type RAW: Section Contributions RAW-NEXT: ============================================================ -RAW-NEXT: SC | mod = 0, 65535:1288, size = 14, data crc = 0, reloc crc = 0 -RAW-NEXT: IMAGE_SCN_CNT_CODE | IMAGE_SCN_ALIGN_16BYTES | IMAGE_SCN_MEM_EXECUTE | -RAW-NEXT: IMAGE_SCN_MEM_READ -RAW-NEXT: SC | mod = 0, 65535:1312, size = 8, data crc = 0, reloc crc = 0 -RAW-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_MEM_READ -RAW-NEXT: SC | mod = 0, 65535:1320, size = 12, data crc = 0, reloc crc = 0 -RAW-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_MEM_READ -RAW-NEXT: SC | mod = 1, 65535:1144, size = 6, data crc = 0, reloc crc = 0 -RAW-NEXT: IMAGE_SCN_CNT_CODE | IMAGE_SCN_ALIGN_16BYTES | IMAGE_SCN_MEM_EXECUTE | -RAW-NEXT: IMAGE_SCN_MEM_READ +RAW-NEXT: SC[.pdata] | mod = 0, 0001:0000, size = 12, data crc = 361370162, reloc crc = 0 +RAW-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_MEM_READ +RAW-NEXT: SC[.text] | mod = 0, 0002:0000, size = 14, data crc = 1682752513, reloc crc = 0 +RAW-NEXT: IMAGE_SCN_CNT_CODE | IMAGE_SCN_ALIGN_16BYTES | IMAGE_SCN_MEM_EXECUTE | +RAW-NEXT: IMAGE_SCN_MEM_READ +RAW-NEXT: SC[.text] | mod = 1, 0002:0016, size = 6, data crc = 2139436471, reloc crc = 0 +RAW-NEXT: IMAGE_SCN_CNT_CODE | IMAGE_SCN_ALIGN_16BYTES | IMAGE_SCN_MEM_EXECUTE | +RAW-NEXT: IMAGE_SCN_MEM_READ +RAW-NEXT: SC[.xdata] | mod = 0, 0003:0000, size = 8, data crc = 264583633, reloc crc = 0 +RAW-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_ALIGN_4BYTES | IMAGE_SCN_MEM_READ +RAW-NEXT: SC[???] | mod = 2, 0004:0000, size = {{[0-9]+}}, data crc = 0, reloc crc = 0 +RAW-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ +RAW-NEXT: SC[???] | mod = 2, 0004:0028, size = {{[0-9]+}}, data crc = 0, reloc crc = 0 +RAW-NEXT: IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ +RAW-NOT: SC[ RAW: Section Map RAW-NEXT: ============================================================ -RAW-NEXT: Section 0000 | ovl = 0, group = 0, frame = 0, name = 1 +RAW-NEXT: Section 0000 | ovl = 0, group = 0, frame = 1, name = 65535 RAW-NEXT: class = 65535, offset = 0, size = RAW-NEXT: flags = read | 32 bit addr | selector -RAW-NEXT: Section 0001 | ovl = 1, group = 0, frame = 0, name = 2 +RAW-NEXT: Section 0001 | ovl = 0, group = 0, frame = 2, name = 65535 RAW-NEXT: class = 65535, offset = 0, size = RAW-NEXT: flags = read | execute | 32 bit addr | selector -RAW-NEXT: Section 0002 | ovl = 2, group = 0, frame = 0, name = 3 +RAW-NEXT: Section 0002 | ovl = 0, group = 0, frame = 3, name = 65535 RAW-NEXT: class = 65535, offset = 0, size = RAW-NEXT: flags = read | 32 bit addr | selector -RAW-NEXT: Section 0003 | ovl = 3, group = 0, frame = 0, name = 4 +RAW-NEXT: Section 0003 | ovl = 0, group = 0, frame = 4, name = 65535 RAW-NEXT: class = 65535, offset = 0, size = RAW-NEXT: flags = read | 32 bit addr | selector -RAW-NEXT: Section 0004 | ovl = 4, group = 0, frame = 0, name = 5 +RAW-NEXT: Section 0004 | ovl = 0, group = 0, frame = 5, name = 65535 RAW-NEXT: class = 65535, offset = 0, size = RAW-NEXT: flags = 32 bit addr | absolute addr diff --git a/test/COFF/reloc-arm.test b/test/COFF/reloc-arm.test index 1f3de619c44b..872e6d53c8aa 100644 --- a/test/COFF/reloc-arm.test +++ b/test/COFF/reloc-arm.test @@ -28,28 +28,28 @@ sections: Relocations: - VirtualAddress: 0 SymbolName: foo - Type: 1 # IMAGE_REL_ARM_ADDR32 + Type: IMAGE_REL_ARM_ADDR32 - VirtualAddress: 16 SymbolName: foo - Type: 2 # IMAGE_REL_ARM_ADDR32NB + Type: IMAGE_REL_ARM_ADDR32NB - VirtualAddress: 32 SymbolName: foo - Type: 17 # IMAGE_REL_ARM_MOV32T + Type: IMAGE_REL_ARM_MOV32T - VirtualAddress: 48 SymbolName: foo - Type: 20 # IMAGE_REL_ARM_BRANCH24T + Type: IMAGE_REL_ARM_BRANCH24T - VirtualAddress: 64 SymbolName: foo - Type: 18 # IMAGE_REL_ARM_BRANCH20T + Type: IMAGE_REL_ARM_BRANCH20T - VirtualAddress: 80 SymbolName: foo - Type: 21 # IMAGE_REL_ARM_BLX23T + Type: IMAGE_REL_ARM_BLX23T - VirtualAddress: 96 SymbolName: bar - Type: 20 # IMAGE_REL_ARM_BRANCH24T + Type: IMAGE_REL_ARM_BRANCH24T - VirtualAddress: 112 SymbolName: bar - Type: 15 # IMAGE_REL_ARM_SECREL + Type: IMAGE_REL_ARM_SECREL symbols: - Name: .aaa Value: 0 diff --git a/test/COFF/reloc-discarded-dwarf.s b/test/COFF/reloc-discarded-dwarf.s index d779d2f5b8fc..14dc5948b32a 100644 --- a/test/COFF/reloc-discarded-dwarf.s +++ b/test/COFF/reloc-discarded-dwarf.s @@ -13,3 +13,5 @@ f: .section .debug_info,"dr" .quad f + .section .eh_frame,"dr" + .quad f diff --git a/test/COFF/reloc-discarded-early.s b/test/COFF/reloc-discarded-early.s new file mode 100644 index 000000000000..6d1043dbfa74 --- /dev/null +++ b/test/COFF/reloc-discarded-early.s @@ -0,0 +1,8 @@ +# RUN: llvm-mc -triple=x86_64-windows-msvc -filetype=obj -o %t.obj %s +# RUN: lld-link -entry:__ImageBase -subsystem:console -debug %t.obj + +.section .debug_info,"dr" +.quad .Ldrectve + +.section .drectve +.Ldrectve: diff --git a/test/COFF/reloc-discarded-early2.s b/test/COFF/reloc-discarded-early2.s new file mode 100644 index 000000000000..18e200008721 --- /dev/null +++ b/test/COFF/reloc-discarded-early2.s @@ -0,0 +1,9 @@ +# RUN: llvm-mc -triple=x86_64-windows-msvc -filetype=obj -o %t.obj %s +# RUN: not lld-link -entry:__ImageBase -subsystem:console %t.obj 2>&1 | FileCheck %s + +.text +# CHECK: error: relocation against symbol in discarded section: .drectve +.quad .Ldrectve + +.section .drectve +.Ldrectve: diff --git a/test/COFF/reloc-discarded.s b/test/COFF/reloc-discarded.s index 94eaba998330..0be4e110b4db 100644 --- a/test/COFF/reloc-discarded.s +++ b/test/COFF/reloc-discarded.s @@ -18,7 +18,6 @@ main_global: .section .CRT$XCU,"dr",associative,main_global .p2align 3 - .globl assoc_global assoc_global: .quad main_global diff --git a/test/COFF/responsefile.test b/test/COFF/responsefile.test index fd4d221c20dc..742962423cc5 100644 --- a/test/COFF/responsefile.test +++ b/test/COFF/responsefile.test @@ -3,5 +3,23 @@ # RUN: echo /out:%t.exe /entry:main %t.obj > %t.rsp # RUN: lld-link @%t.rsp /heap:0x3000 # RUN: llvm-readobj -file-headers %t.exe | FileCheck %s - CHECK: SizeOfHeapReserve: 12288 + +# RUN: not lld-link --rsp-quoting=foobar @%t.rsp 2>&1 | \ +# RUN: FileCheck --check-prefix=INVRSP %s +INVRSP: invalid response file quoting: foobar + +# RUN: echo "blah\foo" > %t.rsp +# RUN: not lld-link @%t.rsp 2>&1 | \ +# RUN: FileCheck --check-prefix=DEFRSP %s +DEFRSP: error: could not open blah\foo + +# RUN: echo "blah\foo" > %t.rsp +# RUN: not lld-link --rsp-quoting=windows @%t.rsp 2>&1 | \ +# RUN: FileCheck --check-prefix=WINRSP %s +WINRSP: error: could not open blah\foo + +# RUN: echo "blah\foo" > %t.rsp +# RUN: not lld-link --rsp-quoting=posix @%t.rsp 2>&1 | \ +# RUN: FileCheck --check-prefix=POSRSP %s +POSRSP: error: could not open blahfoo diff --git a/test/COFF/rsds.test b/test/COFF/rsds.test index 82b0f220b6c1..176597786848 100644 --- a/test/COFF/rsds.test +++ b/test/COFF/rsds.test @@ -1,11 +1,20 @@ # RUN: yaml2obj %s > %t.obj +# RUN: rm -f %t.dll %t.pdb # RUN: lld-link /debug /dll /out:%t.dll /entry:DllMain %t.obj -# RUN: llvm-readobj -coff-debug-directory %t.dll | FileCheck %s +# RUN: llvm-readobj -coff-debug-directory %t.dll > %t.1.txt +# RUN: lld-link /debug /dll /out:%t.dll /entry:DllMain %t.obj +# RUN: llvm-readobj -coff-debug-directory %t.dll > %t.2.txt +# RUN: cat %t.1.txt %t.2.txt | FileCheck %s +# RUN: rm -f %t.dll %t.pdb +# RUN: lld-link /debug /pdb:%t.pdb /dll /out:%t.dll /entry:DllMain %t.obj +# RUN: llvm-readobj -coff-debug-directory %t.dll > %t.3.txt # RUN: lld-link /debug /pdb:%t.pdb /dll /out:%t.dll /entry:DllMain %t.obj -# RUN: llvm-readobj -coff-debug-directory %t.dll | FileCheck %s +# RUN: llvm-readobj -coff-debug-directory %t.dll > %t.4.txt +# RUN: cat %t.3.txt %t.4.txt | FileCheck %s +# CHECK: File: [[FILE:.*]].dll # CHECK: DebugDirectory [ # CHECK: DebugEntry { # CHECK: Characteristics: 0x0 @@ -13,17 +22,36 @@ # CHECK: MajorVersion: 0x0 # CHECK: MinorVersion: 0x0 # CHECK: Type: CodeView (0x2) -# CHECK: SizeOfData: -# CHECK: AddressOfRawData: -# CHECK: PointerToRawData: +# CHECK: SizeOfData: 0x{{[^0]}} +# CHECK: AddressOfRawData: 0x{{[^0]}} +# CHECK: PointerToRawData: 0x{{[^0]}} # CHECK: PDBInfo { # CHECK: PDBSignature: 0x53445352 -# CHECK: PDBGUID: +# CHECK: PDBGUID: [[GUID:\(([A-Za-z0-9]{2} ?){16}\)]] # CHECK: PDBAge: 1 # CHECK: PDBFileName: {{.*}}.pdb # CHECK: } # CHECK: } # CHECK: ] +# CHECK: File: [[FILE]].dll +# CHECK: DebugDirectory [ +# CHECK: DebugEntry { +# CHECK: Characteristics: 0x0 +# CHECK: TimeDateStamp: 1970-01-01 00:00:00 (0x0) +# CHECK: MajorVersion: 0x0 +# CHECK: MinorVersion: 0x0 +# CHECK: Type: CodeView (0x2) +# CHECK: SizeOfData: 0x{{[^0]}} +# CHECK: AddressOfRawData: 0x{{[^0]}} +# CHECK: PointerToRawData: 0x{{[^0]}} +# CHECK: PDBInfo { +# CHECK: PDBSignature: 0x53445352 +# CHECK: PDBGUID: [[GUID]] +# CHECK: PDBAge: 2 +# CHECK: PDBFileName: {{.*}}.pdb +# CHECK: } +# CHECK: } +# CHECK: ] --- !COFF header: diff --git a/test/COFF/safeseh-md.s b/test/COFF/safeseh-md.s new file mode 100644 index 000000000000..ae731b5211df --- /dev/null +++ b/test/COFF/safeseh-md.s @@ -0,0 +1,34 @@ +# RUN: llvm-mc -triple i686-windows-msvc %s -filetype=obj -o %t.obj +# RUN: lld-link %t.obj %S/Inputs/except_handler3.lib -safeseh -out:%t.exe -opt:noref -entry:main +# RUN: llvm-readobj -coff-load-config %t.exe | FileCheck %s + +# CHECK: SEHTable [ +# CHECK-NEXT: 0x +# CHECK-NEXT: ] + + .def @feat.00; + .scl 3; + .type 0; + .endef + .globl @feat.00 +@feat.00 = 1 + + .def _main; + .scl 2; + .type 32; + .endef + .section .text,"xr",one_only,_main + .globl _main +_main: + movl $42, %eax + ret + +.safeseh __except_handler3 + + .section .rdata,"dr" +.globl __load_config_used +__load_config_used: + .long 72 + .fill 60, 1, 0 + .long ___safe_se_handler_table + .long ___safe_se_handler_count diff --git a/test/COFF/safeseh.s b/test/COFF/safeseh.s index 83c15afbf938..35f54c590d13 100644 --- a/test/COFF/safeseh.s +++ b/test/COFF/safeseh.s @@ -1,9 +1,15 @@ # RUN: llvm-mc -triple i686-windows-msvc %s -filetype=obj -o %t.obj # RUN: lld-link %t.obj -safeseh -out:%t.exe -opt:noref -entry:main -# RUN: llvm-readobj -coff-load-config %t.exe | FileCheck %s --check-prefix=CHECK-NOGC +# RUN: llvm-readobj -coff-basereloc -coff-load-config -file-headers %t.exe | FileCheck %s --check-prefix=CHECK-NOGC # RUN: lld-link %t.obj -safeseh -out:%t.exe -opt:ref -entry:main -# RUN: llvm-readobj -coff-load-config %t.exe | FileCheck %s --check-prefix=CHECK-GC +# RUN: llvm-readobj -coff-basereloc -coff-load-config -file-headers %t.exe | FileCheck %s --check-prefix=CHECK-GC +# __safe_se_handler_table needs to be relocated against ImageBase. +# check that the relocation is present. +# CHECK-NOGC-NOT: IMAGE_DLL_CHARACTERISTICS_NO_SEH +# CHECK-NOGC: BaseReloc [ +# CHECK-NOGC: Entry { +# CHECK-NOGC: Type: HIGHLOW # CHECK-NOGC: LoadConfig [ # CHECK-NOGC: Size: 0x48 # CHECK-NOGC: SEHandlerTable: 0x401048 @@ -13,6 +19,11 @@ # CHECK-NOGC-NEXT: 0x402006 # CHECK-NOGC-NEXT: ] +# Without the SEH table, the address is absolute, so check that we do +# not have a relocation for it. +# CHECK-GC-NOT: IMAGE_DLL_CHARACTERISTICS_NO_SEH +# CHECK-GC: BaseReloc [ +# CHECK-GC-NEXT: ] # CHECK-GC: LoadConfig [ # CHECK-GC: Size: 0x48 # CHECK-GC: SEHandlerTable: 0x0 diff --git a/test/COFF/section-size.s b/test/COFF/section-size.s new file mode 100644 index 000000000000..28f3f4acbc9d --- /dev/null +++ b/test/COFF/section-size.s @@ -0,0 +1,14 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-windows-msvc %s -o %tmain.obj +# RUN: echo '.lcomm s, 0x80000000' | llvm-mc -filetype=obj -triple=x86_64-windows-msvc -o %t1.obj +# RUN: cp %t1.obj %t2.obj +# RUN: echo '.lcomm s, 0xffffffff' | llvm-mc -filetype=obj -triple=x86_64-windows-msvc -o %t3.obj + +# Run: lld-link -entry:main %tmain.obj %t3.obj -out:%t.exe + +# RUN: not lld-link -entry:main %tmain.obj %t1.obj %t2.obj -out:%t.exe 2>&1 | FileCheck %s +# CHECK: error: section larger than 4 GiB: .bss + +.globl main +main: + retq diff --git a/test/COFF/seh-comdat.test b/test/COFF/seh-comdat.test new file mode 100644 index 000000000000..d9133289ed06 --- /dev/null +++ b/test/COFF/seh-comdat.test @@ -0,0 +1,66 @@ +# RUN: yaml2obj < %s > %t1.obj +# RUN: yaml2obj < %s > %t2.obj +# RUN: lld-link /out:%t.exe /subsystem:console /entry:main %t1.obj %t2.obj +# RUN: llvm-objdump -s %t.exe | FileCheck %s + +# CHECK: Contents of section .rdata: +# CHECK: 1000 00200000 + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_I386 + Characteristics: [ ] +sections: + - Name: .text + Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_DISCARDABLE, IMAGE_SCN_MEM_READ, IMAGE_SCN_LNK_COMDAT ] + Alignment: 1 + SectionData: 0000000000000000 + - Name: .sxdata + Characteristics: [ IMAGE_SCN_LNK_INFO ] + Alignment: 4 + SectionData: 02000000 +symbols: + - Name: '@comp.id' + Value: 14766605 + SectionNumber: 65535 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: '@feat.00' + Value: 2147484049 + SectionNumber: 65535 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + - Name: .text + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 4 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + Selection: IMAGE_COMDAT_SELECT_ANY + - Name: .sxdata + Value: 0 + SectionNumber: 2 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_NULL + StorageClass: IMAGE_SYM_CLASS_STATIC + SectionDefinition: + Length: 8 + NumberOfRelocations: 0 + NumberOfLinenumbers: 0 + CheckSum: 0 + Number: 0 + - Name: _main + Value: 0 + SectionNumber: 1 + SimpleType: IMAGE_SYM_TYPE_NULL + ComplexType: IMAGE_SYM_DTYPE_FUNCTION + StorageClass: IMAGE_SYM_CLASS_EXTERNAL +... diff --git a/test/COFF/strtab-size.s b/test/COFF/strtab-size.s new file mode 100644 index 000000000000..6b29049f548c --- /dev/null +++ b/test/COFF/strtab-size.s @@ -0,0 +1,216 @@ +# REQUIRES: x86 + +# Test that the strtab size is included in the allocation even if the +# strtab itself is empty. To achieve this, we need a number of symbols N +# where alignTo(N*18, 512) < alignTo(N*18 + 4, 512), where the first +# positive N fulfilling that is 199. + +# RUN: llvm-mc -triple=x86_64-windows-msvc %s -filetype=obj -o %t.obj +# RUN: lld-link -out:%t.exe -entry:main %t.obj -debug:dwarf + +# If the size of the strtab isn't allocated for, llvm-readobj would +# output SymbolCount: 0 (and dumpbin.exe would error out with "invalid file +# or disk full, cannot seek to 0x1602"). + +# RUN: llvm-readobj -file-headers %t.exe | FileCheck %s +# CHECK: SymbolCount: 199 + +.global main +.text +main: +sym0: +sym1: +sym2: +sym3: +sym4: +sym5: +sym6: +sym7: +sym8: +sym9: +sym10: +sym11: +sym12: +sym13: +sym14: +sym15: +sym16: +sym17: +sym18: +sym19: +sym20: +sym21: +sym22: +sym23: +sym24: +sym25: +sym26: +sym27: +sym28: +sym29: +sym30: +sym31: +sym32: +sym33: +sym34: +sym35: +sym36: +sym37: +sym38: +sym39: +sym40: +sym41: +sym42: +sym43: +sym44: +sym45: +sym46: +sym47: +sym48: +sym49: +sym50: +sym51: +sym52: +sym53: +sym54: +sym55: +sym56: +sym57: +sym58: +sym59: +sym60: +sym61: +sym62: +sym63: +sym64: +sym65: +sym66: +sym67: +sym68: +sym69: +sym70: +sym71: +sym72: +sym73: +sym74: +sym75: +sym76: +sym77: +sym78: +sym79: +sym80: +sym81: +sym82: +sym83: +sym84: +sym85: +sym86: +sym87: +sym88: +sym89: +sym90: +sym91: +sym92: +sym93: +sym94: +sym95: +sym96: +sym97: +sym98: +sym99: +sym100: +sym101: +sym102: +sym103: +sym104: +sym105: +sym106: +sym107: +sym108: +sym109: +sym110: +sym111: +sym112: +sym113: +sym114: +sym115: +sym116: +sym117: +sym118: +sym119: +sym120: +sym121: +sym122: +sym123: +sym124: +sym125: +sym126: +sym127: +sym128: +sym129: +sym130: +sym131: +sym132: +sym133: +sym134: +sym135: +sym136: +sym137: +sym138: +sym139: +sym140: +sym141: +sym142: +sym143: +sym144: +sym145: +sym146: +sym147: +sym148: +sym149: +sym150: +sym151: +sym152: +sym153: +sym154: +sym155: +sym156: +sym157: +sym158: +sym159: +sym160: +sym161: +sym162: +sym163: +sym164: +sym165: +sym166: +sym167: +sym168: +sym169: +sym170: +sym171: +sym172: +sym173: +sym174: +sym175: +sym176: +sym177: +sym178: +sym179: +sym180: +sym181: +sym182: +sym183: +sym184: +sym185: +sym186: +sym187: +sym188: +sym189: +sym190: +sym191: +sym192: +sym193: +sym194: + ret diff --git a/test/COFF/subsystem-drectve.test b/test/COFF/subsystem-drectve.test new file mode 100644 index 000000000000..fa567bc7a9af --- /dev/null +++ b/test/COFF/subsystem-drectve.test @@ -0,0 +1,21 @@ +# RUN: yaml2obj < %s > %t.obj +# RUN: lld-link /dll /noentry /out:%t.dll %t.obj +# RUN: llvm-readobj -file-headers %t.dll | FileCheck %s + +# CHECK: MajorOperatingSystemVersion: 42 +# CHECK: MinorOperatingSystemVersion: 43 +# CHECK: MajorSubsystemVersion: 42 +# CHECK: MinorSubsystemVersion: 43 +# CHECK: Subsystem: IMAGE_SUBSYSTEM_WINDOWS_CUI + +--- !COFF +header: + Machine: IMAGE_FILE_MACHINE_I386 + Characteristics: [] +sections: + - Name: .drectve + Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ] + Alignment: 1 + SectionData: 2f73756273797374656d3a636f6e736f6c652c34322e343300 # /subsystem:console,42.43 +symbols: +... diff --git a/test/COFF/symtab.test b/test/COFF/symtab.test index ffaca285d6f0..4e46e3383a4a 100644 --- a/test/COFF/symtab.test +++ b/test/COFF/symtab.test @@ -1,10 +1,10 @@ # RUN: yaml2obj < %s > %t.obj -# RUN: lld-link /debug /out:%t.exe /entry:main %t.obj %p/Inputs/std64.lib +# RUN: lld-link /debug:dwarf /out:%t.exe /entry:main %t.obj %p/Inputs/std64.lib # RUN: llvm-readobj -symbols %t.exe | FileCheck %s -# RUN: lld-link /debug /opt:noref /out:%t.exe /entry:main %t.obj %p/Inputs/std64.lib +# RUN: lld-link /debug:dwarf /opt:noref /out:%t.exe /entry:main %t.obj %p/Inputs/std64.lib # RUN: llvm-readobj -symbols %t.exe | FileCheck %s -# RUN: lld-link /debug /nosymtab /out:%t.exe /entry:main %t.obj %p/Inputs/std64.lib +# RUN: lld-link /debug /out:%t.exe /entry:main %t.obj %p/Inputs/std64.lib # RUN: llvm-readobj -symbols %t.exe | FileCheck -check-prefix=NO %s # CHECK: Symbols [ diff --git a/test/COFF/thinlto.ll b/test/COFF/thinlto.ll index f01d0d802289..77ba9b91de70 100644 --- a/test/COFF/thinlto.ll +++ b/test/COFF/thinlto.ll @@ -4,7 +4,7 @@ ; RUN: opt -thinlto-bc -o %T/thinlto/main.obj %s ; RUN: opt -thinlto-bc -o %T/thinlto/foo.obj %S/Inputs/lto-dep.ll ; RUN: lld-link /lldsavetemps /out:%T/thinlto/main.exe /entry:main /subsystem:console %T/thinlto/main.obj %T/thinlto/foo.obj -; RUN: llvm-nm %T/thinlto/main.exe.lto.obj | FileCheck %s +; RUN: llvm-nm %T/thinlto/main.exe1.lto.obj | FileCheck %s ; CHECK-NOT: U foo diff --git a/test/COFF/wholearchive.s b/test/COFF/wholearchive.s new file mode 100644 index 000000000000..da9976382b0d --- /dev/null +++ b/test/COFF/wholearchive.s @@ -0,0 +1,19 @@ +# REQEUIRES: x86 + +# RUN: yaml2obj < %p/Inputs/export.yaml > %t.archive.obj +# RUN: llvm-ar rcs %t.archive.lib %t.archive.obj +# RUN: llvm-mc -triple=x86_64-windows-msvc %s -filetype=obj -o %t.main.obj + +# RUN: lld-link -dll -out:%t.dll -entry:main %t.main.obj -wholearchive:%t.archive.lib -implib:%t.lib +# RUN: llvm-readobj %t.lib | FileCheck %s -check-prefix CHECK-IMPLIB + +# RUN: lld-link -dll -out:%t.dll -entry:main %t.main.obj -wholearchive %t.archive.lib -implib:%t.lib +# RUN: llvm-readobj %t.lib | FileCheck %s -check-prefix CHECK-IMPLIB + +# CHECK-IMPLIB: Symbol: __imp_exportfn3 +# CHECK-IMPLIB: Symbol: exportfn3 + +.global main +.text +main: + ret diff --git a/test/COFF/wx.s b/test/COFF/wx.s new file mode 100644 index 000000000000..3a470edc261c --- /dev/null +++ b/test/COFF/wx.s @@ -0,0 +1,17 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -triple=x86_64-windows-msvc -filetype=obj -o %t.obj %s +# RUN: not lld-link /out:%t.exe /entry:main -notarealoption /WX %t.obj 2>&1 | \ +# RUN: FileCheck -check-prefix=ERROR %s +# RUN: not lld-link /out:%t.exe /entry:main -notarealoption /WX:NO /WX %t.obj 2>&1 | \ +# RUN: FileCheck -check-prefix=ERROR %s +# RUN: lld-link /out:%t.exe /entry:main -notarealoption /WX /WX:NO %t.obj 2>&1 | \ +# RUN: FileCheck -check-prefix=WARNING %s + +# ERROR: error: ignoring unknown argument: -notarealoption +# WARNING: warning: ignoring unknown argument: -notarealoption + +.text +.global main +main: + ret diff --git a/test/ELF/Inputs/amdgpu-kernel-0.s b/test/ELF/Inputs/amdgpu-kernel-0.s new file mode 100644 index 000000000000..1567c3fda10f --- /dev/null +++ b/test/ELF/Inputs/amdgpu-kernel-0.s @@ -0,0 +1,6 @@ +.text +.globl kernel_0 +.align 64 +.amdgpu_hsa_kernel kernel_0 +kernel_0: + s_endpgm diff --git a/test/ELF/Inputs/amdgpu-kernel-1.s b/test/ELF/Inputs/amdgpu-kernel-1.s new file mode 100644 index 000000000000..7fb520bfbe32 --- /dev/null +++ b/test/ELF/Inputs/amdgpu-kernel-1.s @@ -0,0 +1,6 @@ +.text +.globl kernel_1 +.align 64 +.amdgpu_hsa_kernel kernel_1 +kernel_1: + s_endpgm diff --git a/test/ELF/Inputs/amdgpu-kernel-2.o b/test/ELF/Inputs/amdgpu-kernel-2.o Binary files differnew file mode 100644 index 000000000000..fa76151f8976 --- /dev/null +++ b/test/ELF/Inputs/amdgpu-kernel-2.o diff --git a/test/ELF/Inputs/copy-rel-abs.s b/test/ELF/Inputs/copy-rel-abs.s new file mode 100644 index 000000000000..66d08807b9c9 --- /dev/null +++ b/test/ELF/Inputs/copy-rel-abs.s @@ -0,0 +1,13 @@ + .global foo + .type foo, @object + .size foo, 4 +foo: + .weak bar + .type bar, @object + .size bar, 4 +bar: + .long 42 + + .weak zed + .type zed, @object + zed = 0x1000 diff --git a/test/ELF/Inputs/copy-rel-large.s b/test/ELF/Inputs/copy-rel-large.s new file mode 100644 index 000000000000..8786a2fa1a3f --- /dev/null +++ b/test/ELF/Inputs/copy-rel-large.s @@ -0,0 +1,4 @@ + .global foo + .type foo, @object +foo: + .size foo, 0x100000001 diff --git a/test/ELF/Inputs/copy-rel-pie.s b/test/ELF/Inputs/copy-rel-pie.s index 6dac01ddec62..b3345ceea672 100644 --- a/test/ELF/Inputs/copy-rel-pie.s +++ b/test/ELF/Inputs/copy-rel-pie.s @@ -9,3 +9,4 @@ foo: .global bar .type bar, @function bar: +retq diff --git a/test/ELF/Inputs/corrupt-version-reference.so b/test/ELF/Inputs/corrupt-version-reference.so Binary files differnew file mode 100644 index 000000000000..ef6adc6a026c --- /dev/null +++ b/test/ELF/Inputs/corrupt-version-reference.so diff --git a/test/ELF/Inputs/dynamic-list-weak-archive.s b/test/ELF/Inputs/dynamic-list-weak-archive.s new file mode 100644 index 000000000000..dd28fcbd5255 --- /dev/null +++ b/test/ELF/Inputs/dynamic-list-weak-archive.s @@ -0,0 +1,2 @@ +.globl foo +foo: diff --git a/test/ELF/Inputs/eh-frame.s b/test/ELF/Inputs/eh-frame.s new file mode 100644 index 000000000000..0aa4008b7b2c --- /dev/null +++ b/test/ELF/Inputs/eh-frame.s @@ -0,0 +1,3 @@ +.cfi_startproc +.cfi_def_cfa_offset 32 +.cfi_endproc diff --git a/test/ELF/Inputs/gc-sections-shared.s b/test/ELF/Inputs/gc-sections-shared.s new file mode 100644 index 000000000000..e7017f566411 --- /dev/null +++ b/test/ELF/Inputs/gc-sections-shared.s @@ -0,0 +1,3 @@ +.global baz +.type baz, @function +baz: diff --git a/test/ELF/Inputs/gc-sections-shared2.s b/test/ELF/Inputs/gc-sections-shared2.s new file mode 100644 index 000000000000..fb69c0e218fb --- /dev/null +++ b/test/ELF/Inputs/gc-sections-shared2.s @@ -0,0 +1,3 @@ +.global qux +.type qux, @function +qux: diff --git a/test/ELF/Inputs/local-symbol-in-dso.so b/test/ELF/Inputs/local-symbol-in-dso.so Binary files differnew file mode 100755 index 000000000000..5062a7aeead2 --- /dev/null +++ b/test/ELF/Inputs/local-symbol-in-dso.so diff --git a/test/ELF/Inputs/map-file5.s b/test/ELF/Inputs/map-file5.s new file mode 100644 index 000000000000..2a89b4c7f6f5 --- /dev/null +++ b/test/ELF/Inputs/map-file5.s @@ -0,0 +1,23 @@ +.bss +.type sharedFoo,@object +.globl sharedFoo +sharedFoo: +.long 0 +.size sharedFoo, 4 + +.type sharedBar,@object +.globl sharedBar +sharedBar: +.quad 0 +.size sharedBar, 8 + +.text +.globl sharedFunc1 +.type sharedFunc1,@function +sharedFunc1: + nop + +.globl sharedFunc2 +.type sharedFunc2,@function +sharedFunc2: + nop diff --git a/test/ELF/Inputs/mips-micro.s b/test/ELF/Inputs/mips-micro.s new file mode 100644 index 000000000000..0d0b11f6fdb2 --- /dev/null +++ b/test/ELF/Inputs/mips-micro.s @@ -0,0 +1,12 @@ + .text + .set micromips + .global foo + .type foo,@function +foo: + nop + + .set nomicromips + .global bar + .type bar,@function +bar: + nop diff --git a/test/ELF/Inputs/shared3.s b/test/ELF/Inputs/shared3.s index d1f6ffea1332..e7017f566411 100644 --- a/test/ELF/Inputs/shared3.s +++ b/test/ELF/Inputs/shared3.s @@ -1,3 +1,3 @@ .global baz -.type barz, @function +.type baz, @function baz: diff --git a/test/ELF/Inputs/undefined-error.s b/test/ELF/Inputs/undefined-error.s new file mode 100644 index 000000000000..84ac4f121361 --- /dev/null +++ b/test/ELF/Inputs/undefined-error.s @@ -0,0 +1 @@ +callq fmod@PLT diff --git a/test/ELF/Inputs/verdef-defaultver.s b/test/ELF/Inputs/verdef-defaultver.s index 6664d62c90f5..d9e7f3829f32 100644 --- a/test/ELF/Inputs/verdef-defaultver.s +++ b/test/ELF/Inputs/verdef-defaultver.s @@ -1,4 +1,7 @@ +.global b@V1 b@V1 = b_1 + +.global b@@V2 b@@V2 = b_2 .globl a diff --git a/test/ELF/Inputs/verneed.so.sh b/test/ELF/Inputs/verneed.so.sh deleted file mode 100755 index 3423f678e47a..000000000000 --- a/test/ELF/Inputs/verneed.so.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/sh -eu - -# This script was used to produce the verneed{1,2}.so files. - -tmp=$(mktemp -d) - -echo "v1 {}; v2 {}; v3 {}; { local: *; };" > $tmp/verneed.script - -cat > $tmp/verneed1.s <<eof -.globl f1_v1 -f1_v1: -ret - -.globl f1_v2 -f1_v2: -ret - -.globl f1_v3 -f1_v3: -ret - -.symver f1_v1, f1@v1 -.symver f1_v2, f1@v2 -.symver f1_v3, f1@@v3 - -.globl f2_v1 -f2_v1: -ret - -.globl f2_v2 -f2_v2: -ret - -.symver f2_v1, f2@v1 -.symver f2_v2, f2@@v2 - -.globl f3_v1 -f3_v1: -ret - -.symver f3_v1, f3@v1 -eof - -as -o $tmp/verneed1.o $tmp/verneed1.s -ld.gold -shared -o verneed1.so $tmp/verneed1.o --version-script $tmp/verneed.script -soname verneed1.so.0 - -cat > $tmp/verneed2.s <<eof -.globl g1_v1 -g1_v1: -ret - -.symver g1_v1, g1@@v1 -eof - -as -o $tmp/verneed2.o $tmp/verneed2.s -ld.gold -shared -o verneed2.so $tmp/verneed2.o --version-script $tmp/verneed.script -soname verneed2.so.0 - -rm -rf $tmp diff --git a/test/ELF/Inputs/verneed1.s b/test/ELF/Inputs/verneed1.s new file mode 100644 index 000000000000..a342d7dd797f --- /dev/null +++ b/test/ELF/Inputs/verneed1.s @@ -0,0 +1,32 @@ +.globl f1_v1 +f1_v1: +ret + +.globl f1_v2 +f1_v2: +ret + +.globl f1_v3 +f1_v3: +ret + +.symver f1_v1, f1@v1 +.symver f1_v2, f1@v2 +.symver f1_v3, f1@@v3 + +.globl f2_v1 +f2_v1: +ret + +.globl f2_v2 +f2_v2: +ret + +.symver f2_v1, f2@v1 +.symver f2_v2, f2@@v2 + +.globl f3_v1 +f3_v1: +ret + +.symver f3_v1, f3@v1 diff --git a/test/ELF/Inputs/verneed1.so b/test/ELF/Inputs/verneed1.so Binary files differdeleted file mode 100755 index 744852b9660a..000000000000 --- a/test/ELF/Inputs/verneed1.so +++ /dev/null diff --git a/test/ELF/Inputs/verneed2.s b/test/ELF/Inputs/verneed2.s new file mode 100644 index 000000000000..1b46de6880b1 --- /dev/null +++ b/test/ELF/Inputs/verneed2.s @@ -0,0 +1,5 @@ +.globl g1_v1 +g1_v1: +ret + +.symver g1_v1, g1@@v1 diff --git a/test/ELF/Inputs/verneed2.so b/test/ELF/Inputs/verneed2.so Binary files differdeleted file mode 100755 index ba6c05ee6b1c..000000000000 --- a/test/ELF/Inputs/verneed2.so +++ /dev/null diff --git a/test/ELF/Inputs/weak-undef-lazy.s b/test/ELF/Inputs/weak-undef-lazy.s new file mode 100644 index 000000000000..c77477315156 --- /dev/null +++ b/test/ELF/Inputs/weak-undef-lazy.s @@ -0,0 +1,3 @@ +.global foobar +foobar: + nop diff --git a/test/ELF/Inputs/wrap-no-real.s b/test/ELF/Inputs/wrap-no-real.s new file mode 100644 index 000000000000..2fd1bcc6bc29 --- /dev/null +++ b/test/ELF/Inputs/wrap-no-real.s @@ -0,0 +1,3 @@ +.globl foo, __wrap_foo +foo = 0x11000 +__wrap_foo = 0x11010 diff --git a/test/ELF/Inputs/wrap-no-real2.s b/test/ELF/Inputs/wrap-no-real2.s new file mode 100644 index 000000000000..dbcb0889b965 --- /dev/null +++ b/test/ELF/Inputs/wrap-no-real2.s @@ -0,0 +1,2 @@ +.globl __real_foo +__real_foo = 0x11020 diff --git a/test/ELF/Inputs/wrap.s b/test/ELF/Inputs/wrap.s index 584e27033d5c..e0765196606b 100644 --- a/test/ELF/Inputs/wrap.s +++ b/test/ELF/Inputs/wrap.s @@ -1,4 +1,7 @@ -.globl foo, __wrap_foo, __real_foo +.global foo +.weak __wrap_foo +.protected __wrap_foo +.global __real_foo foo = 0x11000 __wrap_foo = 0x11010 __real_foo = 0x11020 diff --git a/test/ELF/aarch64-abs16.s b/test/ELF/aarch64-abs16.s index c4f5b3e44b58..20a65b1cf4a8 100644 --- a/test/ELF/aarch64-abs16.s +++ b/test/ELF/aarch64-abs16.s @@ -24,4 +24,4 @@ _start: // | FileCheck %s --check-prefix=OVERFLOW // RUN: not ld.lld %t.o %t257.o -o %t2 // | FileCheck %s --check-prefix=OVERFLOW -// OVERFLOW: Relocation R_AARCH64_ABS16 out of range +// OVERFLOW: Relocation R_AARCH64_ABS16 out of range: 65536 is not in [-32768, 65535] diff --git a/test/ELF/aarch64-abs32.s b/test/ELF/aarch64-abs32.s index b051692374b1..b93f27a0bc4b 100644 --- a/test/ELF/aarch64-abs32.s +++ b/test/ELF/aarch64-abs32.s @@ -24,4 +24,4 @@ _start: // | FileCheck %s --check-prefix=OVERFLOW // RUN: not ld.lld %t.o %t257.o -o %t2 // | FileCheck %s --check-prefix=OVERFLOW -// OVERFLOW: Relocation R_AARCH64_ABS32 out of range +// OVERFLOW: Relocation R_AARCH64_ABS32 out of range: 4294967296 is not in [-2147483648, 4294967295] diff --git a/test/ELF/aarch64-call26-error.s b/test/ELF/aarch64-call26-error.s deleted file mode 100644 index 4b666c69011a..000000000000 --- a/test/ELF/aarch64-call26-error.s +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %S/Inputs/abs.s -o %tabs -// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %s -o %t -// RUN: not ld.lld %t %tabs -o %t2 2>&1 | FileCheck %s -// REQUIRES: aarch64 - -.text -.globl _start -_start: - bl big - -// CHECK: R_AARCH64_CALL26 out of range diff --git a/test/ELF/aarch64-call26-thunk.s b/test/ELF/aarch64-call26-thunk.s new file mode 100644 index 000000000000..0fe99cec974d --- /dev/null +++ b/test/ELF/aarch64-call26-thunk.s @@ -0,0 +1,21 @@ +// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %S/Inputs/abs.s -o %tabs +// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %s -o %t +// RUN: ld.lld %t %tabs -o %t2 2>&1 +// RUN: llvm-objdump -d -triple=aarch64-pc-freebsd %t2 | FileCheck %s +// REQUIRES: aarch64 + +.text +.globl _start +_start: + bl big + +// CHECK: Disassembly of section .text: +// CHECK-NEXT: _start: +// CHECK-NEXT: 20000: 02 00 00 94 bl #8 +// CHECK: __AArch64AbsLongThunk_big: +// CHECK-NEXT: 20008: 50 00 00 58 ldr x16, #8 +// CHECK-NEXT: 2000c: 00 02 1f d6 br x16 +// CHECK: $d: +// CHECK-NEXT: 20010: 00 00 00 00 .word 0x00000000 +// CHECK-NEXT: 20014: 10 00 00 00 .word 0x00000010 + diff --git a/test/ELF/aarch64-cortex-a53-843419-address.s b/test/ELF/aarch64-cortex-a53-843419-address.s new file mode 100644 index 000000000000..e9f6ff4c38db --- /dev/null +++ b/test/ELF/aarch64-cortex-a53-843419-address.s @@ -0,0 +1,180 @@ +// REQUIRES: aarch64 +// RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux %s -o %t.o +// RUN: echo "SECTIONS { \ +// RUN: .text : { *(.text) *(.text.*) *(.newisd) } \ +// RUN: .text2 : { *.(newos) } \ +// RUN: .data : { *(.data) } }" > %t.script +// RUN: ld.lld --script %t.script -fix-cortex-a53-843419 -verbose %t.o -o %t2 | FileCheck -check-prefix=CHECK-PRINT %s +// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 | FileCheck %s + +// Test cases for Cortex-A53 Erratum 843419 that involve interactions +// between the generated patches and the address of sections. + +// See ARM-EPM-048406 Cortex_A53_MPCore_Software_Developers_Errata_Notice.pdf +// for full erratum details. +// In Summary +// 1.) +// ADRP (0xff8 or 0xffc). +// 2.) +// - load or store single register or either integer or vector registers. +// - STP or STNP of either vector or vector registers. +// - Advanced SIMD ST1 store instruction. +// - Must not write Rn. +// 3.) optional instruction, can't be a branch, must not write Rn, may read Rn. +// 4.) A load or store instruction from the Load/Store register unsigned +// immediate class using Rn as the base register. + +// An aarch64 section can contain ranges of literal data embedded within the +// code, these ranges are encoded with mapping symbols. This tests that we +// can match the erratum sequence in code, but not data. +// - We can handle more than one patch per code range (denoted by mapping +// symbols). +// - We can handle a patch in more than range of code, with literal data +// inbetween. +// - We can handle redundant mapping symbols (two or more consecutive mapping +// symbols with the same type). +// - We can ignore erratum sequences in multiple literal data ranges. + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at FF8 in unpatched output. +// CHECK: t3_ff8_ldr: +// CHECK-NEXT: ff8: 20 00 00 d0 adrp x0, #24576 +// CHECK-NEXT: ffc: 21 00 40 f9 ldr x1, [x1] +// CHECK-NEXT: 1000: f9 0f 00 14 b #16356 +// CHECK-NEXT: 1004: c0 03 5f d6 ret + .section .text.01, "ax", %progbits + .balign 4096 + .space 4096 - 8 + .globl t3_ff8_ldr + .type t3_ff8_ldr, %function +t3_ff8_ldr: + adrp x0, dat + ldr x1, [x1, #0] + ldr x0, [x0, :got_lo12:dat] + ret + + // create a redundant mapping symbol as we are already in a $x range + // some object producers unconditionally generate a mapping symbol on + // every symbol so we need to handle the case of $x $x. + .local $x.999 +$x.999: +// CHECK-PRINT-NEXT: detected cortex-a53-843419 erratum sequence starting at 1FFC in unpatched output. +// CHECK: t3_ffc_ldrsimd: +// CHECK-NEXT: 1ffc: 20 00 00 b0 adrp x0, #20480 +// CHECK-NEXT: 2000: 21 00 40 bd ldr s1, [x1] +// CHECK-NEXT: 2004: fa 0b 00 14 b #12264 +// CHECK-NEXT: 2008: c0 03 5f d6 ret + .globl t3_ffc_ldrsimd + .type t3_ffc_ldrsimd, %function + .space 4096 - 12 +t3_ffc_ldrsimd: + adrp x0, dat + ldr s1, [x1, #0] + ldr x2, [x0, :got_lo12:dat] + ret + +// Inline data containing bit pattern of erratum sequence, expect no patch. + .globl t3_ffc_ldralldata + .type t3_ff8_ldralldata, %function + .space 4096 - 20 +t3_ff8_ldralldata: + // 0x90000000 = adrp x0, #0 + .byte 0x00 + .byte 0x00 + .byte 0x00 + .byte 0x90 + // 0xf9400021 = ldr x1, [x1] + .byte 0x21 + .byte 0x00 + .byte 0x40 + .byte 0xf9 + // 0xf9400000 = ldr x0, [x0] + .byte 0x00 + .byte 0x00 + .byte 0x40 + .byte 0xf9 + // Check that we can recognise the erratum sequence post literal data. + +// CHECK-PRINT-NEXT: detected cortex-a53-843419 erratum sequence starting at 3FF8 in unpatched output. +// CHECK: t3_ffc_ldr: +// CHECK-NEXT: 3ff8: 00 00 00 f0 adrp x0, #12288 +// CHECK-NEXT: 3ffc: 21 00 40 f9 ldr x1, [x1] +// CHECK-NEXT: 4000: fd 03 00 14 b #4084 +// CHECK-NEXT: 4004: c0 03 5f d6 ret + .space 4096 - 12 + .globl t3_ffc_ldr + .type t3_ffc_ldr, %function + t3_ffc_ldr: + adrp x0, dat + ldr x1, [x1, #0] + ldr x0, [x0, :got_lo12:dat] + ret + +// CHECK: __CortexA53843419_1000: +// CHECK-NEXT: 4fe4: 00 0c 40 f9 ldr x0, [x0, #24] +// CHECK-NEXT: 4fe8: 07 f0 ff 17 b #-16356 +// CHECK: __CortexA53843419_2004: +// CHECK-NEXT: 4fec: 02 0c 40 f9 ldr x2, [x0, #24] +// CHECK-NEXT: 4ff0: 06 f4 ff 17 b #-12264 +// CHECK: __CortexA53843419_4000: +// CHECK-NEXT: 4ff4: 00 0c 40 f9 ldr x0, [x0, #24] +// CHECK-NEXT: 4ff8: 03 fc ff 17 b #-4084 + + .section .text.02, "ax", %progbits + .space 4096 - 36 + + // Start a new InputSectionDescription (see Linker Script) so the + // start address will be affected by any patches added to previous + // InputSectionDescription. + +// CHECK-PRINT-NEXT: detected cortex-a53-843419 erratum sequence starting at 4FFC in unpatched output +// CHECK: t3_ffc_str: +// CHECK-NEXT: 4ffc: 00 00 00 d0 adrp x0, #8192 +// CHECK-NEXT: 5000: 21 00 00 f9 str x1, [x1] +// CHECK-NEXT: 5004: fb 03 00 14 b #4076 +// CHECK-NEXT: 5008: c0 03 5f d6 ret + + .section .newisd, "ax", %progbits + .globl t3_ffc_str + .type t3_ffc_str, %function +t3_ffc_str: + adrp x0, dat + str x1, [x1, #0] + ldr x0, [x0, :got_lo12:dat] + ret + .space 4096 - 28 + +// CHECK: __CortexA53843419_5004: +// CHECK-NEXT: 5ff0: 00 0c 40 f9 ldr x0, [x0, #24] +// CHECK-NEXT: 5ff4: 05 fc ff 17 b #-4076 + + // Start a new OutputSection (see Linker Script) so the + // start address will be affected by any patches added to previous + // InputSectionDescription. + +//CHECK-PRINT-NEXT: detected cortex-a53-843419 erratum sequence starting at 5FF8 in unpatched output +// CHECK: t3_ff8_str: +// CHECK-NEXT: 5ff8: 00 00 00 b0 adrp x0, #4096 +// CHECK-NEXT: 5ffc: 21 00 00 f9 str x1, [x1] +// CHECK-NEXT: 6000: 03 00 00 14 b #12 +// CHECK-NEXT: 6004: c0 03 5f d6 ret + + .section .newos, "ax", %progbits + .globl t3_ff8_str + .type t3_ff8_str, %function +t3_ff8_str: + adrp x0, dat + str x1, [x1, #0] + ldr x0, [x0, :got_lo12:dat] + ret + .globl _start + .type _start, %function +_start: + ret + +// CHECK: __CortexA53843419_6000: +// CHECK-NEXT: 600c: 00 0c 40 f9 ldr x0, [x0, #24] +// CHECK-NEXT: 6010: fd ff ff 17 b #-12 + + .data + .globl dat +dat: .word 0 diff --git a/test/ELF/aarch64-cortex-a53-843419-cli.s b/test/ELF/aarch64-cortex-a53-843419-cli.s new file mode 100644 index 000000000000..30abc8f06d20 --- /dev/null +++ b/test/ELF/aarch64-cortex-a53-843419-cli.s @@ -0,0 +1,10 @@ +// REQUIRES: x86 +// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +// RUN: not ld.lld %t -fix-cortex-a53-843419 -o %t2 2>&1 | FileCheck %s + +// CHECK: --fix-cortex-a53-843419 is only supported on AArch64 targets. +.globl entry +.text + .quad 0 +entry: + ret diff --git a/test/ELF/aarch64-cortex-a53-843419-large.s b/test/ELF/aarch64-cortex-a53-843419-large.s new file mode 100644 index 000000000000..00c92ebeb182 --- /dev/null +++ b/test/ELF/aarch64-cortex-a53-843419-large.s @@ -0,0 +1,115 @@ +// REQUIRES: aarch64 +// RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux %s -o %t.o +// RUN: ld.lld --fix-cortex-a53-843419 %t.o -o %t2 +// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=131072 -stop-address=131084 | FileCheck --check-prefix=CHECK1 %s +// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=135168 -stop-address=135172 | FileCheck --check-prefix=CHECK2 %s +// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=139256 -stop-address=139272 | FileCheck --check-prefix=CHECK3 %s +// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=67256312 -stop-address=67256328 | FileCheck --check-prefix=CHECK4 %s +// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=100810760 -stop-address=100810776 | FileCheck --check-prefix=CHECK5 %s +// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=134352908 -stop-address=134352912 | FileCheck --check-prefix=CHECK6 %s +// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 -start-address=134356988 -stop-address=134357012 | FileCheck --check-prefix=CHECK7 %s +// Test case for Cortex-A53 Erratum 843419 in an OutputSection exceeding +// the maximum branch range. Both range extension thunks and patches are +// required. + +// CHECK1: __AArch64AbsLongThunk_need_thunk_after_patch: +// CHECK1-NEXT: 20000: 50 00 00 58 ldr x16, #8 +// CHECK1-NEXT: 20004: 00 02 1f d6 br x16 +// CHECK1: $d: +// CHECK1-NEXT: 20008: 0c 10 02 08 .word 0x0802100c + + .section .text.01, "ax", %progbits + .balign 4096 + .globl _start + .type _start, %function +_start: + // Expect thunk on pass 2 + bl need_thunk_after_patch + .section .text.02, "ax", %progbits + .space 4096 - 12 + +// CHECK2: _start: +// CHECK2-NEXT: 21000: 00 fc ff 97 bl #-4096 + + // Expect patch on pass 1 + .section .text.03, "ax", %progbits + .globl t3_ff8_ldr + .type t3_ff8_ldr, %function +t3_ff8_ldr: + adrp x0, dat + ldr x1, [x1, #0] + ldr x0, [x0, :got_lo12:dat] + ret + +// CHECK3: t3_ff8_ldr: +// CHECK3-NEXT: 21ff8: 60 00 04 f0 adrp x0, #134279168 +// CHECK3-NEXT: 21ffc: 21 00 40 f9 ldr x1, [x1] +// CHECK3-NEXT: 22000: 02 08 80 15 b #100671496 +// CHECK3-NEXT: 22004: c0 03 5f d6 ret + + .section .text.04, "ax", %progbits + .space 64 * 1024 * 1024 + + // Expect patch on pass 1 + .section .text.05, "ax", %progbits + .balign 4096 + .space 4096 - 8 + .globl t3_ff8_str + .type t3_ff8_str, %function +t3_ff8_str: + adrp x0, dat + ldr x1, [x1, #0] + str x0, [x0, :got_lo12:dat] + ret + +// CHECK4: t3_ff8_str: +// CHECK4-NEXT: 4023ff8: 60 00 02 b0 adrp x0, #67162112 +// CHECK4-NEXT: 4023ffc: 21 00 40 f9 ldr x1, [x1] +// CHECK4-NEXT: 4024000: 04 00 80 14 b #33554448 +// CHECK4-NEXT: 4024004: c0 03 5f d6 ret + + .section .text.06, "ax", %progbits + .space 32 * 1024 * 1024 + +// CHECK5: __CortexA53843419_21000: +// CHECK5-NEXT: 6024008: 00 00 40 f9 ldr x0, [x0] +// CHECK5-NEXT: 602400c: fe f7 7f 16 b #-100671496 +// CHECK5: __CortexA53843419_4023000: +// CHECK5-NEXT: 6024010: 00 00 00 f9 str x0, [x0] +// CHECK5-NEXT: 6024014: fc ff 7f 17 b #-33554448 + + .section .text.07, "ax", %progbits + .space (32 * 1024 * 1024) - 12300 + + .section .text.08, "ax", %progbits + .globl need_thunk_after_patch + .type need_thunk_after_patch, %function +need_thunk_after_patch: + ret + +// CHECK6: need_thunk_after_patch: +// CHECK6-NEXT: 802100c: c0 03 5f d6 ret + + // Will need a patch on pass 2 + .section .text.09, "ax", %progbits + .space 4096 - 20 + .globl t3_ffc_ldr + .type t3_ffc_ldr, %function +t3_ffc_ldr: + adrp x0, dat + ldr x1, [x1, #0] + ldr x0, [x0, :got_lo12:dat] + ret + +// CHECK7: t3_ffc_ldr: +// CHECK7-NEXT: 8021ffc: 60 00 00 f0 adrp x0, #61440 +// CHECK7-NEXT: 8022000: 21 00 40 f9 ldr x1, [x1] +// CHECK7-NEXT: 8022004: 02 00 00 14 b #8 +// CHECK7-NEXT: 8022008: c0 03 5f d6 ret +// CHECK7: __CortexA53843419_8022004: +// CHECK7-NEXT: 802200c: 00 00 40 f9 ldr x0, [x0] +// CHECK7-NEXT: 8022010: fe ff ff 17 b #-8 + + .section .data + .globl dat +dat: .quad 0 diff --git a/test/ELF/aarch64-cortex-a53-843419-nopatch.s b/test/ELF/aarch64-cortex-a53-843419-nopatch.s new file mode 100644 index 000000000000..389bf4505735 --- /dev/null +++ b/test/ELF/aarch64-cortex-a53-843419-nopatch.s @@ -0,0 +1,338 @@ +// REQUIRES: aarch64 +// RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux %s -o %t.o +// RUN: ld.lld -fix-cortex-a53-843419 -verbose -t %t.o -o %t2 | FileCheck %s +// Test cases for Cortex-A53 Erratum 843419 that we don't expect to recognize +// as needing a patch as one or more of the conditions isn't satisfied. +// See ARM-EPM-048406 Cortex_A53_MPCore_Software_Developers_Errata_Notice.pdf +// for full erratum details. +// In Summary +// 1.) +// ADRP (0xff8 or 0xffc) +// 2.) +// - load or store single register or either integer or vector registers +// - STP or STNP of either vector or vector registers +// - Advanced SIMD ST1 store instruction +// Must not write Rn +// 3.) optional instruction, can't be a branch, must not write Rn, may read Rn +// 4.) A load or store instruction from the Load/Store register unsigned +// immediate class using Rn as the base register + +// Expect no patches detected. +// CHECK-NOT: detected cortex-a53-843419 erratum sequence + +// erratum sequence but adrp (address & 0xfff) is not 0xff8 or 0xffc + .section .text.01, "ax", %progbits + .balign 4096 + .globl t3_0_ldr + .type t3_ff8_ldr, %function +t3_0_ldr: + adrp x0, dat + ldr x1, [x1, #0] + ldr x0, [x0, :got_lo12:dat] + ret + + .section .text.02, "ax", %progbits + .balign 4096 + .globl t3_ff4_ldr + .space 4096 - 12 + .type t3_ff4_ldr, %function +t3_ff4_ldr: + adrp x0, dat + ldr x1, [x1, #0] + ldr x0, [x0, :got_lo12:dat] + ret + +// Close matches for erratum sequence, with adrp at correct address but +// instruction 2 is a load or store but not one that matches the erratum +// conditions, but with a similar encoding to an instruction that does. + + // ldp is not part of sequence, although stp is. + .section .text.03, "ax", %progbits + .balign 4096 + .globl t3_ff8_ldp + .type t3_ff8_ldp, %function + .space 4096 - 8 +t3_ff8_ldp: + adrp x16, dat + ldp x1,x2, [x3, #0] + ldr x13, [x16, :got_lo12:dat] + ret + + // st2 is not part of sequence although st1 is. + .section .text.04, "ax", %progbits + .balign 4096 + .globl t3_ffc_st2 + .type t3_ffc_st2, %function + .space 4096 - 4 +t3_ffc_st2: + adrp x16, dat + st2 { v0.16b, v1.16b }, [x1] + ldr x13, [x16, :got_lo12:dat] + ret + + // st3 is not part of sequence although st1 is. + .section .text.05, "ax", %progbits + .balign 4096 + .globl t3_ffc_st3 + .type t3_ffc_st3, %function + .space 4096 - 4 +t3_ffc_st3: + adrp x16, dat + st3 { v0.16b, v1.16b, v2.16b }, [x1], x2 + ldr x13, [x16, :got_lo12:dat] + ret + + // ld1 is not part of sequence although st1 is. + .section .text.06, "ax", %progbits + .balign 4096 + .globl t3_ffc_ld2 + .type t3_ffc_st3, %function + .space 4096 - 4 +t3_ffc_ld1: + adrp x16, dat + ld1 { v0.16b }, [x2], x3 + ldr x13, [x16, :got_lo12:dat] + ret + + // ldnp is not part of sequence although stnp is. + .section .text.07, "ax", %progbits + .balign 4096 + .globl t4_ff8_ldnp + .type t4_ff8_ldnp, %function + .space 4096 - 8 +t4_ff8_ldnp: + adrp x7, dat + ldnp x1,x2, [x3, #0] + nop + ldr x10, [x7, :got_lo12:dat] + ret + +// Close match for erratum sequence, with adrp at correct address but +// instruction 2 writes to Rn, with Rn as either destination or as the +// transfer register but with writeback. + + // ldr instruction writes to Rn + .section .text.08, "ax", %progbits + .balign 4096 + .globl t3_ff8_ldr + .type t3_ff8_ldr, %function + .space 4096 - 8 +t3_ff8_ldr: + adrp x0, dat + ldr x0, [x1, #0] + ldr x0, [x0, :got_lo12:dat] + ret + + // str instruction writes to Rn via writeback (pre index) + .section .text.09, "ax", %progbits + .balign 4096 + .globl t3_ff8_str + .type t3_ff8_str, %function + .space 4096 - 8 +t3_ff8_str: + adrp x0, dat + str x1, [x0, #4]! + ldr x0, [x0, :got_lo12:dat] + ret + + // ldr instruction writes to Rn via writeback (post index) + .section .text.09, "ax", %progbits + .balign 4096 + .globl t3_ffc_ldr + .type t3_ffc_ldr, %function + .space 4096 - 8 +t3_ffc_ldr: + adrp x0, dat + ldr x1, [x0], 0x8 + ldr x0, [x0, :got_lo12:dat] + ret + + // stp writes to Rn via writeback (pre index) + .section .text.10, "ax", %progbits + .balign 4096 + .globl t4_ffc_stppre + .type t4_ffc_stppre, %function + .space 4096 - 4 +t4_ffc_stppre: + adrp x16, dat + stp x1,x2, [x16, #16]! + mul x3, x16, x16 + ldr x14, [x16, #8] + ret + + // stp writes to Rn via writeback (post index) + .section .text.11, "ax", %progbits + .balign 4096 + .globl t4_ff8_stppost + .type t4_ff8_stppost, %function + .space 4096 - 8 +t4_ff8_stppost: + adrp x16, dat + stp x1,x2, [x16], #16 + mul x3, x16, x16 + ldr x14, [x16, #8] + ret + + // st1 writes to Rn via writeback + .section .text.12, "ax", %progbits + .balign 4096 + .globl t3_ff8_st1 + .type t3_ff8_st1, %function + .space 4096 - 8 +t3_ff8_st1: + adrp x16, dat + st1 { v0.16b}, [x16], x2 + ldr x13, [x16, :got_lo12:dat] + ret + +// Close match for erratum sequence, but with optional instruction 3 a branch + + // function call via immediate + .section .text.13, "ax", %progbits + .balign 4096 + .globl t4_ffc_blimm + .type t4_ffc_blimm, %function + .space 4096 - 4 +t4_ffc_blimm: + adrp x7, dat + stnp x1,x2, [x3, #0] + bl t4_ffc_blimm + ldr x10, [x7, :got_lo12:dat] + ret + + // function call via register + .section .text.14, "ax", %progbits + .balign 4096 + .globl t4_ffc_blreg + .type t4_ffc_blreg, %function + .space 4096 - 4 +t4_ffc_blreg: + adrp x7, dat + stnp x1,x2, [x3, #0] + blr x4 + ldr x10, [x7, :got_lo12:dat] + ret + + // Unconditional branch immediate + .section .text.15, "ax", %progbits + .balign 4096 + .globl t4_ffc_branchimm + .type t4_ffc_branchimm, %function + .space 4096 - 4 +t4_ffc_branchimm: + adrp x7, dat + stnp x1,x2, [x3, #0] + b t4_ffc_branchimm + ldr x10, [x7, :got_lo12:dat] + ret + + // Unconditional branch register + .section .text.16, "ax", %progbits + .balign 4096 + .globl t4_ffc_branchreg + .type t4_ffc_branchreg, %function + .space 4096 - 4 +t4_ffc_branchreg: + adrp x7, dat + stnp x1,x2, [x3, #0] + br x4 + ldr x10, [x7, :got_lo12:dat] + ret + + // Conditional branch + .section .text.17, "ax", %progbits + .balign 4096 + .globl t4_ffc_branchcond + .type t4_ffc_branchcond, %function + .space 4096 - 4 +t4_ffc_branchcond: + adrp x7, dat + stnp x1,x2, [x3, #0] + cbz x5, t4_ffc_branchcond + ldr x10, [x7, :got_lo12:dat] + ret + + // Conditional branch immediate + .section .text.18, "ax", %progbits + .balign 4096 + .globl t4_ffc_branchcondimm + .type t4_ffc_branchcondimm, %function + .space 4096 - 4 +t4_ffc_branchcondimm: + adrp x7, dat + stnp x1,x2, [x3, #0] + beq t4_ffc_branchcondimm + ldr x10, [x7, :got_lo12:dat] + ret + +// Bitpattern matches erratum sequence but either all or part of the sequence +// is in inline literal data + .section .text.19, "ax", %progbits + .balign 4096 + .globl t3_ffc_ldrtraildata + .type t3_ff8_ldrtraildata, %function + .space 4096 - 8 +t3_ff8_ldrtraildata: + adrp x0, dat + ldr x1, [x1, #0] + // 0xf9400000 = ldr x0, [x0] + .byte 0x00 + .byte 0x00 + .byte 0x40 + .byte 0xf9 + ldr x0, [x0, :got_lo12:dat] + ret + + .section .text.20, "ax", %progbits + .balign 4096 + .globl t3_ffc_ldrpredata + .type t3_ff8_ldrpredata, %function + .space 4096 - 8 +t3_ff8_ldrpredata: + // 0x90000000 = adrp x0, #0 + .byte 0x00 + .byte 0x00 + .byte 0x00 + .byte 0x90 + ldr x1, [x1, #0] + ldr x0, [x0, :got_lo12:dat] + ret + + .section .text.21, "ax", %progbits + .balign 4096 + .globl t3_ffc_ldralldata + .type t3_ff8_ldralldata, %function + .space 4096 - 8 +t3_ff8_ldralldata: + // 0x90000000 = adrp x0, #0 + .byte 0x00 + .byte 0x00 + .byte 0x00 + .byte 0x90 + // 0xf9400021 = ldr x1, [x1] + .byte 0x21 + .byte 0x00 + .byte 0x40 + .byte 0xf9 + // 0xf9400000 = ldr x0, [x0] + .byte 0x00 + .byte 0x00 + .byte 0x40 + .byte 0xf9 + + ret + + .text + .globl _start + .type _start, %function +_start: + ret + + + + + +// Bitpattern matches erratum sequence but section is not executable + .data + .globl dat +dat: .word 0 diff --git a/test/ELF/aarch64-cortex-a53-843419-recognize.s b/test/ELF/aarch64-cortex-a53-843419-recognize.s new file mode 100644 index 000000000000..3674dd2744da --- /dev/null +++ b/test/ELF/aarch64-cortex-a53-843419-recognize.s @@ -0,0 +1,563 @@ +// REQUIRES: aarch64 +// RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux %s -o %t.o +// RUN: ld.lld -fix-cortex-a53-843419 -verbose %t.o -o %t2 | FileCheck -check-prefix CHECK-PRINT %s +// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 | FileCheck %s -check-prefixes=CHECK,CHECK-FIX +// RUN: ld.lld -verbose %t.o -o %t3 +// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t3 | FileCheck %s -check-prefixes=CHECK,CHECK-NOFIX +// Test cases for Cortex-A53 Erratum 843419 +// See ARM-EPM-048406 Cortex_A53_MPCore_Software_Developers_Errata_Notice.pdf +// for full erratum details. +// In Summary +// 1.) +// ADRP (0xff8 or 0xffc). +// 2.) +// - load or store single register or either integer or vector registers. +// - STP or STNP of either vector or vector registers. +// - Advanced SIMD ST1 store instruction. +// - Must not write Rn. +// 3.) optional instruction, can't be a branch, must not write Rn, may read Rn. +// 4.) A load or store instruction from the Load/Store register unsigned +// immediate class using Rn as the base register. + +// Each section contains a sequence of instructions that should be recognized +// as erratum 843419. The test cases cover the major variations such as: +// - adrp starts at 0xfff8 or 0xfffc. +// - Variations in instruction class for instruction 2. +// - Optional instruction 3 present or not. +// - Load or store for instruction 4. + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 21FF8 in unpatched output. +// CHECK: t3_ff8_ldr: +// CHECK-NEXT: 21ff8: e0 01 00 f0 adrp x0, #258048 +// CHECK-NEXT: 21ffc: 21 00 40 f9 ldr x1, [x1] +// CHECK-FIX: 22000: 03 b8 00 14 b #188428 +// CHECK-NOFIX: 22000: 00 00 40 f9 ldr x0, [x0] +// CHECK-NEXT: 22004: c0 03 5f d6 ret + .section .text.01, "ax", %progbits + .balign 4096 + .globl t3_ff8_ldr + .type t3_ff8_ldr, %function + .space 4096 - 8 +t3_ff8_ldr: + adrp x0, dat1 + ldr x1, [x1, #0] + ldr x0, [x0, :got_lo12:dat1] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 23FF8 in unpatched output. +// CHECK: t3_ff8_ldrsimd: +// CHECK-NEXT: 23ff8: e0 01 00 b0 adrp x0, #249856 +// CHECK-NEXT: 23ffc: 21 00 40 bd ldr s1, [x1] +// CHECK-FIX: 24000: 05 b0 00 14 b #180244 +// CHECK-NOFIX: 24000: 02 04 40 f9 ldr x2, [x0, #8] +// CHECK-NEXT: 24004: c0 03 5f d6 ret + .section .text.02, "ax", %progbits + .balign 4096 + .globl t3_ff8_ldrsimd + .type t3_ff8_ldrsimd, %function + .space 4096 - 8 +t3_ff8_ldrsimd: + adrp x0, dat2 + ldr s1, [x1, #0] + ldr x2, [x0, :got_lo12:dat2] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 25FFC in unpatched output. +// CHECK: t3_ffc_ldrpost: +// CHECK-NEXT: 25ffc: c0 01 00 f0 adrp x0, #241664 +// CHECK-NEXT: 26000: 21 84 40 bc ldr s1, [x1], #8 +// CHECK-FIX: 26004: 06 a8 00 14 b #172056 +// CHECK-NOFIX: 26004: 03 08 40 f9 ldr x3, [x0, #16] +// CHECK-NEXT: 26008: c0 03 5f d6 ret + .section .text.03, "ax", %progbits + .balign 4096 + .globl t3_ffc_ldrpost + .type t3_ffc_ldrpost, %function + .space 4096 - 4 +t3_ffc_ldrpost: + adrp x0, dat3 + ldr s1, [x1], #8 + ldr x3, [x0, :got_lo12:dat3] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 27FF8 in unpatched output. +// CHECK: t3_ff8_strpre: +// CHECK-NEXT: 27ff8: c0 01 00 b0 adrp x0, #233472 +// CHECK-NEXT: 27ffc: 21 8c 00 bc str s1, [x1, #8]! +// CHECK-FIX: 28000: 09 a0 00 14 b #163876 +// CHECK-NOFIX: 28000: 02 00 40 f9 ldr x2, [x0] +// CHECK-NEXT: 28004: c0 03 5f d6 ret + .section .text.04, "ax", %progbits + .balign 4096 + .globl t3_ff8_strpre + .type t3_ff8_strpre, %function + .space 4096 - 8 +t3_ff8_strpre: + adrp x0, dat1 + str s1, [x1, #8]! + ldr x2, [x0, :lo12:dat1] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 29FFC in unpatched output. +// CHECK: t3_ffc_str: +// CHECK-NEXT: 29ffc: bc 01 00 f0 adrp x28, #225280 +// CHECK-NEXT: 2a000: 42 00 00 f9 str x2, [x2] +// CHECK-FIX: 2a004: 0a 98 00 14 b #155688 +// CHECK-NOFIX: 2a004: 9c 07 00 f9 str x28, [x28, #8] +// CHECK-NEXT: 2a008: c0 03 5f d6 ret + .section .text.05, "ax", %progbits + .balign 4096 + .globl t3_ffc_str + .type t3_ffc_str, %function + .space 4096 - 4 +t3_ffc_str: + adrp x28, dat2 + str x2, [x2, #0] + str x28, [x28, :lo12:dat2] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 2BFFC in unpatched output. +// CHECK: t3_ffc_strsimd: +// CHECK-NEXT: 2bffc: bc 01 00 b0 adrp x28, #217088 +// CHECK-NEXT: 2c000: 44 00 00 b9 str w4, [x2] +// CHECK-FIX: 2c004: 0c 90 00 14 b #147504 +// CHECK-NOFIX: 2c004: 84 0b 00 f9 str x4, [x28, #16] +// CHECK-NEXT: 2c008: c0 03 5f d6 ret + .section .text.06, "ax", %progbits + .balign 4096 + .globl t3_ffc_strsimd + .type t3_ffc_strsimd, %function + .space 4096 - 4 +t3_ffc_strsimd: + adrp x28, dat3 + str w4, [x2, #0] + str x4, [x28, :lo12:dat3] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 2DFF8 in unpatched output. +// CHECK: t3_ff8_ldrunpriv: +// CHECK-NEXT: 2dff8: 9d 01 00 f0 adrp x29, #208896 +// CHECK-NEXT: 2dffc: 41 08 40 38 ldtrb w1, [x2] +// CHECK-FIX: 2e000: 0f 88 00 14 b #139324 +// CHECK-NOFIX: 2e000: bd 03 40 f9 ldr x29, [x29] +// CHECK-NEXT: 2e004: c0 03 5f d6 ret + .section .text.07, "ax", %progbits + .balign 4096 + .globl t3_ff8_ldrunpriv + .type t3_ff8_ldrunpriv, %function + .space 4096 - 8 +t3_ff8_ldrunpriv: + adrp x29, dat1 + ldtrb w1, [x2, #0] + ldr x29, [x29, :got_lo12:dat1] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 2FFFC in unpatched output. +// CHECK: t3_ffc_ldur: +// CHECK-NEXT: 2fffc: 9d 01 00 b0 adrp x29, #200704 +// CHECK-NEXT: 30000: 42 40 40 b8 ldur w2, [x2, #4] +// CHECK-FIX: 30004: 10 80 00 14 b #131136 +// CHECK-NOFIX: 30004: bd 07 40 f9 ldr x29, [x29, #8] +// CHECK-NEXT: 30008: c0 03 5f d6 ret + .balign 4096 + .globl t3_ffc_ldur + .type t3_ffc_ldur, %function + .space 4096 - 4 +t3_ffc_ldur: + adrp x29, dat2 + ldur w2, [x2, #4] + ldr x29, [x29, :got_lo12:dat2] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 31FFC in unpatched output. +// CHECK: t3_ffc_sturh: +// CHECK-NEXT: 31ffc: 72 01 00 f0 adrp x18, #192512 +// CHECK-NEXT: 32000: 43 40 00 78 sturh w3, [x2, #4] +// CHECK-FIX: 32004: 12 78 00 14 b #122952 +// CHECK-NOFIX: 32004: 41 0a 40 f9 ldr x1, [x18, #16] +// CHECK-NEXT: 32008: c0 03 5f d6 ret + .section .text.09, "ax", %progbits + .balign 4096 + .globl t3_ffc_sturh + .type t3_ffc_sturh, %function + .space 4096 - 4 +t3_ffc_sturh: + adrp x18, dat3 + sturh w3, [x2, #4] + ldr x1, [x18, :got_lo12:dat3] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 33FF8 in unpatched output. +// CHECK: t3_ff8_literal: +// CHECK-NEXT: 33ff8: 72 01 00 b0 adrp x18, #184320 +// CHECK-NEXT: 33ffc: e3 ff ff 58 ldr x3, #-4 +// CHECK-FIX: 34000: 15 70 00 14 b #114772 +// CHECK-NOFIX: 34000: 52 02 40 f9 ldr x18, [x18] +// CHECK-NEXT: 34004: c0 03 5f d6 ret + .section .text.10, "ax", %progbits + .balign 4096 + .globl t3_ff8_literal + .type t3_ff8_literal, %function + .space 4096 - 8 +t3_ff8_literal: + adrp x18, dat1 + ldr x3, t3_ff8_literal + ldr x18, [x18, :lo12:dat1] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 35FFC in unpatched output. +// CHECK: t3_ffc_register: +// CHECK-NEXT: 35ffc: 4f 01 00 f0 adrp x15, #176128 +// CHECK-NEXT: 36000: 43 68 61 f8 ldr x3, [x2, x1] +// CHECK-FIX: 36004: 16 68 00 14 b #106584 +// CHECK-NOFIX: 36004: ea 05 40 f9 ldr x10, [x15, #8] +// CHECK-NEXT: 36008: c0 03 5f d6 ret + .section .text.11, "ax", %progbits + .balign 4096 + .globl t3_ffc_register + .type t3_ffc_register, %function + .space 4096 - 4 +t3_ffc_register: + adrp x15, dat2 + ldr x3, [x2, x1] + ldr x10, [x15, :lo12:dat2] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 37FF8 in unpatched output. +// CHECK: t3_ff8_stp: +// CHECK-NEXT: 37ff8: 50 01 00 b0 adrp x16, #167936 +// CHECK-NEXT: 37ffc: 61 08 00 a9 stp x1, x2, [x3] +// CHECK-FIX: 38000: 19 60 00 14 b #98404 +// CHECK-NOFIX: 38000: 0d 0a 40 f9 ldr x13, [x16, #16] +// CHECK-NEXT: 38004: c0 03 5f d6 ret + .section .text.12, "ax", %progbits + .balign 4096 + .globl t3_ff8_stp + .type t3_ff8_stp, %function + .space 4096 - 8 +t3_ff8_stp: + adrp x16, dat3 + stp x1,x2, [x3, #0] + ldr x13, [x16, :lo12:dat3] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 39FFC in unpatched output. +// CHECK: t3_ffc_stnp: +// CHECK-NEXT: 39ffc: 27 01 00 f0 adrp x7, #159744 +// CHECK-NEXT: 3a000: 61 08 00 a8 stnp x1, x2, [x3] +// CHECK-FIX: 3a004: 1a 58 00 14 b #90216 +// CHECK-NOFIX: 3a004: e9 00 40 f9 ldr x9, [x7] +// CHECK-NEXT: 3a008: c0 03 5f d6 ret + .section .text.13, "ax", %progbits + .balign 4096 + .globl t3_ffc_stnp + .type t3_ffc_stnp, %function + .space 4096 - 4 +t3_ffc_stnp: + adrp x7, dat1 + stnp x1,x2, [x3, #0] + ldr x9, [x7, :lo12:dat1] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 3BFFC in unpatched output. +// CHECK: t3_ffc_st1singlepost: +// CHECK-NEXT: 3bffc: 37 01 00 b0 adrp x23, #151552 +// CHECK-NEXT: 3c000: 20 70 82 4c st1 { v0.16b }, [x1], x2 +// CHECK-FIX: 3c004: 1c 50 00 14 b #82032 +// CHECK-NOFIX: 3c004: f6 06 40 f9 ldr x22, [x23, #8] +// CHECK-NEXT: 3c008: c0 03 5f d6 ret + .section .text.14, "ax", %progbits + .balign 4096 + .globl t3_ffc_st1singlepost + .type t3_ffc_st1singlepost, %function + .space 4096 - 4 +t3_ffc_st1singlepost: + adrp x23, dat2 + st1 { v0.16b }, [x1], x2 + ldr x22, [x23, :lo12:dat2] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 3DFF8 in unpatched output. +// CHECK: t3_ff8_st1multiple: +// CHECK-NEXT: 3dff8: 17 01 00 f0 adrp x23, #143360 +// CHECK-NEXT: 3dffc: 20 a0 00 4c st1 { v0.16b, v1.16b }, [x1] +// CHECK-FIX: 3e000: 1f 48 00 14 b #73852 +// CHECK-NOFIX: 3e000: f8 0a 40 f9 ldr x24, [x23, #16] +// CHECK-NEXT: 3e004: c0 03 5f d6 ret + .section .text.15, "ax", %progbits + .balign 4096 + .globl t3_ff8_st1multiple + .type t3_ff8_st1muliple, %function + .space 4096 - 8 +t3_ff8_st1multiple: + adrp x23, dat3 + st1 { v0.16b, v1.16b }, [x1] + ldr x24, [x23, :lo12:dat3] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 3FFF8 in unpatched output. +// CHECK: t4_ff8_ldr: +// CHECK-NEXT: 3fff8: 00 01 00 b0 adrp x0, #135168 +// CHECK-NEXT: 3fffc: 21 00 40 f9 ldr x1, [x1] +// CHECK-NEXT: 40000: 42 00 00 8b add x2, x2, x0 +// CHECK-FIX: 40004: 20 40 00 14 b #65664 +// CHECK-NOFIX: 40004: 02 00 40 f9 ldr x2, [x0] +// CHECK-NEXT: 40008: c0 03 5f d6 ret + .section .text.16, "ax", %progbits + .balign 4096 + .globl t4_ff8_ldr + .type t4_ff8_ldr, %function + .space 4096 - 8 +t4_ff8_ldr: + adrp x0, dat1 + ldr x1, [x1, #0] + add x2, x2, x0 + ldr x2, [x0, :got_lo12:dat1] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 41FFC in unpatched output. +// CHECK: t4_ffc_str: +// CHECK-NEXT: 41ffc: fc 00 00 f0 adrp x28, #126976 +// CHECK-NEXT: 42000: 42 00 00 f9 str x2, [x2] +// CHECK-NEXT: 42004: 20 00 02 cb sub x0, x1, x2 +// CHECK-FIX: 42008: 21 38 00 14 b #57476 +// CHECK-NOFIX: 42008: 9b 07 00 f9 str x27, [x28, #8] +// CHECK-NEXT: 4200c: c0 03 5f d6 ret + .section .text.17, "ax", %progbits + .balign 4096 + .globl t4_ffc_str + .type t4_ffc_str, %function + .space 4096 - 4 +t4_ffc_str: + adrp x28, dat2 + str x2, [x2, #0] + sub x0, x1, x2 + str x27, [x28, :got_lo12:dat2] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 43FF8 in unpatched output. +// CHECK: t4_ff8_stp: +// CHECK-NEXT: 43ff8: f0 00 00 b0 adrp x16, #118784 +// CHECK-NEXT: 43ffc: 61 08 00 a9 stp x1, x2, [x3] +// CHECK-NEXT: 44000: 03 7e 10 9b mul x3, x16, x16 +// CHECK-FIX: 44004: 24 30 00 14 b #49296 +// CHECK-NOFIX: 44004: 0e 0a 40 f9 ldr x14, [x16, #16] +// CHECK-NEXT: 44008: c0 03 5f d6 ret + .section .text.18, "ax", %progbits + .balign 4096 + .globl t4_ff8_stp + .type t4_ff8_stp, %function + .space 4096 - 8 +t4_ff8_stp: + adrp x16, dat3 + stp x1,x2, [x3, #0] + mul x3, x16, x16 + ldr x14, [x16, :got_lo12:dat3] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 45FF8 in unpatched output. +// CHECK: t4_ff8_stppre: +// CHECK-NEXT: 45ff8: d0 00 00 f0 adrp x16, #110592 +// CHECK-NEXT: 45ffc: 61 08 81 a9 stp x1, x2, [x3, #16]! +// CHECK-NEXT: 46000: 03 7e 10 9b mul x3, x16, x16 +// CHECK-FIX: 46004: 26 28 00 14 b #41112 +// CHECK-NOFIX: 46004: 0e 06 40 f9 ldr x14, [x16, #8] +// CHECK-NEXT: 46008: c0 03 5f d6 ret + .section .text.19, "ax", %progbits + .balign 4096 + .globl t4_ff8_stppre + .type t4_ff8_stppre, %function + .space 4096 - 8 +t4_ff8_stppre: + adrp x16, dat1 + stp x1,x2, [x3, #16]! + mul x3, x16, x16 + ldr x14, [x16, #8] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 47FF8 in unpatched output. +// CHECK: t4_ff8_stppost: +// CHECK-NEXT: 47ff8: d0 00 00 b0 adrp x16, #102400 +// CHECK-NEXT: 47ffc: 61 08 81 a8 stp x1, x2, [x3], #16 +// CHECK-NEXT: 48000: 03 7e 10 9b mul x3, x16, x16 +// CHECK-FIX: 48004: 28 20 00 14 b #32928 +// CHECK-NOFIX: 48004: 0e 06 40 f9 ldr x14, [x16, #8] +// CHECK-NEXT: 48008: c0 03 5f d6 ret + .section .text.20, "ax", %progbits + .balign 4096 + .globl t4_ff8_stppost + .type t4_ff8_stppost, %function + .space 4096 - 8 +t4_ff8_stppost: + adrp x16, dat2 + stp x1,x2, [x3], #16 + mul x3, x16, x16 + ldr x14, [x16, #8] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 49FFC in unpatched output. +// CHECK: t4_ffc_stpsimd: +// CHECK-NEXT: 49ffc: b0 00 00 f0 adrp x16, #94208 +// CHECK-NEXT: 4a000: 61 08 00 ad stp q1, q2, [x3] +// CHECK-NEXT: 4a004: 03 7e 10 9b mul x3, x16, x16 +// CHECK-FIX: 4a008: 29 18 00 14 b #24740 +// CHECK-NOFIX: 4a008: 0e 06 40 f9 ldr x14, [x16, #8] +// CHECK-NEXT: 4a00c: c0 03 5f d6 ret + .section .text.21, "ax", %progbits + .balign 4096 + .globl t4_ffc_stpsimd + .type t4_ffc_stpsimd, %function + .space 4096 - 4 +t4_ffc_stpsimd: + adrp x16, dat3 + stp q1,q2, [x3, #0] + mul x3, x16, x16 + ldr x14, [x16, #8] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 4BFFC in unpatched output. +// CHECK: t4_ffc_stnp: +// CHECK-NEXT: 4bffc: a7 00 00 b0 adrp x7, #86016 +// CHECK-NEXT: 4c000: 61 08 00 a8 stnp x1, x2, [x3] +// CHECK-NEXT: 4c004: 1f 20 03 d5 nop +// CHECK-FIX: 4c008: 2b 10 00 14 b #16556 +// CHECK-NOFIX: 4c008: ea 00 40 f9 ldr x10, [x7] +// CHECK-NEXT: 4c00c: c0 03 5f d6 ret + .section .text.22, "ax", %progbits + .balign 4096 + .globl t4_ffc_stnp + .type t4_ffc_stnp, %function + .space 4096 - 4 +t4_ffc_stnp: + adrp x7, dat1 + stnp x1,x2, [x3, #0] + nop + ldr x10, [x7, :got_lo12:dat1] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 4DFFC in unpatched output. +// CHECK: t4_ffc_st1: +// CHECK-NEXT: 4dffc: 98 00 00 f0 adrp x24, #77824 +// CHECK-NEXT: 4e000: 20 70 00 4c st1 { v0.16b }, [x1] +// CHECK-NEXT: 4e004: f6 06 40 f9 ldr x22, [x23, #8] +// CHECK-FIX: 4e008: 2d 08 00 14 b #8372 +// CHECK-NOFIX: 4e008: 18 ff 3f f9 str x24, [x24, #32760] +// CHECK-NEXT: 4e00c: c0 03 5f d6 ret + .section .text.23, "ax", %progbits + .balign 4096 + .globl t4_ffc_st1 + .type t4_ffc_st1, %function + .space 4096 - 4 +t4_ffc_st1: + adrp x24, dat2 + st1 { v0.16b }, [x1] + ldr x22, [x23, :got_lo12:dat2] + str x24, [x24, #32760] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 4FFF8 in unpatched output. +// CHECK: t3_ff8_ldr_once: +// CHECK-NEXT: 4fff8: 80 00 00 b0 adrp x0, #69632 +// CHECK-NEXT: 4fffc: 20 70 82 4c st1 { v0.16b }, [x1], x2 +// CHECK-FIX: 50000: 31 00 00 14 b #196 +// CHECK-NOFIX: 50000: 01 08 40 f9 ldr x1, [x0, #16] +// CHECK-NEXT: 50004: 02 08 40 f9 ldr x2, [x0, #16] +// CHECK-NEXT: 50008: c0 03 5f d6 ret + .section .text.24, "ax", %progbits + .balign 4096 + .globl t3_ff8_ldr_once + .type t3_ff8_ldr_once, %function + .space 4096 - 8 +t3_ff8_ldr_once: + adrp x0, dat3 + st1 { v0.16b }, [x1], x2 + ldr x1, [x0, #16] + ldr x2, [x0, #16] + ret + + .text + .globl _start + .type _start, %function +_start: + ret + +// CHECK-FIX: __CortexA53843419_22000: +// CHECK-FIX-NEXT: 5000c: 00 00 40 f9 ldr x0, [x0] +// CHECK-FIX-NEXT: 50010: fd 47 ff 17 b #-188428 +// CHECK-FIX: __CortexA53843419_24000: +// CHECK-FIX-NEXT: 50014: 02 04 40 f9 ldr x2, [x0, #8] +// CHECK-FIX-NEXT: 50018: fb 4f ff 17 b #-180244 +// CHECK-FIX: __CortexA53843419_26004: +// CHECK-FIX-NEXT: 5001c: 03 08 40 f9 ldr x3, [x0, #16] +// CHECK-FIX-NEXT: 50020: fa 57 ff 17 b #-172056 +// CHECK-FIX: __CortexA53843419_28000: +// CHECK-FIX-NEXT: 50024: 02 00 40 f9 ldr x2, [x0] +// CHECK-FIX-NEXT: 50028: f7 5f ff 17 b #-163876 +// CHECK-FIX: __CortexA53843419_2A004: +// CHECK-FIX-NEXT: 5002c: 9c 07 00 f9 str x28, [x28, #8] +// CHECK-FIX-NEXT: 50030: f6 67 ff 17 b #-155688 +// CHECK-FIX: __CortexA53843419_2C004: +// CHECK-FIX-NEXT: 50034: 84 0b 00 f9 str x4, [x28, #16] +// CHECK-FIX-NEXT: 50038: f4 6f ff 17 b #-147504 +// CHECK-FIX: __CortexA53843419_2E000: +// CHECK-FIX-NEXT: 5003c: bd 03 40 f9 ldr x29, [x29] +// CHECK-FIX-NEXT: 50040: f1 77 ff 17 b #-139324 +// CHECK-FIX: __CortexA53843419_30004: +// CHECK-FIX-NEXT: 50044: bd 07 40 f9 ldr x29, [x29, #8] +// CHECK-FIX-NEXT: 50048: f0 7f ff 17 b #-131136 +// CHECK-FIX: __CortexA53843419_32004: +// CHECK-FIX-NEXT: 5004c: 41 0a 40 f9 ldr x1, [x18, #16] +// CHECK-FIX-NEXT: 50050: ee 87 ff 17 b #-122952 +// CHECK-FIX: __CortexA53843419_34000: +// CHECK-FIX-NEXT: 50054: 52 02 40 f9 ldr x18, [x18] +// CHECK-FIX-NEXT: 50058: eb 8f ff 17 b #-114772 +// CHECK-FIX: __CortexA53843419_36004: +// CHECK-FIX-NEXT: 5005c: ea 05 40 f9 ldr x10, [x15, #8] +// CHECK-FIX-NEXT: 50060: ea 97 ff 17 b #-106584 +// CHECK-FIX: __CortexA53843419_38000: +// CHECK-FIX-NEXT: 50064: 0d 0a 40 f9 ldr x13, [x16, #16] +// CHECK-FIX-NEXT: 50068: e7 9f ff 17 b #-98404 +// CHECK-FIX: __CortexA53843419_3A004: +// CHECK-FIX-NEXT: 5006c: e9 00 40 f9 ldr x9, [x7] +// CHECK-FIX-NEXT: 50070: e6 a7 ff 17 b #-90216 +// CHECK-FIX: __CortexA53843419_3C004: +// CHECK-FIX-NEXT: 50074: f6 06 40 f9 ldr x22, [x23, #8] +// CHECK-FIX-NEXT: 50078: e4 af ff 17 b #-82032 +// CHECK-FIX: __CortexA53843419_3E000: +// CHECK-FIX-NEXT: 5007c: f8 0a 40 f9 ldr x24, [x23, #16] +// CHECK-FIX-NEXT: 50080: e1 b7 ff 17 b #-73852 +// CHECK-FIX: __CortexA53843419_40004: +// CHECK-FIX-NEXT: 50084: 02 00 40 f9 ldr x2, [x0] +// CHECK-FIX-NEXT: 50088: e0 bf ff 17 b #-65664 +// CHECK-FIX: __CortexA53843419_42008: +// CHECK-FIX-NEXT: 5008c: 9b 07 00 f9 str x27, [x28, #8] +// CHECK-FIX-NEXT: 50090: df c7 ff 17 b #-57476 +// CHECK-FIX: __CortexA53843419_44004: +// CHECK-FIX-NEXT: 50094: 0e 0a 40 f9 ldr x14, [x16, #16] +// CHECK-FIX-NEXT: 50098: dc cf ff 17 b #-49296 +// CHECK-FIX: __CortexA53843419_46004: +// CHECK-FIX-NEXT: 5009c: 0e 06 40 f9 ldr x14, [x16, #8] +// CHECK-FIX-NEXT: 500a0: da d7 ff 17 b #-41112 +// CHECK-FIX: __CortexA53843419_48004: +// CHECK-FIX-NEXT: 500a4: 0e 06 40 f9 ldr x14, [x16, #8] +// CHECK-FIX-NEXT: 500a8: d8 df ff 17 b #-32928 +// CHECK-FIX: __CortexA53843419_4A008: +// CHECK-FIX-NEXT: 500ac: 0e 06 40 f9 ldr x14, [x16, #8] +// CHECK-FIX-NEXT: 500b0: d7 e7 ff 17 b #-24740 +// CHECK-FIX: __CortexA53843419_4C008: +// CHECK-FIX-NEXT: 500b4: ea 00 40 f9 ldr x10, [x7] +// CHECK-FIX-NEXT: 500b8: d5 ef ff 17 b #-16556 +// CHECK-FIX: __CortexA53843419_4E008: +// CHECK-FIX-NEXT: 500bc: 18 ff 3f f9 str x24, [x24, #32760] +// CHECK-FIX-NEXT: 500c0: d3 f7 ff 17 b #-8372 +// CHECK-FIX: __CortexA53843419_50000: +// CHECK-FIX-NEXT: 500c4: 01 08 40 f9 ldr x1, [x0, #16] +// CHECK-FIX-NEXT: 500c8: cf ff ff 17 b #-196 + + .data + .globl dat + .globl dat2 + .globl dat3 +dat1: .quad 1 +dat2: .quad 2 +dat3: .quad 3 diff --git a/test/ELF/aarch64-cortex-a53-843419-thunk.s b/test/ELF/aarch64-cortex-a53-843419-thunk.s new file mode 100644 index 000000000000..4568095a2fa7 --- /dev/null +++ b/test/ELF/aarch64-cortex-a53-843419-thunk.s @@ -0,0 +1,57 @@ +// REQUIRES: aarch64 +// RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux %s -o %t.o +// RUN: echo "SECTIONS { \ +// RUN: .text1 0x10000 : { *(.text.01) *(.text.02) *(.text.03) } \ +// RUN: .text2 0x8010000 : { *(.text.04) } } " > %t.script +// RUN: ld.lld --script %t.script -fix-cortex-a53-843419 -verbose %t.o -o %t2 | FileCheck -check-prefix=CHECK-PRINT %s +// RUN: llvm-objdump -triple=aarch64-linux-gnu -d %t2 | FileCheck %s + +// %t2 is 128 Megabytes, so delete it early. +// RUN: rm %t2 + +// Test cases for Cortex-A53 Erratum 843419 that involve interactions with +// range extension thunks. Both erratum fixes and range extension thunks need +// precise address information and after creation alter address information. + + + .section .text.01, "ax", %progbits + .balign 4096 + .globl _start + .type _start, %function +_start: + bl far_away + // Thunk to far_away, size 16-bytes goes here. + + .section .text.02, "ax", %progbits + .space 4096 - 28 + + // Erratum sequence will only line up at address 0 modulo 0xffc when + // Thunk is inserted. + .section .text.03, "ax", %progbits + .globl t3_ff8_ldr + .type t3_ff8_ldr, %function +t3_ff8_ldr: + adrp x0, dat + ldr x1, [x1, #0] + ldr x0, [x0, :got_lo12:dat] + ret + +// CHECK-PRINT: detected cortex-a53-843419 erratum sequence starting at 10FFC in unpatched output. +// CHECK: t3_ff8_ldr: +// CHECK-NEXT: 10ffc: 00 00 04 90 adrp x0, #134217728 +// CHECK-NEXT: 11000: 21 00 40 f9 ldr x1, [x1] +// CHECK-NEXT: 11004: 02 00 00 14 b #8 +// CHECK-NEXT: 11008: c0 03 5f d6 ret +// CHECK: __CortexA53843419_11004: +// CHECK-NEXT: 1100c: 00 08 40 f9 ldr x0, [x0, #16] +// CHECK-NEXT: 11010: fe ff ff 17 b #-8 + + .section .text.04, "ax", %progbits + .globl far_away + .type far_away, function +far_away: + ret + + .section .data + .globl dat +dat: .quad 0 diff --git a/test/ELF/aarch64-gnu-ifunc-plt.s b/test/ELF/aarch64-gnu-ifunc-plt.s index be9a8a7e674a..5138675676d3 100644 --- a/test/ELF/aarch64-gnu-ifunc-plt.s +++ b/test/ELF/aarch64-gnu-ifunc-plt.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %S/Inputs/shared2.s -o %t1.o // RUN: ld.lld %t1.o --shared -o %t.so // RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux-gnu %s -o %t.o -// RUN: ld.lld %t.so %t.o -o %tout +// RUN: ld.lld --hash-style=sysv %t.so %t.o -o %tout // RUN: llvm-objdump -d %tout | FileCheck %s --check-prefix=DISASM // RUN: llvm-objdump -s %tout | FileCheck %s --check-prefix=GOTPLT // RUN: llvm-readobj -r -dynamic-table %tout | FileCheck %s diff --git a/test/ELF/aarch64-gnu-ifunc.s b/test/ELF/aarch64-gnu-ifunc.s index 46f4a292d2ea..4e0dc328025d 100644 --- a/test/ELF/aarch64-gnu-ifunc.s +++ b/test/ELF/aarch64-gnu-ifunc.s @@ -15,7 +15,7 @@ // CHECK-NEXT: Address: [[RELA:.*]] // CHECK-NEXT: Offset: 0x158 // CHECK-NEXT: Size: 48 -// CHECK-NEXT: Link: 6 +// CHECK-NEXT: Link: 0 // CHECK-NEXT: Info: 0 // CHECK-NEXT: AddressAlignment: 8 // CHECK-NEXT: EntrySize: 24 diff --git a/test/ELF/aarch64-got-reloc.s b/test/ELF/aarch64-got-reloc.s index fec1ad6a1d22..1882dcd43a48 100644 --- a/test/ELF/aarch64-got-reloc.s +++ b/test/ELF/aarch64-got-reloc.s @@ -9,8 +9,8 @@ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: SHF_WRITE // CHECK-NEXT: ] -// CHECK-NEXT: Address: 0x30000 -// CHECK-NEXT: Offset: 0x20000 +// CHECK-NEXT: Address: +// CHECK-NEXT: Offset: // CHECK-NEXT: Size: 8 // CHECK-NEXT: Link: 0 // CHECK-NEXT: Info: 0 diff --git a/test/ELF/aarch64-got-relocations.s b/test/ELF/aarch64-got-relocations.s index 13ee09a892e9..a7745b05904d 100644 --- a/test/ELF/aarch64-got-relocations.s +++ b/test/ELF/aarch64-got-relocations.s @@ -1,6 +1,6 @@ # REQUIRES: aarch64 # RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-cloudabi %s -o %t.o -# RUN: ld.lld -pie %t.o -o %t +# RUN: ld.lld --hash-style=sysv -pie %t.o -o %t # RUN: llvm-readobj -r %t | FileCheck %s # If we're addressing a global relatively through the GOT, we still need to diff --git a/test/ELF/aarch64-jump26-error.s b/test/ELF/aarch64-jump26-error.s deleted file mode 100644 index 81fbba1f4551..000000000000 --- a/test/ELF/aarch64-jump26-error.s +++ /dev/null @@ -1,11 +0,0 @@ -// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %S/Inputs/abs.s -o %tabs -// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %s -o %t -// RUN: not ld.lld %t %tabs -o %t2 2>&1 | FileCheck %s -// REQUIRES: aarch64 - -.text -.globl _start -_start: - b big - -// CHECK: R_AARCH64_JUMP26 out of range diff --git a/test/ELF/aarch64-jump26-thunk.s b/test/ELF/aarch64-jump26-thunk.s new file mode 100644 index 000000000000..088ab3a9e1a5 --- /dev/null +++ b/test/ELF/aarch64-jump26-thunk.s @@ -0,0 +1,20 @@ +// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %S/Inputs/abs.s -o %tabs +// RUN: llvm-mc -filetype=obj -triple=aarch64-pc-freebsd %s -o %t +// RUN: ld.lld %t %tabs -o %t2 2>&1 +// RUN: llvm-objdump -d -triple=aarch64-pc-freebsd %t2 | FileCheck %s +// REQUIRES: aarch64 + +.text +.globl _start +_start: + b big + +// CHECK: Disassembly of section .text: +// CHECK-NEXT: _start: +// CHECK-NEXT: 20000: 02 00 00 14 b #8 +// CHECK: __AArch64AbsLongThunk_big: +// CHECK-NEXT: 20008: 50 00 00 58 ldr x16, #8 +// CHECK-NEXT: 2000c: 00 02 1f d6 br x16 +// CHECK: $d: +// CHECK-NEXT: 20010: 00 00 00 00 .word 0x00000000 +// CHECK-NEXT: 20014: 10 00 00 00 .word 0x00000010 diff --git a/test/ELF/aarch64-ldprel-lo19-invalid.s b/test/ELF/aarch64-ldprel-lo19-invalid.s new file mode 100644 index 000000000000..04df32e05904 --- /dev/null +++ b/test/ELF/aarch64-ldprel-lo19-invalid.s @@ -0,0 +1,11 @@ +# REQUIRES: aarch64 + +# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-none %s -o %t.o +# RUN: not ld.lld -shared %t.o -o %t 2>&1 | FileCheck %s + +# CHECK: relocation R_AARCH64_LD_PREL_LO19 out of range: 2065536 is not in [-1048576, 1048575] + + ldr x8, patatino + .data + .zero 2000000 +patatino: diff --git a/test/ELF/aarch64-lo12-alignment.s b/test/ELF/aarch64-lo12-alignment.s new file mode 100644 index 000000000000..2b30022658e6 --- /dev/null +++ b/test/ELF/aarch64-lo12-alignment.s @@ -0,0 +1,45 @@ +// REQUIRES: aarch64 +// RUN: llvm-mc -filetype=obj -triple=aarch64-none-linux %s -o %t +// RUN: not ld.lld %t -o %t2 2>&1 | FileCheck %s + +// Test derived from a typical ODR violation where a global is declared +// extern int but defined as a half or byte sized type. + .section .text + .globl _start + .type _start, %function +// Access foo2 as if it were an aligned 32-bit int, expect an error as +// foo is not aligned + +_start: + ldrb w2, [x0, #:lo12:foo1] // Ok as no shift involved + ldrh w2, [x0, #:lo12:foo1] // Error foo1 is not 2-byte aligned + ldrh w2, [x0, #:lo12:foo2] // Ok as foo2 is 2-byte aligned + ldr w2, [x0, #:lo12:foo2] // Error foo2 is not 4-byte aligned + ldr w2, [x0, #:lo12:foo4] // Ok as foo4 is 4-byte aligned + ldr x3, [x0, #:lo12:foo4] // Error foo4 is not 8-byte aligned + ldr x3, [x0, #:lo12:foo8] // Ok as foo8 is 8-byte aligned + ldr q0, [x0, #:lo12:foo8] // Error foo8 is not 16-byte aligned + ldr q0, [x0, #:lo12:foo16] // Ok as foo16 is 16-byte aligned + + .section .data.bool, "a", @nobits + .balign 16 + .globl foo16 + .globl foo1 + .globl foo2 + .globl foo4 + .globl foo8 +foo16: + .space 1 +foo1: + .space 1 +foo2: + .space 2 +foo4: + .space 4 +foo8: + .space 8 + +// CHECK: improper alignment for relocation R_AARCH64_LDST16_ABS_LO12_NC: 0x30001 is not aligned to 2 bytes +// CHECK-NEXT: improper alignment for relocation R_AARCH64_LDST32_ABS_LO12_NC: 0x30002 is not aligned to 4 bytes +// CHECK-NEXT: improper alignment for relocation R_AARCH64_LDST64_ABS_LO12_NC: 0x30004 is not aligned to 8 bytes +// CHECK-NEXT: improper alignment for relocation R_AARCH64_LDST128_ABS_LO12_NC: 0x30008 is not aligned to 16 bytes diff --git a/test/ELF/aarch64-load-alignment.s b/test/ELF/aarch64-load-alignment.s new file mode 100644 index 000000000000..7b1129b7afa5 --- /dev/null +++ b/test/ELF/aarch64-load-alignment.s @@ -0,0 +1,11 @@ +# REQUIRES: aarch64 + +# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-none %s -o %t.o +# RUN: not ld.lld -shared %t.o -o %t 2>&1 | FileCheck %s + +# CHECK: improper alignment for relocation R_AARCH64_LD_PREL_LO19: 0x10005 is not aligned to 4 bytes + + ldr x8, patatino + .data + .zero 5 +patatino: diff --git a/test/ELF/aarch64-prel16.s b/test/ELF/aarch64-prel16.s index 4ae1f87e2081..fc34f010853c 100644 --- a/test/ELF/aarch64-prel16.s +++ b/test/ELF/aarch64-prel16.s @@ -28,4 +28,4 @@ _start: // | FileCheck %s --check-prefix=OVERFLOW // RUN: not ld.lld %t.o %t257.o -o %t2 // | FileCheck %s --check-prefix=OVERFLOW -// OVERFLOW: Relocation R_AARCH64_PREL16 out of range +// OVERFLOW: Relocation R_AARCH64_PREL16 out of range: -94209 is not in [-32768, 65535] diff --git a/test/ELF/aarch64-prel32.s b/test/ELF/aarch64-prel32.s index 302f4521f46b..7aa290382c53 100644 --- a/test/ELF/aarch64-prel32.s +++ b/test/ELF/aarch64-prel32.s @@ -28,4 +28,4 @@ _start: // | FileCheck %s --check-prefix=OVERFLOW // RUN: not ld.lld %t.o %t257.o -o %t2 // | FileCheck %s --check-prefix=OVERFLOW -// OVERFLOW: Relocation R_AARCH64_PREL32 out of range +// OVERFLOW: Relocation R_AARCH64_PREL32 out of range: 18446744071562006527 is not in [-2147483648, 4294967295] diff --git a/test/ELF/aarch64-thunk-pi.s b/test/ELF/aarch64-thunk-pi.s new file mode 100644 index 000000000000..91e2b7f0f3cd --- /dev/null +++ b/test/ELF/aarch64-thunk-pi.s @@ -0,0 +1,91 @@ +// RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %s -o %t +// RUN: echo "SECTIONS { \ +// RUN: .text_low : { *(.text_low) } \ +// RUN: .text_high 0x10000000 : { *(.text_high) } \ +// RUN: } " > %t.script +// RUN: ld.lld --script %t.script --shared %t -o %t2 2>&1 +// RUN: llvm-objdump -d -triple=aarch64-linux-gnu %t2 | FileCheck %s +// REQUIRES: aarch64 + +// Check that Position Independent thunks are generated for shared libraries. + .section .text_low, "ax", %progbits + .globl low_target + .type low_target, %function +low_target: + // Need thunk to high_target@plt + bl high_target + ret +// CHECK: low_target: +// CHECK-NEXT: 0: 04 00 00 94 bl #16 +// CHECK-NEXT: 4: c0 03 5f d6 ret + + .hidden low_target2 + .globl low_target2 + .type low_target2, %function +low_target2: + // Need thunk to high_target + bl high_target2 + ret +// CHECK: low_target2: +// CHECK-NEXT: 8: 05 00 00 94 bl #20 +// CHECK-NEXT: c: c0 03 5f d6 ret + +// Expect range extension thunks for .text_low +// adrp calculation is (PC + signed immediate) & (!0xfff) +// CHECK: __AArch64ADRPThunk_high_target: +// CHECK-NEXT: 10: 10 00 08 90 adrp x16, #268435456 +// CHECK-NEXT: 14: 10 82 04 91 add x16, x16, #288 +// CHECK-NEXT: 18: 00 02 1f d6 br x16 +// CHECK: __AArch64ADRPThunk_high_target2: +// CHECK-NEXT: 1c: 10 00 08 90 adrp x16, #268435456 +// CHECK-NEXT: 20: 10 22 00 91 add x16, x16, #8 +// CHECK-NEXT: 24: 00 02 1f d6 br x16 + + + .section .text_high, "ax", %progbits + .globl high_target + .type high_target, %function +high_target: + // No thunk needed as we can reach low_target@plt + bl low_target + ret +// CHECK: high_target: +// CHECK-NEXT: 10000000: 4c 00 00 94 bl #304 +// CHECK-NEXT: 10000004: c0 03 5f d6 ret + + .hidden high_target2 + .globl high_target2 + .type high_target2, %function +high_target2: + // Need thunk to low_target + bl low_target2 + ret +// CHECK: high_target2: +// CHECK-NEXT: 10000008: 02 00 00 94 bl #8 +// CHECK-NEXT: 1000000c: c0 03 5f d6 ret + +// Expect Thunk for .text.high + +// CHECK: __AArch64ADRPThunk_low_target2: +// CHECK-NEXT: 10000010: 10 00 f8 90 adrp x16, #-268435456 +// CHECK-NEXT: 10000014: 10 22 00 91 add x16, x16, #8 +// CHECK-NEXT: 10000018: 00 02 1f d6 br x16 + +// CHECK: Disassembly of section .plt: +// CHECK-NEXT: .plt: +// CHECK-NEXT: 10000100: f0 7b bf a9 stp x16, x30, [sp, #-16]! +// CHECK-NEXT: 10000104: 10 00 00 90 adrp x16, #0 +// CHECK-NEXT: 10000108: 11 aa 40 f9 ldr x17, [x16, #336] +// CHECK-NEXT: 1000010c: 10 42 05 91 add x16, x16, #336 +// CHECK-NEXT: 10000110: 20 02 1f d6 br x17 +// CHECK-NEXT: 10000114: 1f 20 03 d5 nop +// CHECK-NEXT: 10000118: 1f 20 03 d5 nop +// CHECK-NEXT: 1000011c: 1f 20 03 d5 nop +// CHECK-NEXT: 10000120: 10 00 00 90 adrp x16, #0 +// CHECK-NEXT: 10000124: 11 ae 40 f9 ldr x17, [x16, #344] +// CHECK-NEXT: 10000128: 10 62 05 91 add x16, x16, #344 +// CHECK-NEXT: 1000012c: 20 02 1f d6 br x17 +// CHECK-NEXT: 10000130: 10 00 00 90 adrp x16, #0 +// CHECK-NEXT: 10000134: 11 b2 40 f9 ldr x17, [x16, #352] +// CHECK-NEXT: 10000138: 10 82 05 91 add x16, x16, #352 +// CHECK-NEXT: 1000013c: 20 02 1f d6 br x17 diff --git a/test/ELF/aarch64-thunk-script.s b/test/ELF/aarch64-thunk-script.s new file mode 100644 index 000000000000..ebfaf72de5f4 --- /dev/null +++ b/test/ELF/aarch64-thunk-script.s @@ -0,0 +1,41 @@ +// RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %s -o %t +// RUN: echo "SECTIONS { \ +// RUN: .text_low 0x2000: { *(.text_low) } \ +// RUN: .text_high 0x8002000 : { *(.text_high) } \ +// RUN: } " > %t.script +// RUN: ld.lld --script %t.script %t -o %t2 2>&1 +// RUN: llvm-objdump -d -triple=aarch64-linux-gnu %t2 | FileCheck %s +// REQUIRES: aarch64 + +// Check that we have the out of branch range calculation right. The immediate +// field is signed so we have a slightly higher negative displacement. + .section .text_low, "ax", %progbits + .globl _start + .type _start, %function +_start: + // Need thunk to high_target@plt + bl high_target + ret + + .section .text_high, "ax", %progbits + .globl high_target + .type high_target, %function +high_target: + // No Thunk needed as we are within signed immediate range + bl _start + ret + +// CHECK: Disassembly of section .text_low: +// CHECK-NEXT: _start: +// CHECK-NEXT: 2000: 02 00 00 94 bl #8 +// CHECK-NEXT: 2004: c0 03 5f d6 ret +// CHECK: __AArch64AbsLongThunk_high_target: +// CHECK-NEXT: 2008: 50 00 00 58 ldr x16, #8 +// CHECK-NEXT: 200c: 00 02 1f d6 br x16 +// CHECK: $d: +// CHECK-NEXT: 2010: 00 20 00 08 .word 0x08002000 +// CHECK-NEXT: 2014: 00 00 00 00 .word 0x00000000 +// CHECK: Disassembly of section .text_high: +// CHECK-NEXT: high_target: +// CHECK-NEXT: 8002000: 00 00 00 96 bl #-134217728 +// CHECK-NEXT: 8002004: c0 03 5f d6 ret diff --git a/test/ELF/aarch64-thunk-section-location.s b/test/ELF/aarch64-thunk-section-location.s new file mode 100644 index 000000000000..bf70b7c365ba --- /dev/null +++ b/test/ELF/aarch64-thunk-section-location.s @@ -0,0 +1,41 @@ +// RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %s -o %t +// RUN: ld.lld %t -o %t2 2>&1 +// RUN: llvm-objdump -d -start-address=134086664 -stop-address=134086676 -triple=aarch64-linux-gnu %t2 | FileCheck %s +// REQUIRES: aarch64 +// Check that the range extension thunks are dumped close to the aarch64 branch +// range of 128 MiB + .section .text.1, "ax", %progbits + .balign 0x1000 + .globl _start +_start: + bl high_target + ret + + .section .text.2, "ax", %progbits + .space 0x2000000 + + .section .text.2, "ax", %progbits + .space 0x2000000 + + .section .text.3, "ax", %progbits + .space 0x2000000 + + .section .text.4, "ax", %progbits + .space 0x2000000 - 0x40000 + + .section .text.5, "ax", %progbits + .space 0x40000 + + .section .text.6, "ax", %progbits + .balign 0x1000 + + .globl high_target + .type high_target, %function +high_target: + ret + +// CHECK: __AArch64AbsLongThunk_high_target: +// CHECK-NEXT: 7fe0008: 50 00 00 58 ldr x16, #8 +// CHECK-NEXT: 7fe000c: 00 02 1f d6 br x16 +// CHECK: $d: +// CHECK-NEXT: 7fe0010: 00 10 02 08 .word 0x08021000 diff --git a/test/ELF/aarch64-tls-gdie.s b/test/ELF/aarch64-tls-gdie.s index c66ea6cfcadb..ab7461ac2973 100644 --- a/test/ELF/aarch64-tls-gdie.s +++ b/test/ELF/aarch64-tls-gdie.s @@ -2,7 +2,7 @@ // RUN: llvm-mc %s -o %t.o -filetype=obj -triple=aarch64-pc-linux // RUN: llvm-mc %p/Inputs/aarch64-tls-gdie.s -o %t2.o -filetype=obj -triple=aarch64-pc-linux // RUN: ld.lld %t2.o -o %t2.so -shared -// RUN: ld.lld %t.o %t2.so -o %t +// RUN: ld.lld --hash-style=sysv %t.o %t2.so -o %t // RUN: llvm-readobj -s %t | FileCheck --check-prefix=SEC %s // RUN: llvm-objdump -d %t | FileCheck %s diff --git a/test/ELF/aarch64-tls-ie.s b/test/ELF/aarch64-tls-ie.s index 81ca326aff54..8b7431093a26 100644 --- a/test/ELF/aarch64-tls-ie.s +++ b/test/ELF/aarch64-tls-ie.s @@ -2,7 +2,7 @@ # RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-freebsd %p/Inputs/aarch64-tls-ie.s -o %tdso.o # RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-freebsd %s -o %tmain.o # RUN: ld.lld -shared %tdso.o -o %tdso.so -# RUN: ld.lld %tmain.o %tdso.so -o %tout +# RUN: ld.lld --hash-style=sysv %tmain.o %tdso.so -o %tout # RUN: llvm-objdump -d %tout | FileCheck %s # RUN: llvm-readobj -s -r %tout | FileCheck -check-prefix=RELOC %s # REQUIRES: aarch64 diff --git a/test/ELF/aarch64-tls-static.s b/test/ELF/aarch64-tls-static.s index 24306d5d7ee3..309a2e9f56ca 100644 --- a/test/ELF/aarch64-tls-static.s +++ b/test/ELF/aarch64-tls-static.s @@ -1,6 +1,6 @@ // REQUIRES: aarch64 // RUN: llvm-mc %s -o %t.o -triple aarch64-pc-linux -filetype=obj -// RUN: ld.lld %t.o -o %t.so -shared +// RUN: ld.lld --hash-style=sysv %t.o -o %t.so -shared // RUN: llvm-readobj -s %t.so | FileCheck --check-prefix=SEC %s // RUN: llvm-objdump -d %t.so | FileCheck %s diff --git a/test/ELF/aarch64-tlsdesc.s b/test/ELF/aarch64-tlsdesc.s index 09dfd04d8ac9..b7c2e65a164f 100644 --- a/test/ELF/aarch64-tlsdesc.s +++ b/test/ELF/aarch64-tlsdesc.s @@ -1,6 +1,6 @@ // REQUIRES: aarch64 // RUN: llvm-mc -filetype=obj -triple=aarch64-pc-linux %s -o %t.o -// RUN: ld.lld -shared %t.o -o %t.so +// RUN: ld.lld --hash-style=sysv -shared %t.o -o %t.so // RUN: llvm-objdump -d %t.so | FileCheck %s // RUN: llvm-readobj -r %t.so | FileCheck --check-prefix=REL %s diff --git a/test/ELF/aarch64-undefined-weak.s b/test/ELF/aarch64-undefined-weak.s index 1c21213643ac..35f50417497e 100644 --- a/test/ELF/aarch64-undefined-weak.s +++ b/test/ELF/aarch64-undefined-weak.s @@ -30,9 +30,11 @@ _start: .xword target - . // R_AARCH64_PREL16 .hword target - . +// R_AARCH64_LD_PREL_LO19 + ldr x8, target // CHECK: Disassembly of section .text: -// 131076 = 0x20004 +// 131072 = 0x20000 // CHECK: 20000: {{.*}} b #4 // CHECK-NEXT: 20004: {{.*}} bl #4 // CHECK-NEXT: 20008: {{.*}} b.eq #4 @@ -43,3 +45,5 @@ _start: // CHECK-NEXT: 2001c: {{.*}} .word 0x00000000 // CHECK-NEXT: 20020: {{.*}} .word 0x00000000 // CHECK-NEXT: 20024: {{.*}} .short 0x0000 +// CHECK: $x.2: +// CHECK-NEXT: 20026: {{.*}} ldr x8, #0 diff --git a/test/ELF/abs-hidden.s b/test/ELF/abs-hidden.s index 5fad4cf6c40d..82d19cdc015a 100644 --- a/test/ELF/abs-hidden.s +++ b/test/ELF/abs-hidden.s @@ -1,7 +1,7 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/abs-hidden.s -o %t2.o -// RUN: ld.lld %t.o %t2.o -o %t.so -shared +// RUN: ld.lld --hash-style=sysv %t.o %t2.o -o %t.so -shared // RUN: llvm-readobj -r -s -section-data %t.so | FileCheck %s .quad foo diff --git a/test/ELF/allow-multiple-definition.s b/test/ELF/allow-multiple-definition.s index e4637e1a5367..c54438d9f1e0 100644 --- a/test/ELF/allow-multiple-definition.s +++ b/test/ELF/allow-multiple-definition.s @@ -8,6 +8,11 @@ # RUN: llvm-objdump -d %t3 | FileCheck %s # RUN: llvm-objdump -d %t4 | FileCheck -check-prefix=REVERT %s +# RUN: ld.lld -z muldefs %t1 %t2 -o %t3 +# RUN: ld.lld -z muldefs %t2 %t1 -o %t4 +# RUN: llvm-objdump -d %t3 | FileCheck %s +# RUN: llvm-objdump -d %t4 | FileCheck -check-prefix=REVERT %s + # inputs contain different constants for instuction movl. # Tests below checks that order of files in command line # affects on what symbol will be used. diff --git a/test/ELF/amdgpu-elf-flags-err.s b/test/ELF/amdgpu-elf-flags-err.s new file mode 100644 index 000000000000..4c295b5b92e4 --- /dev/null +++ b/test/ELF/amdgpu-elf-flags-err.s @@ -0,0 +1,7 @@ +# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 -filetype=obj %S/Inputs/amdgpu-kernel-0.s -o %t-0.o +# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 -filetype=obj %S/Inputs/amdgpu-kernel-1.s -o %t-1.o +# RUN: not ld.lld -shared %t-0.o %t-1.o %S/Inputs/amdgpu-kernel-2.o -o %t.so 2>&1 | FileCheck %s + +# REQUIRES: amdgpu + +# CHECK: error: incompatible e_flags: {{.*}}amdgpu-kernel-2.o diff --git a/test/ELF/amdgpu-elf-flags.s b/test/ELF/amdgpu-elf-flags.s new file mode 100644 index 000000000000..85f891a98364 --- /dev/null +++ b/test/ELF/amdgpu-elf-flags.s @@ -0,0 +1,10 @@ +# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 -filetype=obj %S/Inputs/amdgpu-kernel-0.s -o %t-0.o +# RUN: llvm-mc -triple amdgcn-amd-amdhsa -mcpu=gfx803 -filetype=obj %S/Inputs/amdgpu-kernel-1.s -o %t-1.o +# RUN: ld.lld -shared %t-0.o %t-1.o -o %t.so +# RUN: llvm-readobj -file-headers %t.so | FileCheck %s + +# REQUIRES: amdgpu + +# CHECK: Flags [ (0x2) +# CHECK: EF_AMDGPU_ARCH_GCN (0x2) +# CHECK: ] diff --git a/test/ELF/amdgpu-relocs.s b/test/ELF/amdgpu-relocs.s index 1adb1faf20fd..8b5a61ed21f4 100644 --- a/test/ELF/amdgpu-relocs.s +++ b/test/ELF/amdgpu-relocs.s @@ -1,5 +1,5 @@ # RUN: llvm-mc -filetype=obj -triple=amdgcn--amdhsa -mcpu=fiji %s -o %t.o -# RUN: ld.lld -shared %t.o -o %t.so +# RUN: ld.lld --hash-style=sysv -shared %t.o -o %t.so # RUN: llvm-readobj -r %t.so | FileCheck %s # RUN: llvm-objdump -s %t.so | FileCheck %s --check-prefix=OBJDUMP @@ -65,10 +65,23 @@ ptr: .quad temp .size ptr, 8 +# R_AMDGPU_RELATIVE64: + .type temp2, @object + .local temp2 + .size temp2, 4 + + .type ptr2, @object + .globl ptr2 + .size ptr2, 8 + .p2align 3 +ptr2: + .quad temp2 + # The relocation for local_var{0, 1, 2} and var should be resolved by the # linker. # CHECK: Relocations [ # CHECK: .rela.dyn { +# CHECK-NEXT: R_AMDGPU_RELATIVE64 - 0x0 # CHECK-NEXT: R_AMDGPU_ABS64 common_var0 0x0 # CHECK-NEXT: R_AMDGPU_ABS64 common_var1 0x0 # CHECK-NEXT: R_AMDGPU_ABS64 common_var2 0x0 diff --git a/test/ELF/arm-bl-v6.s b/test/ELF/arm-bl-v6.s new file mode 100644 index 000000000000..6317aa433d6c --- /dev/null +++ b/test/ELF/arm-bl-v6.s @@ -0,0 +1,51 @@ +// RUN: llvm-mc -filetype=obj -triple=arm-none-linux-gnueabi %s -o %t +// RUN: ld.lld %t -o %t2 2>&1 | FileCheck %s +// REQUIRES: arm + +// On Arm v6 the range of a Thumb BL instruction is only 4 megabytes as the +// extended range encoding is not supported. The following example has a Thumb +// BL that is out of range on ARM v6 and requires a range extension thunk. +// As v6 does not support MOVT or MOVW instructions the Thunk must not +// use these instructions either. At present we don't support v6 so we give a +// warning for unsupported features. + +// CHECK: warning: lld uses extended branch encoding, no object with architecture supporting feature detected. +// CHECK-NEXT: warning: lld may use movt/movw, no object with architecture supporting feature detected. +// ARM v6 supports blx so we shouldn't see the blx not supported warning. +// CHECK-NOT: warning: lld uses blx instruction, no object with architecture supporting feature detected. + .text + .syntax unified + .cpu arm1176jzf-s + .eabi_attribute 6, 6 @ Tag_CPU_arch + .globl _start + .type _start,%function + .balign 0x1000 +_start: + bl thumbfunc + bx lr + + .thumb + .section .text.2, "ax", %progbits + .globl thumbfunc + .type thumbfunc,%function +thumbfunc: + bl farthumbfunc + +// 6 Megabytes, enough to make farthumbfunc out of range of caller on a v6 +// Arm, but not on a v7 Arm. + .section .text.3, "ax", %progbits + .space 0x200000 + + .section .text.4, "ax", %progbits + .space 0x200000 + + .section .text.5, "ax", %progbits + .space 0x200000 + + .thumb + .section .text.6, "ax", %progbits + .balign 0x1000 + .globl farthumbfunc + .type farthumbfunc,%function +farthumbfunc: + bx lr diff --git a/test/ELF/arm-blx-v4t.s b/test/ELF/arm-blx-v4t.s new file mode 100644 index 000000000000..858b93fd5891 --- /dev/null +++ b/test/ELF/arm-blx-v4t.s @@ -0,0 +1,30 @@ +// RUN: llvm-mc -filetype=obj -triple=arm-none-linux-gnueabi %s -o %t +// RUN: ld.lld %t -o %t2 2>&1 | FileCheck %s +// REQUIRES: arm + +// On Arm v4t there is no blx instruction so all interworking must go via +// a thunk. At present we don't support v4t so we give a warning for unsupported +// features. + +// CHECK: warning: lld uses blx instruction, no object with architecture supporting feature detected. +// CHECK-NEXT: warning: lld uses extended branch encoding, no object with architecture supporting feature detected. +// CHECK-NEXT: warning: lld may use movt/movw, no object with architecture supporting feature detected. + + .text + .syntax unified + .cpu arm7tdmi + .eabi_attribute 6, 2 @ Tag_CPU_arch + .arm + .globl _start + .type _start,%function + .p2align 2 +_start: + bl thumbfunc + bx lr + + .thumb + .section .text.2, "ax", %progbits + .globl thumbfunc + .type thumbfunc,%function +thumbfunc: + bx lr diff --git a/test/ELF/arm-branch-error.s b/test/ELF/arm-branch-error.s deleted file mode 100644 index f1a855d7373f..000000000000 --- a/test/ELF/arm-branch-error.s +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t -// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %S/Inputs/far-arm-abs.s -o %tfar -// RUN: not ld.lld %t %tfar -o %t2 2>&1 | FileCheck %s -// REQUIRES: arm - .syntax unified - .section .text, "ax",%progbits - .globl _start - .balign 0x10000 - .type _start,%function -_start: - // address of too_far symbols are just out of range of ARM branch with - // 26-bit immediate field and an addend of -8 - bl too_far1 - b too_far2 - beq too_far3 - -// CHECK: R_ARM_CALL out of range -// CHECK-NEXT: R_ARM_JUMP24 out of range -// CHECK-NEXT: R_ARM_JUMP24 out of range diff --git a/test/ELF/arm-branch-rangethunk.s b/test/ELF/arm-branch-rangethunk.s new file mode 100644 index 000000000000..c61ec899adae --- /dev/null +++ b/test/ELF/arm-branch-rangethunk.s @@ -0,0 +1,34 @@ +// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t +// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %S/Inputs/far-arm-abs.s -o %tfar +// RUN: ld.lld %t %tfar -o %t2 2>&1 +// RUN: llvm-objdump -d -triple=armv7a-none-linux-gnueabi %t2 | FileCheck %s +// REQUIRES: arm + .syntax unified + .section .text, "ax",%progbits + .globl _start + .balign 0x10000 + .type _start,%function +_start: + // address of too_far symbols are just out of range of ARM branch with + // 26-bit immediate field and an addend of -8 + bl too_far1 + b too_far2 + beq too_far3 + +// CHECK: Disassembly of section .text: +// CHECK-NEXT: _start: +// CHECK-NEXT: 20000: 01 00 00 eb bl #4 <__ARMv7ABSLongThunk_too_far1> +// CHECK-NEXT: 20004: 03 00 00 ea b #12 <__ARMv7ABSLongThunk_too_far2> +// CHECK-NEXT: 20008: 05 00 00 0a beq #20 <__ARMv7ABSLongThunk_too_far3> +// CHECK: __ARMv7ABSLongThunk_too_far1: +// CHECK-NEXT: 2000c: 08 c0 00 e3 movw r12, #8 +// CHECK-NEXT: 20010: 02 c2 40 e3 movt r12, #514 +// CHECK-NEXT: 20014: 1c ff 2f e1 bx r12 +// CHECK: __ARMv7ABSLongThunk_too_far2: +// CHECK-NEXT: 20018: 0c c0 00 e3 movw r12, #12 +// CHECK-NEXT: 2001c: 02 c2 40 e3 movt r12, #514 +// CHECK-NEXT: 20020: 1c ff 2f e1 bx r12 +// CHECK: __ARMv7ABSLongThunk_too_far3: +// CHECK-NEXT: 20024: 10 c0 00 e3 movw r12, #16 +// CHECK-NEXT: 20028: 02 c2 40 e3 movt r12, #514 +// CHECK-NEXT: 2002c: 1c ff 2f e1 bx r12 diff --git a/test/ELF/arm-branch-undef-weak-plt-thunk.s b/test/ELF/arm-branch-undef-weak-plt-thunk.s new file mode 100644 index 000000000000..f95da0dcec21 --- /dev/null +++ b/test/ELF/arm-branch-undef-weak-plt-thunk.s @@ -0,0 +1,35 @@ +// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %S/Inputs/arm-shared.s -o %t +// RUN: ld.lld %t --shared -o %t.so +// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t2 +// RUN: ld.lld %t2 %t.so -o %t3 +// RUN: llvm-objdump -d -triple=armv7a-none-linux-gnueabi -start-address=69632 -stop-address=69664 %t3 | FileCheck %s +// REQUIRES: arm + +// When we are dynamic linking, undefined weak references have a PLT entry so +// we must create a thunk for the branch to the PLT entry. + + .text + .globl bar2 + .weak undefined_weak_we_expect_a_plt_entry_for +_start: + .globl _start + .type _start, %function + b undefined_weak_we_expect_a_plt_entry_for + bl bar2 +// Create 32 Mb gap between the call to the weak reference and the PLT so that +// the b and bl need a range-extension thunk. + .section .text.1, "ax", %progbits + .space 32 * 1024 * 1024 + +// CHECK: Disassembly of section .text: +// CHECK-NEXT: _start: +// CHECK-NEXT: 11000: 00 00 00 ea b #0 <__ARMv7ABSLongThunk_undefined_weak_we_expect_a_plt_entry_for> +// CHECK-NEXT: 11004: 02 00 00 eb bl #8 <__ARMv7ABSLongThunk_bar2> +// CHECK: __ARMv7ABSLongThunk_undefined_weak_we_expect_a_plt_entry_for: +// CHECK-NEXT: 11008: 40 c0 01 e3 movw r12, #4160 +// CHECK-NEXT: 1100c: 01 c2 40 e3 movt r12, #513 +// CHECK-NEXT: 11010: 1c ff 2f e1 bx r12 +// CHECK: __ARMv7ABSLongThunk_bar2: +// CHECK-NEXT: 11014: 50 c0 01 e3 movw r12, #4176 +// CHECK-NEXT: 11018: 01 c2 40 e3 movt r12, #513 +// CHECK-NEXT: 1101c: 1c ff 2f e1 bx r12 diff --git a/test/ELF/arm-copy.s b/test/ELF/arm-copy.s index e5ce1577babd..dc9e3628de4f 100644 --- a/test/ELF/arm-copy.s +++ b/test/ELF/arm-copy.s @@ -2,7 +2,7 @@ // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %p/Inputs/relocation-copy-arm.s -o %t2.o // RUN: ld.lld -shared %t2.o -o %t2.so -// RUN: ld.lld %t.o %t2.so -o %t3 +// RUN: ld.lld --hash-style=sysv %t.o %t2.so -o %t3 // RUN: llvm-readobj -s -r --expand-relocs -symbols %t3 | FileCheck %s // RUN: llvm-objdump -d -triple=armv7a-none-linux-gnueabi %t3 | FileCheck -check-prefix=CODE %s // RUN: llvm-objdump -s -triple=armv7a-none-linux-gnueabi -section=.rodata %t3 | FileCheck -check-prefix=RODATA %s diff --git a/test/ELF/arm-exidx-dedup.s b/test/ELF/arm-exidx-dedup.s new file mode 100644 index 000000000000..1648f77152e9 --- /dev/null +++ b/test/ELF/arm-exidx-dedup.s @@ -0,0 +1,126 @@ +// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t +// RUN: ld.lld %t --no-merge-exidx-entries -o %t2 +// RUN: llvm-objdump -s %t2 | FileCheck --check-prefix CHECK-DUPS %s +// RUN: ld.lld %t -o %t3 +// RUN: llvm-objdump -s %t3 | FileCheck %s +// REQUIRES: arm +// Test that lld can at least remove duplicate .ARM.exidx sections. A more +// fine grained implementation will be able to remove duplicate entries within +// a .ARM.exidx section. + +// With duplicate entries +// CHECK-DUPS: Contents of section .ARM.exidx: +// CHECK-DUPS-NEXT: 100d4 2c0f0000 01000000 280f0000 01000000 +// CHECK-DUPS-NEXT: 100e4 240f0000 01000000 200f0000 01000000 +// CHECK-DUPS-NEXT: 100f4 1c0f0000 08849780 180f0000 08849780 +// CHECK-DUPS-NEXT: 10104 140f0000 08849780 100f0000 14000000 +// CHECK-DUPS-NEXT: 10114 0c0f0000 18000000 080f0000 01000000 +// CHECK-DUPS-NEXT: Contents of section .ARM.extab: + +// After duplicate entry removal +// CHECK: Contents of section .ARM.exidx: +// CHECK-NEXT: 100d4 2c0f0000 01000000 340f0000 08849780 +// CHECK-NEXT: 100e4 380f0000 14000000 340f0000 18000000 +// CHECK-NEXT: 100f4 300f0000 01000000 +// CHECK-NEXT: Contents of section .ARM.extab: + .syntax unified + + // Expect 1 EXIDX_CANTUNWIND entry. + .section .text.00, "ax", %progbits + .globl _start +_start: + .fnstart + bx lr + .cantunwind + .fnend + + // Expect .ARM.exidx.text.01 to be identical to .ARM.exidx.text.00 + .section .text.01, "ax", %progbits + .globl f1 +f1: + .fnstart + bx lr + .cantunwind + .fnend + + // Expect 2 EXIDX_CANTUNWIND entries, these can be duplicated into + // .ARM.exid.text.00 + .section .text.02, "ax", %progbits + .globl f2 +f2: + .fnstart + bx lr + .cantunwind + .fnend + + .globl f3 +f3: + .fnstart + bx lr + .cantunwind + .fnend + + // Expect inline unwind instructions, not a duplicate of previous entry. + .section .text.03, "ax", %progbits + .global f4 +f4: + .fnstart + bx lr + .save {r7, lr} + .setfp r7, sp, #0 + .fnend + + // Expect 2 inline unwind entries that are a duplicate of + // .ARM.exidx.text.03 + .section .text.04, "ax", %progbits + .global f5 +f5: + .fnstart + bx lr + .save {r7, lr} + .setfp r7, sp, #0 + .fnend + + .global f6 +f6: + .fnstart + bx lr + .save {r7, lr} + .setfp r7, sp, #0 + .fnend + + // Expect a section with a reference to an .ARM.extab. Not a duplicate + // of previous inline table entry. + .section .text.05, "ax",%progbits + .global f7 +f7: + .fnstart + bx lr + .personality __gxx_personality_v0 + .handlerdata + .long 0 + .fnend + + // Expect a reference to an identical .ARM.extab. We do not try to + // deduplicate references to .ARM.extab sections. + .section .text.06, "ax",%progbits + .global f8 +f8: + .fnstart + bx lr + .personality __gxx_personality_v0 + .handlerdata + .long 0 + .fnend + + // Dummy implementation of personality routines to satisfy reference from + // exception tables + .section .text.__gcc_personality_v0, "ax", %progbits + .global __gxx_personality_v0 +__gxx_personality_v0: + bx lr + + .section .text.__aeabi_unwind_cpp_pr0, "ax", %progbits + .global __aeabi_unwind_cpp_pr0 +__aeabi_unwind_cpp_pr0: + bx lr diff --git a/test/ELF/arm-exidx-gc.s b/test/ELF/arm-exidx-gc.s index 1336c256f7c1..34bd9dbe37b2 100644 --- a/test/ELF/arm-exidx-gc.s +++ b/test/ELF/arm-exidx-gc.s @@ -1,5 +1,5 @@ // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t -// RUN: ld.lld %t -o %t2 --gc-sections 2>&1 +// RUN: ld.lld %t --no-merge-exidx-entries -o %t2 --gc-sections 2>&1 // RUN: llvm-objdump -d -triple=armv7a-none-linux-gnueabi %t2 | FileCheck %s // RUN: llvm-objdump -s -triple=armv7a-none-linux-gnueabi %t2 | FileCheck -check-prefix=CHECK-EXIDX %s // REQUIRES: arm diff --git a/test/ELF/arm-exidx-order.s b/test/ELF/arm-exidx-order.s index 951c71a4c33e..c988ad8a2cfe 100644 --- a/test/ELF/arm-exidx-order.s +++ b/test/ELF/arm-exidx-order.s @@ -1,6 +1,6 @@ // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %S/Inputs/arm-exidx-cantunwind.s -o %tcantunwind -// RUN: ld.lld %t %tcantunwind -o %t2 2>&1 +// RUN: ld.lld --no-merge-exidx-entries %t %tcantunwind -o %t2 2>&1 // RUN: llvm-objdump -d -triple=armv7a-none-linux-gnueabi %t2 | FileCheck %s // RUN: llvm-objdump -s -triple=armv7a-none-linux-gnueabi %t2 | FileCheck -check-prefix=CHECK-EXIDX %s // RUN: llvm-readobj --program-headers --sections %t2 | FileCheck -check-prefix=CHECK-PT %s @@ -8,7 +8,7 @@ // RUN: echo "SECTIONS { \ // RUN: .text 0x11000 : { *(.text*) } \ // RUN: .ARM.exidx : { *(.ARM.exidx) } } " > %t.script -// RUN: ld.lld --script %t.script %tcantunwind %t -o %t3 2>&1 +// RUN: ld.lld --no-merge-exidx-entries --script %t.script %tcantunwind %t -o %t3 2>&1 // RUN: llvm-objdump -d -triple=armv7a-none-linux-gnueabi %t3 | FileCheck -check-prefix=CHECK-SCRIPT %s // RUN: llvm-objdump -s -triple=armv7a-none-linux-gnueabi %t3 | FileCheck -check-prefix=CHECK-SCRIPT-EXIDX %s // REQUIRES: arm diff --git a/test/ELF/arm-exidx-sentinel-orphan.s b/test/ELF/arm-exidx-sentinel-orphan.s index c054fe940db6..0e68c245dd10 100644 --- a/test/ELF/arm-exidx-sentinel-orphan.s +++ b/test/ELF/arm-exidx-sentinel-orphan.s @@ -4,7 +4,7 @@ // RUN: echo "SECTIONS { \ // RUN: .text 0x11000 : { *(.text*) } \ // RUN: } " > %t.script -// RUN: ld.lld --script %t.script %t -o %t2 +// RUN: ld.lld --no-merge-exidx-entries --script %t.script %t -o %t2 // RUN: llvm-objdump -s -triple=armv7a-none-linux-gnueabi %t2 | FileCheck %s // REQUIRES: arm diff --git a/test/ELF/arm-exidx-shared.s b/test/ELF/arm-exidx-shared.s index e06733352a37..bf7c2dc383e7 100644 --- a/test/ELF/arm-exidx-shared.s +++ b/test/ELF/arm-exidx-shared.s @@ -1,5 +1,5 @@ // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t -// RUN: ld.lld %t --shared -o %t2 2>&1 +// RUN: ld.lld --hash-style=sysv %t --shared -o %t2 2>&1 // RUN: llvm-readobj --relocations %t2 | FileCheck %s // RUN: llvm-objdump -s -triple=armv7a-none-linux-gnueabi %t2 | FileCheck -check-prefix=CHECK-EXTAB %s // REQUIRES: arm @@ -41,5 +41,5 @@ __aeabi_unwind_cpp_pr0: // CHECK-NEXT: 0x200C R_ARM_JUMP_SLOT __gxx_personality_v0 // CHECK-EXTAB: Contents of section .ARM.extab: -// 014c + 0ed8 = 0x1024 = __gxx_personality_v0(PLT) -// CHECK-EXTAB-NEXT: 014c d80e0000 b0b0b000 00000000 +// 014c + 0ee4 = 0x1030 = __gxx_personality_v0(PLT) +// CHECK-EXTAB-NEXT: 014c e40e0000 b0b0b000 00000000 diff --git a/test/ELF/arm-gnu-ifunc-plt.s b/test/ELF/arm-gnu-ifunc-plt.s index efcaee1e9889..2ff2ec0a143d 100644 --- a/test/ELF/arm-gnu-ifunc-plt.s +++ b/test/ELF/arm-gnu-ifunc-plt.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -filetype=obj -triple=armv7a-linux-gnueabihf %S/Inputs/arm-shared.s -o %t1.o // RUN: ld.lld %t1.o --shared -o %t.so // RUN: llvm-mc -filetype=obj -triple=armv7a-linux-gnueabihf %s -o %t.o -// RUN: ld.lld %t.so %t.o -o %tout +// RUN: ld.lld --hash-style=sysv %t.so %t.o -o %tout // RUN: llvm-objdump -triple=armv7a-linux-gnueabihf -d %tout | FileCheck %s --check-prefix=DISASM // RUN: llvm-objdump -s %tout | FileCheck %s --check-prefix=GOTPLT // RUN: llvm-readobj -r -dynamic-table %tout | FileCheck %s @@ -33,49 +33,49 @@ // DISASM-NEXT: 11000: 1e ff 2f e1 bx lr // DISASM: bar: // DISASM-NEXT: 11004: 1e ff 2f e1 bx lr -// DISASM: _start: +// DISASM: _start: // DISASM-NEXT: 11008: 14 00 00 eb bl #80 // DISASM-NEXT: 1100c: 17 00 00 eb bl #92 -// DISASM: 11010: 00 00 00 00 .word 0x00000000 +// DISASM: $d.1: +// DISASM-NEXT: 11010: 00 00 00 00 .word 0x00000000 // DISASM-NEXT: 11014: 04 00 00 00 .word 0x00000004 -// DISASM: 11018: 05 00 00 eb bl #20 -// DISASM-NEXT: 1101c: 08 00 00 eb bl #32 +// DISASM: 11018: 08 00 00 eb bl #32 +// DISASM-NEXT: 1101c: 0b 00 00 eb bl #44 // DISASM-NEXT: Disassembly of section .plt: // DISASM-NEXT: $a: // DISASM-NEXT: 11020: 04 e0 2d e5 str lr, [sp, #-4]! -// DISASM-NEXT: 11024: 04 e0 9f e5 ldr lr, [pc, #4] -// DISASM-NEXT: 11028: 0e e0 8f e0 add lr, pc, lr -// DISASM-NEXT: 1102c: 08 f0 be e5 ldr pc, [lr, #8]! +// DISASM-NEXT: 11024: 00 e6 8f e2 add lr, pc, #0, #12 +// DISASM-NEXT: 11028: 00 ea 8e e2 add lr, lr, #0, #20 +// DISASM-NEXT: 1102c: dc ff be e5 ldr pc, [lr, #4060]! // DISASM: $d: -// DISASM-NEXT: 11030: d0 0f 00 00 .word 0x00000fd0 +// DISASM-NEXT: 11030: d4 d4 d4 d4 .word 0xd4d4d4d4 +// DISASM-NEXT: 11034: d4 d4 d4 d4 .word 0xd4d4d4d4 +// DISASM-NEXT: 11038: d4 d4 d4 d4 .word 0xd4d4d4d4 +// DISASM-NEXT: 1103c: d4 d4 d4 d4 .word 0xd4d4d4d4 // DISASM: $a: -// DISASM-NEXT: 11034: 04 c0 9f e5 ldr r12, [pc, #4] -// DISASM-NEXT: 11038: 0f c0 8c e0 add r12, r12, pc -// DISASM-NEXT: 1103c: 00 f0 9c e5 ldr pc, [r12] +// DISASM-NEXT: 11040: 00 c6 8f e2 add r12, pc, #0, #12 +// DISASM-NEXT: 11044: 00 ca 8c e2 add r12, r12, #0, #20 +// DISASM-NEXT: 11048: c4 ff bc e5 ldr pc, [r12, #4036]! // DISASM: $d: -// DISASM-NEXT: 11040: cc 0f 00 00 .word 0x00000fcc +// DISASM-NEXT: 1104c: d4 d4 d4 d4 .word 0xd4d4d4d4 // DISASM: $a: -// DISASM-NEXT: 11044: 04 c0 9f e5 ldr r12, [pc, #4] -// DISASM-NEXT: 11048: 0f c0 8c e0 add r12, r12, pc -// DISASM-NEXT: 1104c: 00 f0 9c e5 ldr pc, [r12] +// DISASM-NEXT: 11050: 00 c6 8f e2 add r12, pc, #0, #12 +// DISASM-NEXT: 11054: 00 ca 8c e2 add r12, r12, #0, #20 +// DISASM-NEXT: 11058: b8 ff bc e5 ldr pc, [r12, #4024]! // DISASM: $d: -// DISASM-NEXT: 11050: c0 0f 00 00 .word 0x00000fc0 -// Alignment to 16 byte boundary not strictly necessary on ARM, but harmless -// DISASM-NEXT: 11054: d4 d4 d4 d4 .word 0xd4d4d4d4 -// DISASM-NEXT: 11058: d4 d4 d4 d4 .word 0xd4d4d4d4 // DISASM-NEXT: 1105c: d4 d4 d4 d4 .word 0xd4d4d4d4 // DISASM: $a: -// DISASM-NEXT: 11060: 04 c0 9f e5 ldr r12, [pc, #4] -// DISASM-NEXT: 11064: 0f c0 8c e0 add r12, r12, pc -// DISASM-NEXT: 11068: 00 f0 9c e5 ldr pc, [r12] +// DISASM-NEXT: 11060: 00 c6 8f e2 add r12, pc, #0, #12 +// DISASM-NEXT: 11064: 02 ca 8c e2 add r12, r12, #8192 +// DISASM-NEXT: 11068: 18 f0 bc e5 ldr pc, [r12, #24]! // DISASM: $d: -// DISASM-NEXT: 1106c: 14 20 00 00 .word 0x00002014 +// DISASM-NEXT: 1106c: d4 d4 d4 d4 .word 0xd4d4d4d4 // DISASM: $a: -// DISASM-NEXT: 11070: 04 c0 9f e5 ldr r12, [pc, #4] -// DISASM-NEXT: 11074: 0f c0 8c e0 add r12, r12, pc -// DISASM-NEXT: 11078: 00 f0 9c e5 ldr pc, [r12] +// DISASM-NEXT: 11070: 00 c6 8f e2 add r12, pc, #0, #12 +// DISASM-NEXT: 11074: 02 ca 8c e2 add r12, r12, #8192 +// DISASM-NEXT: 11078: 0c f0 bc e5 ldr pc, [r12, #12]! // DISASM: $d: -// DISASM-NEXT: 1107c: 08 20 00 00 .word 0x00002008 +// DISASM-NEXT: 1107c: d4 d4 d4 d4 .word 0xd4d4d4d4 .syntax unified .text diff --git a/test/ELF/arm-gnu-ifunc.s b/test/ELF/arm-gnu-ifunc.s index 23c540310b3c..799b8b17f62b 100644 --- a/test/ELF/arm-gnu-ifunc.s +++ b/test/ELF/arm-gnu-ifunc.s @@ -111,30 +111,29 @@ _start: // DISASM: Disassembly of section .text: // DISASM-NEXT: foo: -// DISASM-NEXT: 11000: 1e ff 2f e1 bx lr -// DISASM: bar: -// DISASM-NEXT: 11004: 1e ff 2f e1 bx lr -// DISASM: _start: -// DISASM-NEXT: 11008: 04 00 00 eb bl #16 -// DISASM-NEXT: 1100c: 07 00 00 eb bl #28 +// DISASM-NEXT: 11000: 1e ff 2f e1 bx lr +// DISASM: bar: +// DISASM-NEXT: 11004: 1e ff 2f e1 bx lr +// DISASM: _start: +// DISASM-NEXT: 11008: 04 00 00 eb bl #16 +// DISASM-NEXT: 1100c: 07 00 00 eb bl #28 // 1 * 65536 + 244 = 0x100f4 __rel_iplt_start -// DISASM-NEXT: 11010: f4 00 00 e3 movw r0, #244 -// DISASM-NEXT: 11014: 01 00 40 e3 movt r0, #1 +// DISASM-NEXT: 11010: f4 00 00 e3 movw r0, #244 +// DISASM-NEXT: 11014: 01 00 40 e3 movt r0, #1 // 1 * 65536 + 260 = 0x10104 __rel_iplt_end -// DISASM-NEXT: 11018: 04 01 00 e3 movw r0, #260 -// DISASM-NEXT: 1101c: 01 00 40 e3 movt r0, #1 +// DISASM-NEXT: 11018: 04 01 00 e3 movw r0, #260 +// DISASM-NEXT: 1101c: 01 00 40 e3 movt r0, #1 // DISASM-NEXT: Disassembly of section .plt: -// DISASM: $a: -// DISASM-NEXT: 11020: 04 c0 9f e5 ldr r12, [pc, #4] -// DISASM-NEXT: 11024: 0f c0 8c e0 add r12, r12, pc -// 11024 + 8 + fd4 = 0x12000 -// DISASM-NEXT: 11028: 00 f0 9c e5 ldr pc, [r12] +// DISASM-NEXT: $a: +// DISASM-NEXT: 11020: 00 c6 8f e2 add r12, pc, #0, #12 +// DISASM-NEXT: 11024: 00 ca 8c e2 add r12, r12, #0, #20 +// DISASM-NEXT: 11028: d8 ff bc e5 ldr pc, [r12, #4056]! // DISASM: $d: -// DISASM-NEXT: 1102c: d4 0f 00 00 .word 0x00000fd4 +// DISASM-NEXT: 1102c: d4 d4 d4 d4 .word 0xd4d4d4d4 // DISASM: $a: -// DISASM-NEXT: 11030: 04 c0 9f e5 ldr r12, [pc, #4] -// DISASM-NEXT: 11034: 0f c0 8c e0 add r12, r12, pc -// 11034 + 8 + fc8 = 0x12004 -// DISASM-NEXT: 11038: 00 f0 9c e5 ldr pc, [r12] +// DISASM-NEXT: 11030: 00 c6 8f e2 add r12, pc, #0, #12 +// DISASM-NEXT: 11034: 00 ca 8c e2 add r12, r12, #0, #20 +// DISASM-NEXT: 11038: cc ff bc e5 ldr pc, [r12, #4044]! // DISASM: $d: -// DISASM-NEXT: 1103c: c8 0f 00 00 .word 0x00000fc8 +// DISASM-NEXT: 1103c: d4 d4 d4 d4 .word 0xd4d4d4d4 + diff --git a/test/ELF/arm-got-relative.s b/test/ELF/arm-got-relative.s index 46a3ca97d080..cf8b0a64a966 100644 --- a/test/ELF/arm-got-relative.s +++ b/test/ELF/arm-got-relative.s @@ -1,6 +1,6 @@ // REQUIRES: arm // RUN: llvm-mc -position-independent -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o -// RUN: ld.lld %t.o -shared -o %t +// RUN: ld.lld --hash-style=sysv %t.o -shared -o %t // RUN: llvm-readobj -s -symbols -dyn-relocations %t | FileCheck %s // RUN: llvm-objdump -d -triple=armv7a-none-linux-gnueabi %t | FileCheck -check-prefix=CODE %s .syntax unified diff --git a/test/ELF/arm-icf-exidx.s b/test/ELF/arm-icf-exidx.s index 6af30285db67..629505cb7ffa 100644 --- a/test/ELF/arm-icf-exidx.s +++ b/test/ELF/arm-icf-exidx.s @@ -23,7 +23,7 @@ __aeabi_unwind_cpp_pr0: bx lr // CHECK: Disassembly of section .text: -// CHECK-NEXT: f: +// CHECK-NEXT: g: // CHECK-NEXT: 11000: 1e ff 2f e1 bx lr // CHECK: __aeabi_unwind_cpp_pr0: // CHECK-NEXT: 11004: 00 f0 20 e3 nop diff --git a/test/ELF/arm-pie-relative.s b/test/ELF/arm-pie-relative.s index f965c24f4fa6..f225015eb5f3 100644 --- a/test/ELF/arm-pie-relative.s +++ b/test/ELF/arm-pie-relative.s @@ -1,5 +1,5 @@ // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t -// RUN: ld.lld %t --pie -o %t2 +// RUN: ld.lld --hash-style=sysv %t --pie -o %t2 // RUN: llvm-readobj -r %t2 | FileCheck %s // RUN: llvm-objdump -s %t2 | FileCheck %s --check-prefix=GOT // REQUIRES: arm diff --git a/test/ELF/arm-plt-reloc.s b/test/ELF/arm-plt-reloc.s index 1588f745f22c..f8166d60ffcf 100644 --- a/test/ELF/arm-plt-reloc.s +++ b/test/ELF/arm-plt-reloc.s @@ -2,7 +2,7 @@ // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t2 // RUN: ld.lld %t1 %t2 -o %t // RUN: llvm-objdump -triple=armv7a-none-linux-gnueabi -d %t | FileCheck %s -// RUN: ld.lld -shared %t1 %t2 -o %t3 +// RUN: ld.lld --hash-style=sysv -shared %t1 %t2 -o %t3 // RUN: llvm-objdump -triple=armv7a-none-linux-gnueabi -d %t3 | FileCheck -check-prefix=DSO %s // RUN: llvm-readobj -s -r %t3 | FileCheck -check-prefix=DSOREL %s // REQUIRES: arm @@ -32,51 +32,55 @@ _start: // CHECK-NEXT: 11014: fb ff ff 0a beq #-20 <func3> // Expect PLT entries as symbols can be preempted +// The .got.plt and .plt displacement is small so we can use small PLT entries. // DSO: Disassembly of section .text: // DSO-NEXT: func1: -// DSO-NEXT: 1000: 1e ff 2f e1 bx lr +// DSO-NEXT: 1000: 1e ff 2f e1 bx lr // DSO: func2: -// DSO-NEXT: 1004: 1e ff 2f e1 bx lr +// DSO-NEXT: 1004: 1e ff 2f e1 bx lr // DSO: func3: -// DSO-NEXT: 1008: 1e ff 2f e1 bx lr +// DSO-NEXT: 1008: 1e ff 2f e1 bx lr // DSO: _start: -// S(0x1034) - P(0x100c) + A(-8) = 0x20 = 32 -// DSO-NEXT: 100c: 08 00 00 ea b #32 -// S(0x1044) - P(0x1010) + A(-8) = 0x2c = 44 -// DSO-NEXT: 1010: 0b 00 00 eb bl #44 -// S(0x1054) - P(0x1014) + A(-8) = 0x38 = 56 -// DSO-NEXT: 1014: 0e 00 00 0a beq #56 - -// DSO: Disassembly of section .plt: +// S(0x1040) - P(0x100c) + A(-8) = 0x2c = 32 +// DSO-NEXT: 100c: 0b 00 00 ea b #44 +// S(0x1050) - P(0x1010) + A(-8) = 0x38 = 56 +// DSO-NEXT: 1010: 0e 00 00 eb bl #56 +// S(0x10160) - P(0x1014) + A(-8) = 0x44 = 68 +// DSO-NEXT: 1014: 11 00 00 0a beq #68 +// DSO-NEXT: Disassembly of section .plt: // DSO-NEXT: $a: // DSO-NEXT: 1020: 04 e0 2d e5 str lr, [sp, #-4]! -// DSO-NEXT: 1024: 04 e0 9f e5 ldr lr, [pc, #4] -// DSO-NEXT: 1028: 0e e0 8f e0 add lr, pc, lr -// DSO-NEXT: 102c: 08 f0 be e5 ldr pc, [lr, #8]! -// 0x1028 + 8 + 0fd0 = 0x2000 +// (0x1024 + 8) + (0 RoR 12) + (0 RoR 20) + (0xfdc) = 0x2008 = .got.plt[3] +// DSO-NEXT: 1024: 00 e6 8f e2 add lr, pc, #0, #12 +// DSO-NEXT: 1028: 00 ea 8e e2 add lr, lr, #0, #20 +// DSO-NEXT: 102c: dc ff be e5 ldr pc, [lr, #4060]! // DSO: $d: -// DSO-NEXT: 1030: d0 0f 00 00 .word 0x00000fd0 +// DSO-NEXT: 1030: d4 d4 d4 d4 .word 0xd4d4d4d4 +// DSO-NEXT: 1034: d4 d4 d4 d4 .word 0xd4d4d4d4 +// DSO-NEXT: 1038: d4 d4 d4 d4 .word 0xd4d4d4d4 +// DSO-NEXT: 103c: d4 d4 d4 d4 .word 0xd4d4d4d4 // DSO: $a: -// DSO-NEXT: 1034: 04 c0 9f e5 ldr r12, [pc, #4] -// DSO-NEXT: 1038: 0f c0 8c e0 add r12, r12, pc -// DSO-NEXT: 103c: 00 f0 9c e5 ldr pc, [r12] -// 0x1038 + 8 + 0fcc = 0x200c +// (0x1040 + 8) + (0 RoR 12) + (0 RoR 20) + (0xfc4) = 0x200c +// DSO-NEXT: 1040: 00 c6 8f e2 add r12, pc, #0, #12 +// DSO-NEXT: 1044: 00 ca 8c e2 add r12, r12, #0, #20 +// DSO-NEXT: 1048: c4 ff bc e5 ldr pc, [r12, #4036]! // DSO: $d: -// DSO-NEXT: 1040: cc 0f 00 00 .word 0x00000fcc +// DSO-NEXT: 104c: d4 d4 d4 d4 .word 0xd4d4d4d4 // DSO: $a: -// DSO-NEXT: 1044: 04 c0 9f e5 ldr r12, [pc, #4] -// DSO-NEXT: 1048: 0f c0 8c e0 add r12, r12, pc -// DSO-NEXT: 104c: 00 f0 9c e5 ldr pc, [r12] -// 0x1048 + 8 + 0fc0 = 0x2010 +// (0x1050 + 8) + (0 RoR 12) + (0 RoR 20) + (0xfb8) = 0x2010 +// DSO-NEXT: 1050: 00 c6 8f e2 add r12, pc, #0, #12 +// DSO-NEXT: 1054: 00 ca 8c e2 add r12, r12, #0, #20 +// DSO-NEXT: 1058: b8 ff bc e5 ldr pc, [r12, #4024]! // DSO: $d: -// DSO-NEXT: 1050: c0 0f 00 00 .word 0x00000fc0 +// DSO-NEXT: 105c: d4 d4 d4 d4 .word 0xd4d4d4d4 // DSO: $a: -// DSO-NEXT: 1054: 04 c0 9f e5 ldr r12, [pc, #4] -// DSO-NEXT: 1058: 0f c0 8c e0 add r12, r12, pc -// DSO-NEXT: 105c: 00 f0 9c e5 ldr pc, [r12] -// 0x1058 + 8 + 0fb4 = 0x2014 +// (0x1060 + 8) + (0 RoR 12) + (0 RoR 20) + (0xfac) = 0x2014 +// DSO-NEXT: 1060: 00 c6 8f e2 add r12, pc, #0, #12 +// DSO-NEXT: 1064: 00 ca 8c e2 add r12, r12, #0, #20 +// DSO-NEXT: 1068: ac ff bc e5 ldr pc, [r12, #4012]! // DSO: $d: -// DSO-NEXT: 1060: b4 0f 00 00 .word 0x00000fb4 +// DSO-NEXT: 106c: d4 d4 d4 d4 .word 0xd4d4d4d4 + // DSOREL: Name: .got.plt // DSOREL-NEXT: Type: SHT_PROGBITS @@ -96,3 +100,199 @@ _start: // DSOREL-NEXT: 0x200C R_ARM_JUMP_SLOT func1 0x0 // DSOREL-NEXT: 0x2010 R_ARM_JUMP_SLOT func2 0x0 // DSOREL-NEXT: 0x2014 R_ARM_JUMP_SLOT func3 0x0 + +// Test a large separation between the .plt and .got.plt +// The .got.plt and .plt displacement is large but still within the range +// of the short plt sequence. +// RUN: echo "SECTIONS { \ +// RUN: .text 0x1000 : { *(.text) } \ +// RUN: .plt 0x2000 : { *(.plt) *(.plt.*) } \ +// RUN: .got.plt 0x1100000 : { *(.got.plt) } \ +// RUN: }" > %t.script +// RUN: ld.lld --hash-style=sysv --script %t.script -shared %t1 %t2 -o %t4 +// RUN: llvm-objdump -triple=armv7a-none-linux-gnueabi -d %t4 | FileCheck --check-prefix=CHECKHIGH %s +// RUN: llvm-readobj -s -r %t4 | FileCheck --check-prefix=DSORELHIGH %s + +// CHECKHIGH: Disassembly of section .text: +// CHECKHIGH-NEXT: func1: +// CHECKHIGH-NEXT: 1000: 1e ff 2f e1 bx lr +// CHECKHIGH: func2: +// CHECKHIGH-NEXT: 1004: 1e ff 2f e1 bx lr +// CHECKHIGH: func3: +// CHECKHIGH-NEXT: 1008: 1e ff 2f e1 bx lr +// CHECKHIGH: _start: +// CHECKHIGH-NEXT: 100c: 03 04 00 ea b #4108 <$a> +// CHECKHIGH-NEXT: 1010: 06 04 00 eb bl #4120 <$a> +// CHECKHIGH-NEXT: 1014: 09 04 00 0a beq #4132 <$a> +// CHECKHIGH-NEXT: Disassembly of section .plt: +// CHECKHIGH-NEXT: $a: +// CHECKHIGH-NEXT: 2000: 04 e0 2d e5 str lr, [sp, #-4]! +// CHECKHIGH-NEXT: 2004: 10 e6 8f e2 add lr, pc, #16, #12 +// CHECKHIGH-NEXT: 2008: fd ea 8e e2 add lr, lr, #1036288 +// CHECKHIGH-NEXT: 200c: fc ff be e5 ldr pc, [lr, #4092]! +// CHECKHIGH: $d: +// CHECKHIGH-NEXT: 2010: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECKHIGH-NEXT: 2014: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECKHIGH-NEXT: 2018: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECKHIGH-NEXT: 201c: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECKHIGH: $a: +// CHECKHIGH-NEXT: 2020: 10 c6 8f e2 add r12, pc, #16, #12 +// CHECKHIGH-NEXT: 2024: fd ca 8c e2 add r12, r12, #1036288 +// CHECKHIGH-NEXT: 2028: e4 ff bc e5 ldr pc, [r12, #4068]! +// CHECKHIGH: $d: +// CHECKHIGH-NEXT: 202c: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECKHIGH: $a: +// CHECKHIGH-NEXT: 2030: 10 c6 8f e2 add r12, pc, #16, #12 +// CHECKHIGH-NEXT: 2034: fd ca 8c e2 add r12, r12, #1036288 +// CHECKHIGH-NEXT: 2038: d8 ff bc e5 ldr pc, [r12, #4056]! +// CHECKHIGH: $d: +// CHECKHIGH-NEXT: 203c: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECKHIGH: $a: +// CHECKHIGH-NEXT: 2040: 10 c6 8f e2 add r12, pc, #16, #12 +// CHECKHIGH-NEXT: 2044: fd ca 8c e2 add r12, r12, #1036288 +// CHECKHIGH-NEXT: 2048: cc ff bc e5 ldr pc, [r12, #4044]! +// CHECKHIGH: $d: +// CHECKHIGH-NEXT: 204c: d4 d4 d4 d4 .word 0xd4d4d4d4 + +// DSORELHIGH: Name: .got.plt +// DSORELHIGH-NEXT: Type: SHT_PROGBITS +// DSORELHIGH-NEXT: Flags [ +// DSORELHIGH-NEXT: SHF_ALLOC +// DSORELHIGH-NEXT: SHF_WRITE +// DSORELHIGH-NEXT: ] +// DSORELHIGH-NEXT: Address: 0x1100000 +// DSORELHIGH: Relocations [ +// DSORELHIGH-NEXT: Section (6) .rel.plt { +// DSORELHIGH-NEXT: 0x110000C R_ARM_JUMP_SLOT func1 0x0 +// DSORELHIGH-NEXT: 0x1100010 R_ARM_JUMP_SLOT func2 0x0 +// DSORELHIGH-NEXT: 0x1100014 R_ARM_JUMP_SLOT func3 0x0 + +// Test a very large separation between the .plt and .got.plt so we must use +// large plt entries that do not have any range restriction. +// RUN: echo "SECTIONS { \ +// RUN: .text 0x1000 : { *(.text) } \ +// RUN: .plt 0x2000 : { *(.plt) *(.plt.*) } \ +// RUN: .got.plt 0x11111100 : { *(.got.plt) } \ +// RUN: }" > %t2.script +// RUN: ld.lld --hash-style=sysv --script %t2.script -shared %t1 %t2 -o %t5 +// RUN: llvm-objdump -triple=armv7a-none-linux-gnueabi -d %t5 | FileCheck --check-prefix=CHECKLONG %s +// RUN: llvm-readobj -s -r %t5 | FileCheck --check-prefix=DSORELLONG %s + +// CHECKLONG: Disassembly of section .text: +// CHECKLONG-NEXT: func1: +// CHECKLONG-NEXT: 1000: 1e ff 2f e1 bx lr +// CHECKLONG: func2: +// CHECKLONG-NEXT: 1004: 1e ff 2f e1 bx lr +// CHECKLONG: func3: +// CHECKLONG-NEXT: 1008: 1e ff 2f e1 bx lr +// CHECKLONG: _start: +// CHECKLONG-NEXT: 100c: 03 04 00 ea b #4108 <$a> +// CHECKLONG-NEXT: 1010: 06 04 00 eb bl #4120 <$a> +// CHECKLONG-NEXT: 1014: 09 04 00 0a beq #4132 <$a> +// CHECKLONG-NEXT: Disassembly of section .plt: +// CHECKLONG-NEXT: $a: +// CHECKLONG-NEXT: 2000: 04 e0 2d e5 str lr, [sp, #-4]! +// CHECKLONG-NEXT: 2004: 04 e0 9f e5 ldr lr, [pc, #4] +// CHECKLONG-NEXT: 2008: 0e e0 8f e0 add lr, pc, lr +// CHECKLONG-NEXT: 200c: 08 f0 be e5 ldr pc, [lr, #8]! +// CHECKLONG: $d: +// CHECKLONG-NEXT: 2010: f0 f0 10 11 .word 0x1110f0f0 +// CHECKLONG-NEXT: 2014: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECKLONG-NEXT: 2018: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECKLONG-NEXT: 201c: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECKLONG: $a: +// CHECKLONG-NEXT: 2020: 04 c0 9f e5 ldr r12, [pc, #4] +// CHECKLONG-NEXT: 2024: 0f c0 8c e0 add r12, r12, pc +// CHECKLONG-NEXT: 2028: 00 f0 9c e5 ldr pc, [r12] +// CHECKLONG: $d: +// CHECKLONG-NEXT: 202c: e0 f0 10 11 .word 0x1110f0e0 +// CHECKLONG: $a: +// CHECKLONG-NEXT: 2030: 04 c0 9f e5 ldr r12, [pc, #4] +// CHECKLONG-NEXT: 2034: 0f c0 8c e0 add r12, r12, pc +// CHECKLONG-NEXT: 2038: 00 f0 9c e5 ldr pc, [r12] +// CHECKLONG: $d: +// CHECKLONG-NEXT: 203c: d4 f0 10 11 .word 0x1110f0d4 +// CHECKLONG: $a: +// CHECKLONG-NEXT: 2040: 04 c0 9f e5 ldr r12, [pc, #4] +// CHECKLONG-NEXT: 2044: 0f c0 8c e0 add r12, r12, pc +// CHECKLONG-NEXT: 2048: 00 f0 9c e5 ldr pc, [r12] +// CHECKLONG: $d: +// CHECKLONG-NEXT: 204c: c8 f0 10 11 .word 0x1110f0c8 + +// DSORELLONG: Name: .got.plt +// DSORELLONG-NEXT: Type: SHT_PROGBITS +// DSORELLONG-NEXT: Flags [ +// DSORELLONG-NEXT: SHF_ALLOC +// DSORELLONG-NEXT: SHF_WRITE +// DSORELLONG-NEXT: ] +// DSORELLONG-NEXT: Address: 0x11111100 +// DSORELLONG: Relocations [ +// DSORELLONG-NEXT: Section (6) .rel.plt { +// DSORELLONG-NEXT: 0x1111110C R_ARM_JUMP_SLOT func1 0x0 +// DSORELLONG-NEXT: 0x11111110 R_ARM_JUMP_SLOT func2 0x0 +// DSORELLONG-NEXT: 0x11111114 R_ARM_JUMP_SLOT func3 0x0 + +// Test a separation between the .plt and .got.plt that is part in range of +// short table entries and part needing long entries. We use the long entries +// only when we need to. +// RUN: echo "SECTIONS { \ +// RUN: .text 0x1000 : { *(.text) } \ +// RUN: .plt 0x2000 : { *(.plt) *(.plt.*) } \ +// RUN: .got.plt 0x8002020 : { *(.got.plt) } \ +// RUN: }" > %t3.script +// RUN: ld.lld --hash-style=sysv --script %t3.script -shared %t1 %t2 -o %t6 +// RUN: llvm-objdump -triple=armv7a-none-linux-gnueabi -d %t6 | FileCheck --check-prefix=CHECKMIX %s +// RUN: llvm-readobj -s -r %t6 | FileCheck --check-prefix=DSORELMIX %s + +// CHECKMIX: Disassembly of section .text: +// CHECKMIX-NEXT: func1: +// CHECKMIX-NEXT: 1000: 1e ff 2f e1 bx lr +// CHECKMIX: func2: +// CHECKMIX-NEXT: 1004: 1e ff 2f e1 bx lr +// CHECKMIX: func3: +// CHECKMIX-NEXT: 1008: 1e ff 2f e1 bx lr +// CHECKMIX: _start: +// CHECKMIX-NEXT: 100c: 03 04 00 ea b #4108 <$a> +// CHECKMIX-NEXT: 1010: 06 04 00 eb bl #4120 <$a> +// CHECKMIX-NEXT: 1014: 09 04 00 0a beq #4132 <$a> +// CHECKMIX-NEXT: Disassembly of section .plt: +// CHECKMIX-NEXT: $a: +// CHECKMIX-NEXT: 2000: 04 e0 2d e5 str lr, [sp, #-4]! +// CHECKMIX-NEXT: 2004: 04 e0 9f e5 ldr lr, [pc, #4] +// CHECKMIX-NEXT: 2008: 0e e0 8f e0 add lr, pc, lr +// CHECKMIX-NEXT: 200c: 08 f0 be e5 ldr pc, [lr, #8]! +// CHECKMIX: $d: +// CHECKMIX-NEXT: 2010: 10 00 00 08 .word 0x08000010 +// CHECKMIX-NEXT: 2014: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECKMIX-NEXT: 2018: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECKMIX-NEXT: 201c: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECKMIX: $a: +// CHECKMIX-NEXT: 2020: 04 c0 9f e5 ldr r12, [pc, #4] +// CHECKMIX-NEXT: 2024: 0f c0 8c e0 add r12, r12, pc +// CHECKMIX-NEXT: 2028: 00 f0 9c e5 ldr pc, [r12] +// CHECKMIX: $d: +// CHECKMIX-NEXT: 202c: 00 00 00 08 .word 0x08000000 +// CHECKMIX: $a: +// CHECKMIX-NEXT: 2030: 7f c6 8f e2 add r12, pc, #133169152 +// CHECKMIX-NEXT: 2034: ff ca 8c e2 add r12, r12, #1044480 +// CHECKMIX-NEXT: 2038: f8 ff bc e5 ldr pc, [r12, #4088]! +// CHECKMIX: $d: +// CHECKMIX-NEXT: 203c: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECKMIX: $a: +// CHECKMIX-NEXT: 2040: 7f c6 8f e2 add r12, pc, #133169152 +// CHECKMIX-NEXT: 2044: ff ca 8c e2 add r12, r12, #1044480 +// CHECKMIX-NEXT: 2048: ec ff bc e5 ldr pc, [r12, #4076]! +// CHECKMIX: $d: +// CHECKMIX-NEXT: 204c: d4 d4 d4 d4 .word 0xd4d4d4d4 + +// DSORELMIX: Name: .got.plt +// DSORELMIX-NEXT: Type: SHT_PROGBITS +// DSORELMIX-NEXT: Flags [ +// DSORELMIX-NEXT: SHF_ALLOC +// DSORELMIX-NEXT: SHF_WRITE +// DSORELMIX-NEXT: ] +// DSORELMIX-NEXT: Address: 0x8002020 +// DSORELMIX: Section (6) .rel.plt { +// DSORELMIX-NEXT: 0x800202C R_ARM_JUMP_SLOT func1 0x0 +// DSORELMIX-NEXT: 0x8002030 R_ARM_JUMP_SLOT func2 0x0 +// DSORELMIX-NEXT: 0x8002034 R_ARM_JUMP_SLOT func3 0x0 diff --git a/test/ELF/arm-static-defines.s b/test/ELF/arm-static-defines.s index 0012841fb32c..815c20ca9451 100644 --- a/test/ELF/arm-static-defines.s +++ b/test/ELF/arm-static-defines.s @@ -1,5 +1,5 @@ // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t -// RUN: ld.lld %t --static -o %t2 2>&1 +// RUN: ld.lld --no-merge-exidx-entries %t --static -o %t2 2>&1 // RUN: llvm-readobj --symbols %t2 | FileCheck %s // REQUIRES: arm diff --git a/test/ELF/arm-thumb-branch-error.s b/test/ELF/arm-thumb-branch-error.s deleted file mode 100644 index de6c1bc16c96..000000000000 --- a/test/ELF/arm-thumb-branch-error.s +++ /dev/null @@ -1,19 +0,0 @@ -// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t -// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %S/Inputs/far-arm-thumb-abs.s -o %tfar -// RUN: not ld.lld %t %tfar -o %t2 2>&1 | FileCheck %s -// REQUIRES: arm - .syntax unified - .section .text, "ax",%progbits - .globl _start - .balign 0x10000 - .type _start,%function -_start: - // address of too_far symbols are just out of range of ARM branch with - // 26-bit immediate field and an addend of -8 - bl too_far1 - b too_far2 - beq.w too_far3 - -// CHECK: R_ARM_THM_CALL out of range -// CHECK-NEXT: R_ARM_THM_JUMP24 out of range -// CHECK-NEXT: R_ARM_THM_JUMP19 out of range diff --git a/test/ELF/arm-thumb-branch-rangethunk.s b/test/ELF/arm-thumb-branch-rangethunk.s new file mode 100644 index 000000000000..f83e64144d70 --- /dev/null +++ b/test/ELF/arm-thumb-branch-rangethunk.s @@ -0,0 +1,36 @@ +// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t +// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %S/Inputs/far-arm-thumb-abs.s -o %tfar +// RUN: ld.lld %t %tfar -o %t2 2>&1 +// RUN: llvm-objdump -d -triple=thumbv7a-none-linux-gnueabi %t2 +// REQUIRES: arm + .syntax unified + .thumb + .section .text, "ax",%progbits + .globl _start + .balign 0x10000 + .type _start,%function +_start: + // address of too_far symbols are just out of range of ARM branch with + // 26-bit immediate field and an addend of -8 + bl too_far1 + b too_far2 + beq.w too_far3 + +// CHECK: Disassembly of section .text: +// CHECK-NEXT: _start: +// CHECK-NEXT: 20000: 00 f0 04 f8 bl #8 +// CHECK-NEXT: 20004: 00 f0 07 b8 b.w #14 <__Thumbv7ABSLongThunk_too_far2> +// CHECK-NEXT: 20008: 00 f0 0a 80 beq.w #20 <__Thumbv7ABSLongThunk_too_far3> +// CHECK: __Thumbv7ABSLongThunk_too_far1: +// CHECK-NEXT: 2000c: 40 f2 05 0c movw r12, #5 +// CHECK-NEXT: 20010: c0 f2 02 1c movt r12, #258 +// CHECK-NEXT: 20014: 60 47 bx r12 +// CHECK: __Thumbv7ABSLongThunk_too_far2: +// CHECK-NEXT: 20016: 40 f2 09 0c movw r12, #9 +// CHECK-NEXT: 2001a: c0 f2 02 1c movt r12, #258 +// CHECK-NEXT: 2001e: 60 47 bx r12 +// CHECK: __Thumbv7ABSLongThunk_too_far3: +// CHECK-NEXT: 20020: 40 f2 0d 0c movw r12, #13 +// CHECK-NEXT: 20024: c0 f2 12 0c movt r12, #18 +// CHECK-NEXT: 20028: 60 47 bx r12 +// CHECK-NEXT: 2002a: 00 00 movs r0, r0 diff --git a/test/ELF/arm-thumb-condbranch-thunk.s b/test/ELF/arm-thumb-condbranch-thunk.s new file mode 100644 index 000000000000..c527e5df297c --- /dev/null +++ b/test/ELF/arm-thumb-condbranch-thunk.s @@ -0,0 +1,117 @@ +// REQUIRES: arm +// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t +// RUN: ld.lld %t -o %t2 2>&1 +// The output file is large, most of it zeroes. We dissassemble only the +// parts we need to speed up the test and avoid a large output file +// RUN: llvm-objdump -d %t2 -start-address=524288 -stop-address=524316 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK1 %s +// RUN: llvm-objdump -d %t2 -start-address=1048576 -stop-address=1048584 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK2 %s +// RUN: llvm-objdump -d %t2 -start-address=1572864 -stop-address=1572872 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK3 %s +// RUN: llvm-objdump -d %t2 -start-address=5242884 -stop-address=5242894 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK4 %s +// RUN: llvm-objdump -d %t2 -start-address=5767168 -stop-address=5767174 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK5 %s +// RUN: llvm-objdump -d %t2 -start-address=16777220 -stop-address=16777240 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK6 %s +// RUN: llvm-objdump -d %t2 -start-address=17825792 -stop-address=17825798 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK7 %s +// Test Range extension Thunks for the Thumb conditional branch instruction. +// This instruction only has a range of 1Mb whereas all the other Thumb wide +// Branch instructions have 16Mb range. We still place our pre-created Thunk +// Sections at 16Mb intervals as conditional branches to a target defined +// in a different section are rare. + .syntax unified +// Define a function aligned on a half megabyte boundary + .macro FUNCTION suff + .section .text.\suff\(), "ax", %progbits + .thumb + .balign 0x80000 + .globl tfunc\suff\() + .type tfunc\suff\(), %function +tfunc\suff\(): + bx lr + .endm + + .globl _start +_start: + FUNCTION 00 +// Long Range Thunk needed for 16Mb range branch, can reach pre-created Thunk +// Section + bl tfunc33 +// CHECK1: Disassembly of section .text: +// CHECK1-NEXT: tfunc00: +// CHECK1-NEXT: 80000: 70 47 bx lr +// CHECK1-NEXT: 80002: 7f f3 ff d7 bl #16252926 +// CHECK1: __Thumbv7ABSLongThunk_tfunc05: +// CHECK1-NEXT: 80008: 40 f2 01 0c movw r12, #1 +// CHECK1-NEXT: 8000c: c0 f2 30 0c movt r12, #48 +// CHECK1-NEXT: 80010: 60 47 bx r12 +// CHECK1: __Thumbv7ABSLongThunk_tfunc00: +// CHECK1-NEXT: 80012: 40 f2 01 0c movw r12, #1 +// CHECK1-NEXT: 80016: c0 f2 08 0c movt r12, #8 +// CHECK1-NEXT: 8001a: 60 47 bx r12 + FUNCTION 01 +// tfunc02 is within range of tfunc02 + beq.w tfunc02 +// tfunc05 is out of range, and we can't reach the pre-created Thunk Section +// create a new one. + bne.w tfunc05 +// CHECK2: tfunc01: +// CHECK2-NEXT: 100000: 70 47 bx lr +// CHECK2-NEXT: 100002: 3f f0 fd a7 beq.w #524282 <tfunc02> +// CHECK2-NEXT: 100006: 7f f4 ff a7 bne.w #-524290 <__Thumbv7ABSLongThunk_tfunc05> + FUNCTION 02 +// We can reach the Thunk Section created for bne.w tfunc05 + bne.w tfunc05 + beq.w tfunc00 +// CHECK3: 180000: 70 47 bx lr +// CHECK3-NEXT: 180002: 40 f4 01 80 bne.w #-1048574 <__Thumbv7ABSLongThunk_tfunc05> +// CHECK3-NEXT: 180006: 00 f4 04 80 beq.w #-1048568 <__Thumbv7ABSLongThunk_tfunc00> + FUNCTION 03 + FUNCTION 04 + FUNCTION 05 + FUNCTION 06 + FUNCTION 07 + FUNCTION 08 + FUNCTION 09 +// CHECK4: __Thumbv7ABSLongThunk_tfunc03: +// CHECK4-NEXT: 500004: 40 f2 01 0c movw r12, #1 +// CHECK4-NEXT: 500008: c0 f2 20 0c movt r12, #32 +// CHECK4-NEXT: 50000c: 60 47 bx r12 + FUNCTION 10 +// We can't reach any Thunk Section, create a new one + beq.w tfunc03 +// CHECK5: tfunc10: +// CHECK5-NEXT: 580000: 70 47 bx lr +// CHECK5-NEXT: 580002: 3f f4 ff a7 beq.w #-524290 <__Thumbv7ABSLongThunk_tfunc03> + FUNCTION 11 + FUNCTION 12 + FUNCTION 13 + FUNCTION 14 + FUNCTION 15 + FUNCTION 16 + FUNCTION 17 + FUNCTION 18 + FUNCTION 19 + FUNCTION 20 + FUNCTION 21 + FUNCTION 22 + FUNCTION 23 + FUNCTION 24 + FUNCTION 25 + FUNCTION 26 + FUNCTION 27 + FUNCTION 28 + FUNCTION 29 + FUNCTION 30 + FUNCTION 31 +// CHECK6: __Thumbv7ABSLongThunk_tfunc33: +// CHECK6-NEXT: 1000004: 40 f2 01 0c movw r12, #1 +// CHECK6-NEXT: 1000008: c0 f2 10 1c movt r12, #272 +// CHECK6-NEXT: 100000c: 60 47 bx r12 +// CHECK6: __Thumbv7ABSLongThunk_tfunc00: +// CHECK6-NEXT: 100000e: 40 f2 01 0c movw r12, #1 +// CHECK6-NEXT: 1000012: c0 f2 08 0c movt r12, #8 +// CHECK6-NEXT: 1000016: 60 47 bx r12 + FUNCTION 32 + FUNCTION 33 + // We should be able to reach an existing ThunkSection. + b.w tfunc00 +// CHECK7: tfunc33: +// CHECK7-NEXT: 1100000: 70 47 bx lr +// CHECK7-NEXT: 1100002: 00 f7 04 b8 b.w #-1048568 <__Thumbv7ABSLongThunk_tfunc00> diff --git a/test/ELF/arm-thumb-interwork-shared.s b/test/ELF/arm-thumb-interwork-shared.s index 8362ae26aed4..cadcd451ad67 100644 --- a/test/ELF/arm-thumb-interwork-shared.s +++ b/test/ELF/arm-thumb-interwork-shared.s @@ -19,34 +19,37 @@ sym1: // CHECK-NEXT: 1000: 00 f0 02 b8 b.w #4 <__ThumbV7PILongThunk_elsewhere> // CHECK-NEXT: 1004: 00 f0 06 b8 b.w #12 <__ThumbV7PILongThunk_weakref> // CHECK: __ThumbV7PILongThunk_elsewhere: -// CHECK-NEXT: 1008: 40 f2 20 0c movw r12, #32 +// CHECK-NEXT: 1008: 40 f2 2c 0c movw r12, #44 // CHECK-NEXT: 100c: c0 f2 00 0c movt r12, #0 // CHECK-NEXT: 1010: fc 44 add r12, pc // CHECK-NEXT: 1012: 60 47 bx r12 - // CHECK: __ThumbV7PILongThunk_weakref: -// CHECK-NEXT: 1014: 40 f2 24 0c movw r12, #36 +// CHECK-NEXT: 1014: 40 f2 30 0c movw r12, #48 // CHECK-NEXT: 1018: c0 f2 00 0c movt r12, #0 // CHECK-NEXT: 101c: fc 44 add r12, pc // CHECK-NEXT: 101e: 60 47 bx r12 // PLT: Disassembly of section .plt: -// PLT: $a: -// PLT-NEXT: 1020: 04 e0 2d e5 str lr, [sp, #-4]! -// PLT-NEXT: 1024: 04 e0 9f e5 ldr lr, [pc, #4] -// PLT-NEXT: 1028: 0e e0 8f e0 add lr, pc, lr -// PLT-NEXT: 102c: 08 f0 be e5 ldr pc, [lr, #8]! +// PLT-NEXT: $a: +// PLT-NEXT: 1020: 04 e0 2d e5 str lr, [sp, #-4]! +// PLT-NEXT: 1024: 00 e6 8f e2 add lr, pc, #0, #12 +// PLT-NEXT: 1028: 00 ea 8e e2 add lr, lr, #0, #20 +// PLT-NEXT: 102c: dc ff be e5 ldr pc, [lr, #4060]! // PLT: $d: -// PLT-NEXT: 1030: d0 0f 00 00 .word 0x00000fd0 +// PLT-NEXT: 1030: d4 d4 d4 d4 .word 0xd4d4d4d4 +// PLT-NEXT: 1034: d4 d4 d4 d4 .word 0xd4d4d4d4 +// PLT-NEXT: 1038: d4 d4 d4 d4 .word 0xd4d4d4d4 +// PLT-NEXT: 103c: d4 d4 d4 d4 .word 0xd4d4d4d4 // PLT: $a: -// PLT-NEXT: 1034: 04 c0 9f e5 ldr r12, [pc, #4] -// PLT-NEXT: 1038: 0f c0 8c e0 add r12, r12, pc -// PLT-NEXT: 103c: 00 f0 9c e5 ldr pc, [r12] +// PLT-NEXT: 1040: 00 c6 8f e2 add r12, pc, #0, #12 +// PLT-NEXT: 1044: 00 ca 8c e2 add r12, r12, #0, #20 +// PLT-NEXT: 1048: c4 ff bc e5 ldr pc, [r12, #4036]! // PLT: $d: -// PLT-NEXT: 1040: cc 0f 00 00 .word 0x00000fcc +// PLT-NEXT: 104c: d4 d4 d4 d4 .word 0xd4d4d4d4 // PLT: $a: -// PLT-NEXT: 1044: 04 c0 9f e5 ldr r12, [pc, #4] -// PLT-NEXT: 1048: 0f c0 8c e0 add r12, r12, pc -// PLT-NEXT: 104c: 00 f0 9c e5 ldr pc, [r12] +// PLT-NEXT: 1050: 00 c6 8f e2 add r12, pc, #0, #12 +// PLT-NEXT: 1054: 00 ca 8c e2 add r12, r12, #0, #20 +// PLT-NEXT: 1058: b8 ff bc e5 ldr pc, [r12, #4024]! // PLT: $d: -// PLT-NEXT: 1050: c0 0f 00 00 .word 0x00000fc0 +// PLT-NEXT: 105c: d4 d4 d4 d4 .word 0xd4d4d4d4 + diff --git a/test/ELF/arm-thumb-mix-range-thunk-os.s b/test/ELF/arm-thumb-mix-range-thunk-os.s new file mode 100644 index 000000000000..beff4148b6ff --- /dev/null +++ b/test/ELF/arm-thumb-mix-range-thunk-os.s @@ -0,0 +1,195 @@ +// REQUIRES: arm +// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t +// RUN: ld.lld %t -o %t2 2>&1 +// The output file is large, most of it zeroes. We dissassemble only the +// parts we need to speed up the test and avoid a large output file +// RUN: llvm-objdump -d %t2 -start-address=1048576 -stop-address=1048604 -triple=armv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK1 %s +// RUN: llvm-objdump -d %t2 -start-address=2097152 -stop-address=2097162 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK2 %s +// RUN: llvm-objdump -d %t2 -start-address=16777220 -stop-address=16777232 -triple=armv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK3 %s +// RUN: llvm-objdump -d %t2 -start-address=16777232 -stop-address=16777242 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK4 %s +// RUN: llvm-objdump -d %t2 -start-address=32505860 -stop-address=32505870 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK5 %s +// RUN: llvm-objdump -d %t2 -start-address=35651584 -stop-address=35651590 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK6 %s +// RUN: llvm-objdump -d %t2 -start-address=36700160 -stop-address=36700168 -triple=armv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK7 %s +// RUN: llvm-objdump -d %t2 -start-address=48234500 -stop-address=48234512 -triple=armv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK8 %s +// RUN: llvm-objdump -d %t2 -start-address=63963140 -stop-address=63963160 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK9 %s +// RUN: llvm-objdump -d %t2 -start-address=68157440 -stop-address=68157452 -triple=armv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK10 %s +// RUN: llvm-objdump -d %t2 -start-address=69206016 -stop-address=69206024 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK11 %s + +// Test the Range extension Thunks for ARM and Thumb when all the code is in a +// single OutputSection. The ARM branches and branch and link instructions +// have a range of 32Mb, the Thumb unconditional branch and +// branch and link instructions have . We create a series of Functions a +// megabyte apart. We expect range extension thunks to be created when a +// branch is out of range. Thunks will be reused whenever they are in range + .syntax unified + +// Define a function aligned on a megabyte boundary + .macro ARMFUNCTION suff + .section .text.\suff\(), "ax", %progbits + .arm + .balign 0x100000 + .globl afunc\suff\() + .type afunc\suff\(), %function +afunc\suff\(): + bx lr + .endm + +// Define a function aligned on a megabyte boundary + .macro THUMBFUNCTION suff + .section .text.\suff\(), "ax", %progbits + .thumb + .balign 0x100000 + .globl tfunc\suff\() + .type tfunc\suff\(), %function +tfunc\suff\(): + bx lr + .endm + + .section .text, "ax", %progbits + .thumb + .globl _start +_start: + + ARMFUNCTION 00 +// Expect ARM bl to be in range (can use blx to change state) + bl tfunc31 +// ARM b and beq are in range but need Thunk to change state to Thumb + b tfunc31 + beq tfunc31 +// afunc32 is out of range of ARM branch and branch and link + bl afunc32 + b afunc32 + bne afunc32 +// CHECK1: afunc00: +// CHECK1-NEXT: 100000: 1e ff 2f e1 bx lr +// CHECK1-NEXT: 100004: fd ff 7b fa blx #32505844 +// CHECK1-NEXT: 100008: fd ff 3b ea b #15728628 +// CHECK1-NEXT: 10000c: fc ff 3b 0a beq #15728624 +// CHECK1-NEXT: 100010: fa ff 7f eb bl #33554408 +// CHECK1-NEXT: 100014: f9 ff 7f ea b #33554404 +// CHECK1-NEXT: 100018: f8 ff 7f 1a bne #33554400 + THUMBFUNCTION 01 +// Expect Thumb bl to be in range (can use blx to change state) + bl afunc14 +// In range but need thunk to change state to Thumb + b.w afunc14 +// CHECK2: tfunc01: +// CHECK2-NEXT: 200000: 70 47 bx lr +// CHECK2-NEXT: 200002: ff f0 fe c7 blx #13631484 +// CHECK2-NEXT: 200006: 00 f2 03 90 b.w #14680070 <__Thumbv7ABSLongThunk_afunc14> + + ARMFUNCTION 02 + THUMBFUNCTION 03 + ARMFUNCTION 04 + THUMBFUNCTION 05 + ARMFUNCTION 06 + THUMBFUNCTION 07 + ARMFUNCTION 08 + THUMBFUNCTION 09 + ARMFUNCTION 10 + THUMBFUNCTION 11 + ARMFUNCTION 12 + THUMBFUNCTION 13 + ARMFUNCTION 14 +// CHECK3: __ARMv7ABSLongThunk_tfunc31: +// CHECK3-NEXT: 1000004: 01 c0 00 e3 movw r12, #1 +// CHECK3-NEXT: 1000008: 00 c2 40 e3 movt r12, #512 +// CHECK3-NEXT: 100000c: 1c ff 2f e1 bx r12 +// CHECK4: __Thumbv7ABSLongThunk_afunc14: +// CHECK4-NEXT: 1000010: 40 f2 00 0c movw r12, #0 +// CHECK4-NEXT: 1000014: c0 f2 f0 0c movt r12, #240 +// CHECK4-NEXT: 1000018: 60 47 bx r12 + THUMBFUNCTION 15 + ARMFUNCTION 16 + THUMBFUNCTION 17 + ARMFUNCTION 18 + THUMBFUNCTION 19 + ARMFUNCTION 20 + THUMBFUNCTION 21 + ARMFUNCTION 22 + THUMBFUNCTION 23 + ARMFUNCTION 24 + THUMBFUNCTION 25 + ARMFUNCTION 26 + THUMBFUNCTION 27 + ARMFUNCTION 28 + THUMBFUNCTION 29 + ARMFUNCTION 30 +// Expect precreated Thunk Section here +// CHECK5: __Thumbv7ABSLongThunk_afunc00: +// CHECK5-NEXT: 1f00004: 40 f2 00 0c movw r12, #0 +// CHECK5-NEXT: 1f00008: c0 f2 10 0c movt r12, #16 +// CHECK5-NEXT: 1f0000c: 60 47 bx r12 + THUMBFUNCTION 31 + ARMFUNCTION 32 + THUMBFUNCTION 33 +// Out of range, can only reach closest Thunk Section + bl afunc00 +// CHECK6: tfunc33: +// CHECK6-NEXT: 2200000: 70 47 bx lr +// CHECK6-NEXT: 2200002: ff f4 ff ff bl #-3145730 + ARMFUNCTION 34 +// Out of range, can reach earlier Thunk Section +// CHECK7: afunc34: +// CHECK7-NEXT: 2300000: 1e ff 2f e1 bx lr +// CHECK7-NEXT: 2300004: fe ff ef fa blx #-4194312 <__Thumbv7ABSLongThunk_afunc00 + bl afunc00 + THUMBFUNCTION 35 + ARMFUNCTION 36 + THUMBFUNCTION 37 + ARMFUNCTION 38 + THUMBFUNCTION 39 + ARMFUNCTION 40 + THUMBFUNCTION 41 + ARMFUNCTION 42 + THUMBFUNCTION 43 + ARMFUNCTION 44 + THUMBFUNCTION 45 +// Expect precreated Thunk Section here +// CHECK8: __ARMv7ABSLongThunk_tfunc35: +// CHECK8-NEXT: 2e00004: 01 c0 00 e3 movw r12, #1 +// CHECK8-NEXT: 2e00008: 40 c2 40 e3 movt r12, #576 +// CHECK8-NEXT: 2e0000c: 1c ff 2f e1 bx r12 + ARMFUNCTION 46 + THUMBFUNCTION 47 + ARMFUNCTION 48 + THUMBFUNCTION 49 + ARMFUNCTION 50 + THUMBFUNCTION 51 + ARMFUNCTION 52 + THUMBFUNCTION 53 + ARMFUNCTION 54 + THUMBFUNCTION 55 + ARMFUNCTION 56 + THUMBFUNCTION 57 + ARMFUNCTION 58 + THUMBFUNCTION 59 + ARMFUNCTION 60 +// Expect precreated Thunk Section here +// CHECK9: __Thumbv7ABSLongThunk_afunc34: +// CHECK9-NEXT: 3d00004: 40 f2 00 0c movw r12, #0 +// CHECK9-NEXT: 3d00008: c0 f2 30 2c movt r12, #560 +// CHECK9-NEXT: 3d0000c: 60 47 bx r12 +// CHECK9: __Thumbv7ABSLongThunk_tfunc35: +// CHECK9-NEXT: 3d0000e: 40 f2 01 0c movw r12, #1 +// CHECK9-NEXT: 3d00012: c0 f2 40 2c movt r12, #576 +// CHECK9-NEXT: 3d00016: 60 47 bx r12 + THUMBFUNCTION 61 + ARMFUNCTION 62 + THUMBFUNCTION 63 + ARMFUNCTION 64 +// afunc34 is in range, as is tfunc35 but a branch needs a state change Thunk + bl afunc34 + b tfunc35 +// CHECK10: afunc64: +// CHECK10-NEXT: 4100000: 1e ff 2f e1 bx lr +// CHECK10-NEXT: 4100004: fd ff 87 eb bl #-31457292 <afunc34> +// CHECK10-NEXT: 4100008: fd ff b3 ea b #-19922956 <__ARMv7ABSLongThunk_tfunc35> + THUMBFUNCTION 65 +// afunc34 and tfunc35 are both out of range + bl afunc34 + bl tfunc35 +// CHECK11: tfunc65: +// CHECK11: 4200000: 70 47 bx lr +// CHECK11-NEXT: 4200002: ff f6 ff f7 bl #-5242882 +// CHECK11-NEXT: 4200006: 00 f7 02 f0 bl #-5242876 diff --git a/test/ELF/arm-thumb-plt-range-thunk-os.s b/test/ELF/arm-thumb-plt-range-thunk-os.s new file mode 100644 index 000000000000..f412faa98eca --- /dev/null +++ b/test/ELF/arm-thumb-plt-range-thunk-os.s @@ -0,0 +1,92 @@ +// REQUIRES: arm +// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t +// RUN: ld.lld %t --shared -o %t.so +// The output file is large, most of it zeroes. We dissassemble only the +// parts we need to speed up the test and avoid a large output file +// RUN: llvm-objdump -d %t.so -start-address=8388608 -stop-address=8388624 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK1 %s +// RUN: llvm-objdump -d %t.so -start-address=16777216 -stop-address=16777256 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK2 %s +// RUN: llvm-objdump -d %t.so -start-address=25165824 -stop-address=25165828 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK3 %s +// RUN: llvm-objdump -d %t.so -start-address=25165828 -stop-address=25165924 -triple=armv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK4 %s + .syntax unified + .thumb + +// Make sure that we generate a range extension thunk to a PLT entry + .section ".text.1", "ax", %progbits + .global sym1 + .global elsewhere + .type elsewhere, %function + .global preemptible + .type preemptible, %function + .global far_preemptible + .type far_preemptible, %function +sym1: + bl elsewhere + bl preemptible + bx lr +preemptible: + bl far_preemptible + bx lr +// CHECK1: Disassembly of section .text: +// CHECK1-NEXT: sym1: +// CHECK1-NEXT: 800000: 00 f0 00 d8 bl #8388608 +// CHECK1-NEXT: 800004: 00 f0 04 d8 bl #8388616 +// CHECK1-NEXT: 800008: 70 47 bx lr +// CHECK1: preemptible: +// CHECK1-NEXT: 80000a: 00 f0 07 d8 bl #8388622 +// CHECK1-NEXT: 80000e: 70 47 bx lr + + .section .text.2, "ax", %progbits + .balign 0x0800000 + bx lr +// CHECK2: __ThumbV7PILongThunk_elsewhere: +// CHECK2-NEXT: 1000004: 40 f2 20 0c movw r12, #32 +// CHECK2-NEXT: 1000008: c0 f2 80 0c movt r12, #128 +// CHECK2-NEXT: 100000c: fc 44 add r12, pc +// CHECK2-NEXT: 100000e: 60 47 bx r12 +// CHECK2: __ThumbV7PILongThunk_preemptible: +// CHECK2-NEXT: 1000010: 40 f2 24 0c movw r12, #36 +// CHECK2-NEXT: 1000014: c0 f2 80 0c movt r12, #128 +// CHECK2-NEXT: 1000018: fc 44 add r12, pc +// CHECK2-NEXT: 100001a: 60 47 bx r12 +// CHECK2: __ThumbV7PILongThunk_far_preemptible: +// CHECK2-NEXT: 100001c: 40 f2 28 0c movw r12, #40 +// CHECK2-NEXT: 1000020: c0 f2 80 0c movt r12, #128 +// CHECK2-NEXT: 1000024: fc 44 add r12, pc +// CHECK2-NEXT: 1000026: 60 47 bx r12 + + .section .text.3, "ax", %progbits +.balign 0x0800000 +far_preemptible: + bl elsewhere +// CHECK3: far_preemptible: +// CHECK3: 1800000: 00 f0 16 e8 blx #44 + +// CHECK4: Disassembly of section .plt: +// CHECK4-NEXT: $a: +// CHECK4-NEXT: 1800010: 04 e0 2d e5 str lr, [sp, #-4]! +// CHECK4-NEXT: 1800014: 00 e6 8f e2 add lr, pc, #0, #12 +// CHECK4-NEXT: 1800018: 00 ea 8e e2 add lr, lr, #0, #20 +// CHECK4-NEXT: 180001c: ec ff be e5 ldr pc, [lr, #4076]! +// CHECK4: $d: +// CHECK4-NEXT: 1800020: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECK4-NEXT: 1800024: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECK4-NEXT: 1800028: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECK4-NEXT: 180002c: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECK4: $a: +// CHECK4-NEXT: 1800030: 00 c6 8f e2 add r12, pc, #0, #12 +// CHECK4-NEXT: 1800034: 00 ca 8c e2 add r12, r12, #0, #20 +// CHECK4-NEXT: 1800038: d4 ff bc e5 ldr pc, [r12, #4052]! +// CHECK4: $d: +// CHECK4-NEXT: 180003c: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECK4: $a: +// CHECK4-NEXT: 1800040: 00 c6 8f e2 add r12, pc, #0, #12 +// CHECK4-NEXT: 1800044: 00 ca 8c e2 add r12, r12, #0, #20 +// CHECK4-NEXT: 1800048: c8 ff bc e5 ldr pc, [r12, #4040]! +// CHECK4: $d: +// CHECK4-NEXT: 180004c: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECK4: $a: +// CHECK4-NEXT: 1800050: 00 c6 8f e2 add r12, pc, #0, #12 +// CHECK4-NEXT: 1800054: 00 ca 8c e2 add r12, r12, #0, #20 +// CHECK4-NEXT: 1800058: bc ff bc e5 ldr pc, [r12, #4028]! +// CHECK4: $d: +// CHECK4-NEXT: 180005c: d4 d4 d4 d4 .word 0xd4d4d4d4 diff --git a/test/ELF/arm-thumb-plt-reloc.s b/test/ELF/arm-thumb-plt-reloc.s index f9afbb9c0ce1..dd8770edc3c1 100644 --- a/test/ELF/arm-thumb-plt-reloc.s +++ b/test/ELF/arm-thumb-plt-reloc.s @@ -2,7 +2,7 @@ // RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t2 // RUN: ld.lld %t1 %t2 -o %t // RUN: llvm-objdump -triple=thumbv7a-none-linux-gnueabi -d %t | FileCheck %s -// RUN: ld.lld -shared %t1 %t2 -o %t3 +// RUN: ld.lld --hash-style=sysv -shared %t1 %t2 -o %t3 // RUN: llvm-objdump -triple=thumbv7a-none-linux-gnueabi -d %t3 | FileCheck -check-prefix=DSOTHUMB %s // RUN: llvm-objdump -triple=armv7a-none-linux-gnueabi -d %t3 | FileCheck -check-prefix=DSOARM %s // RUN: llvm-readobj -s -r %t3 | FileCheck -check-prefix=DSOREL %s @@ -43,50 +43,54 @@ _start: // .text is Thumb and .plt is ARM, llvm-objdump can currently only disassemble // as ARM or Thumb. Work around by disassembling twice. // DSOTHUMB: Disassembly of section .text: -// DSOTHUMB: func1: -// DSOTHUMB-NEXT: 1000: 70 47 bx lr +// DSOTHUMB-NEXT: func1: +// DSOTHUMB-NEXT: 1000: 70 47 bx lr // DSOTHUMB: func2: -// DSOTHUMB-NEXT: 1002: 70 47 bx lr +// DSOTHUMB-NEXT: 1002: 70 47 bx lr // DSOTHUMB: func3: -// DSOTHUMB-NEXT: 1004: 70 47 bx lr -// DSOTHUMB-NEXT: 1006: d4 d4 +// DSOTHUMB-NEXT: 1004: 70 47 bx lr +// DSOTHUMB-NEXT: 1006: d4 d4 bmi #-88 // DSOTHUMB: _start: -// 0x1008 + 0x28 + 4 = 0x1034 = PLT func1 -// DSOTHUMB-NEXT: 1008: 00 f0 14 e8 blx #40 -// 0x100c + 0x34 + 4 = 0x1044 = PLT func2 -// DSOTHUMB-NEXT: 100c: 00 f0 1a e8 blx #52 -// 0x1010 + 0x40 + 4 = 0x1054 = PLT func3 -// DSOTHUMB-NEXT: 1010: 00 f0 20 e8 blx #64 +// 0x1008 + 0x34 + 4 = 0x1040 = PLT func1 +// DSOTHUMB-NEXT: 1008: 00 f0 1a e8 blx #52 +// 0x100c + 0x40 + 4 = 0x1050 = PLT func2 +// DSOTHUMB-NEXT: 100c: 00 f0 20 e8 blx #64 +// 0x1010 + 0x4C + 4 = 0x1060 = PLT func3 +// DSOTHUMB-NEXT: 1010: 00 f0 26 e8 blx #76 // DSOARM: Disassembly of section .plt: // DSOARM-NEXT: $a: -// DSOARM-NEXT: 1020: 04 e0 2d e5 str lr, [sp, #-4]! -// DSOARM-NEXT: 1024: 04 e0 9f e5 ldr lr, [pc, #4] -// DSOARM-NEXT: 1028: 0e e0 8f e0 add lr, pc, lr -// DSOARM-NEXT: 102c: 08 f0 be e5 ldr pc, [lr, #8]! +// DSOARM-NEXT: 1020: 04 e0 2d e5 str lr, [sp, #-4]! +// (0x1024 + 8) + (0 RoR 12) + (0 RoR 20) + (0xfdc) = 0x2008 = .got.plt[3] +// DSOARM-NEXT: 1024: 00 e6 8f e2 add lr, pc, #0, #12 +// DSOARM-NEXT: 1028: 00 ea 8e e2 add lr, lr, #0, #20 +// DSOARM-NEXT: 102c: dc ff be e5 ldr pc, [lr, #4060]! // DSOARM: $d: -// DSOARM-NEXT: 1030: d0 0f 00 00 .word 0x00000fd0 -// 0x1028 + 8 + 0fd0 = 0x2000 + +// DSOARM-NEXT: 1030: d4 d4 d4 d4 .word 0xd4d4d4d4 +// DSOARM-NEXT: 1034: d4 d4 d4 d4 .word 0xd4d4d4d4 +// DSOARM-NEXT: 1038: d4 d4 d4 d4 .word 0xd4d4d4d4 +// DSOARM-NEXT: 103c: d4 d4 d4 d4 .word 0xd4d4d4d4 // DSOARM: $a: -// DSOARM-NEXT: 1034: 04 c0 9f e5 ldr r12, [pc, #4] -// DSOARM-NEXT: 1038: 0f c0 8c e0 add r12, r12, pc -// DSOARM-NEXT: 103c: 00 f0 9c e5 ldr pc, [r12] +// (0x1040 + 8) + (0 RoR 12) + (0 RoR 20) + (0xfc4) = 0x200c +// DSOARM-NEXT: 1040: 00 c6 8f e2 add r12, pc, #0, #12 +// DSOARM-NEXT: 1044: 00 ca 8c e2 add r12, r12, #0, #20 +// DSOARM-NEXT: 1048: c4 ff bc e5 ldr pc, [r12, #4036]! // DSOARM: $d: -// DSOARM-NEXT: 1040: cc 0f 00 00 .word 0x00000fcc -// 0x1038 + 8 + 0fcc = 0x200c +// DSOARM-NEXT: 104c: d4 d4 d4 d4 .word 0xd4d4d4d4 // DSOARM: $a: -// DSOARM-NEXT: 1044: 04 c0 9f e5 ldr r12, [pc, #4] -// DSOARM-NEXT: 1048: 0f c0 8c e0 add r12, r12, pc -// DSOARM-NEXT: 104c: 00 f0 9c e5 ldr pc, [r12] +// (0x1050 + 8) + (0 RoR 12) + (0 RoR 20) + (0xfb8) = 0x2010 +// DSOARM-NEXT: 1050: 00 c6 8f e2 add r12, pc, #0, #12 +// DSOARM-NEXT: 1054: 00 ca 8c e2 add r12, r12, #0, #20 +// DSOARM-NEXT: 1058: b8 ff bc e5 ldr pc, [r12, #4024]! // DSOARM: $d: -// DSOARM-NEXT: 1050: c0 0f 00 00 .word 0x00000fc0 -// 0x1048 + 8 + 0fc0 = 0x2010 +// DSOARM-NEXT: 105c: d4 d4 d4 d4 .word 0xd4d4d4d4 // DSOARM: $a: -// DSOARM-NEXT: 1054: 04 c0 9f e5 ldr r12, [pc, #4] -// DSOARM-NEXT: 1058: 0f c0 8c e0 add r12, r12, pc -// DSOARM-NEXT: 105c: 00 f0 9c e5 ldr pc, [r12] +// (0x1060 + 8) + (0 RoR 12) + (0 RoR 20) + (0xfac) = 0x2014 +// DSOARM-NEXT: 1060: 00 c6 8f e2 add r12, pc, #0, #12 +// DSOARM-NEXT: 1064: 00 ca 8c e2 add r12, r12, #0, #20 +// DSOARM-NEXT: 1068: ac ff bc e5 ldr pc, [r12, #4012]! // DSOARM: $d: -// DSOARM-NEXT: 1060: b4 0f 00 00 .word 0x00000fb4 -// 0x1058 + 8 + 0fb4 = 0x2014 +// DSOARM-NEXT: 106c: d4 d4 d4 d4 .word 0xd4d4d4d4 // DSOREL: Name: .got.plt // DSOREL-NEXT: Type: SHT_PROGBITS diff --git a/test/ELF/arm-thumb-range-thunk-os.s b/test/ELF/arm-thumb-range-thunk-os.s new file mode 100644 index 000000000000..588539ddab8c --- /dev/null +++ b/test/ELF/arm-thumb-range-thunk-os.s @@ -0,0 +1,159 @@ +// REQUIRES: arm +// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t +// RUN: ld.lld %t -o %t2 2>&1 +// The output file is large, most of it zeroes. We dissassemble only the +// parts we need to speed up the test and avoid a large output file +// RUN: llvm-objdump -d %t2 -start-address=1048576 -stop-address=1048588 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK1 %s +// RUN: llvm-objdump -d %t2 -start-address=2097152 -stop-address=2097154 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK2 %s +// RUN: llvm-objdump -d %t2 -start-address=3145728 -stop-address=3145730 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK3 %s +// RUN: llvm-objdump -d %t2 -start-address=4194304 -stop-address=4194310 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK4 %s +// RUN: llvm-objdump -d %t2 -start-address=16777216 -stop-address=16777270 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK5 %s +// RUN: llvm-objdump -d %t2 -start-address=17825792 -stop-address=17825808 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK6 %s +// RUN: llvm-objdump -d %t2 -start-address=31457280 -stop-address=31457286 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK7 %s +// RUN: llvm-objdump -d %t2 -start-address=32505860 -stop-address=32505880 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK8 %s +// RUN: llvm-objdump -d %t2 -start-address=35651584 -stop-address=35651594 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK9 %s +// RUN: llvm-objdump -d %t2 -start-address=36700160 -stop-address=36700170 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK10 %s + +// Test the Range extension Thunks for Thumb when all the code is in a single +// OutputSection. The Thumb unconditional branch b.w and branch and link bl +// instructions have a range of 16Mb. We create a series of Functions a +// megabyte apart. We expect range extension thunks to be created when a +// branch is out of range. Thunks will be reused whenever they are in range + .syntax unified + +// Define a function aligned on a megabyte boundary + .macro FUNCTION suff + .section .text.\suff\(), "ax", %progbits + .thumb + .balign 0x100000 + .globl tfunc\suff\() + .type tfunc\suff\(), %function +tfunc\suff\(): + bx lr + .endm + + .section .text, "ax", %progbits + .thumb + .globl _start +_start: +// tfunc00 and tfunc15 are within 16Mb no Range Thunks expected + bl tfunc00 + bl tfunc15 +// tfunc16 is > 16Mb away, expect a Range Thunk to be generated, to go into +// the first of the pre-created ThunkSections. + bl tfunc16 +// CHECK1: Disassembly of section .text: +// CHECK1-NEXT: _start: +// CHECK1-NEXT: 100000: ff f0 fe ff bl #1048572 +// CHECK1-NEXT: 100004: ff f3 fc d7 bl #16777208 +// CHECK1-NEXT: 100008: ff f2 fc d7 bl #15728632 + + FUNCTION 00 +// CHECK2: tfunc00: +// CHECK2-NEXT: 200000: 70 47 bx lr + FUNCTION 01 +// CHECK3: tfunc01: +// CHECK3-NEXT: 300000: 70 47 bx lr + FUNCTION 02 +// tfunc28 is > 16Mb away, expect a Range Thunk to be generated, to go into +// the first of the pre-created ThunkSections. + b.w tfunc28 +// CHECK4: tfunc02: +// CHECK4-NEXT: 400000: 70 47 bx lr +// CHECK4-NEXT: 400002: 00 f0 04 90 b.w #12582920 <__Thumbv7ABSLongThunk_tfunc28> + FUNCTION 03 + FUNCTION 04 + FUNCTION 05 + FUNCTION 06 + FUNCTION 07 + FUNCTION 08 + FUNCTION 09 + FUNCTION 10 + FUNCTION 11 + FUNCTION 12 + FUNCTION 13 + FUNCTION 14 +// Expect precreated ThunkSection here +// CHECK5: __Thumbv7ABSLongThunk_tfunc16: +// CHECK5-NEXT: 1000004: 40 f2 01 0c movw r12, #1 +// CHECK5-NEXT: 1000008: c0 f2 20 1c movt r12, #288 +// CHECK5-NEXT: 100000c: 60 47 bx r12 +// CHECK5: __Thumbv7ABSLongThunk_tfunc28: +// CHECK5-NEXT: 100000e: 40 f2 01 0c movw r12, #1 +// CHECK5-NEXT: 1000012: c0 f2 e0 1c movt r12, #480 +// CHECK5-NEXT: 1000016: 60 47 bx r12 +// CHECK5: __Thumbv7ABSLongThunk_tfunc32: +// CHECK5-NEXT: 1000018: 40 f2 01 0c movw r12, #1 +// CHECK5-NEXT: 100001c: c0 f2 20 2c movt r12, #544 +// CHECK5-NEXT: 1000020: 60 47 bx r12 +// CHECK5: __Thumbv7ABSLongThunk_tfunc33: +// CHECK5-NEXT: 1000022: 40 f2 01 0c movw r12, #1 +// CHECK5-NEXT: 1000026: c0 f2 30 2c movt r12, #560 +// CHECK5-NEXT: 100002a: 60 47 bx r12 +// CHECK5: __Thumbv7ABSLongThunk_tfunc02: +// CHECK5-NEXT: 100002c: 40 f2 01 0c movw r12, #1 +// CHECK5-NEXT: 1000030: c0 f2 40 0c movt r12, #64 +// CHECK5-NEXT: 1000034: 60 47 bx r12 + FUNCTION 15 +// tfunc00 and tfunc01 are < 16Mb away, expect no range extension thunks + bl tfunc00 + bl tfunc01 +// tfunc32 and tfunc33 are > 16Mb away, expect range extension thunks in the +// precreated thunk section + bl tfunc32 + bl tfunc33 +// CHECK6: tfunc15: +// CHECK6-NEXT: 1100000: 70 47 bx lr +// CHECK6-NEXT: 1100002: ff f4 fd d7 bl #-15728646 +// CHECK6-NEXT: 1100006: ff f5 fb d7 bl #-14680074 +// CHECK6-NEXT: 110000a: 00 f7 05 f8 bl #-1048566 +// CHECK6-NEXT: 110000e: 00 f7 08 f8 bl #-1048560 + FUNCTION 16 + FUNCTION 17 + FUNCTION 18 + FUNCTION 19 + FUNCTION 20 + FUNCTION 21 + FUNCTION 22 + FUNCTION 23 + FUNCTION 24 + FUNCTION 25 + FUNCTION 26 + FUNCTION 27 + FUNCTION 28 +// tfunc02 is > 16Mb away, expect range extension thunks in precreated thunk +// section +// CHECK7: tfunc28: +// CHECK7-NEXT: 1e00000: 70 47 bx lr +// CHECK7-NEXT: 1e00002: 00 f6 13 90 b.w #-14680026 <__Thumbv7ABSLongThunk_tfunc02> + + b.w tfunc02 + FUNCTION 29 +// Expect another precreated thunk section here +// CHECK8: __Thumbv7ABSLongThunk_tfunc15: +// CHECK8-NEXT: 1f00004: 40 f2 01 0c movw r12, #1 +// CHECK8-NEXT: 1f00008: c0 f2 10 1c movt r12, #272 +// CHECK8-NEXT: 1f0000c: 60 47 bx r12 +// CHECK8: __Thumbv7ABSLongThunk_tfunc16: +// CHECK8-NEXT: 1f0000e: 40 f2 01 0c movw r12, #1 +// CHECK8-NEXT: 1f00012: c0 f2 20 1c movt r12, #288 +// CHECK8-NEXT: 1f00016: 60 47 bx r12 + FUNCTION 30 + FUNCTION 31 + FUNCTION 32 + // tfunc15 and tfunc16 are > 16 Mb away expect Thunks in the nearest + // precreated thunk section. + bl tfunc15 + bl tfunc16 +// CHECK9: tfunc32: +// CHECK9: 2200000: 70 47 bx lr +// CHECK9-NEXT: 2200002: ff f4 ff ff bl #-3145730 +// CHECK9-NEXT: 2200006: 00 f5 02 f8 bl #-3145724 + + FUNCTION 33 + bl tfunc15 + bl tfunc16 +// CHECK10: tfunc33: +// CHECK10: 2300000: 70 47 bx lr +// CHECK10-NEXT: 2300002: ff f7 ff f7 bl #-4194306 +// CHECK10-NEXT: 2300006: 00 f4 02 f8 bl #-4194300 diff --git a/test/ELF/arm-thumb-thunk-empty-pass.s b/test/ELF/arm-thumb-thunk-empty-pass.s new file mode 100644 index 000000000000..9ff6ed6a7807 --- /dev/null +++ b/test/ELF/arm-thumb-thunk-empty-pass.s @@ -0,0 +1,32 @@ +// REQUIRES: arm +// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t +// RUN: ld.lld %t -o %t2 2>&1 +// RUN: llvm-objdump -d %t2 -start-address=69632 -stop-address=69646 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK1 %s +// RUN: llvm-objdump -d %t2 -start-address=16846860 -stop-address=16846874 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK2 %s + .syntax unified + .global _start, foo + .type _start, %function + .section .text.start,"ax",%progbits +_start: + bl _start + .section .text.dummy1,"ax",%progbits + .space 0xfffffe + .section .text.foo,"ax",%progbits + .type foo, %function +foo: + bl _start + +// CHECK1: Disassembly of section .text: +// CHECK1-NEXT: _start: +// CHECK1-NEXT: 11000: ff f7 fe ff bl #-4 +// CHECK1: __Thumbv7ABSLongThunk__start: +// CHECK1-NEXT: 11004: 41 f2 01 0c movw r12, #4097 +// CHECK1-NEXT: 11008: c0 f2 01 0c movt r12, #1 +// CHECK1-NEXT: 1100c: 60 47 bx r12 + +// CHECK2: __Thumbv7ABSLongThunk__start: +// CHECK2: 101100c: 41 f2 01 0c movw r12, #4097 +// CHECK2-NEXT: 1011010: c0 f2 01 0c movt r12, #1 +// CHECK2-NEXT: 1011014: 60 47 bx r12 +// CHECK2: foo: +// CHECK2-NEXT: 1011016: ff f7 f9 ff bl #-14 diff --git a/test/ELF/arm-thumb-thunk-symbols.s b/test/ELF/arm-thumb-thunk-symbols.s index 42046f802f96..faa39fec0218 100644 --- a/test/ELF/arm-thumb-thunk-symbols.s +++ b/test/ELF/arm-thumb-thunk-symbols.s @@ -25,18 +25,18 @@ arm_fn: b thumb_fn // CHECK: Name: __Thumbv7ABSLongThunk_arm_fn -// CHECK-NEXT: Value: 0x11005 +// CHECK-NEXT: Value: 0x12005 // CHECK-NEXT: Size: 10 // CHECK-NEXT: Binding: Local (0x0) // CHECK-NEXT: Type: Function (0x2) // CHECK: Name: __ARMv7ABSLongThunk_thumb_fn -// CHECK-NEXT: Value: 0x11010 +// CHECK-NEXT: Value: 0x12010 // CHECK-NEXT: Size: 12 // CHECK-NEXT: Binding: Local (0x0) // CHECK-NEXT: Type: Function (0x2) // CHECK-PI: Name: __ThumbV7PILongThunk_arm_fn -// CHECK-PI-NEXT: Value: 0x1005 +// CHECK-PI-NEXT: Value: 0x2005 // CHECK-PI-NEXT: Size: 12 // CHECK-PI-NEXT: Binding: Local (0x0) // CHECK-PI-NEXT: Type: Function (0x2) diff --git a/test/ELF/arm-thunk-edgecase.s b/test/ELF/arm-thunk-edgecase.s new file mode 100644 index 000000000000..81837c7b3284 --- /dev/null +++ b/test/ELF/arm-thunk-edgecase.s @@ -0,0 +1,37 @@ +// REQUIRES: arm +// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o +// RUN: echo "SECTIONS { \ +// RUN: .text_armfunc 0x1000 : { *(.text_armfunc) } \ +// RUN: .text_thumbfunc 0x11010 : { *(.text_thumbfunc) } \ +// RUN: }" > %tarm_to_thumb.script +// RUN: echo "SECTIONS { \ +// RUN: .text_thumbfunc 0x1000 : { *(.text_thumbfunc) } \ +// RUN: .text_armfunc 0x1100c : { *(.text_armfunc) } \ +// RUN: }" > %tthumb_to_arm.script +// RUN: ld.lld -shared -Bsymbolic -script %tarm_to_thumb.script %t.o -o %tarm_to_thumb.so +// RUN: ld.lld -shared -Bsymbolic -script %tthumb_to_arm.script %t.o -o %tthumb_to_arm.so +// RUN: llvm-objdump -triple=armv7a-none-linux-gnueabi -d %tarm_to_thumb.so | FileCheck -check-prefix=ARM-TO-THUMB %s +// RUN: llvm-objdump -triple=thumbv7a-none-linux-gnueabi -d %tthumb_to_arm.so | FileCheck -check-prefix=THUMB-TO-ARM %s + +.syntax unified + +.arm +.section .text_armfunc, "ax", %progbits +.globl armfunc +armfunc: + b thumbfunc + +.thumb +.section .text_thumbfunc, "ax", %progbits +.globl thumbfunc +.thumb_func +thumbfunc: + b.w armfunc + +// ARM-TO-THUMB: __ARMV7PILongThunk_thumbfunc: +// ARM-TO-THUMB-NEXT: 1004: fd cf 0f e3 movw r12, #65533 +// ARM-TO-THUMB-NEXT: 1008: 00 c0 40 e3 movt r12, #0 + +// THUMB-TO-ARM: __ThumbV7PILongThunk_armfunc: +// THUMB-TO-ARM-NEXT: 1004: 4f f6 fc 7c movw r12, #65532 +// THUMB-TO-ARM-NEXT: 1008: c0 f2 00 0c movt r12, #0 diff --git a/test/ELF/arm-thunk-largesection.s b/test/ELF/arm-thunk-largesection.s new file mode 100644 index 000000000000..950f789764a6 --- /dev/null +++ b/test/ELF/arm-thunk-largesection.s @@ -0,0 +1,42 @@ +// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t +// RUN: ld.lld %t -o %t2 2>&1 +// RUN: llvm-objdump -d -triple=thumbv7a-none-linux-gnueabi -start-address=69632 -stop-address=69636 %t2 | FileCheck -check-prefix=CHECK1 %s +// RUN: llvm-objdump -d -triple=thumbv7a-none-linux-gnueabi -start-address=73732 -stop-address=73742 %t2 | FileCheck -check-prefix=CHECK2 %s +// RUN: llvm-objdump -d -triple=thumbv7a-none-linux-gnueabi -start-address=16850944 -stop-address=16850948 %t2 | FileCheck -check-prefix=CHECK3 %s +// RUN: llvm-objdump -d -triple=thumbv7a-none-linux-gnueabi -start-address=33628160 -stop-address=33628164 %t2 | FileCheck -check-prefix=CHECK4 %s +// RUN: llvm-objdump -d -triple=thumbv7a-none-linux-gnueabi -start-address=50405364 -stop-address=50405376 %t2 | FileCheck -check-prefix=CHECK5 %s +// REQUIRES: arm + .syntax unified + .balign 0x1000 + .thumb + .text + .globl _start + .type _start, %function +_start: + bx lr + .space 0x1000 +// CHECK1: Disassembly of section .text: +// CHECK1-NEXT: _start: +// CHECK1-NEXT: 11000: 70 47 bx lr +// CHECK1-NEXT: 11002: 00 00 movs r0, r0 + +// CHECK2: __Thumbv7ABSLongThunk__start: +// CHECK2-NEXT: 12004: 41 f2 01 0c movw r12, #4097 +// CHECK2-NEXT: 12008: c0 f2 01 0c movt r12, #1 +// CHECK2-NEXT: 1200c: 60 47 bx r12 + +// Gigantic section where we need a ThunkSection either side of it + .section .text.large1, "ax", %progbits + .balign 4 + .space (16 * 1024 * 1024) - 16 + bl _start + .space (16 * 1024 * 1024) - 4 + bl _start + .space (16 * 1024 * 1024) - 16 +// CHECK3: 1012000: 00 f4 00 d0 bl #-16777216 +// CHECK4: 2012000: ff f3 f8 d7 bl #16777200 + +// CHECK5: __Thumbv7ABSLongThunk__start: +// CHECK5-NEXT: 3011ff4: 41 f2 01 0c movw r12, #4097 +// CHECK5-NEXT: 3011ff8: c0 f2 01 0c movt r12, #1 +// CHECK5-NEXT: 3011ffc: 60 47 bx r12 diff --git a/test/ELF/arm-thunk-linkerscript-dotexpr.s b/test/ELF/arm-thunk-linkerscript-dotexpr.s new file mode 100644 index 000000000000..bd0e9a293102 --- /dev/null +++ b/test/ELF/arm-thunk-linkerscript-dotexpr.s @@ -0,0 +1,77 @@ +// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t +// RUN: echo "SECTIONS { \ +// RUN: . = SIZEOF_HEADERS; \ +// RUN: .text_low : { *(.text_low) *(.text_low2) . = . + 0x2000000 ; *(.text_high) *(.text_high2) } \ +// RUN: } " > %t.script +// RUN: ld.lld --script %t.script %t -o %t2 2>&1 +// RUN: llvm-objdump -d %t2 -start-address=148 -stop-address=188 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK1 %s +// RUN: llvm-objdump -d %t2 -start-address=33554620 -stop-address=33554654 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK2 %s +// REQUIRES: arm +// Test that range extension thunks can handle location expressions within +// a Section Description + .syntax unified + .section .text_low, "ax", %progbits + .thumb + .globl _start +_start: bx lr + .globl low_target + .type low_target, %function +low_target: + bl high_target + bl high_target2 + + .section .text_low2, "ax", %progbits + .thumb + .globl low_target2 + .type low_target2, %function +low_target2: + bl high_target + bl high_target2 +// CHECK1: Disassembly of section .text_low: +// CHECK1-NEXT: _start: +// CHECK1-NEXT: 94: 70 47 bx lr +// CHECK1: low_target: +// CHECK1-NEXT: 96: 00 f0 03 f8 bl #6 +// CHECK1-NEXT: 9a: 00 f0 06 f8 bl #12 +// CHECK1: __Thumbv7ABSLongThunk_high_target: +// CHECK1-NEXT: a0: 40 f2 bd 0c movw r12, #189 +// CHECK1-NEXT: a4: c0 f2 00 2c movt r12, #512 +// CHECK1-NEXT: a8: 60 47 bx r12 +// CHECK1: __Thumbv7ABSLongThunk_high_target2: +// CHECK1-NEXT: aa: 40 f2 d9 0c movw r12, #217 +// CHECK1-NEXT: ae: c0 f2 00 2c movt r12, #512 +// CHECK1-NEXT: b2: 60 47 bx r12 +// CHECK1: low_target2: +// CHECK1-NEXT: b4: ff f7 f4 ff bl #-24 +// CHECK1-NEXT: b8: ff f7 f7 ff bl #-18 + + .section .text_high, "ax", %progbits + .thumb + .globl high_target + .type high_target, %function +high_target: + bl low_target + bl low_target2 + + .section .text_high2, "ax", %progbits + .thumb + .globl high_target2 + .type high_target2, %function +high_target2: + bl low_target + bl low_target2 + +// CHECK2: high_target: +// CHECK2-NEXT: 20000bc: 00 f0 02 f8 bl #4 +// CHECK2-NEXT: 20000c0: 00 f0 05 f8 bl #10 +// CHECK2: __Thumbv7ABSLongThunk_low_target: +// CHECK2-NEXT: 20000c4: 40 f2 97 0c movw r12, #151 +// CHECK2-NEXT: 20000c8: c0 f2 00 0c movt r12, #0 +// CHECK2-NEXT: 20000cc: 60 47 bx r12 +// CHECK2: __Thumbv7ABSLongThunk_low_target2: +// CHECK2-NEXT: 20000ce: 40 f2 b5 0c movw r12, #181 +// CHECK2-NEXT: 20000d2: c0 f2 00 0c movt r12, #0 +// CHECK2-NEXT: 20000d6: 60 47 bx r12 +// CHECK2: high_target2: +// CHECK2-NEXT: 20000d8: ff f7 f4 ff bl #-24 +// CHECK2-NEXT: 20000dc: ff f7 f7 ff bl #-18 diff --git a/test/ELF/arm-thunk-linkerscript-large.s b/test/ELF/arm-thunk-linkerscript-large.s new file mode 100644 index 000000000000..07cd1dd87976 --- /dev/null +++ b/test/ELF/arm-thunk-linkerscript-large.s @@ -0,0 +1,176 @@ +// REQUIRES: arm +// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t +// RUN: echo "SECTIONS { \ +// RUN: .text 0x100000 : { *(.text) } \ +// RUN: .textl : { *(.text_l0*) *(.text_l1*) *(.text_l2*) *(.text_l3*) } \ +// RUN: .texth : { *(.text_h0*) *(.text_h1*) *(.text_h2*) *(.text_h3*) } \ +// RUN: }" > %t.script +// RUN: ld.lld --script %t.script %t -o %t2 2>&1 +// The output file is large, most of it zeroes. We dissassemble only the +// parts we need to speed up the test and avoid a large output file +// RUN: llvm-objdump -d %t2 -start-address=1048576 -stop-address=1048594 -triple=thumbv7a-linux-gnueabihf | FileCheck --check-prefix=CHECK1 %s +// RUN: llvm-objdump -d %t2 -start-address=2097152 -stop-address=2097160 -triple=thumbv7a-linux-gnueabihf | FileCheck --check-prefix=CHECK2 %s +// RUN: llvm-objdump -d %t2 -start-address=11534340 -stop-address=11534350 -triple=thumbv7a-linux-gnueabihf | FileCheck --check-prefix=CHECK3 %s +// RUN: llvm-objdump -d %t2 -start-address=34603008 -stop-address=34603034 -triple=thumbv7a-linux-gnueabihf | FileCheck --check-prefix=CHECK4 %s +// RUN: llvm-objdump -d %t2 -start-address=35651584 -stop-address=35651598 -triple=thumbv7a-linux-gnueabihf | FileCheck --check-prefix=CHECK5 %s +// RUN: llvm-objdump -d %t2 -start-address=68157440 -stop-address=68157472 -triple=thumbv7a-linux-gnueabihf | FileCheck --check-prefix=CHECK6 %s + +// Test the range extensions in a linker script where there are several +// OutputSections requiring range extension Thunks. We should be able to reuse +// Thunks between OutputSections but our placement of new Thunks is done on a +// per OutputSection basis + .syntax unified + +// Define a function that we can match with .text_l* aligned on a megabyte // boundary + .macro FUNCTIONL suff + .section .text_l\suff\(), "ax", %progbits + .thumb + .balign 0x100000 + .globl tfuncl\suff\() + .type tfuncl\suff\(), %function +tfuncl\suff\(): + bx lr + .endm + +// Define a function that we can match with .text_h* aligned on a megabyte +// boundary + .macro FUNCTIONH suff + .section .text_h\suff\(), "ax", %progbits + .thumb + .balign 0x100000 + .globl tfunch\suff\() + .type tfunch\suff\(), %function +tfunch\suff\(): + bx lr + .endm + + .section .text, "ax", %progbits + .thumb + .globl _start +_start: + bl tfuncl00 + // Expect a range extension thunk in .text OutputSection + bl tfunch31 +// CHECK1: Disassembly of section .text: +// CHECK1-NEXT: _start: +// CHECK1-NEXT: 100000: ff f0 fe ff bl #1048572 +// CHECK1-NEXT: 100004: 00 f0 00 f8 bl #0 +// CHECK1: __Thumbv7ABSLongThunk_tfunch31: +// CHECK1-NEXT: 100008: 40 f2 01 0c movw r12, #1 +// CHECK1-NEXT: 10000c: c0 f2 10 4c movt r12, #1040 +// CHECK1-NEXT: 100010: 60 47 bx r12 + FUNCTIONL 00 + // Create a range extension thunk in .textl + bl tfuncl24 + // We can reuse existing thunk in .text + bl tfunch31 +// CHECK2: Disassembly of section .textl: +// CHECK2-NEXT: tfuncl00: +// CHECK2-NEXT: 200000: 70 47 bx lr +// CHECK2-NEXT: 200002: ff f0 ff df bl #9437182 +// CHECK2-NEXT: 200006: ff f6 ff ff bl #-1048578 + FUNCTIONL 01 + FUNCTIONL 02 + FUNCTIONL 03 + FUNCTIONL 04 + FUNCTIONL 05 + FUNCTIONL 06 + FUNCTIONL 07 + FUNCTIONL 08 + FUNCTIONL 09 +// CHECK3: __Thumbv7ABSLongThunk_tfuncl24: +// CHECK3-NEXT: b00004: 40 f2 01 0c movw r12, #1 +// CHECK3-NEXT: b00008: c0 f2 a0 1c movt r12, #416 +// CHECK3-NEXT: b0000c: 60 47 bx r12 + FUNCTIONL 10 + FUNCTIONL 11 + FUNCTIONL 12 + FUNCTIONL 13 + FUNCTIONL 14 + FUNCTIONL 15 + FUNCTIONL 16 + FUNCTIONL 17 + FUNCTIONL 18 + FUNCTIONL 19 + FUNCTIONL 20 + FUNCTIONL 21 + FUNCTIONL 22 + FUNCTIONL 23 + FUNCTIONL 24 + FUNCTIONL 25 + FUNCTIONL 26 + FUNCTIONL 27 + FUNCTIONL 28 + FUNCTIONL 29 + FUNCTIONL 30 + FUNCTIONL 31 + // Create range extension thunks in .textl + bl tfuncl00 + bl tfuncl24 + // Shouldn't need a thunk + bl tfunch00 +// CHECK4: 2100002: 00 f0 05 f8 bl #10 +// CHECK4-NEXT: 2100006: ff f4 fb f7 bl #-7340042 +// CHECK4-NEXT: 210000a: ff f0 f9 ff bl #1048562 +// CHECK4: __Thumbv7ABSLongThunk_tfuncl00: +// CHECK4-NEXT: 2100010: 40 f2 01 0c movw r12, #1 +// CHECK4-NEXT: 2100014: c0 f2 20 0c movt r12, #32 +// CHECK4-NEXT: 2100018: 60 47 bx r12 + FUNCTIONH 00 + // Can reuse existing thunks in .textl + bl tfuncl00 + bl tfuncl24 + // Shouldn't need a thunk + bl tfuncl31 +// CHECK5: Disassembly of section .texth: +// CHECK5-NEXT: tfunch00: +// CHECK5-NEXT: 2200000: 70 47 bx lr +// CHECK5-NEXT: 2200002: 00 f7 05 f8 bl #-1048566 +// CHECK5-NEXT: 2200006: ff f7 fb df bl #-8388618 +// CHECK5-NEXT: 220000a: ff f6 f9 ff bl #-1048590 + FUNCTIONH 01 + FUNCTIONH 02 + FUNCTIONH 03 + FUNCTIONH 04 + FUNCTIONH 05 + FUNCTIONH 06 + FUNCTIONH 07 + FUNCTIONH 08 + FUNCTIONH 09 + FUNCTIONH 10 + FUNCTIONH 11 + FUNCTIONH 12 + FUNCTIONH 13 + FUNCTIONH 14 + FUNCTIONH 15 + FUNCTIONH 16 + FUNCTIONH 17 + FUNCTIONH 18 + FUNCTIONH 19 + FUNCTIONH 20 + FUNCTIONH 21 + FUNCTIONH 22 + FUNCTIONH 23 + FUNCTIONH 24 + FUNCTIONH 25 + FUNCTIONH 26 + FUNCTIONH 27 + FUNCTIONH 28 + FUNCTIONH 29 + FUNCTIONH 30 + FUNCTIONH 31 +// expect Thunks in .texth + bl tfuncl00 + bl tfunch00 +// CHECK6: tfunch31: +// CHECK6-NEXT: 4100000: 70 47 bx lr +// CHECK6-NEXT: 4100002: 00 f0 03 f8 bl #6 +// CHECK6-NEXT: 4100006: 00 f0 06 f8 bl #12 +// CHECK6: __Thumbv7ABSLongThunk_tfuncl00: +// CHECK6-NEXT: 410000c: 40 f2 01 0c movw r12, #1 +// CHECK6-NEXT: 4100010: c0 f2 20 0c movt r12, #32 +// CHECK6-NEXT: 4100014: 60 47 bx r12 +// CHECK6: __Thumbv7ABSLongThunk_tfunch00: +// CHECK6-NEXT: 4100016: 40 f2 01 0c movw r12, #1 +// CHECK6-NEXT: 410001a: c0 f2 20 2c movt r12, #544 +// CHECK6-NEXT: 410001e: 60 47 bx r12 diff --git a/test/ELF/arm-thunk-linkerscript-orphan.s b/test/ELF/arm-thunk-linkerscript-orphan.s new file mode 100644 index 000000000000..f05cc0de9069 --- /dev/null +++ b/test/ELF/arm-thunk-linkerscript-orphan.s @@ -0,0 +1,63 @@ +// REQUIRES: arm +// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t +// RUN: echo "SECTIONS { \ +// RUN: .text_low 0x100000 : { *(.text_low) } \ +// RUN: .text_high 0x2000000 : { *(.text_high) } \ +// RUN: .data : { *(.data) } \ +// RUN: }" > %t.script +// RUN: ld.lld --script %t.script %t -o %t2 2>&1 +// RUN: llvm-objdump -d -triple=thumbv7a-none-linux-gnueabi %t2 | FileCheck %s + .syntax unified + .section .text_low, "ax", %progbits + .thumb + .globl _start +_start: bx lr + .globl low_target + .type low_target, %function +low_target: + bl high_target + bl orphan_target +// CHECK: Disassembly of section .text_low: +// CHECK-NEXT: _start: +// CHECK-NEXT: 100000: 70 47 bx lr +// CHECK: low_target: +// CHECK-NEXT: 100002: 00 f0 03 f8 bl #6 +// CHECK-NEXT: 100006: 00 f0 06 f8 bl #12 +// CHECK: __Thumbv7ABSLongThunk_high_target: +// CHECK-NEXT: 10000c: 40 f2 01 0c movw r12, #1 +// CHECK-NEXT: 100010: c0 f2 00 2c movt r12, #512 +// CHECK-NEXT: 100014: 60 47 bx r12 +// CHECK: __Thumbv7ABSLongThunk_orphan_target: +// CHECK-NEXT: 100016: 40 f2 15 0c movw r12, #21 +// CHECK-NEXT: 10001a: c0 f2 00 2c movt r12, #512 +// CHECK-NEXT: 10001e: 60 47 bx r12 + .section .text_high, "ax", %progbits + .thumb + .globl high_target + .type high_target, %function +high_target: + bl low_target + bl orphan_target +// CHECK: Disassembly of section .text_high: +// CHECK-NEXT: high_target: +// CHECK-NEXT: 2000000: 00 f0 02 f8 bl #4 +// CHECK-NEXT: 2000004: 00 f0 06 f8 bl #12 +// CHECK: __Thumbv7ABSLongThunk_low_target: +// CHECK-NEXT: 2000008: 40 f2 03 0c movw r12, #3 +// CHECK-NEXT: 200000c: c0 f2 10 0c movt r12, #16 +// CHECK-NEXT: 2000010: 60 47 bx r12 + + .section orphan, "ax", %progbits + .thumb + .globl orphan_target + .type orphan_target, %function +orphan_target: + bl low_target + bl high_target +// CHECK: Disassembly of section orphan: +// CHECK-NEXT: orphan_target: +// CHECK-NEXT: 2000014: ff f7 f8 ff bl #-16 +// CHECK-NEXT: 2000018: ff f7 f2 ff bl #-28 + + .data + .word 10 diff --git a/test/ELF/arm-thunk-linkerscript-sort.s b/test/ELF/arm-thunk-linkerscript-sort.s new file mode 100644 index 000000000000..69d176765780 --- /dev/null +++ b/test/ELF/arm-thunk-linkerscript-sort.s @@ -0,0 +1,71 @@ +// REQUIRES: arm +// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t +// RUN: echo "SECTIONS { \ +// RUN: .text 0x100000 : { *(SORT_BY_NAME(.text.*)) } \ +// RUN: }" > %t.script +// RUN: ld.lld --script %t.script %t -o %t2 2>&1 +// RUN: llvm-objdump -d %t2 -start-address=1048576 -stop-address=1048584 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK1 %s +// RUN: llvm-objdump -d %t2 -start-address=16777220 -stop-address=16777230 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK2 %s + + .syntax unified + +// Test that linkerscript sorting does not apply to Thunks, we expect that the +// sort will reverse the order of sections presented here. + +// Define a function aligned on a megabyte boundary + .macro FUNCTION suff + .section .text.\suff\(), "ax", %progbits + .thumb + .balign 0x100000 + .globl tfunc\suff\() + .type tfunc\suff\(), %function +tfunc\suff\(): + bx lr + .endm + + FUNCTION 31 + FUNCTION 30 + FUNCTION 29 + FUNCTION 28 + FUNCTION 27 + FUNCTION 26 + FUNCTION 25 + FUNCTION 24 + FUNCTION 23 + FUNCTION 22 + FUNCTION 21 + FUNCTION 20 + FUNCTION 19 + FUNCTION 18 + FUNCTION 17 + FUNCTION 16 + FUNCTION 15 +// CHECK2: __Thumbv7ABSLongThunk_tfunc31: +// CHECK2-NEXT: 1000004: 40 f2 01 0c movw r12, #1 +// CHECK2-NEXT: 1000008: c0 f2 00 2c movt r12, #512 +// CHECK2-NEXT: 100000c: 60 47 bx r12 + FUNCTION 14 + FUNCTION 13 + FUNCTION 12 + FUNCTION 11 + FUNCTION 10 + FUNCTION 09 + FUNCTION 08 + FUNCTION 07 + FUNCTION 06 + FUNCTION 05 + FUNCTION 04 + FUNCTION 03 + FUNCTION 02 + FUNCTION 01 + .section .text.00, "ax", %progbits + .thumb + .globl _start +_start: +// Expect no range extension needed for tfunc01 and an extension needed for +// tfunc31 + bl tfunc01 + bl tfunc31 +// CHECK1: _start: +// CHECK1-NEXT: 100000: ff f0 fe ff bl #1048572 +// CHECK1-NEXT: 100004: ff f2 fe d7 bl #15728636 diff --git a/test/ELF/arm-thunk-linkerscript.s b/test/ELF/arm-thunk-linkerscript.s new file mode 100644 index 000000000000..9aaa29237cbe --- /dev/null +++ b/test/ELF/arm-thunk-linkerscript.s @@ -0,0 +1,78 @@ +// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t +// RUN: echo "SECTIONS { \ +// RUN: . = SIZEOF_HEADERS; \ +// RUN: .text_low : { *(.text_low) *(.text_low2) } \ +// RUN: .text_high 0x2000000 : { *(.text_high) *(.text_high2) } \ +// RUN: } " > %t.script +// RUN: ld.lld --script %t.script %t -o %t2 2>&1 +// RUN: llvm-objdump -d -triple=thumbv7a-none-linux-gnueabi %t2 | FileCheck %s +// REQUIRES: arm +// Simple test that we can support range extension thunks with linker scripts + .syntax unified + .section .text_low, "ax", %progbits + .thumb + .globl _start +_start: bx lr + .globl low_target + .type low_target, %function +low_target: + bl high_target + bl high_target2 + + .section .text_low2, "ax", %progbits + .thumb + .globl low_target2 + .type low_target2, %function +low_target2: + bl high_target + bl high_target2 + +// CHECK: Disassembly of section .text_low: +// CHECK-NEXT: _start: +// CHECK-NEXT: 94: 70 47 bx lr +// CHECK: low_target: +// CHECK-NEXT: 96: 00 f0 03 f8 bl #6 +// CHECK-NEXT: 9a: 00 f0 06 f8 bl #12 +// CHECK: __Thumbv7ABSLongThunk_high_target: +// CHECK-NEXT: a0: 40 f2 01 0c movw r12, #1 +// CHECK-NEXT: a4: c0 f2 00 2c movt r12, #512 +// CHECK-NEXT: a8: 60 47 bx r12 +// CHECK: __Thumbv7ABSLongThunk_high_target2: +// CHECK-NEXT: aa: 40 f2 1d 0c movw r12, #29 +// CHECK-NEXT: ae: c0 f2 00 2c movt r12, #512 +// CHECK-NEXT: b2: 60 47 bx r12 +// CHECK: low_target2: +// CHECK-NEXT: b4: ff f7 f4 ff bl #-24 +// CHECK-NEXT: b8: ff f7 f7 ff bl #-18 + + .section .text_high, "ax", %progbits + .thumb + .globl high_target + .type high_target, %function +high_target: + bl low_target + bl low_target2 + + .section .text_high2, "ax", %progbits + .thumb + .globl high_target2 + .type high_target2, %function +high_target2: + bl low_target + bl low_target2 + +// CHECK: Disassembly of section .text_high: +// CHECK-NEXT: high_target: +// CHECK-NEXT: 2000000: 00 f0 02 f8 bl #4 +// CHECK-NEXT: 2000004: 00 f0 05 f8 bl #10 +// CHECK: __Thumbv7ABSLongThunk_low_target: +// CHECK-NEXT: 2000008: 40 f2 97 0c movw r12, #151 +// CHECK-NEXT: 200000c: c0 f2 00 0c movt r12, #0 +// CHECK-NEXT: 2000010: 60 47 bx r12 +// CHECK: __Thumbv7ABSLongThunk_low_target2: +// CHECK-NEXT: 2000012: 40 f2 b5 0c movw r12, #181 +// CHECK-NEXT: 2000016: c0 f2 00 0c movt r12, #0 +// CHECK-NEXT: 200001a: 60 47 bx r12 +// CHECK: high_target2: +// CHECK-NEXT: 200001c: ff f7 f4 ff bl #-24 +// CHECK-NEXT: 2000020: ff f7 f7 ff bl #-18 diff --git a/test/ELF/arm-thunk-multipass.s b/test/ELF/arm-thunk-multipass.s new file mode 100644 index 000000000000..25bf5235f755 --- /dev/null +++ b/test/ELF/arm-thunk-multipass.s @@ -0,0 +1,96 @@ +// REQUIRES: arm +// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t +// RUN: ld.lld %t -o %t2 2>&1 +// The output file is large, most of it zeroes. We dissassemble only the +// parts we need to speed up the test and avoid a large output file +// RUN: llvm-objdump -d %t2 -start-address=1048578 -stop-address=1048586 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK1 %s +// RUN: llvm-objdump -d %t2 -start-address=16777224 -stop-address=16777254 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK2 %s +// RUN: llvm-objdump -d %t2 -start-address=17825818 -stop-address=17825828 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK3 %s +// In this test case a branch that is in range and does not need its range +// extended can be pushed out of range by another Thunk, necessitating another +// pass + + .macro FUNCTION suff + .section .text.\suff\(), "ax", %progbits + .thumb + .balign 0x100000 + .globl tfunc\suff\() + .type tfunc\suff\(), %function +tfunc\suff\(): + bx lr + .endm + + FUNCTION 00 + .globl _start +_start: + bl target + b.w arm_target +// arm_target is in range but needs an interworking thunk +// CHECK1: _start: +// CHECK1-NEXT: 100002: 00 f3 06 d0 bl #15728652 +// CHECK1-NEXT: 100006: ff f2 ff 97 b.w #15728638 <__Thumbv7ABSLongThunk_arm_target> + nop + nop + nop + .globl target2 + .type target2, %function + nop + +target2: + FUNCTION 01 + FUNCTION 02 + FUNCTION 03 + FUNCTION 04 + FUNCTION 05 + FUNCTION 06 + FUNCTION 07 + FUNCTION 08 + FUNCTION 09 + FUNCTION 10 + FUNCTION 11 + FUNCTION 12 + FUNCTION 13 + FUNCTION 14 + FUNCTION 15 + + .section .text.16, "ax", %progbits + .arm + .globl arm_target + .type arm_target, %function +arm_target: + bx lr +// CHECK2: __Thumbv7ABSLongThunk_arm_target: +// CHECK2-NEXT: 1000008: 40 f2 02 0c movw r12, #2 +// CHECK2-NEXT: 100000c: c0 f2 00 1c movt r12, #256 +// CHECK2-NEXT: 1000010: 60 47 bx r12 +// CHECK2: __Thumbv7ABSLongThunk_target: +// CHECK2-NEXT: 1000012: 40 f2 1b 0c movw r12, #27 +// CHECK2-NEXT: 1000016: c0 f2 10 1c movt r12, #272 +// CHECK2-NEXT: 100001a: 60 47 bx r12 +// CHECK2: __Thumbv7ABSLongThunk_target2: +// CHECK2-NEXT: 100001c: 40 f2 13 0c movw r12, #19 +// CHECK2-NEXT: 1000020: c0 f2 10 0c movt r12, #16 +// CHECK2-NEXT: 1000024: 60 47 bx r12 + + .section .text.17, "ax", %progbits +// Just enough space so that bl target is in range if no extension thunks are +// generated. + + .space 0x100000 - 12 + + .section .text.18, "ax", %progbits + .thumb + .globl target + .type target, %function +// target is at maximum ARM branch range away from caller. +target: +// Similar case in the backwards direction + bl target2 + nop + nop + bx lr +// CHECK3: target: +// CHECK3-NEXT: 110001a: ff f6 ff ff bl #-1048578 +// CHECK3-NEXT: 110001e: 00 bf nop +// CHECK3-NEXT: 1100020: 00 bf nop +// CHECK3-NEXT: 1100022: 70 47 bx lr diff --git a/test/ELF/arm-thunk-re-add.s b/test/ELF/arm-thunk-re-add.s new file mode 100644 index 000000000000..760e18f57313 --- /dev/null +++ b/test/ELF/arm-thunk-re-add.s @@ -0,0 +1,123 @@ +// REQUIRES: arm +// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t +// RUN: ld.lld %t --shared -o %t.so +// The output file is large, most of it zeroes. We dissassemble only the +// parts we need to speed up the test and avoid a large output file +// RUN: llvm-objdump -d %t.so -start-address=16777220 -stop-address=16777244 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK1 %s +// RUN: llvm-objdump -d %t.so -start-address=17825800 -stop-address=17825826 -triple=thumbv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK2 %s +// RUN: llvm-objdump -d %t.so -start-address=17825824 -stop-address=17825892 -triple=armv7a-linux-gnueabihf | FileCheck -check-prefix=CHECK3 %s + +// A branch to a Thunk that we create on pass N, can drift out of range if +// other Thunks are added in between. In this case we must create a new Thunk +// for the branch that is in range. We also need to make sure that if the +// destination of the Thunk is in the PLT the new Thunk also targets the PLT + .syntax unified + .thumb + + .macro FUNCTION suff + .section .text.\suff\(), "ax", %progbits + .thumb + .balign 0x80000 + .globl tfunc\suff\() + .type tfunc\suff\(), %function +tfunc\suff\(): + bx lr + .endm + + .globl imported + .type imported, %function + .globl imported2 + .type imported2, %function + .globl imported3 + .type imported3, %function +.globl imported4 + .type imported4, %function + FUNCTION 00 + FUNCTION 01 + FUNCTION 02 + FUNCTION 03 + FUNCTION 04 + FUNCTION 05 + FUNCTION 06 + FUNCTION 07 + FUNCTION 08 + FUNCTION 09 + FUNCTION 10 + FUNCTION 11 + FUNCTION 12 + FUNCTION 13 + FUNCTION 14 + FUNCTION 15 + FUNCTION 16 + FUNCTION 17 + FUNCTION 18 + FUNCTION 19 + FUNCTION 20 + FUNCTION 21 + FUNCTION 22 + FUNCTION 23 + FUNCTION 24 + FUNCTION 25 + FUNCTION 26 + FUNCTION 27 + FUNCTION 28 + FUNCTION 29 + FUNCTION 30 + FUNCTION 31 +// Precreated Thunk Pool goes here +// CHECK1: __ThumbV7PILongThunk_imported: +// CHECK1-NEXT: 1000004: 40 f2 30 0c movw r12, #48 +// CHECK1-NEXT: 1000008: c0 f2 10 0c movt r12, #16 +// CHECK1-NEXT: 100000c: fc 44 add r12, pc +// CHECK1-NEXT: 100000e: 60 47 bx r12 +// CHECK1: __ThumbV7PILongThunk_imported2: +// CHECK1-NEXT: 1000010: 40 f2 34 0c movw r12, #52 +// CHECK1-NEXT: 1000014: c0 f2 10 0c movt r12, #16 +// CHECK1-NEXT: 1000018: fc 44 add r12, pc +// CHECK1-NEXT: 100001a: 60 47 bx r12 + + .section .text.32, "ax", %progbits + .space 0x80000 + .section .text.33, "ax", %progbits + .space 0x80000 - 0x14 + .section .text.34, "ax", %progbits + // Need a Thunk to the PLT entry, can use precreated ThunkSection + .globl callers + .type callers, %function +callers: + b.w imported + beq.w imported + b.w imported2 +// CHECK2: __ThumbV7PILongThunk_imported: +// CHECK2-NEXT: 1100008: 40 f2 2c 0c movw r12, #44 +// CHECK2-NEXT: 110000c: c0 f2 00 0c movt r12, #0 +// CHECK2-NEXT: 1100010: fc 44 add r12, pc +// CHECK2-NEXT: 1100012: 60 47 bx r12 +// CHECK2: callers: +// CHECK2-NEXT: 1100014: ff f6 f6 bf b.w #-1048596 <__ThumbV7PILongThunk_imported> +// CHECK2-NEXT: 1100018: 3f f4 f6 af beq.w #-20 <__ThumbV7PILongThunk_imported> +// CHECK2-NEXT: 110001c: ff f6 f8 bf b.w #-1048592 <__ThumbV7PILongThunk_imported2> + +// CHECK3: Disassembly of section .plt: +// CHECK3-NEXT: $a: +// CHECK3-NEXT: 1100020: 04 e0 2d e5 str lr, [sp, #-4]! +// CHECK3-NEXT: 1100024: 00 e6 8f e2 add lr, pc, #0, #12 +// CHECK3-NEXT: 1100028: 00 ea 8e e2 add lr, lr, #0, #20 +// CHECK3-NEXT: 110002c: dc ff be e5 ldr pc, [lr, #4060]! +// CHECK3: $d: +// CHECK3-NEXT: 1100030: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECK3-NEXT: 1100034: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECK3-NEXT: 1100038: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECK3-NEXT: 110003c: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECK3: $a: +// CHECK3-NEXT: 1100040: 00 c6 8f e2 add r12, pc, #0, #12 +// CHECK3-NEXT: 1100044: 00 ca 8c e2 add r12, r12, #0, #20 +// CHECK3-NEXT: 1100048: c4 ff bc e5 ldr pc, [r12, #4036]! +// CHECK3: $d: +// CHECK3-NEXT: 110004c: d4 d4 d4 d4 .word 0xd4d4d4d4 +// CHECK3: $a: +// CHECK3-NEXT: 1100050: 00 c6 8f e2 add r12, pc, #0, #12 +// CHECK3-NEXT: 1100054: 00 ca 8c e2 add r12, r12, #0, #20 +// CHECK3-NEXT: 1100058: b8 ff bc e5 ldr pc, [r12, #4024]! +// CHECK3: $d: +// CHECK3-NEXT: 110005c: d4 d4 d4 d4 .word 0xd4d4d4d4 diff --git a/test/ELF/arm-thunk-toolargesection.s b/test/ELF/arm-thunk-toolargesection.s new file mode 100644 index 000000000000..28fb94a8ccfd --- /dev/null +++ b/test/ELF/arm-thunk-toolargesection.s @@ -0,0 +1,19 @@ +// RUN: llvm-mc -filetype=obj -triple=thumbv7a-none-linux-gnueabi %s -o %t +// RUN: not ld.lld %t -o %t2 2>&1 | FileCheck %s +// REQUIRES: arm + .syntax unified + .balign 0x1000 + .thumb + .text + .globl _start + .type _start, %function +_start: + bx lr + + .section .text.large1, "ax", %progbits + .balign 4 +.space (17 * 1024 * 1024) + bl _start +.space (17 * 1024 * 1024) + +// CHECK: error: InputSection too large for range extension thunk {{.*}}.text.large1 diff --git a/test/ELF/arm-tls-gd-nonpreemptible.s b/test/ELF/arm-tls-gd-nonpreemptible.s index 650c00800269..ebaad4788c76 100644 --- a/test/ELF/arm-tls-gd-nonpreemptible.s +++ b/test/ELF/arm-tls-gd-nonpreemptible.s @@ -2,7 +2,7 @@ // RUN: ld.lld %t -o %t2 // RUN: llvm-mc %s -o %t.o -filetype=obj -triple=armv7a-linux-gnueabi // RUN: llvm-objdump -s %t2 | FileCheck %s -// RUN: ld.lld %t --shared -o %t3.so +// RUN: ld.lld --hash-style=sysv %t --shared -o %t3.so // RUN: llvm-objdump -s %t3.so | FileCheck -check-prefix=CHECK-SHARED %s // REQUIRES: arm diff --git a/test/ELF/arm-tls-gd32.s b/test/ELF/arm-tls-gd32.s index 206b65d05af9..a32e26f2aeb9 100644 --- a/test/ELF/arm-tls-gd32.s +++ b/test/ELF/arm-tls-gd32.s @@ -1,5 +1,5 @@ // RUN: llvm-mc %s -o %t.o -filetype=obj -triple=armv7a-linux-gnueabi -// RUN: ld.lld %t.o -o %t.so -shared +// RUN: ld.lld --hash-style=sysv %t.o -o %t.so -shared // RUN: llvm-readobj -s -dyn-relocations %t.so | FileCheck --check-prefix=SEC %s // RUN: llvm-objdump -d -triple=armv7a-linux-gnueabi %t.so | FileCheck %s // REQUIRES: arm diff --git a/test/ELF/arm-tls-ie32.s b/test/ELF/arm-tls-ie32.s index 48120fa682da..26e1265568c8 100644 --- a/test/ELF/arm-tls-ie32.s +++ b/test/ELF/arm-tls-ie32.s @@ -1,5 +1,5 @@ // RUN: llvm-mc %s -o %t.o -filetype=obj -triple=armv7a-linux-gnueabi -// RUN: ld.lld %t.o -o %t.so -shared +// RUN: ld.lld --hash-style=sysv %t.o -o %t.so -shared // RUN: llvm-readobj -s -dyn-relocations %t.so | FileCheck --check-prefix=SEC %s // RUN: llvm-objdump -d -triple=armv7a-linux-gnueabi %t.so | FileCheck %s // REQUIRES: arm diff --git a/test/ELF/arm-tls-ldm32.s b/test/ELF/arm-tls-ldm32.s index 47e879102707..629dcd038899 100644 --- a/test/ELF/arm-tls-ldm32.s +++ b/test/ELF/arm-tls-ldm32.s @@ -1,5 +1,5 @@ // RUN: llvm-mc %s -o %t.o -filetype=obj -triple=armv7a-linux-gnueabi -// RUN: ld.lld %t.o -o %t.so -shared +// RUN: ld.lld --hash-style=sysv %t.o -o %t.so -shared // RUN: llvm-readobj -s -dyn-relocations %t.so | FileCheck --check-prefix=SEC %s // RUN: llvm-objdump -d -triple=armv7a-linux-gnueabi %t.so | FileCheck %s // REQUIRES: arm diff --git a/test/ELF/arm-tls-norelax-gd-ie.s b/test/ELF/arm-tls-norelax-gd-ie.s index 2617089b4080..bcee56165958 100644 --- a/test/ELF/arm-tls-norelax-gd-ie.s +++ b/test/ELF/arm-tls-norelax-gd-ie.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %p/Inputs/arm-tls-get-addr.s -o %t1 // RUN: ld.lld %t1 --shared -o %t1.so // RUN: llvm-mc %s -o %t.o -filetype=obj -triple=armv7a-linux-gnueabi -// RUN: ld.lld %t1.so %t.o -o %t +// RUN: ld.lld --hash-style=sysv %t1.so %t.o -o %t // RUN: llvm-readobj -s -dyn-relocations %t | FileCheck %s // REQUIRES: arm diff --git a/test/ELF/arm-tls-norelax-gd-le.s b/test/ELF/arm-tls-norelax-gd-le.s index 41df72494f8b..788c845b3f8b 100644 --- a/test/ELF/arm-tls-norelax-gd-le.s +++ b/test/ELF/arm-tls-norelax-gd-le.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %p/Inputs/arm-tls-get-addr.s -o %t1 // RUN: ld.lld %t1 --shared -o %t1.so // RUN: llvm-mc %s -o %t.o -filetype=obj -triple=armv7a-linux-gnueabi -// RUN: ld.lld %t1.so %t.o -o %t +// RUN: ld.lld --hash-style=sysv %t1.so %t.o -o %t // RUN: llvm-objdump -s %t | FileCheck %s // REQUIRES: arm @@ -35,3 +35,7 @@ x: // Module index is always 1 for executable // CHECK-NEXT: 13060 01000000 00000000 + +// Without any definition of __tls_get_addr we get an error +// RUN: not ld.lld %t.o -o %t 2>&1 | FileCheck --check-prefix=ERR %s +// ERR: error: undefined symbol: __tls_get_addr diff --git a/test/ELF/arm-tls-norelax-ie-le.s b/test/ELF/arm-tls-norelax-ie-le.s index e8c528b401ca..eb96aa0fad57 100644 --- a/test/ELF/arm-tls-norelax-ie-le.s +++ b/test/ELF/arm-tls-norelax-ie-le.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %p/Inputs/arm-tls-get-addr.s -o %t1 // RUN: ld.lld %t1 --shared -o %t1.so // RUN: llvm-mc %s -o %t.o -filetype=obj -triple=armv7a-linux-gnueabi -// RUN: ld.lld %t1.so %t.o -o %t +// RUN: ld.lld --hash-style=sysv %t1.so %t.o -o %t // RUN: llvm-objdump -s -triple=armv7a-linux-gnueabi %t | FileCheck %s // REQUIRES: arm diff --git a/test/ELF/arm-tls-norelax-ld-le.s b/test/ELF/arm-tls-norelax-ld-le.s index 9fd822aefef7..fc5b72b80f9c 100644 --- a/test/ELF/arm-tls-norelax-ld-le.s +++ b/test/ELF/arm-tls-norelax-ld-le.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %p/Inputs/arm-tls-get-addr.s -o %t1 // RUN: ld.lld %t1 --shared -o %t1.so // RUN: llvm-mc %s -o %t.o -filetype=obj -triple=armv7a-linux-gnueabi -// RUN: ld.lld %t1.so %t.o -o %t +// RUN: ld.lld --hash-style=sysv %t1.so %t.o -o %t // RUN: llvm-objdump -s %t | FileCheck %s // REQUIRES: arm diff --git a/test/ELF/as-needed.s b/test/ELF/as-needed.s index 37c6103b0ed0..bcfa32d01f66 100644 --- a/test/ELF/as-needed.s +++ b/test/ELF/as-needed.s @@ -15,6 +15,10 @@ // RUN: ld.lld --as-needed %t.o %t2.so %t3.so %t4.so -o %t2 // RUN: llvm-readobj -dynamic-table %t2 | FileCheck -check-prefix=CHECK2 %s +// Test with the .o last +// RUN: ld.lld --as-needed %t2.so %t3.so %t4.so %t.o -o %t2 +// RUN: llvm-readobj -dynamic-table %t2 | FileCheck -check-prefix=CHECK2 %s + // RUN: ld.lld --as-needed %t.o %t2.so --no-as-needed %t3.so %t4.so -o %t2 // RUN: llvm-readobj -dynamic-table %t2 | FileCheck %s diff --git a/test/ELF/assignment-archive.s b/test/ELF/assignment-archive.s new file mode 100644 index 000000000000..11753a692130 --- /dev/null +++ b/test/ELF/assignment-archive.s @@ -0,0 +1,27 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %ta.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux -o %t.o < /dev/null +# RUN: rm -f %tar.a +# RUN: llvm-ar rcs %tar.a %ta.o + +# RUN: echo "SECTIONS { foo = 1; }" > %t1.script +# RUN: ld.lld -o %t1.exe --script %t1.script %tar.a %t.o +# RUN: llvm-readobj -symbols %t1.exe | FileCheck %s +# CHECK-NOT: bar +# CHECK: foo +# CHECK-NOT: bar + +# RUN: echo "SECTIONS { zed = foo; }" > %t2.script +# RUN: ld.lld -o %t2.exe --script %t2.script %tar.a %t.o +# RUN: llvm-readobj -symbols %t2.exe | FileCheck %s --check-prefix=SYMS +# SYMS: bar +# SYMS: foo + +.text +.globl foo +foo: + nop + +.globl bar +bar: + nop diff --git a/test/ELF/avoid-empty-program-headers.s b/test/ELF/avoid-empty-program-headers.s index 271d1a303850..731ecce67cbc 100644 --- a/test/ELF/avoid-empty-program-headers.s +++ b/test/ELF/avoid-empty-program-headers.s @@ -42,8 +42,8 @@ _start: // CHECK-NEXT: Offset: 0x1000 // CHECK-NEXT: VirtualAddress: 0x201000 // CHECK-NEXT: PhysicalAddress: 0x201000 -// CHECK-NEXT: FileSize: 1 -// CHECK-NEXT: MemSize: 1 +// CHECK-NEXT: FileSize: 4096 +// CHECK-NEXT: MemSize: 4096 // CHECK-NEXT: Flags [ (0x5) // CHECK-NEXT: PF_R (0x4) // CHECK-NEXT: PF_X (0x1) @@ -52,7 +52,7 @@ _start: // CHECK-NEXT: } // CHECK-NEXT: ProgramHeader { // CHECK-NEXT: Type: PT_TLS (0x7) -// CHECK-NEXT: Offset: 0x1001 +// CHECK-NEXT: Offset: 0x2000 // CHECK-NEXT: VirtualAddress: 0x201001 // CHECK-NEXT: PhysicalAddress: 0x201001 // CHECK-NEXT: FileSize: 0 diff --git a/test/ELF/basic-aarch64.s b/test/ELF/basic-aarch64.s index 144fe6aee41b..6527d3dc0def 100644 --- a/test/ELF/basic-aarch64.s +++ b/test/ELF/basic-aarch64.s @@ -26,7 +26,7 @@ _start: # CHECK-NEXT: Version: 1 # CHECK-NEXT: Entry: [[ENTRY:0x[0-9A-F]+]] # CHECK-NEXT: ProgramHeaderOffset: 0x40 -# CHECK-NEXT: SectionHeaderOffset: 0x10098 +# CHECK-NEXT: SectionHeaderOffset: 0x11088 # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: HeaderSize: 64 @@ -76,12 +76,12 @@ _start: # CHECK-NEXT: SHF_STRINGS (0x20) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x1000C +# CHECK-NEXT: Offset: 0x11000 # CHECK-NEXT: Size: 8 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 # CHECK-NEXT: AddressAlignment: 1 -# CHECK-NEXT: EntrySize: 0 +# CHECK-NEXT: EntrySize: 1 # CHECK-NEXT: } # CHECK-NEXT: Section { # CHECK-NEXT: Index: 3 @@ -90,7 +90,7 @@ _start: # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x10018 +# CHECK-NEXT: Offset: 0x11008 # CHECK-NEXT: Size: 72 # CHECK-NEXT: Link: 5 # CHECK-NEXT: Info: 2 @@ -104,7 +104,7 @@ _start: # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x10060 +# CHECK-NEXT: Offset: 0x11050 # CHECK-NEXT: Size: 42 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 @@ -118,7 +118,7 @@ _start: # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x1008A +# CHECK-NEXT: Offset: 0x1107A # CHECK-NEXT: Size: 13 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 @@ -185,8 +185,8 @@ _start: # CHECK-NEXT: Offset: 0x1000 # CHECK-NEXT: VirtualAddress: 0x20000 # CHECK-NEXT: PhysicalAddress: 0x20000 -# CHECK-NEXT: FileSize: 12 -# CHECK-NEXT: MemSize: 12 +# CHECK-NEXT: FileSize: 4096 +# CHECK-NEXT: MemSize: 4096 # CHECK-NEXT: Flags [ (0x5) # CHECK-NEXT: PF_R (0x4) # CHECK-NEXT: PF_X (0x1) diff --git a/test/ELF/basic-mips.s b/test/ELF/basic-mips.s index 4c7a66cf0050..a193529b3487 100644 --- a/test/ELF/basic-mips.s +++ b/test/ELF/basic-mips.s @@ -164,7 +164,7 @@ __start: # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 # CHECK-NEXT: AddressAlignment: 1 -# CHECK-NEXT: EntrySize: 0 +# CHECK-NEXT: EntrySize: 1 # CHECK-NEXT: } # CHECK-NEXT: Section { # CHECK-NEXT: Index: 8 @@ -228,7 +228,7 @@ __start: # CHECK-NEXT: Other [ (0x2) # CHECK-NEXT: STV_HIDDEN (0x2) # CHECK-NEXT: ] -# CHECK-NEXT: Section: Absolute +# CHECK-NEXT: Section: .got # CHECK-NEXT: } # CHECK-NEXT: Symbol { # CHECK-NEXT: Name: __start diff --git a/test/ELF/basic-ppc.s b/test/ELF/basic-ppc.s index 4a36af99ed72..cda32245fd2b 100644 --- a/test/ELF/basic-ppc.s +++ b/test/ELF/basic-ppc.s @@ -1,5 +1,5 @@ # RUN: llvm-mc -filetype=obj -triple=powerpc-unknown-freebsd %s -o %t -# RUN: ld.lld -discard-all -shared %t -o %t2 +# RUN: ld.lld --hash-style=sysv -discard-all -shared %t -o %t2 # RUN: llvm-readobj -file-headers -sections -section-data -program-headers %t2 | FileCheck %s # REQUIRES: ppc @@ -163,7 +163,7 @@ // CHECK-NEXT: Link: 0 // CHECK-NEXT: Info: 0 // CHECK-NEXT: AddressAlignment: 1 -// CHECK-NEXT: EntrySize: 0 +// CHECK-NEXT: EntrySize: 1 // CHECK-NEXT: SectionData ( // CHECK-NEXT: 0000: 4C4C4420 312E3000 |LLD 1.0.| // CHECK-NEXT: ) diff --git a/test/ELF/basic-sparcv9.s b/test/ELF/basic-sparcv9.s index 983224c52913..75c20476a43b 100644 --- a/test/ELF/basic-sparcv9.s +++ b/test/ELF/basic-sparcv9.s @@ -26,7 +26,7 @@ _start: # CHECK-NEXT: Version: 1 # CHECK-NEXT: Entry: [[ENTRY:0x[0-9A-F]+]] # CHECK-NEXT: ProgramHeaderOffset: 0x40 -# CHECK-NEXT: SectionHeaderOffset: 0x100080 +# CHECK-NEXT: SectionHeaderOffset: 0x102070 # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: HeaderSize: 64 @@ -76,12 +76,12 @@ _start: # CHECK-NEXT: SHF_STRINGS (0x20) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x10000C +# CHECK-NEXT: Offset: 0x102000 # CHECK-NEXT: Size: 8 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 # CHECK-NEXT: AddressAlignment: 1 -# CHECK-NEXT: EntrySize: 0 +# CHECK-NEXT: EntrySize: 1 # CHECK-NEXT: } # CHECK-NEXT: Section { # CHECK-NEXT: Index: 3 @@ -90,7 +90,7 @@ _start: # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x100018 +# CHECK-NEXT: Offset: 0x102008 # CHECK-NEXT: Size: 48 # CHECK-NEXT: Link: 5 # CHECK-NEXT: Info: 1 @@ -104,7 +104,7 @@ _start: # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x100048 +# CHECK-NEXT: Offset: 0x102038 # CHECK-NEXT: Size: 42 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 @@ -118,7 +118,7 @@ _start: # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x100072 +# CHECK-NEXT: Offset: 0x102062 # CHECK-NEXT: Size: 8 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 @@ -176,8 +176,8 @@ _start: # CHECK-NEXT: Offset: 0x100000 # CHECK-NEXT: VirtualAddress: 0x200000 # CHECK-NEXT: PhysicalAddress: 0x200000 -# CHECK-NEXT: FileSize: 12 -# CHECK-NEXT: MemSize: 12 +# CHECK-NEXT: FileSize: 8192 +# CHECK-NEXT: MemSize: 8192 # CHECK-NEXT: Flags [ (0x5) # CHECK-NEXT: PF_R (0x4) # CHECK-NEXT: PF_X (0x1) diff --git a/test/ELF/basic.s b/test/ELF/basic.s index c62a516c1bf6..a62f3dc0e853 100644 --- a/test/ELF/basic.s +++ b/test/ELF/basic.s @@ -28,7 +28,7 @@ _start: # CHECK-NEXT: Version: 1 # CHECK-NEXT: Entry: [[ENTRY:0x[0-9A-F]+]] # CHECK-NEXT: ProgramHeaderOffset: 0x40 -# CHECK-NEXT: SectionHeaderOffset: 0x1080 +# CHECK-NEXT: SectionHeaderOffset: 0x2070 # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: HeaderSize: 64 @@ -78,12 +78,12 @@ _start: # CHECK-NEXT: SHF_STRINGS (0x20) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x1010 +# CHECK-NEXT: Offset: 0x2000 # CHECK-NEXT: Size: 8 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 # CHECK-NEXT: AddressAlignment: 1 -# CHECK-NEXT: EntrySize: 0 +# CHECK-NEXT: EntrySize: 1 # CHECK-NEXT: } # CHECK-NEXT: Section { # CHECK-NEXT: Index: 3 @@ -92,7 +92,7 @@ _start: # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x1018 +# CHECK-NEXT: Offset: 0x2008 # CHECK-NEXT: Size: 48 # CHECK-NEXT: Link: 5 # CHECK-NEXT: Info: 1 @@ -106,7 +106,7 @@ _start: # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x1048 +# CHECK-NEXT: Offset: 0x2038 # CHECK-NEXT: Size: 42 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 @@ -120,7 +120,7 @@ _start: # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x1072 +# CHECK-NEXT: Offset: 0x2062 # CHECK-NEXT: Size: 8 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 @@ -178,8 +178,8 @@ _start: # CHECK-NEXT: Offset: 0x1000 # CHECK-NEXT: VirtualAddress: 0x201000 # CHECK-NEXT: PhysicalAddress: 0x201000 -# CHECK-NEXT: FileSize: 16 -# CHECK-NEXT: MemSize: 16 +# CHECK-NEXT: FileSize: 4096 +# CHECK-NEXT: MemSize: 4096 # CHECK-NEXT: Flags [ (0x5) # CHECK-NEXT: PF_R (0x4) # CHECK-NEXT: PF_X (0x1) @@ -246,7 +246,9 @@ _start: # UNKNOWN_EMUL: unknown emulation: wrong_emul_fbsd # RUN: not ld.lld %t --lto-partitions=0 2>&1 | FileCheck --check-prefix=NOTHREADS %s +# RUN: not ld.lld %t --plugin-opt=lto-partitions=0 2>&1 | FileCheck --check-prefix=NOTHREADS %s # NOTHREADS: --lto-partitions: number of threads must be > 0 # RUN: not ld.lld %t --thinlto-jobs=0 2>&1 | FileCheck --check-prefix=NOTHREADSTHIN %s +# RUN: not ld.lld %t --plugin-opt=jobs=0 2>&1 | FileCheck --check-prefix=NOTHREADSTHIN %s # NOTHREADSTHIN: --thinlto-jobs: number of threads must be > 0 diff --git a/test/ELF/basic32.s b/test/ELF/basic32.s index cbf67eec8b7d..071a06332f0a 100644 --- a/test/ELF/basic32.s +++ b/test/ELF/basic32.s @@ -25,7 +25,7 @@ _start: # CHECK-NEXT: Version: 1 # CHECK-NEXT: Entry: 0x11000 # CHECK-NEXT: ProgramHeaderOffset: 0x34 -# CHECK-NEXT: SectionHeaderOffset: 0x1068 +# CHECK-NEXT: SectionHeaderOffset: 0x205C # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: HeaderSize: 52 @@ -75,12 +75,12 @@ _start: # CHECK-NEXT: SHF_STRINGS (0x20) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x100C +# CHECK-NEXT: Offset: 0x2000 # CHECK-NEXT: Size: 8 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 # CHECK-NEXT: AddressAlignment: 1 -# CHECK-NEXT: EntrySize: 0 +# CHECK-NEXT: EntrySize: 1 # CHECK-NEXT: } # CHECK-NEXT: Section { # CHECK-NEXT: Index: 3 @@ -89,7 +89,7 @@ _start: # CHECK-NEXT: Flags [ # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x1014 +# CHECK-NEXT: Offset: 0x2008 # CHECK-NEXT: Size: 32 # CHECK-NEXT: Link: 5 # CHECK-NEXT: Info: 1 @@ -103,7 +103,7 @@ _start: # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x1034 +# CHECK-NEXT: Offset: 0x2028 # CHECK-NEXT: Size: 42 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 @@ -117,7 +117,7 @@ _start: # CHECK-NEXT: Flags [ (0x0) # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x0 -# CHECK-NEXT: Offset: 0x105E +# CHECK-NEXT: Offset: 0x2052 # CHECK-NEXT: Size: 8 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 @@ -155,8 +155,8 @@ _start: # CHECK-NEXT: Offset: 0x1000 # CHECK-NEXT: VirtualAddress: 0x11000 # CHECK-NEXT: PhysicalAddress: 0x11000 -# CHECK-NEXT: FileSize: 12 -# CHECK-NEXT: MemSize: 12 +# CHECK-NEXT: FileSize: 4096 +# CHECK-NEXT: MemSize: 4096 # CHECK-NEXT: Flags [ (0x5) # CHECK-NEXT: PF_R (0x4) # CHECK-NEXT: PF_X (0x1) diff --git a/test/ELF/basic64be.s b/test/ELF/basic64be.s index c39669bfd547..d16f4a074175 100644 --- a/test/ELF/basic64be.s +++ b/test/ELF/basic64be.s @@ -175,7 +175,7 @@ _start: # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 # CHECK-NEXT: AddressAlignment: 1 -# CHECK-NEXT: EntrySize: 0 +# CHECK-NEXT: EntrySize: 1 # CHECK-NEXT: SectionData ( # CHECK-NEXT: 0000: 4C4C4420 312E3000 |LLD 1.0.| # CHECK-NEXT: ) diff --git a/test/ELF/build-id.s b/test/ELF/build-id.s index 2d193478df71..9447a14d4e8a 100644 --- a/test/ELF/build-id.s +++ b/test/ELF/build-id.s @@ -2,6 +2,9 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +# RUN: ld.lld --build-id %t -o %t2 +# RUN: llvm-readobj -s %t2 | FileCheck -check-prefix=ALIGN %s + # RUN: ld.lld --build-id %t -o %t2 -threads # RUN: llvm-objdump -s %t2 | FileCheck -check-prefix=DEFAULT %s # RUN: ld.lld --build-id %t -o %t2 -no-threads @@ -45,18 +48,30 @@ _start: .section .note.test, "a", @note .quad 42 +# ALIGN: Name: .note.gnu.build-id +# ALIGN-NEXT: Type: SHT_NOTE +# ALIGN-NEXT: Flags [ +# ALIGN-NEXT: SHF_ALLOC +# ALIGN-NEXT: ] +# ALIGN-NEXT: Address: +# ALIGN-NEXT: Offset: [[_:0x[0-9A-Z]*(0|4|8|C)$]] +# ALIGN-NEXT: Size: +# ALIGN-NEXT: Link: +# ALIGN-NEXT: Info: +# ALIGN-NEXT: AddressAlignment: 4 + # DEFAULT: Contents of section .note.test: # DEFAULT: Contents of section .note.gnu.build-id: # DEFAULT-NEXT: 04000000 08000000 03000000 474e5500 ............GNU. -# DEFAULT-NEXT: fd36edb1 f6ff02af +# DEFAULT-NEXT: 894c04e8 fbf5556b # MD5: Contents of section .note.gnu.build-id: # MD5-NEXT: 04000000 10000000 03000000 474e5500 ............GNU. -# MD5-NEXT: fc +# MD5-NEXT: 6a51bbd7 9e8ee3f9 2e02d213 711cfec9 # SHA1: Contents of section .note.gnu.build-id: # SHA1-NEXT: 04000000 14000000 03000000 474e5500 ............GNU. -# SHA1-NEXT: 55b1eedb 03b588e1 09987d1d e9a79be7 +# SHA1-NEXT: 9a8618b1 d6fd0e5c eda73dd8 76de5596 # UUID: Contents of section .note.gnu.build-id: # UUID-NEXT: 04000000 10000000 03000000 474e5500 ............GNU. diff --git a/test/ELF/chroot.s b/test/ELF/chroot.s new file mode 100644 index 000000000000..8c97e99af4dc --- /dev/null +++ b/test/ELF/chroot.s @@ -0,0 +1,12 @@ +# REQUIRES: x86 +# RUN: rm -rf %t.dir +# RUN: mkdir %t.dir +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.dir/chroot.o +# RUN: ld.lld --chroot %t.dir -o %t.exe /chroot.o + +# RUN: echo 'INPUT(/chroot.o)' > %t.dir/scr +# RUN: ld.lld --chroot %t.dir -o %t.exe /scr + +.globl _start +_start: + ret diff --git a/test/ELF/comment-gc.s b/test/ELF/comment-gc.s index 8018ff89bbf9..44c08fe9cef9 100644 --- a/test/ELF/comment-gc.s +++ b/test/ELF/comment-gc.s @@ -5,8 +5,7 @@ # RUN: llvm-objdump -s %t1 | FileCheck %s # CHECK: Contents of section .comment: -# CHECK-NEXT: 0000 00666f6f 00626172 004c4c44 20312e30 .foo.bar.LLD 1.0 -# CHECK-NEXT: 0010 00 . +# CHECK-NEXT: foo..LLD 1.0.bar .ident "foo" diff --git a/test/ELF/common-gc.s b/test/ELF/common-gc.s new file mode 100644 index 000000000000..99fde9ea3c39 --- /dev/null +++ b/test/ELF/common-gc.s @@ -0,0 +1,41 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t + +# RUN: ld.lld %t -o %t2 +# RUN: llvm-readobj -sections -symbols %t2 | FileCheck %s --check-prefix=NOGC + +# NOGC: Name: .bss +# NOGC-NEXT: Type: +# NOGC-NEXT: Flags [ +# NOGC-NEXT: SHF_ALLOC +# NOGC-NEXT: SHF_WRITE +# NOGC-NEXT: ] +# NOGC-NEXT: Address: +# NOGC-NEXT: Offset: +# NOGC-NEXT: Size: 8 + +# NOGC: Name: bar +# NOGC: Name: foo + +# RUN: ld.lld -gc-sections %t -o %t1 +# RUN: llvm-readobj -sections -symbols %t1 | FileCheck %s --check-prefix=GC + +# GC: Name: .bss +# GC-NEXT: Type: +# GC-NEXT: Flags [ +# GC-NEXT: SHF_ALLOC +# GC-NEXT: SHF_WRITE +# GC-NEXT: ] +# GC-NEXT: Address: +# GC-NEXT: Offset: +# GC-NEXT: Size: 4 + +# GC-NOT: Name: bar + +.comm foo,4,4 +.comm bar,4,4 + +.text +.globl _start +_start: + .quad foo diff --git a/test/ELF/common-gc2.s b/test/ELF/common-gc2.s new file mode 100644 index 000000000000..165bf625394e --- /dev/null +++ b/test/ELF/common-gc2.s @@ -0,0 +1,15 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t +# RUN: ld.lld -gc-sections -export-dynamic %t -o %t1 +# RUN: llvm-readobj --dyn-symbols %t1 | FileCheck %s + +# CHECK: Name: bar@ +# CHECK: Name: foo@ + +.comm foo,4,4 +.comm bar,4,4 + +.text +.globl _start +_start: + .quad foo diff --git a/test/ELF/common-gc3.s b/test/ELF/common-gc3.s new file mode 100644 index 000000000000..e161a635c077 --- /dev/null +++ b/test/ELF/common-gc3.s @@ -0,0 +1,18 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: ld.lld %t.o -o %t1 --gc-sections +# RUN: llvm-objdump -s %t1 | FileCheck %s + +# CHECK: Contents of section .noalloc: +# 0000 00000000 00000000 ........ + + .section .text._start,"ax",@progbits + .globl _start +_start: + retq + + .type unused,@object + .comm unused,4,4 + + .section .noalloc,"",@progbits + .quad unused diff --git a/test/ELF/common.s b/test/ELF/common.s index c8011a0a5088..7f241ee4d65b 100644 --- a/test/ELF/common.s +++ b/test/ELF/common.s @@ -12,13 +12,13 @@ // CHECK-NEXT: ] // CHECK-NEXT: Address: 0x201000 // CHECK-NEXT: Offset: -// CHECK-NEXT: Size: 22 +// CHECK-NEXT: Size: 36 // CHECK-NEXT: Link: 0 // CHECK-NEXT: Info: 0 // CHECK-NEXT: AddressAlignment: 16 // CHECK: Name: sym1 -// CHECK-NEXT: Value: 0x201004 +// CHECK-NEXT: Value: 0x201000 // CHECK-NEXT: Size: 8 // CHECK-NEXT: Binding: Global // CHECK-NEXT: Type: Object @@ -26,7 +26,7 @@ // CHECK-NEXT: Section: .bss // CHECK: Name: sym2 -// CHECK-NEXT: Value: 0x20100C +// CHECK-NEXT: Value: 0x201008 // CHECK-NEXT: Size: 8 // CHECK-NEXT: Binding: Global // CHECK-NEXT: Type: Object @@ -34,7 +34,7 @@ // CHECK-NEXT: Section: .bss // CHECK: Name: sym3 -// CHECK-NEXT: Value: 0x201014 +// CHECK-NEXT: Value: 0x201010 // CHECK-NEXT: Size: 2 // CHECK-NEXT: Binding: Global // CHECK-NEXT: Type: Object @@ -42,7 +42,7 @@ // CHECK-NEXT: Section: .bss // CHECK: Name: sym4 -// CHECK-NEXT: Value: 0x201000 +// CHECK-NEXT: Value: 0x201020 // CHECK-NEXT: Size: 4 // CHECK-NEXT: Binding: Global // CHECK-NEXT: Type: Object diff --git a/test/ELF/compress-debug-sections.s b/test/ELF/compress-debug-sections.s index 5fb7ee515dcb..a7933e130b77 100644 --- a/test/ELF/compress-debug-sections.s +++ b/test/ELF/compress-debug-sections.s @@ -15,12 +15,17 @@ # ZLIBFLAGS-NEXT: Flags [ # ZLIBFLAGS-NEXT: SHF_COMPRESSED -# RUN: llvm-dwarfdump %t1 -debug-dump=str | \ +# RUN: llvm-dwarfdump %t1 -debug-str | \ # RUN: FileCheck %s --check-prefix=DEBUGSTR # DEBUGSTR: .debug_str contents: # DEBUGSTR-NEXT: AAAAAAAAAAAAAAAAAAAAAAAAAAA # DEBUGSTR-NEXT: BBBBBBBBBBBBBBBBBBBBBBBBBBB +## Test alias. +# RUN: ld.lld %t.o -o %t2 --compress-debug-sections zlib +# RUN: llvm-objdump -s %t2 | FileCheck %s --check-prefix=ZLIBCONTENT +# RUN: llvm-readobj -s %t2 | FileCheck %s --check-prefix=ZLIBFLAGS + # RUN: not ld.lld %t.o -o %t1 --compress-debug-sections=zlib-gabi 2>&1 | \ # RUN: FileCheck -check-prefix=ERR %s # ERR: unknown --compress-debug-sections value: zlib-gabi diff --git a/test/ELF/compressed-debug-conflict.s b/test/ELF/compressed-debug-conflict.s new file mode 100644 index 000000000000..c67bc9201803 --- /dev/null +++ b/test/ELF/compressed-debug-conflict.s @@ -0,0 +1,29 @@ +# REQUIRES: x86, zlib +# RUN: llvm-mc -filetype=obj -triple i686-linux-gnu -compress-debug-sections=zlib %s -o %t.o +# RUN: llvm-readobj -sections %t.o | FileCheck -check-prefix=OBJ %s +# RUN: not ld.lld %t.o %t.o -o %tout 2>&1 | FileCheck -check-prefix=ERROR %s + +# OBJ: Sections [ +# OBJ: Section { +# OBJ: Index: 3 +# OBJ-NEXT: Name: .debug_line (16) +# OBJ-NEXT: Type: SHT_PROGBITS (0x1) +# OBJ-NEXT: Flags [ (0x800) +# OBJ-NEXT: SHF_COMPRESSED (0x800) +# OBJ-NEXT: ] + +# ERROR: error: duplicate symbol: main +# ERROR-NEXT: >>> defined at reduced.c:2 (/tmp/reduced.c:2) +# ERROR-NEXT: >>> +# ERROR-NEXT: >>> defined at reduced.c:2 (/tmp/reduced.c:2) +# ERROR-NEXT: >>> + + .text + .file "reduced.c" + .globl main +main: + .file 1 "/tmp" "reduced.c" + .loc 1 2 0 + xorl %eax, %eax + retl + .file 2 "/tmp/repeat/repeat/repeat/repeat" "repeat.h" diff --git a/test/ELF/compressed-debug-input.s b/test/ELF/compressed-debug-input.s index d96ebdcb30b4..aad8cd02b3b1 100644 --- a/test/ELF/compressed-debug-input.s +++ b/test/ELF/compressed-debug-input.s @@ -39,10 +39,10 @@ # GNU-NEXT: EntrySize: 1 # GNU-NEXT: } -# RUN: ld.lld %t -o %t.so -shared +# RUN: ld.lld --hash-style=sysv %t -o %t.so -shared # RUN: llvm-readobj -sections -section-data %t.so | FileCheck -check-prefix=DATA %s -# RUN: ld.lld %t2 -o %t2.so -shared +# RUN: ld.lld --hash-style=sysv %t2 -o %t2.so -shared # RUN: llvm-readobj -sections -section-data %t2.so | FileCheck -check-prefix=DATA %s # DATA: Section { @@ -59,13 +59,13 @@ # DATA-NEXT: Link: 0 # DATA-NEXT: Info: 0 # DATA-NEXT: AddressAlignment: 1 -# DATA-NEXT: EntrySize: 0 +# DATA-NEXT: EntrySize: 1 # DATA-NEXT: SectionData ( -# DATA-NEXT: 0000: 73686F72 7420756E 7369676E 65642069 |short unsigned i| -# DATA-NEXT: 0010: 6E740075 6E736967 6E656420 696E7400 |nt.unsigned int.| -# DATA-NEXT: 0020: 6C6F6E67 20756E73 69676E65 6420696E |long unsigned in| -# DATA-NEXT: 0030: 74006368 61720075 6E736967 6E656420 |t.char.unsigned | -# DATA-NEXT: 0040: 63686172 00 |char.| +# DATA-NEXT: 0000: 6C6F6E67 20756E73 69676E65 6420696E |long unsigned in| +# DATA-NEXT: 0010: 7400756E 7369676E 65642063 68617200 |t.unsigned char.| +# DATA-NEXT: 0020: 756E7369 676E6564 20696E74 00636861 |unsigned int.cha| +# DATA-NEXT: 0030: 72007368 6F727420 756E7369 676E6564 |r.short unsigned| +# DATA-NEXT: 0040: 20696E74 00 | int.| # DATA-NEXT: ) # DATA-NEXT: } diff --git a/test/ELF/conflict-debug-variable.s b/test/ELF/conflict-debug-variable.s new file mode 100644 index 000000000000..297ed4bbe1ea --- /dev/null +++ b/test/ELF/conflict-debug-variable.s @@ -0,0 +1,144 @@ +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck -check-prefix=INPUT %s +# RUN: not ld.lld %t.o %t.o -o %t 2>&1 | FileCheck %s + +# INPUT: .debug_info contents: +# INPUT: DW_TAG_variable +# INPUT-NEXT: DW_AT_name ("foo") +# INPUT-NEXT: DW_AT_decl_file ("1.c") +# INPUT-NEXT: DW_AT_decl_line (1) +# INPUT-NEXT: DW_AT_type (cu + 0x0032 "int") +# INPUT-NEXT: DW_AT_external (true) +# INPUT-NEXT: DW_AT_location (DW_OP_addr 0x0) +# INPUT: DW_TAG_variable +# INPUT-NEXT: DW_AT_name ("bar") +# INPUT-NEXT: DW_AT_decl_file ("1.c") +# INPUT-NEXT: DW_AT_decl_line (2) +# INPUT-NEXT: DW_AT_type (cu + 0x0032 "int") +# INPUT-NEXT: DW_AT_external (true) +# INPUT-NEXT: DW_AT_location (DW_OP_addr 0x0) + +## Check we use information from .debug_info in messages. +# CHECK: duplicate symbol: bar +# CHECK-NEXT: >>> defined at 1.c:2 +# CHECK-NEXT: >>> {{.*}}:(bar) +# CHECK-NEXT: >>> defined at 1.c:2 +# CHECK-NEXT: >>> {{.*}}:(.data+0x0) +# CHECK: duplicate symbol: foo +# CHECK-NEXT: >>> defined at 1.c:1 +# CHECK-NEXT: >>> {{.*}}:(foo) +# CHECK-NEXT: >>> defined at 1.c:1 +# CHECK-NEXT: >>> {{.*}}:(.bss+0x0) + +## Check that stripping debug sections does not break error reporting. +# RUN: not ld.lld --strip-debug %t.o %t.o -o %t 2>&1 | FileCheck %s + +# Used reduced output from following code and gcc 7.1.0 +# to produce this input file: +# Source (1.c): +# int foo = 0; +# int bar = 1; +# Invocation: g++ -g -S 1.c + +.bss +.globl foo +.type foo, @object +.size foo, 4 +foo: + +.data +.globl bar +.type bar, @object +.size bar, 4 +bar: + +.text +.file 1 "1.c" + +.section .debug_info,"",@progbits + .long 0x4b # Compile Unit: length = 0x0000004b) + .value 0x4 # version = 0x0004 + .long 0 # abbr_offset = 0x0 + .byte 0x8 # addr_size = 0x08 + + .uleb128 0x1 # DW_TAG_compile_unit [1] * + .long 0 # DW_AT_producer [DW_FORM_strp] ( .debug_str[0x00000000] = ) + .byte 0x4 # DW_AT_language [DW_FORM_data1] (DW_LANG_C_plus_plus) + .string "1.c" # DW_AT_name [DW_FORM_string] ("1.c") + .long 0 # DW_AT_comp_dir [DW_FORM_strp] ( .debug_str[0x00000000] = ) + .long 0 # DW_AT_stmt_list [DW_FORM_sec_offset] (0x00000000) + + .uleb128 0x2 # DW_TAG_variable [2] + .string "foo" # DW_AT_name [DW_FORM_string] ("foo") + .byte 0x1 # DW_AT_decl_file [DW_FORM_data1] ("1.c") + .byte 0x1 # DW_AT_decl_line [DW_FORM_data1] (1) + .long 0x32 # DW_AT_type [DW_FORM_ref4] (cu + 0x0032 => {0x00000032}) + .uleb128 0x9 # DW_AT_external [DW_FORM_flag_present] (true) + .byte 0x3 + .quad foo # DW_AT_location [DW_FORM_exprloc] (DW_OP_addr 0x0) + + .uleb128 0x3 # DW_TAG_base_type [3] + .byte 0x4 # DW_AT_byte_size [DW_FORM_data1] (0x04) + .byte 0x5 # DW_AT_encoding [DW_FORM_data1] (DW_ATE_signed) + .string "int" # DW_AT_name [DW_FORM_string] ("int") + + .uleb128 0x2 # DW_TAG_variable [2] + .string "bar" # DW_AT_name [DW_FORM_string] ("bar") + .byte 0x1 # DW_AT_decl_file [DW_FORM_data1] ("1.c") + .byte 0x2 # DW_AT_decl_line [DW_FORM_data1] (2) + .long 0x32 # DW_AT_type [DW_FORM_ref4] (cu + 0x0032 => {0x00000032}) + .uleb128 0x9 # DW_AT_external [DW_FORM_flag_present] (true) + .byte 0x3 + .quad bar # DW_AT_location [DW_FORM_exprloc] (DW_OP_addr 0x0) + .byte 0 # END + + +.section .debug_abbrev,"",@progbits + .uleb128 0x1 # Abbreviation code. + .uleb128 0x11 # DW_TAG_compile_unit + + .byte 0x1 # ID + .uleb128 0x25 # DW_AT_producer, DW_FORM_strp + .uleb128 0xe + .uleb128 0x13 # DW_AT_language, DW_FORM_data1 + .uleb128 0xb + .uleb128 0x3 # DW_AT_name, DW_FORM_string + .uleb128 0x8 + .uleb128 0x1b # DW_AT_comp_dir, DW_FORM_strp + .uleb128 0xe + .uleb128 0x10 # DW_AT_stmt_list, DW_FORM_sec_offset + .uleb128 0x17 + .byte 0 + .byte 0 + + .uleb128 0x2 # ID + .uleb128 0x34 # DW_TAG_variable, DW_CHILDREN_no + .byte 0 + .uleb128 0x3 # DW_AT_name, DW_FORM_string + .uleb128 0x8 + .uleb128 0x3a # DW_AT_decl_file, DW_FORM_data1 + .uleb128 0xb + .uleb128 0x3b # DW_AT_decl_line, DW_FORM_data1 + .uleb128 0xb + .uleb128 0x49 # DW_AT_type, DW_FORM_ref4 + .uleb128 0x13 + .uleb128 0x3f # DW_AT_external, DW_FORM_flag_present + .uleb128 0x19 + .uleb128 0x2 # DW_AT_location, DW_FORM_exprloc + .uleb128 0x18 + .byte 0 + .byte 0 + + .uleb128 0x3 # ID + .uleb128 0x24 # DW_TAG_base_type, DW_CHILDREN_no + .byte 0 + .uleb128 0xb # DW_AT_byte_size, DW_FORM_data1 + .uleb128 0xb + .uleb128 0x3e # DW_AT_encoding, DW_FORM_data1 + .uleb128 0xb + .uleb128 0x3 # DW_AT_name, DW_FORM_string + .uleb128 0x8 + .byte 0 + .byte 0 + .byte 0 + diff --git a/test/ELF/conflict-debug-variable2.s b/test/ELF/conflict-debug-variable2.s new file mode 100644 index 000000000000..1fb9b09443b4 --- /dev/null +++ b/test/ELF/conflict-debug-variable2.s @@ -0,0 +1,160 @@ +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o + +# RUN: llvm-dwarfdump -v %t.o | FileCheck -check-prefix=INPUT %s +# INPUT: .debug_info contents: +# INPUT: DW_TAG_variable +# INPUT-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x00000027] = "foo") +# INPUT-NEXT: DW_AT_type [DW_FORM_ref4] (cu + 0x0033 => {0x00000033} "int") +# INPUT-NEXT: DW_AT_external [DW_FORM_flag_present] (true) +# INPUT-NEXT: DW_AT_decl_file [DW_FORM_data1] ("/home/path/test.c") +# INPUT-NEXT: DW_AT_decl_line [DW_FORM_data1] (1) +# INPUT-NEXT: DW_AT_location [DW_FORM_exprloc] (DW_OP_addr 0x0) +# INPUT: DW_TAG_variable +# INPUT-NEXT: DW_AT_name [DW_FORM_strp] ( .debug_str[0x0000002f] = "bar") +# INPUT-NEXT: DW_AT_type [DW_FORM_ref4] (cu + 0x0033 => {0x00000033} "int") +# INPUT-NEXT: DW_AT_external [DW_FORM_flag_present] (true) +# INPUT-NEXT: DW_AT_decl_file [DW_FORM_data1] ("/home/path/test.c") +# INPUT-NEXT: DW_AT_decl_line [DW_FORM_data1] (2) +# INPUT-NEXT: DW_AT_location [DW_FORM_exprloc] (DW_OP_addr 0x0) + +## Check we use information from .debug_info in messages. +# RUN: not ld.lld %t.o %t.o -o %t 2>&1 | FileCheck %s +# CHECK: duplicate symbol: bar +# CHECK-NEXT: >>> defined at test.c:2 +# CHECK-NEXT: >>> {{.*}}:(bar) +# CHECK-NEXT: >>> defined at test.c:2 +# CHECK-NEXT: >>> {{.*}}:(.data+0x0) +# CHECK: duplicate symbol: foo +# CHECK-NEXT: >>> defined at test.c:1 +# CHECK-NEXT: >>> {{.*}}:(foo) +# CHECK-NEXT: >>> defined at test.c:1 +# CHECK-NEXT: >>> {{.*}}:(.bss+0x0) + +# Used reduced output from following code and clang +# version 6.0.0 (trunk 316661) to produce this input file: +# Source (test.c): +# int foo = 0; +# int bar = 1; +# Invocation: clang -g -S test.c + +.text +.file "test.c" +.file 1 "test.c" + +.type foo,@object +.bss +.globl foo +.p2align 2 +foo: + .long 0 + .size foo, 4 + +.type bar,@object +.data +.globl bar +.p2align 2 +bar: + .long 1 + .size bar, 4 + +.section .debug_str,"MS",@progbits,1 +.Linfo_string0: + .asciz "clang version 6.0.0" +.Linfo_string1: + .asciz "test.c" +.Linfo_string2: + .asciz "/home/path/" +.Linfo_string3: + .asciz "foo" +.Linfo_string4: + .asciz "int" +.Linfo_string5: + .asciz "bar" + +.section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 14 # DW_FORM_strp + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 14 # DW_FORM_strp + .ascii "\264B" # DW_AT_GNU_pubnames + .byte 25 # DW_FORM_flag_present + .byte 0 # EOM(1) + .byte 0 # EOM(2) + + .byte 2 # Abbreviation Code + .byte 52 # DW_TAG_variable + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 63 # DW_AT_external + .byte 25 # DW_FORM_flag_present + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 2 # DW_AT_location + .byte 24 # DW_FORM_exprloc + .byte 0 # EOM(1) + .byte 0 # EOM(2) + + .byte 3 # Abbreviation Code + .byte 36 # DW_TAG_base_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 62 # DW_AT_encoding + .byte 11 # DW_FORM_data1 + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + +.section .debug_info,"",@progbits +.Lcu_begin0: + .long 76 # Length of Unit + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + + .byte 1 # Abbrev [1] 0xb:0x45 DW_TAG_compile_unit + .long .Linfo_string0 # DW_AT_producer + .short 12 # DW_AT_language + .long .Linfo_string1 # DW_AT_name + .long 0 # DW_AT_stmt_list + .long .Linfo_string2 # DW_AT_comp_dir + + .byte 2 # Abbrev [2] 0x1e:0x15 DW_TAG_variable + .long .Linfo_string3 # DW_AT_name + .long 51 # DW_AT_type + .byte 1 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .byte 9 # DW_AT_location + .byte 3 + .quad foo + + .byte 3 # Abbrev [3] 0x33:0x7 DW_TAG_base_type + .long .Linfo_string4 # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + + .byte 2 # Abbrev [2] 0x3a:0x15 DW_TAG_variable + .long .Linfo_string5 # DW_AT_name + .long 51 # DW_AT_type + .byte 1 # DW_AT_decl_file + .byte 2 # DW_AT_decl_line + .byte 9 # DW_AT_location + .byte 3 + .quad bar + .byte 0 # End Of Children Mark diff --git a/test/ELF/copy-errors.s b/test/ELF/copy-errors.s index d0d6abdf68da..0af4638120d1 100644 --- a/test/ELF/copy-errors.s +++ b/test/ELF/copy-errors.s @@ -9,6 +9,9 @@ // CHECK: >>> referenced by {{.*}}.o:(.text+0x1) // CHECK: symbol 'zed' defined in {{.*}}.so has no type +// RUN: not ld.lld --noinhibit-exec %t.o %t2.so -o %t 2>&1 | FileCheck %s --check-prefix=NOINHIBIT +// NOINHIBIT: warning: symbol 'zed' defined in {{.*}}.so has no type + .global _start _start: call bar diff --git a/test/ELF/copy-rel-abs.s b/test/ELF/copy-rel-abs.s new file mode 100644 index 000000000000..37a2c4323819 --- /dev/null +++ b/test/ELF/copy-rel-abs.s @@ -0,0 +1,47 @@ +// REQUIRES: x86 +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/copy-rel-abs.s -o %t1.o +// RUN: ld.lld --hash-style=gnu -shared %t1.o -o %t1.so +// RUN: llvm-readelf --dyn-symbols %t1.so | FileCheck --check-prefix=SYMS %s + +// The symbols have the same st_value, but one is ABS. +// SYMS: 0000000000001000 {{.*}} 4 bar +// SYMS: 0000000000001000 {{.*}} 4 foo +// SYMS: 0000000000001000 {{.*}} ABS zed + +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t2.o +// RUN: ld.lld %t2.o %t1.so -o %t2 +// RUN: llvm-readobj --dyn-symbols %t2 | FileCheck %s + +// CHECK: DynamicSymbols [ +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: +// CHECK-NEXT: Binding: +// CHECK-NEXT: Type: +// CHECK-NEXT: Other: +// CHECK-NEXT: Section: +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: foo +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: +// CHECK-NEXT: Binding: +// CHECK-NEXT: Type: +// CHECK-NEXT: Other: +// CHECK-NEXT: Section: .bss.rel.ro +// CHECK-NEXT: } +// CHECK-NEXT: Symbol { +// CHECK-NEXT: Name: bar +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: +// CHECK-NEXT: Binding: +// CHECK-NEXT: Type: +// CHECK-NEXT: Other: +// CHECK-NEXT: Section: .bss.rel.ro +// CHECK-NEXT: } +// CHECK-NEXT: ] + +.global _start +_start: +.quad foo diff --git a/test/ELF/copy-rel-large.s b/test/ELF/copy-rel-large.s new file mode 100644 index 000000000000..035eca3bf10d --- /dev/null +++ b/test/ELF/copy-rel-large.s @@ -0,0 +1,20 @@ +// REQUIRES: x86 +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/copy-rel-large.s -o %t1.o +// RUN: ld.lld -shared %t1.o -o %t1.so +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t2.o +// RUN: ld.lld %t2.o %t1.so -o %t2 +// RUN: llvm-readobj --dyn-symbols %t2 | FileCheck %s + + .global _start +_start: + .quad foo + +// CHECK: Symbol { +// CHECK: Name: foo +// CHECK-NEXT: Value: +// CHECK-NEXT: Size: 4294967297 +// CHECK-NEXT: Binding: +// CHECK-NEXT: Type: +// CHECK-NEXT: Other: +// CHECK-NEXT: Section: .bss.rel.ro +// CHECK-NEXT: } diff --git a/test/ELF/copy-rel-pie.s b/test/ELF/copy-rel-pie.s index 769a2431d850..dcccf8e30b1d 100644 --- a/test/ELF/copy-rel-pie.s +++ b/test/ELF/copy-rel-pie.s @@ -1,7 +1,7 @@ // RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux // RUN: llvm-mc %p/Inputs/copy-rel-pie.s -o %t2.o -filetype=obj -triple=x86_64-pc-linux // RUN: ld.lld %t2.o -o %t2.so -shared -// RUN: ld.lld %t.o %t2.so -o %t.exe -pie +// RUN: ld.lld --hash-style=sysv %t.o %t2.so -o %t.exe -pie // RUN: llvm-readobj -s -r %t.exe | FileCheck %s // RUN: llvm-objdump -d %t.exe | FileCheck --check-prefix=DISASM %s diff --git a/test/ELF/corrupted-version-reference.s b/test/ELF/corrupted-version-reference.s new file mode 100644 index 000000000000..d37f272f445d --- /dev/null +++ b/test/ELF/corrupted-version-reference.s @@ -0,0 +1,14 @@ +# RUN: llvm-mc -triple=mips64-unknown-freebsd %s -filetype=obj -o %t.o +# RUN: not ld.lld %t.o %S/Inputs/corrupt-version-reference.so -o %t.exe 2>&1 | FileCheck %s +# REQUIRES: mips + +# CHECK: error: corrupt input file: version definition index 9 for symbol __cxa_finalize is out of bounds +# CHECK: >>> defined in {{.+}}/corrupt-version-reference.so + +# CHECK: error: corrupt input file: version definition index 0 for symbol _Jv_RegisterClasses is out of bounds +# CHECK-NEXT: >>> defined in {{.*}}/corrupt-version-reference.so + +.globl __start +__start: + dla $a0, __cxa_finalize + nop diff --git a/test/ELF/debug-gc.s b/test/ELF/debug-gc.s index 8bcfde16a7b7..5ec43f67829e 100644 --- a/test/ELF/debug-gc.s +++ b/test/ELF/debug-gc.s @@ -4,11 +4,11 @@ # RUN: llvm-objdump -s %t1 | FileCheck %s # CHECK: Contents of section .debug_str: -# CHECK-NEXT: 0000 41414100 42424200 43434300 AAA.BBB.CCC. +# CHECK-NEXT: 0000 41414100 43434300 42424200 AAA.CCC.BBB. # CHECK: Contents of section .foo: # CHECK-NEXT: 0000 2a000000 # CHECK: Contents of section .debug_info: -# CHECK-NEXT: 0000 00000000 04000000 +# CHECK-NEXT: 0000 00000000 08000000 .globl _start _start: diff --git a/test/ELF/defsym-dynamic.s b/test/ELF/defsym-dynamic.s new file mode 100644 index 000000000000..f69e835af34c --- /dev/null +++ b/test/ELF/defsym-dynamic.s @@ -0,0 +1,10 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld -o %t.so -shared %t.o --defsym=foo2=foo1 +# RUN: llvm-readobj --dyn-symbols %t.so | FileCheck %s + +# CHECK: Name: foo1 +# CHECK: Name: foo2 + +.globl foo1 + foo1 = 0x123 diff --git a/test/ELF/defsym.s b/test/ELF/defsym.s index b821484261b2..2abc08f99dfc 100644 --- a/test/ELF/defsym.s +++ b/test/ELF/defsym.s @@ -19,7 +19,7 @@ # CHECK-NEXT: Section: Absolute # CHECK-NEXT: } # CHECK-NEXT: Symbol { -# CHECK-NEXT: Name: foo1 +# CHECK-NEXT: Name: foo2 # CHECK-NEXT: Value: 0x123 # CHECK-NEXT: Size: # CHECK-NEXT: Binding: Global @@ -33,11 +33,43 @@ # USE-NEXT: _start: # USE-NEXT: movl $0x123, %edx -# RUN: not ld.lld -o %t %t.o --defsym=foo2=1 2>&1 | FileCheck %s -check-prefix=ERR1 -# ERR1: error: --defsym: symbol name expected, but got 1 +# RUN: ld.lld -o %t %t.o --defsym=foo2=1 +# RUN: llvm-readobj -t -s %t | FileCheck %s --check-prefix=ABS -# RUN: not ld.lld -o %t %t.o --defsym=foo2=und 2>&1 | FileCheck %s -check-prefix=ERR2 -# ERR2: error: -defsym: undefined symbol: und +# ABS: Symbol { +# ABS: Name: foo2 +# ABS-NEXT: Value: 0x1 +# ABS-NEXT: Size: +# ABS-NEXT: Binding: Global +# ABS-NEXT: Type: +# ABS-NEXT: Other: +# ABS-NEXT: Section: Absolute +# ABS-NEXT: } + +# RUN: ld.lld -o %t %t.o --defsym=foo2=foo1+5 +# RUN: llvm-readobj -t -s %t | FileCheck %s --check-prefix=EXPR + +# EXPR: Symbol { +# EXPR: Name: foo1 +# EXPR-NEXT: Value: 0x123 +# EXPR-NEXT: Size: +# EXPR-NEXT: Binding: Global +# EXPR-NEXT: Type: +# EXPR-NEXT: Other: +# EXPR-NEXT: Section: Absolute +# EXPR-NEXT: } +# EXPR-NEXT: Symbol { +# EXPR-NEXT: Name: foo2 +# EXPR-NEXT: Value: 0x128 +# EXPR-NEXT: Size: +# EXPR-NEXT: Binding: Global +# EXPR-NEXT: Type: +# EXPR-NEXT: Other: +# EXPR-NEXT: Section: Absolute +# EXPR-NEXT: } + +# RUN: not ld.lld -o %t %t.o --defsym=foo2=und 2>&1 | FileCheck %s -check-prefix=ERR +# ERR: error: -defsym:1: symbol not found: und .globl foo1 foo1 = 0x123 diff --git a/test/ELF/driver-access.test b/test/ELF/driver-access.test index 5209483ae480..46b87c1f7e5d 100644 --- a/test/ELF/driver-access.test +++ b/test/ELF/driver-access.test @@ -7,7 +7,7 @@ # RUN: mkdir -p %t.dir # RUN: chmod 100 %t.dir # RUN: cd %t.dir -# RUN: ld.lld %t.o -o %t.exe +# RUN: ld.lld %t.o -o %t.exe -M # RUN: chmod 755 %t.dir .globl _start diff --git a/test/ELF/driver.test b/test/ELF/driver.test index d876218130c3..ac324cbaac45 100644 --- a/test/ELF/driver.test +++ b/test/ELF/driver.test @@ -18,10 +18,10 @@ # HELP: : supported targets:{{.*}} elf # RUN: ld.lld --version 2>&1 | FileCheck -check-prefix=VERSION %s +# RUN: ld.lld -v 2>&1 | FileCheck -check-prefix=VERSION %s +# RUN: not ld.lld -v xyz 2>&1 | FileCheck -check-prefix=VERSION %s # VERSION: LLD {{.*}} (compatible with GNU linkers) -# RUN: not ld.lld -v 2>&1 | FileCheck -check-prefix=VERSION %s - ## Attempt to link DSO with -r # RUN: ld.lld -shared %t -o %t.so # RUN: not ld.lld -r %t.so %t -o %tfail 2>&1 | FileCheck -check-prefix=ERR %s diff --git a/test/ELF/duplicated-synthetic-sym.s b/test/ELF/duplicated-synthetic-sym.s index cfd8642d2d17..92de33ec6278 100644 --- a/test/ELF/duplicated-synthetic-sym.s +++ b/test/ELF/duplicated-synthetic-sym.s @@ -1,9 +1,10 @@ // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o // RUN: cd %S // RUN: not ld.lld %t.o --format=binary duplicated-synthetic-sym.s -o %t.elf 2>&1 | FileCheck %s +// RUN: not ld.lld %t.o --format binary duplicated-synthetic-sym.s -o %t.elf 2>&1 | FileCheck %s // CHECK: duplicate symbol: _binary_duplicated_synthetic_sym_s_start -// CHECK: defined at (internal):(.data+0x0) +// CHECK: defined at <internal>:(.data+0x0) .globl _binary_duplicated_synthetic_sym_s_start _binary_duplicated_synthetic_sym_s_start: diff --git a/test/ELF/dynamic-got.s b/test/ELF/dynamic-got.s index c50c9022329a..385394b9d342 100644 --- a/test/ELF/dynamic-got.s +++ b/test/ELF/dynamic-got.s @@ -1,6 +1,6 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %s -o %t.o -// RUN: ld.lld %t.o -o %t.so -shared +// RUN: ld.lld --hash-style=sysv %t.o -o %t.so -shared // RUN: llvm-readobj -s -l -section-data -r %t.so | FileCheck %s // CHECK: Name: .got diff --git a/test/ELF/dynamic-list-empty.s b/test/ELF/dynamic-list-empty.s new file mode 100644 index 000000000000..5686ce0c431b --- /dev/null +++ b/test/ELF/dynamic-list-empty.s @@ -0,0 +1,18 @@ +# REQUIRES: x86 + +# BFD reports a parse error on empty lists, but it is clear how to +# handle it. + +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: echo "{ };" > %t.list +# RUN: ld.lld -dynamic-list %t.list -shared %t.o -o %t.so +# RUN: llvm-readobj -r %t.so | FileCheck %s + +# CHECK: Relocations [ +# CHECK-NEXT: ] + + .globl foo +foo: + ret + + call foo@PLT diff --git a/test/ELF/dynamic-list-preempt.s b/test/ELF/dynamic-list-preempt.s new file mode 100644 index 000000000000..2bb10a3ed0a6 --- /dev/null +++ b/test/ELF/dynamic-list-preempt.s @@ -0,0 +1,76 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: echo "{ foo; zed; };" > %t.list +# RUN: echo "{ global: foo; bar; local: *; };" > %t.vers +# RUN: ld.lld --hash-style=sysv -fatal-warnings -dynamic-list %t.list -version-script %t.vers -shared %t.o -o %t.so +# RUN: llvm-readobj -r %t.so | FileCheck --check-prefix=RELOCS %s +# RUN: llvm-readobj -dyn-symbols %t.so | FileCheck --check-prefix=DYNSYMS %s + +# RELOCS: Relocations [ +# RELOCS-NEXT: Section ({{.*}}) .rela.plt { +# RELOCS-NEXT: R_X86_64_JUMP_SLOT foo 0x0 +# RELOCS-NEXT: R_X86_64_JUMP_SLOT ext 0x0 +# RELOCS-NEXT: } +# RELOCS-NEXT: ] + +# DYNSYMS: DynamicSymbols [ +# DYNSYMS-NEXT: Symbol { +# DYNSYMS-NEXT: Name: @ (0) +# DYNSYMS-NEXT: Value: 0x0 +# DYNSYMS-NEXT: Size: 0 +# DYNSYMS-NEXT: Binding: Local +# DYNSYMS-NEXT: Type: None +# DYNSYMS-NEXT: Other: 0 +# DYNSYMS-NEXT: Section: Undefined +# DYNSYMS-NEXT: } +# DYNSYMS-NEXT: Symbol { +# DYNSYMS-NEXT: Name: bar@ +# DYNSYMS-NEXT: Value: +# DYNSYMS-NEXT: Size: +# DYNSYMS-NEXT: Binding: Global +# DYNSYMS-NEXT: Type: +# DYNSYMS-NEXT: Other: +# DYNSYMS-NEXT: Section: +# DYNSYMS-NEXT: } +# DYNSYMS-NEXT: Symbol { +# DYNSYMS-NEXT: Name: ext@ +# DYNSYMS-NEXT: Value: +# DYNSYMS-NEXT: Size: +# DYNSYMS-NEXT: Binding: Global +# DYNSYMS-NEXT: Type: +# DYNSYMS-NEXT: Other: +# DYNSYMS-NEXT: Section: +# DYNSYMS-NEXT: } +# DYNSYMS-NEXT: Symbol { +# DYNSYMS-NEXT: Name: foo@ +# DYNSYMS-NEXT: Value: +# DYNSYMS-NEXT: Size: +# DYNSYMS-NEXT: Binding: Global +# DYNSYMS-NEXT: Type: +# DYNSYMS-NEXT: Other: +# DYNSYMS-NEXT: Section: +# DYNSYMS-NEXT: } +# DYNSYMS-NEXT: ] + + .globl foo +foo: + ret + + .globl bar +bar: + ret + + .globl baz +baz: + ret + + .globl zed +zed: + ret + + call foo@PLT + call bar@PLT + call baz@PLT + call zed@PLT + call ext@PLT diff --git a/test/ELF/dynamic-list-weak-archive.s b/test/ELF/dynamic-list-weak-archive.s new file mode 100644 index 000000000000..f7f72afd0c3b --- /dev/null +++ b/test/ELF/dynamic-list-weak-archive.s @@ -0,0 +1,18 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/dynamic-list-weak-archive.s -o %t2.o +# RUN: rm -f %t.a +# RUN: llvm-ar rcs %t.a %t2.o +# RUN: echo "{ zed; };" > %t.list +# RUN: ld.lld -shared --dynamic-list %t.list %t1.o %t.a -o %t.so +# RUN: llvm-readobj -r %t.so | FileCheck %s + +# CHECK: Relocations [ +# CHECK-NEXT: Section ({{.*}}) .rela.plt { +# CHECK-NEXT: 0x2018 R_X86_64_JUMP_SLOT foo +# CHECK-NEXT: } +# CHECK-NEXT: ] + +callq foo@PLT +.weak foo diff --git a/test/ELF/dynamic-list-wildcard.s b/test/ELF/dynamic-list-wildcard.s new file mode 100644 index 000000000000..cd7ed71771ae --- /dev/null +++ b/test/ELF/dynamic-list-wildcard.s @@ -0,0 +1,53 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t + +# RUN: echo "{ foo1*; };" > %t.list +# RUN: ld.lld --hash-style=sysv -pie --dynamic-list %t.list %t -o %t.exe +# RUN: llvm-readobj -dyn-symbols %t.exe | FileCheck %s + +# CHECK: DynamicSymbols [ +# CHECK-NEXT: Symbol { +# CHECK-NEXT: Name: @ (0) +# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Local (0x0) +# CHECK-NEXT: Type: None (0x0) +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: Undefined (0x0) +# CHECK-NEXT: } +# CHECK-NEXT: Symbol { +# CHECK-NEXT: Name: foo1@ (1) +# CHECK-NEXT: Value: 0x1000 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Global (0x1) +# CHECK-NEXT: Type: None (0x0) +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: .text (0x4) +# CHECK-NEXT: } +# CHECK-NEXT: Symbol { +# CHECK-NEXT: Name: foo11@ (6) +# CHECK-NEXT: Value: 0x1001 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Global (0x1) +# CHECK-NEXT: Type: None (0x0) +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: .text (0x4) +# CHECK-NEXT: } +# CHECK-NEXT: ] + +.globl foo1 +foo1: + ret + +.globl foo11 +foo11: + ret + +.globl foo2 +foo2: + ret + +.globl _start +_start: + retq diff --git a/test/ELF/dynamic-list.s b/test/ELF/dynamic-list.s index 7cd587380e59..888508e270a7 100644 --- a/test/ELF/dynamic-list.s +++ b/test/ELF/dynamic-list.s @@ -1,28 +1,24 @@ -## There is some bad quoting interaction between lit's internal shell, which is -## implemented in Python, and the Cygwin implementations of the Unix utilities. -## Avoid running these tests on Windows for now by requiring a real shell. - # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o -# RUN: ld.lld -shared %t2.o -soname shared -o %t2.so +# RUN: ld.lld --hash-style=sysv -shared %t2.o -soname shared -o %t2.so # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t ## Check exporting only one symbol. # RUN: echo "{ foo1; };" > %t.list -# RUN: ld.lld --dynamic-list %t.list %t %t2.so -o %t.exe +# RUN: ld.lld --hash-style=sysv --dynamic-list %t.list %t %t2.so -o %t.exe # RUN: llvm-readobj -dyn-symbols %t.exe | FileCheck %s ## And now using quoted strings (the output is the same since it does ## use any wildcard character). # RUN: echo "{ \"foo1\"; };" > %t.list -# RUN: ld.lld --dynamic-list %t.list %t %t2.so -o %t.exe +# RUN: ld.lld --hash-style=sysv --dynamic-list %t.list %t %t2.so -o %t.exe # RUN: llvm-readobj -dyn-symbols %t.exe | FileCheck %s ## And now using --export-dynamic-symbol. -# RUN: ld.lld --export-dynamic-symbol foo1 %t %t2.so -o %t.exe +# RUN: ld.lld --hash-style=sysv --export-dynamic-symbol foo1 %t %t2.so -o %t.exe # RUN: llvm-readobj -dyn-symbols %t.exe | FileCheck %s -# RUN: ld.lld --export-dynamic-symbol=foo1 %t %t2.so -o %t.exe +# RUN: ld.lld --hash-style=sysv --export-dynamic-symbol=foo1 %t %t2.so -o %t.exe # RUN: llvm-readobj -dyn-symbols %t.exe | FileCheck %s # CHECK: DynamicSymbols [ @@ -49,11 +45,11 @@ ## Now export all the foo1, foo2, and foo31 symbols # RUN: echo "{ foo1; foo2; foo31; };" > %t.list -# RUN: ld.lld --dynamic-list %t.list %t %t2.so -o %t.exe +# RUN: ld.lld --hash-style=sysv --dynamic-list %t.list %t %t2.so -o %t.exe # RUN: llvm-readobj -dyn-symbols %t.exe | FileCheck -check-prefix=CHECK2 %s # RUN: echo "{ foo1; foo2; };" > %t1.list # RUN: echo "{ foo31; };" > %t2.list -# RUN: ld.lld --dynamic-list %t1.list --dynamic-list %t2.list %t %t2.so -o %t.exe +# RUN: ld.lld --hash-style=sysv --dynamic-list %t1.list --dynamic-list %t2.list %t %t2.so -o %t.exe # RUN: llvm-readobj -dyn-symbols %t.exe | FileCheck -check-prefix=CHECK2 %s # CHECK2: DynamicSymbols [ @@ -99,11 +95,11 @@ ## --export-dynamic overrides --dynamic-list, i.e. --export-dynamic with an ## incomplete dynamic-list still exports everything. # RUN: echo "{ foo2; };" > %t.list -# RUN: ld.lld --dynamic-list %t.list --export-dynamic %t %t2.so -o %t.exe +# RUN: ld.lld --hash-style=sysv --dynamic-list %t.list --export-dynamic %t %t2.so -o %t.exe # RUN: llvm-readobj -dyn-symbols %t.exe | FileCheck -check-prefix=CHECK3 %s ## The same with --export-dynamic-symbol. -# RUN: ld.lld --export-dynamic-symbol=foo2 --export-dynamic %t %t2.so -o %t.exe +# RUN: ld.lld --hash-style=sysv --export-dynamic-symbol=foo2 --export-dynamic %t %t2.so -o %t.exe # RUN: llvm-readobj -dyn-symbols %t.exe | FileCheck -check-prefix=CHECK3 %s # CHECK3: DynamicSymbols [ diff --git a/test/ELF/dynamic-no-rosegment.s b/test/ELF/dynamic-no-rosegment.s new file mode 100644 index 000000000000..e5ad26e3fa44 --- /dev/null +++ b/test/ELF/dynamic-no-rosegment.s @@ -0,0 +1,15 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld -shared --no-rosegment -z rodynamic -o %t %t.o +# RUN: llvm-readobj -dynamic-table -s %t | FileCheck %s + +# CHECK: DynamicSection [ (7 entries) +# CHECK-NEXT: Tag Type Name/Value +# CHECK-NEXT: 0x0000000000000006 SYMTAB 0x120 +# CHECK-NEXT: 0x000000000000000B SYMENT 24 (bytes) +# CHECK-NEXT: 0x0000000000000005 STRTAB 0x1D0 +# CHECK-NEXT: 0x000000000000000A STRSZ 1 (bytes) +# CHECK-NEXT: 0x000000006FFFFEF5 GNU_HASH 0x138 +# CHECK-NEXT: 0x0000000000000004 HASH 0x150 +# CHECK-NEXT: 0x0000000000000000 NULL 0x0 +# CHECK-NEXT: ] diff --git a/test/ELF/dynamic-reloc-in-ro.s b/test/ELF/dynamic-reloc-in-ro.s index 23b068ff839f..ecdbfeb6658e 100644 --- a/test/ELF/dynamic-reloc-in-ro.s +++ b/test/ELF/dynamic-reloc-in-ro.s @@ -2,9 +2,9 @@ // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o // RUN: not ld.lld %t.o -o %t.so -shared 2>&1 | FileCheck %s -// CHECK: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment -// CHECK: >>> defined in {{.*}}.o -// CHECK: >>> referenced by {{.*}}.o:(.text+0x0) +// CHECK: can't create dynamic relocation R_X86_64_64 against local symbol in readonly segment; recompile object files with -fPIC +// CHECK-NEXT: >>> defined in {{.*}}.o +// CHECK-NEXT: >>> referenced by {{.*}}.o:(.text+0x0) foo: .quad foo diff --git a/test/ELF/dynamic-reloc.s b/test/ELF/dynamic-reloc.s index 939093c17b41..4d95e41fb803 100644 --- a/test/ELF/dynamic-reloc.s +++ b/test/ELF/dynamic-reloc.s @@ -2,7 +2,7 @@ // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/dynamic-reloc.s -o %t3.o // RUN: ld.lld -shared %t2.o -o %t2.so -// RUN: ld.lld %t.o %t3.o %t2.so -o %t +// RUN: ld.lld --hash-style=sysv %t.o %t3.o %t2.so -o %t // RUN: llvm-readobj -dynamic-table -r --expand-relocs -s %t | FileCheck %s // REQUIRES: x86 diff --git a/test/ELF/dynstr-no-rosegment.s b/test/ELF/dynstr-no-rosegment.s new file mode 100644 index 000000000000..0e12721dac44 --- /dev/null +++ b/test/ELF/dynstr-no-rosegment.s @@ -0,0 +1,12 @@ +# Verify that a .dynstr in the .text segment has null byte terminators + +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld %t.o -no-rosegment -o %t.so -shared +# RUN: llvm-objdump %t.so -s -j .dynstr | FileCheck %s + +# CHECK: 00666f6f 00 .foo. + +.globl foo +foo: + ret diff --git a/test/ELF/dynsym-no-rosegment.s b/test/ELF/dynsym-no-rosegment.s new file mode 100644 index 000000000000..947f526e0575 --- /dev/null +++ b/test/ELF/dynsym-no-rosegment.s @@ -0,0 +1,27 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld -shared --no-rosegment -o %t %t.o +# RUN: llvm-readobj -dyn-symbols -s %t | FileCheck %s + +# CHECK: DynamicSymbols [ +# CHECK-NEXT: Symbol { +# CHECK-NEXT: Name: @ (0) +# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Local +# CHECK-NEXT: Type: None +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: Undefined +# CHECK-NEXT: } +# CHECK-NEXT: Symbol { +# CHECK-NEXT: Name: undef@ +# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: None +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: Undefined +# CHECK-NEXT: } +# CHECK-NEXT: ] + +callq undef@PLT diff --git a/test/ELF/dynsym-pie.s b/test/ELF/dynsym-pie.s index 9d3a9ffe304f..b162d27335ac 100644 --- a/test/ELF/dynsym-pie.s +++ b/test/ELF/dynsym-pie.s @@ -3,6 +3,51 @@ # RUN: ld.lld -pie %t -o %t.out # RUN: llvm-readobj -t -dyn-symbols %t.out | FileCheck %s +# CHECK: Symbols [ +# CHECK: Symbol { +# CHECK: Name: hidden +# CHECK-NEXT: Value: 0x1000 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Local +# CHECK-NEXT: Type: None +# CHECK-NEXT: Other [ +# CHECK-NEXT: STV_HIDDEN +# CHECK-NEXT: ] +# CHECK-NEXT: Section: .text +# CHECK-NEXT: } +# CHECK: Symbol { +# CHECK: Name: internal +# CHECK-NEXT: Value: 0x1000 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Local +# CHECK-NEXT: Type: None +# CHECK-NEXT: Other [ +# CHECK-NEXT: STV_INTERNAL +# CHECK-NEXT: ] +# CHECK-NEXT: Section: .text +# CHECK-NEXT: } +# CHECK: Symbol { +# CHECK: Name: default +# CHECK-NEXT: Value: 0x1000 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: None +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: .text +# CHECK-NEXT: } +# CHECK: Symbol { +# CHECK: Name: protected +# CHECK-NEXT: Value: 0x1000 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: None +# CHECK-NEXT: Other [ +# CHECK-NEXT: STV_PROTECTED +# CHECK-NEXT: ] +# CHECK-NEXT: Section: .text +# CHECK-NEXT: } +# CHECK-NEXT: ] + # CHECK: DynamicSymbols [ # CHECK-NEXT: Symbol { # CHECK-NEXT: Name: @ @@ -23,14 +68,13 @@ _start: default: .global protected +.protected protected protected: .global hidden +.hidden hidden hidden: .global internal +.internal internal internal: - -.global protected_with_hidden -.protected -protected_with_hidden: diff --git a/test/ELF/edata-etext.s b/test/ELF/edata-etext.s index 3b0ba49ad1af..2358399857de 100644 --- a/test/ELF/edata-etext.s +++ b/test/ELF/edata-etext.s @@ -19,7 +19,7 @@ # CHECK: SYMBOL TABLE: # CHECK-NEXT: 0000000000000000 *UND* 00000000 # CHECK-NEXT: 0000000000202002 .data 00000000 _edata -# CHECK-NEXT: 000000000020200a .data 00000000 _end +# CHECK-NEXT: 000000000020200a .bss 00000000 _end # CHECK-NEXT: 0000000000201001 .text 00000000 _etext # CHECK-NEXT: 0000000000201000 .text 00000000 _start diff --git a/test/ELF/edata-no-bss.s b/test/ELF/edata-no-bss.s new file mode 100644 index 000000000000..5127c4710fa9 --- /dev/null +++ b/test/ELF/edata-no-bss.s @@ -0,0 +1,18 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld %t.o -o %t --gc-sections +# RUN: llvm-objdump -t -section-headers %t | FileCheck %s + +# CHECK: .data 00000008 0000000000202000 DATA + +# CHECK: 0000000000202008 .data 00000000 _edata + +.text +.globl _start +_start: +.long .data - . + +.data +.quad 0 + +.globl _edata diff --git a/test/ELF/eh-align-cie.s b/test/ELF/eh-align-cie.s index 343dea5004f0..9e6ac2dc17be 100644 --- a/test/ELF/eh-align-cie.s +++ b/test/ELF/eh-align-cie.s @@ -31,7 +31,7 @@ bar: // OBJ-NEXT: ) -// RUN: ld.lld %t.o -o %t -shared +// RUN: ld.lld --hash-style=sysv %t.o -o %t -shared // RUN: llvm-readobj -s -section-data %t | FileCheck %s // Check that the size of the CIE was changed to (0x1C + 4) and the FDE one was diff --git a/test/ELF/eh-frame-hdr-augmentation.s b/test/ELF/eh-frame-hdr-augmentation.s index 618f5e1a9d7d..135f8119662a 100644 --- a/test/ELF/eh-frame-hdr-augmentation.s +++ b/test/ELF/eh-frame-hdr-augmentation.s @@ -1,6 +1,6 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -// RUN: ld.lld --eh-frame-hdr %t.o -o %t -shared +// RUN: ld.lld --hash-style=sysv --eh-frame-hdr %t.o -o %t -shared // RUN: llvm-objdump --dwarf=frames %t | FileCheck %s // CHECK: .eh_frame contents: diff --git a/test/ELF/eh-frame-hdr-icf-fde.s b/test/ELF/eh-frame-hdr-icf-fde.s new file mode 100644 index 000000000000..54c2cd8bf8c9 --- /dev/null +++ b/test/ELF/eh-frame-hdr-icf-fde.s @@ -0,0 +1,95 @@ +# REQUIRES: x86 + +## Testcase checks that we correctly deduplicate FDEs when ICF +## merges two sections. + +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +# RUN: ld.lld %t -o %t2 --icf=all --eh-frame-hdr +# RUN: llvm-readobj -r %t | FileCheck %s --check-prefix=OBJ +# RUN: llvm-readobj -s -section-data %t2 | FileCheck %s + +# OBJ: Relocations [ +# OBJ-NEXT: Section {{.*}} .rela.eh_frame { +# OBJ-NEXT: 0x20 R_X86_64_PC32 .text.f1 0x0 +# OBJ-NEXT: 0x34 R_X86_64_PC32 .text.f1 0x2 +# OBJ-NEXT: 0x48 R_X86_64_PC32 .text.f2 0x0 +# OBJ-NEXT: 0x5C R_X86_64_PC32 .text.f2 0x2 +# OBJ-NEXT: } +# OBJ-NEXT: ] + +# CHECK: Section { +# CHECK: Index: 1 +# CHECK: Name: .eh_frame_hdr +# CHECK-NEXT: Type: SHT_PROGBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_ALLOC +# CHECK-NEXT: ] +# CHECK-NEXT: Address: 0x200158 +# CHECK-NEXT: Offset: 0x158 +# CHECK-NEXT: Size: 28 +# CHECK-NEXT: Link: 0 +# CHECK-NEXT: Info: 0 +# CHECK-NEXT: AddressAlignment: +# CHECK-NEXT: EntrySize: 0 +# CHECK-NEXT: SectionData ( +# CHECK-NEXT: 0000: 011B033B 1C000000 02000000 A80E0000 +## ^ ^-- FDE(1) PC +## ^-- Number of FDEs +# CHECK-NEXT: 0010: 38000000 AA0E0000 50000000 +## ^-- FDE(2) PC +# CHECK-NEXT: ) +# CHECK-NEXT: } +## FDE(1) == 0x201000 - .eh_frame_hdr(0x200158) = 0xEA8 +## FDE(2) == 0x201000 - .eh_frame_hdr(0x200158) + 2(relocation addend) = 0xEAA + +## Check .eh_frame contains CIE and two FDEs remaining after ICF. +# CHECK-NEXT: Section { +# CHECK-NEXT: Index: 2 +# CHECK-NEXT: Name: .eh_frame +# CHECK-NEXT: Type: SHT_PROGBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_ALLOC +# CHECK-NEXT: ] +# CHECK-NEXT: Address: 0x200178 +# CHECK-NEXT: Offset: 0x178 +# CHECK-NEXT: Size: 72 +# CHECK-NEXT: Link: 0 +# CHECK-NEXT: Info: 0 +# CHECK-NEXT: AddressAlignment: 8 +# CHECK-NEXT: EntrySize: 0 +# CHECK-NEXT: SectionData ( +# CHECK-NEXT: 0000: 14000000 00000000 017A5200 01781001 +# CHECK-NEXT: 0010: 1B0C0708 90010000 14000000 1C000000 +# CHECK-NEXT: 0020: 680E0000 01000000 00000000 00000000 +# CHECK-NEXT: 0030: 14000000 34000000 520E0000 01000000 +# CHECK-NEXT: 0040: 00000000 00000000 +# CHECK-NEXT: ) +# CHECK-NEXT: } + +# CHECK: Section { +# CHECK: Index: +# CHECK: Name: .text +# CHECK-NEXT: Type: SHT_PROGBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_ALLOC +# CHECK-NEXT: SHF_EXECINSTR +# CHECK-NEXT: ] +# CHECK-NEXT: Address: 0x201000 + +.section .text.f1, "ax" +.cfi_startproc +nop +.cfi_endproc +nop +.cfi_startproc +ret +.cfi_endproc + +.section .text.f2, "ax" +.cfi_startproc +nop +.cfi_endproc +nop +.cfi_startproc +ret +.cfi_endproc diff --git a/test/ELF/eh-frame-hdr-icf.s b/test/ELF/eh-frame-hdr-icf.s index 1b42285f5d32..0ef3f97de8d3 100644 --- a/test/ELF/eh-frame-hdr-icf.s +++ b/test/ELF/eh-frame-hdr-icf.s @@ -2,17 +2,18 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t # RUN: ld.lld %t -o %t2 --icf=all --eh-frame-hdr -# RUN: llvm-objdump -s %t2 | FileCheck %s +# RUN: llvm-objdump -s -section-headers %t2 | FileCheck %s + +## Check .eh_frame_hdr contains single FDE and no garbage data at tail. +# CHECK: Sections: +# CHECK: Idx Name Size +# CHECK: .eh_frame_hdr 00000014 # CHECK: Contents of section .eh_frame_hdr: -# CHECK-NEXT: 200158 011b033b 1c000000 01000000 a80e0000 +# CHECK-NEXT: 200158 011b033b 14000000 01000000 # ^ FDE count -# CHECK-NEXT: 200168 38000000 00000000 00000000 -# ^ FDE for f2 -.globl _start, f1, f2 -_start: - ret +.globl f1, f2 .section .text.f1, "ax" f1: diff --git a/test/ELF/eh-frame-hdr.s b/test/ELF/eh-frame-hdr.s index 35c14a4b65dd..4498d7d30eaa 100644 --- a/test/ELF/eh-frame-hdr.s +++ b/test/ELF/eh-frame-hdr.s @@ -1,9 +1,17 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o + // RUN: ld.lld %t.o -o %t -// RUN: llvm-readobj -file-headers -s -section-data -program-headers -symbols %t | FileCheck %s --check-prefix=NOHDR +// RUN: llvm-readobj -file-headers -s -section-data -program-headers -symbols %t \ +// RUN: | FileCheck %s --check-prefix=NOHDR + +// RUN: ld.lld -eh-frame-hdr -no-eh-frame-hdr %t.o -o %t +// RUN: llvm-readobj -file-headers -s -section-data -program-headers -symbols %t \ +// RUN: | FileCheck %s --check-prefix=NOHDR + // RUN: ld.lld --eh-frame-hdr %t.o -o %t -// RUN: llvm-readobj -file-headers -s -section-data -program-headers -symbols %t | FileCheck %s --check-prefix=HDR +// RUN: llvm-readobj -file-headers -s -section-data -program-headers -symbols %t \ +// RUN: | FileCheck %s --check-prefix=HDR // RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=HDRDISASM .section foo,"ax",@progbits diff --git a/test/ELF/eh-frame-merge.s b/test/ELF/eh-frame-merge.s index addbb3f857fe..4b54c173c699 100644 --- a/test/ELF/eh-frame-merge.s +++ b/test/ELF/eh-frame-merge.s @@ -1,6 +1,6 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -// RUN: ld.lld %t.o %t.o -o %t -shared +// RUN: ld.lld --hash-style=sysv %t.o %t.o -o %t -shared // RUN: llvm-readobj -s -section-data %t | FileCheck %s .section foo,"ax",@progbits diff --git a/test/ELF/eh-frame-padding-no-rosegment.s b/test/ELF/eh-frame-padding-no-rosegment.s index 951fed0a56e9..e106f2989d4b 100644 --- a/test/ELF/eh-frame-padding-no-rosegment.s +++ b/test/ELF/eh-frame-padding-no-rosegment.s @@ -31,7 +31,7 @@ bar: // OBJ-NEXT: 0020: 20000000 00000000 00000000 00000000 // OBJ-NEXT: ) -// RUN: ld.lld %t.o -no-rosegment -o %t -shared +// RUN: ld.lld --hash-style=sysv %t.o -no-rosegment -o %t -shared // Check that .eh_frame is in the same segment as .text // RUN: llvm-readobj -l --elf-output-style=GNU %t | FileCheck --check-prefix=PHDR %s diff --git a/test/ELF/eh-frame.s b/test/ELF/eh-frame.s new file mode 100644 index 000000000000..a07d242add15 --- /dev/null +++ b/test/ELF/eh-frame.s @@ -0,0 +1,12 @@ +// REQUIRES: x86 +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/eh-frame.s -o %t2.o +// RUN: ld.lld %t1.o %t2.o -o %t +// RUN: llvm-dwarfdump -eh-frame %t | FileCheck %s + +// CHECK: DW_CFA_def_cfa_offset: +64 +// CHECK: DW_CFA_def_cfa_offset: +32 + +.cfi_startproc +.cfi_def_cfa_offset 64 +.cfi_endproc diff --git a/test/ELF/emit-relocs-gc.s b/test/ELF/emit-relocs-gc.s new file mode 100644 index 000000000000..0741e78ab955 --- /dev/null +++ b/test/ELF/emit-relocs-gc.s @@ -0,0 +1,30 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o + +## Show that we emit .rela.bar and .rela.text when GC is disabled. +# RUN: ld.lld --emit-relocs %t.o -o %t +# RUN: llvm-objdump %t -section-headers | FileCheck %s --check-prefix=NOGC +# NOGC: .rela.text +# NOGC: .rela.bar + +## GC collects .bar section and we exclude .rela.bar from output. We keep +## .rela.text because we keep .text. +# RUN: ld.lld --gc-sections --emit-relocs --print-gc-sections %t.o -o %t \ +# RUN: | FileCheck --check-prefix=MSG %s +# MSG: removing unused section from '.bar' in file +# MSG: removing unused section from '.rela.bar' in file +# RUN: llvm-objdump %t -section-headers | FileCheck %s --check-prefix=GC +# GC-NOT: rela.bar +# GC: rela.text +# GC-NOT: rela.bar + +.section .bar,"a" +.quad .bar + +.text +relocs: +.quad _start + +.global _start +_start: + nop diff --git a/test/ELF/emit-relocs-merge.s b/test/ELF/emit-relocs-merge.s index c700c337e334..3fecca23b735 100644 --- a/test/ELF/emit-relocs-merge.s +++ b/test/ELF/emit-relocs-merge.s @@ -8,7 +8,7 @@ # CHECK-NEXT: 0x1000 R_X86_64_64 zed 0x0 # CHECK-NEXT: 0x1008 R_X86_64_64 zed 0x0 # CHECK-NEXT: } -# CHECK-NEXT: Section ({{.*}}) .rela.data.foo { +# CHECK-NEXT: Section ({{.*}}) .rela.data { # CHECK-NEXT: 0x1000 R_X86_64_64 zed 0x0 # CHECK-NEXT: 0x1008 R_X86_64_64 zed 0x0 # CHECK-NEXT: } diff --git a/test/ELF/emit-relocs-mergeable-i386.s b/test/ELF/emit-relocs-mergeable-i386.s new file mode 100644 index 000000000000..1ddee8c1faf1 --- /dev/null +++ b/test/ELF/emit-relocs-mergeable-i386.s @@ -0,0 +1,66 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t1 +# RUN: ld.lld --emit-relocs %t1 -o %t2 +# RUN: llvm-readobj -sections -section-data %t2 | FileCheck %s + +## Check lf we produce proper relocations when doing merging of SHF_MERGE sections. + +## Check addends of relocations are: 0x0, 0x8, 0x8, 0x4 +# CHECK: Section { +# CHECK: Index: +# CHECK: Name: .foo +# CHECK-NEXT: Type: SHT_PROGBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_ALLOC +# CHECK-NEXT: SHF_EXECINSTR +# CHECK-NEXT: ] +# CHECK-NEXT: Address: +# CHECK-NEXT: Offset: +# CHECK-NEXT: Size: +# CHECK-NEXT: Link: +# CHECK-NEXT: Info: +# CHECK-NEXT: AddressAlignment: +# CHECK-NEXT: EntrySize: +# CHECK-NEXT: SectionData ( +# CHECK-NEXT: 0000: 00000000 08000000 08000000 04000000 +# CHECK-NEXT: ) +# CHECK-NEXT: } + +## Check that offsets for AAA is 0x0, for BBB is 0x8 and CCC has offset 0x4. +# CHECK: Section { +# CHECK: Index: +# CHECK: Name: .strings +# CHECK-NEXT: Type: SHT_PROGBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_MERGE +# CHECK-NEXT: SHF_STRINGS +# CHECK-NEXT: ] +# CHECK-NEXT: Address: +# CHECK-NEXT: Offset: +# CHECK-NEXT: Size: +# CHECK-NEXT: Link: +# CHECK-NEXT: Info: +# CHECK-NEXT: AddressAlignment: +# CHECK-NEXT: EntrySize: +# CHECK-NEXT: SectionData ( +# CHECK-NEXT: |AAA.CCC.BBB.| +# CHECK-NEXT: ) +# CHECK-NEXT: } + +.section .strings,"MS",@progbits,1,unique,10 +.Linfo_string0: + .asciz "AAA" +.Linfo_string1: + .asciz "BBB" + +.section .strings,"MS",@progbits,1,unique,20 +.Linfo_string2: + .asciz "BBB" +.Linfo_string3: + .asciz "CCC" + +.section .foo,"ax",@progbits +.long .Linfo_string0 +.long .Linfo_string1 +.long .Linfo_string2 +.long .Linfo_string3 diff --git a/test/ELF/emit-relocs-mergeable.s b/test/ELF/emit-relocs-mergeable.s new file mode 100644 index 000000000000..1553cb616012 --- /dev/null +++ b/test/ELF/emit-relocs-mergeable.s @@ -0,0 +1,53 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1 +# RUN: ld.lld --emit-relocs %t1 -o %t2 +# RUN: llvm-readobj -sections -section-data -r %t2 | FileCheck %s + +## Check if we produce proper relocations when doing merging of SHF_MERGE sections. + +# CHECK: Section { +# CHECK: Index: +# CHECK: Name: .strings +# CHECK-NEXT: Type: SHT_PROGBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_MERGE +# CHECK-NEXT: SHF_STRINGS +# CHECK-NEXT: ] +# CHECK-NEXT: Address: +# CHECK-NEXT: Offset: +# CHECK-NEXT: Size: 12 +# CHECK-NEXT: Link: +# CHECK-NEXT: Info: +# CHECK-NEXT: AddressAlignment: +# CHECK-NEXT: EntrySize: +# CHECK-NEXT: SectionData ( +# CHECK-NEXT: 0000: 41414100 43434300 42424200 |AAA.CCC.BBB.| +# CHECK-NEXT: ) +# CHECK-NEXT: } + +# CHECK: Relocations [ +# CHECK-NEXT: Section {{.*}} .rela.foo { +# CHECK-NEXT: 0x201000 R_X86_64_64 .strings 0x0 +# CHECK-NEXT: 0x201008 R_X86_64_64 .strings 0x8 +# CHECK-NEXT: 0x201010 R_X86_64_64 .strings 0x8 +# CHECK-NEXT: 0x201018 R_X86_64_64 .strings 0x4 +# CHECK-NEXT: } +# CHECK-NEXT: ] + +.section .strings,"MS",@progbits,1,unique,10 +.Linfo_string0: + .asciz "AAA" +.Linfo_string1: + .asciz "BBB" + +.section .strings,"MS",@progbits,1,unique,20 +.Linfo_string2: + .asciz "BBB" +.Linfo_string3: + .asciz "CCC" + +.section .foo,"ax",@progbits +.quad .Linfo_string0 +.quad .Linfo_string1 +.quad .Linfo_string2 +.quad .Linfo_string3 diff --git a/test/ELF/emit-relocs-shared.s b/test/ELF/emit-relocs-shared.s index 7a0d7911831b..65a12c15ee2e 100644 --- a/test/ELF/emit-relocs-shared.s +++ b/test/ELF/emit-relocs-shared.s @@ -1,6 +1,6 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -# RUN: ld.lld --emit-relocs %t.o -o %t.so -shared +# RUN: ld.lld --hash-style=sysv --emit-relocs %t.o -o %t.so -shared # RUN: llvm-readobj -r %t.so | FileCheck %s .data diff --git a/test/ELF/emit-relocs.s b/test/ELF/emit-relocs.s index fd9722f13ab0..95e70d80acf5 100644 --- a/test/ELF/emit-relocs.s +++ b/test/ELF/emit-relocs.s @@ -64,6 +64,15 @@ # CHECK-NEXT: Section: .text # CHECK-NEXT: } # CHECK-NEXT: Symbol { +# CHECK-NEXT: Name: +# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Local +# CHECK-NEXT: Type: Section +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: .comment +# CHECK-NEXT: } +# CHECK-NEXT: Symbol { # CHECK-NEXT: Name: fn # CHECK-NEXT: Value: 0x201000 # CHECK-NEXT: Size: 0 @@ -83,7 +92,7 @@ # CHECK-NEXT: } # CHECK-NEXT: ] -.section .text,"ax",@progbits,unique,0 +.section .text.fn,"ax",@progbits,unique,0 .globl fn .type fn,@function fn: @@ -94,7 +103,7 @@ bar: callq fn@PLT nop -.section .text,"ax",@progbits,unique,1 +.section .text.fn2,"ax",@progbits,unique,1 .globl fn2 .type fn2,@function fn2: diff --git a/test/ELF/exclude-libs.s b/test/ELF/exclude-libs.s index c36081f40e54..dc7530068586 100644 --- a/test/ELF/exclude-libs.s +++ b/test/ELF/exclude-libs.s @@ -22,6 +22,12 @@ // RUN: ld.lld -shared %t.o %t.dir/exc.a -o %t.exe --exclude-libs=ALL // RUN: llvm-readobj -dyn-symbols %t.exe | FileCheck --check-prefix=EXCLUDE %s +// RUN: ld.lld -shared --whole-archive %t.o %t.dir/exc.a -o %t.exe --exclude-libs foo,bar,exc.a +// RUN: llvm-readobj -dyn-symbols %t.exe | FileCheck --check-prefix=EXCLUDE %s + +// RUN: ld.lld -shared --whole-archive %t.o %t.dir/exc.a -o %t.exe --exclude-libs=ALL +// RUN: llvm-readobj -dyn-symbols %t.exe | FileCheck --check-prefix=EXCLUDE %s + // DEFAULT: Name: fn // EXCLUDE-NOT: Name: fn diff --git a/test/ELF/executable-undefined-ignoreall.s b/test/ELF/executable-undefined-ignoreall.s new file mode 100644 index 000000000000..44f83a687ee2 --- /dev/null +++ b/test/ELF/executable-undefined-ignoreall.s @@ -0,0 +1,13 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +# RUN: ld.lld %t -o %tout --unresolved-symbols=ignore-all -pie +# RUN: llvm-readobj -r %tout | FileCheck %s + +# CHECK: Relocations [ +# CHECK-NEXT: Section ({{.*}}) .rela.plt { +# CHECK-NEXT: 0x2018 R_X86_64_JUMP_SLOT foo 0x0 +# CHECK-NEXT: } +# CHECK-NEXT: ] + +_start: +callq foo@PLT diff --git a/test/ELF/executable-undefined-protected-ignoreall.s b/test/ELF/executable-undefined-protected-ignoreall.s new file mode 100644 index 000000000000..37911791e124 --- /dev/null +++ b/test/ELF/executable-undefined-protected-ignoreall.s @@ -0,0 +1,8 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +# RUN: not ld.lld %t -o %tout --unresolved-symbols=ignore-all -pie 2>&1 | FileCheck %s +# CHECK: error: undefined symbol: foo + +.protected foo +_start: +callq foo@PLT diff --git a/test/ELF/file-access.s b/test/ELF/file-access.s new file mode 100644 index 000000000000..5a9e53b11140 --- /dev/null +++ b/test/ELF/file-access.s @@ -0,0 +1,13 @@ +# REQUIRES: x86, shell + +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: ld.lld -r %t.o -o %t1.o +# RUN: [ ! -x %t1.o ] +# RUN: ld.lld -shared %t.o -o %t2.so +# RUN: [ -x %t2.so ] +# RUN: ld.lld %t.o -o %t3 +# RUN: [ -x %t3 ] + +.global _start +_start: + nop diff --git a/test/ELF/fill-trap.s b/test/ELF/fill-trap.s new file mode 100644 index 000000000000..001b904a7790 --- /dev/null +++ b/test/ELF/fill-trap.s @@ -0,0 +1,25 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +# RUN: ld.lld %t -o %t2 +# RUN: llvm-readobj -program-headers %t2 | FileCheck %s +# RUN: od -Ax -x -N16 -j0x1ff0 %t2 | FileCheck %s -check-prefix=FILL + +# CHECK: ProgramHeader { +# CHECK: Type: PT_LOAD +# CHECK: Offset: 0x1000 +# CHECK-NEXT: VirtualAddress: +# CHECK-NEXT: PhysicalAddress: +# CHECK-NEXT: FileSize: 4096 +# CHECK-NEXT: MemSize: +# CHECK-NEXT: Flags [ +# CHECK-NEXT: PF_R +# CHECK-NEXT: PF_X +# CHECK-NEXT: ] + +## Check that executable page is filled with traps at its end. +# FILL: 001ff0 cccc cccc cccc cccc cccc cccc cccc cccc + +.globl _start +_start: + nop diff --git a/test/ELF/filter.s b/test/ELF/filter.s index fa8e5267b18b..4c9104a32510 100644 --- a/test/ELF/filter.s +++ b/test/ELF/filter.s @@ -2,10 +2,14 @@ # RUN: ld.lld %t.o -shared -F foo.so -F boo.so -o %t1 # RUN: llvm-readobj --dynamic-table %t1 | FileCheck %s -# Test alias. +# Test alias #1. # RUN: ld.lld %t.o -shared --filter=foo.so --filter=boo.so -o %t2 # RUN: llvm-readobj --dynamic-table %t2 | FileCheck %s +# Test alias #2. +# RUN: ld.lld %t.o -shared --filter foo.so --filter boo.so -o %t3 +# RUN: llvm-readobj --dynamic-table %t3 | FileCheck %s + # CHECK: DynamicSection [ # CHECK-NEXT: Tag Type Name/Value # CHECK-NEXT: 0x000000007FFFFFFF FILTER Filter library: [foo.so] diff --git a/test/ELF/format-binary-non-ascii.s b/test/ELF/format-binary-non-ascii.s new file mode 100644 index 000000000000..5a3ad960c30e --- /dev/null +++ b/test/ELF/format-binary-non-ascii.s @@ -0,0 +1,15 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t£.o + +# RUN: ld.lld -o %t.elf %t£.o --format=binary %t£.o +# RUN: llvm-readobj -symbols %t.elf | FileCheck %s + +# CHECK: Name: _binary_{{[a-zA-Z0-9_]+}}test_ELF_Output_format_binary_non_ascii_s_tmp___o_start +# CHECK: Name: _binary_{{[a-zA-Z0-9_]+}}test_ELF_Output_format_binary_non_ascii_s_tmp___o_end +# CHECK: Name: _binary_{{[a-zA-Z0-9_]+}}test_ELF_Output_format_binary_non_ascii_s_tmp___o_size + +.text +.align 4 +.globl _start +_start: + nop diff --git a/test/ELF/gc-collect-undefined.s b/test/ELF/gc-collect-undefined.s new file mode 100644 index 000000000000..7ade554aef13 --- /dev/null +++ b/test/ELF/gc-collect-undefined.s @@ -0,0 +1,19 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +# RUN: ld.lld %t -o %tout --gc-sections -shared +# RUN: llvm-nm -D %tout | FileCheck %s + +# CHECK-NOT: qux +# CHECK: bar +# CHECK-NOT: qux + + .global foo,bar,qux + .local baz + + .section .data.foo,"aw",%progbits +foo: + .dc.a bar + + .section .bata.baz,"aw",%progbits +baz: + .dc.a qux diff --git a/test/ELF/gc-merge-local-sym.s b/test/ELF/gc-merge-local-sym.s index a4540af4d9cc..b02a3a4e4762 100644 --- a/test/ELF/gc-merge-local-sym.s +++ b/test/ELF/gc-merge-local-sym.s @@ -15,7 +15,7 @@ // CHECK-NEXT: Link: 0 // CHECK-NEXT: Info: 0 // CHECK-NEXT: AddressAlignment: 1 -// CHECK-NEXT: EntrySize: 0 +// CHECK-NEXT: EntrySize: 1 // CHECK-NEXT: SectionData ( // CHECK-NEXT: 0000: 61626300 |abc.| // CHECK-NEXT: ) diff --git a/test/ELF/gc-sections-linker-defined-symbol.s b/test/ELF/gc-sections-linker-defined-symbol.s new file mode 100644 index 000000000000..796f7b363559 --- /dev/null +++ b/test/ELF/gc-sections-linker-defined-symbol.s @@ -0,0 +1,18 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld %t.o -o %t.so --gc-sections -shared +# RUN: llvm-readobj --dyn-symbols %t.so | FileCheck %s + +# CHECK: Name: _end@ +# CHECK-NEXT: Value: +# CHECK-NEXT: Size: +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: None +# CHECK-NEXT: Other: +# CHECK-NEXT: Section: .dynamic + + .data + .globl g + g: + .quad _end diff --git a/test/ELF/gc-sections-merge-addend.s b/test/ELF/gc-sections-merge-addend.s index 1c1f6ee2389b..8595f5802be5 100644 --- a/test/ELF/gc-sections-merge-addend.s +++ b/test/ELF/gc-sections-merge-addend.s @@ -16,7 +16,7 @@ // CHECK-NEXT: Link: 0 // CHECK-NEXT: Info: 0 // CHECK-NEXT: AddressAlignment: 1 -// CHECK-NEXT: EntrySize: 0 +// CHECK-NEXT: EntrySize: 1 // CHECK-NEXT: SectionData ( // CHECK-NEXT: 0000: 62617200 |bar.| // CHECK-NEXT: ) diff --git a/test/ELF/gc-sections-merge-implicit-addend.s b/test/ELF/gc-sections-merge-implicit-addend.s index c725e294a187..8a7c804a830a 100644 --- a/test/ELF/gc-sections-merge-implicit-addend.s +++ b/test/ELF/gc-sections-merge-implicit-addend.s @@ -16,7 +16,7 @@ // CHECK-NEXT: Link: 0 // CHECK-NEXT: Info: 0 // CHECK-NEXT: AddressAlignment: 1 -// CHECK-NEXT: EntrySize: 0 +// CHECK-NEXT: EntrySize: 1 // CHECK-NEXT: SectionData ( // CHECK-NEXT: 0000: 62617200 |bar.| // CHECK-NEXT: ) diff --git a/test/ELF/gc-sections-merge.s b/test/ELF/gc-sections-merge.s index d7b3eaeca751..ef2688659871 100644 --- a/test/ELF/gc-sections-merge.s +++ b/test/ELF/gc-sections-merge.s @@ -18,7 +18,7 @@ // CHECK-NEXT: Link: 0 // CHECK-NEXT: Info: 0 // CHECK-NEXT: AddressAlignment: 1 -// CHECK-NEXT: EntrySize: 0 +// CHECK-NEXT: EntrySize: 1 // CHECK-NEXT: SectionData ( // CHECK-NEXT: 0000: 666F6F00 62617200 |foo.bar.| // CHECK-NEXT: ) @@ -36,7 +36,7 @@ // GC-NEXT: Link: 0 // GC-NEXT: Info: 0 // GC-NEXT: AddressAlignment: 1 -// GC-NEXT: EntrySize: 0 +// GC-NEXT: EntrySize: 1 // GC-NEXT: SectionData ( // GC-NEXT: 0000: 666F6F00 |foo.| // GC-NEXT: ) diff --git a/test/ELF/gc-sections-print.s b/test/ELF/gc-sections-print.s index 59177a65367e..e05824177c1f 100644 --- a/test/ELF/gc-sections-print.s +++ b/test/ELF/gc-sections-print.s @@ -5,6 +5,12 @@ # PRINT: removing unused section from '.text.x' in file # PRINT-NEXT: removing unused section from '.text.y' in file +# RUN: ld.lld %t --gc-sections --print-gc-sections --no-print-gc-sections -o %t2 >& %t.log +# RUN: echo >> %t.log +# RUN: FileCheck -check-prefix=NOPRINT %s < %t.log + +# NOPRINT-NOT: removing + .globl _start .protected a, x, y _start: diff --git a/test/ELF/gc-sections-shared.s b/test/ELF/gc-sections-shared.s index efb21faee6bd..2976213e910a 100644 --- a/test/ELF/gc-sections-shared.s +++ b/test/ELF/gc-sections-shared.s @@ -1,12 +1,18 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/gc-sections-shared.s -o %t3.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/gc-sections-shared2.s -o %t4.o # RUN: ld.lld -shared %t2.o -o %t2.so +# RUN: ld.lld -shared %t3.o -o %t3.so +# RUN: ld.lld -shared %t4.o -o %t4.so # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o -# RUN: ld.lld --gc-sections --export-dynamic-symbol foo -o %t %t.o --as-needed %t2.so +# RUN: ld.lld --gc-sections --export-dynamic-symbol foo -o %t %t.o --as-needed %t2.so %t3.so %t4.so # RUN: llvm-readobj --dynamic-table --dyn-symbols %t | FileCheck %s # This test the property that we have a needed line for every undefined. -# It would also be OK to drop bar2 and the need for the .so +# It would also be OK to keep bar2 and the need for %t2.so +# At the same time, weak symbols should not cause adding DT_NEEDED; +# this case is checked with symbol qux and %t4.so. # CHECK: DynamicSymbols [ # CHECK-NEXT: Symbol { @@ -19,7 +25,16 @@ # CHECK-NEXT: Section: Undefined (0x0) # CHECK-NEXT: } # CHECK-NEXT: Symbol { -# CHECK-NEXT: Name: bar2 +# CHECK-NEXT: Name: bar +# CHECK-NEXT: Value: +# CHECK-NEXT: Size: +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: +# CHECK-NEXT: Other: +# CHECK-NEXT: Section: .text +# CHECK-NEXT: } +# CHECK-NEXT: Symbol { +# CHECK-NEXT: Name: baz # CHECK-NEXT: Value: # CHECK-NEXT: Size: # CHECK-NEXT: Binding: Global @@ -36,9 +51,76 @@ # CHECK-NEXT: Other: # CHECK-NEXT: Section: .text # CHECK-NEXT: } +# CHECK-NEXT: Symbol { +# CHECK-NEXT: Name: qux +# CHECK-NEXT: Value: +# CHECK-NEXT: Size: +# CHECK-NEXT: Binding: Weak +# CHECK-NEXT: Type: +# CHECK-NEXT: Other: +# CHECK-NEXT: Section: Undefined +# CHECK-NEXT: } # CHECK-NEXT: ] -# CHECK: NEEDED Shared library: [{{.*}}.so] +# CHECK-NOT: NEEDED +# CHECK: NEEDED Shared library: [{{.*}}3.so] +# CHECK-NOT: NEEDED + +# Test with %t.o at the end too. +# RUN: ld.lld --gc-sections --export-dynamic-symbol foo -o %t --as-needed %t2.so %t3.so %t4.so %t.o +# RUN: llvm-readobj --dynamic-table --dyn-symbols %t | FileCheck --check-prefix=CHECK2 %s + +# CHECK2: DynamicSymbols [ +# CHECK2-NEXT: Symbol { +# CHECK2-NEXT: Name: +# CHECK2-NEXT: Value: +# CHECK2-NEXT: Size: +# CHECK2-NEXT: Binding: Local +# CHECK2-NEXT: Type: +# CHECK2-NEXT: Other: +# CHECK2-NEXT: Section: Undefined (0x0) +# CHECK2-NEXT: } +# CHECK2-NEXT: Symbol { +# CHECK2-NEXT: Name: bar +# CHECK2-NEXT: Value: +# CHECK2-NEXT: Size: +# CHECK2-NEXT: Binding: Global +# CHECK2-NEXT: Type: +# CHECK2-NEXT: Other: +# CHECK2-NEXT: Section: .text +# CHECK2-NEXT: } +# CHECK2-NEXT: Symbol { +# CHECK2-NEXT: Name: baz +# CHECK2-NEXT: Value: +# CHECK2-NEXT: Size: +# CHECK2-NEXT: Binding: Global +# CHECK2-NEXT: Type: +# CHECK2-NEXT: Other: +# CHECK2-NEXT: Section: Undefined +# CHECK2-NEXT: } +# CHECK2-NEXT: Symbol { +# CHECK2-NEXT: Name: qux +# CHECK2-NEXT: Value: +# CHECK2-NEXT: Size: +# CHECK2-NEXT: Binding: Weak +# CHECK2-NEXT: Type: +# CHECK2-NEXT: Other: +# CHECK2-NEXT: Section: Undefined +# CHECK2-NEXT: } +# CHECK2-NEXT: Symbol { +# CHECK2-NEXT: Name: foo +# CHECK2-NEXT: Value: +# CHECK2-NEXT: Size: +# CHECK2-NEXT: Binding: Global +# CHECK2-NEXT: Type: +# CHECK2-NEXT: Other: +# CHECK2-NEXT: Section: .text +# CHECK2-NEXT: } +# CHECK2-NEXT: ] + +# CHECK2-NOT: NEEDED +# CHECK2: NEEDED Shared library: [{{.*}}3.so] +# CHECK2-NOT: NEEDED .section .text.foo, "ax" .globl foo @@ -52,7 +134,10 @@ ret .section .text._start, "ax" .globl _start +.weak qux _start: +call baz +call qux ret .section .text.unused, "ax" diff --git a/test/ELF/gc-sections-undefined.s b/test/ELF/gc-sections-undefined.s new file mode 100644 index 000000000000..e1ce9c739738 --- /dev/null +++ b/test/ELF/gc-sections-undefined.s @@ -0,0 +1,10 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +# RUN: ld.lld %t -o %t1 --gc-sections --undefined=foo +# RUN: llvm-readobj -t %t1 | FileCheck %s + +# CHECK: foo + +.section .foo,"ax" +.global foo +foo: diff --git a/test/ELF/gdb-index-base-addr.s b/test/ELF/gdb-index-base-addr.s new file mode 100644 index 000000000000..3871f8fc92e9 --- /dev/null +++ b/test/ELF/gdb-index-base-addr.s @@ -0,0 +1,70 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o +# RUN: ld.lld --gdb-index %t1.o -o %t +# RUN: llvm-dwarfdump -gdb-index %t | FileCheck %s + +# CHECK: .gnu_index contents: +# CHECK: Address area offset = 0x28, has 2 entries: +# CHECK-NEXT: Low/High address = [0x201000, 0x201001) (Size: 0x1), CU id = 0 +# CHECK-NEXT: Low/High address = [0x201003, 0x201006) (Size: 0x3), CU id = 0 + +.text +.globl foo +.type foo,@function +foo: +.Lfunc_begin0: + nop +.Ltmp0: + nop + nop +.Ltmp1: + nop + nop + nop +.Ltmp2: + +.section .debug_abbrev,"",@progbits +.byte 1 # Abbreviation Code +.byte 17 # DW_TAG_compile_unit +.byte 0 # DW_CHILDREN_no +.byte 37 # DW_AT_producer +.byte 14 # DW_FORM_strp +.byte 19 # DW_AT_language +.byte 5 # DW_FORM_data2 +.byte 3 # DW_AT_name +.byte 14 # DW_FORM_strp +.byte 16 # DW_AT_stmt_list +.byte 23 # DW_FORM_sec_offset +.byte 27 # DW_AT_comp_dir +.byte 14 # DW_FORM_strp +.byte 17 # DW_AT_low_pc +.byte 1 # DW_FORM_addr +.byte 85 # DW_AT_ranges +.byte 23 # DW_FORM_sec_offset +.byte 0 # EOM(1) +.byte 0 # EOM(2) +.byte 0 # EOM(3) + +.section .debug_info,"",@progbits +.Lcu_begin0: +.long 38 # Length of Unit +.short 4 # DWARF version number +.long .debug_abbrev # Offset Into Abbrev. Section +.byte 8 # Address Size (in bytes) +.byte 1 # Abbrev [1] 0xb:0x1f DW_TAG_compile_unit +.long 0 # DW_AT_producer +.short 4 # DW_AT_language +.long 0 # DW_AT_name +.long 0 # DW_AT_stmt_list +.long 0 # DW_AT_comp_dir +.quad .Lfunc_begin0 # DW_AT_low_pc +.long .Ldebug_ranges0 # DW_AT_ranges + +.section .debug_ranges,"",@progbits +.Ldebug_ranges0: + .quad .Lfunc_begin0-.Lfunc_begin0 + .quad .Ltmp0-.Lfunc_begin0 + .quad .Ltmp1-.Lfunc_begin0 + .quad .Ltmp2-.Lfunc_begin0 + .quad 0 + .quad 0 diff --git a/test/ELF/gdb-index-dup-types.s b/test/ELF/gdb-index-dup-types.s index e0bed33eed4d..f5df00c453cc 100644 --- a/test/ELF/gdb-index-dup-types.s +++ b/test/ELF/gdb-index-dup-types.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o # RUN: ld.lld --gdb-index %t.o -o %t -# RUN: llvm-dwarfdump -debug-dump=gdb_index %t | FileCheck %s +# RUN: llvm-dwarfdump -gdb-index %t | FileCheck %s ## Testcase is based on output produced by gcc version 5.4.1 20160904 ## it has duplicate entries in .debug_gnu_pubtypes which seems to be diff --git a/test/ELF/gdb-index-empty.s b/test/ELF/gdb-index-empty.s index 0158357c9bfd..b5b403636290 100644 --- a/test/ELF/gdb-index-empty.s +++ b/test/ELF/gdb-index-empty.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux -o %t %s # RUN: ld.lld --gdb-index --gc-sections -o %t2 %t -# RUN: llvm-dwarfdump -debug-dump=gdb_index %t2 | FileCheck %s +# RUN: llvm-dwarfdump -gdb-index %t2 | FileCheck %s # CHECK: Address area offset = 0x28, has 0 entries: @@ -74,7 +74,7 @@ _start: .quad .Lfunc_begin0 # DW_AT_low_pc .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc .byte 1 # DW_AT_frame_base - .byte 87 + .byte 87 .long 0 # DW_AT_name .byte 1 # DW_AT_decl_file .byte 1 # DW_AT_decl_line diff --git a/test/ELF/gdb-index-gc-sections.s b/test/ELF/gdb-index-gc-sections.s index 58c47ae5e987..6016e9ccdd07 100644 --- a/test/ELF/gdb-index-gc-sections.s +++ b/test/ELF/gdb-index-gc-sections.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux -o %t %s # RUN: ld.lld --gdb-index --gc-sections -o %t2 %t -# RUN: llvm-dwarfdump -debug-dump=gdb_index %t2 | FileCheck %s +# RUN: llvm-dwarfdump -gdb-index %t2 | FileCheck %s # CHECK: Address area offset = 0x28, has 1 entries: # CHECK-NEXT: Low/High address = [0x201000, 0x201001) (Size: 0x1), CU id = 0 diff --git a/test/ELF/gdb-index-noranges.s b/test/ELF/gdb-index-noranges.s new file mode 100644 index 000000000000..29ba91eb5a75 --- /dev/null +++ b/test/ELF/gdb-index-noranges.s @@ -0,0 +1,49 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o + +## Input is reduced from following code and invocation: +## clang++ -gsplit-dwarf -c test.ii -o test.s -S +## clang version: 6.0.0 (trunk 318293) +## +## test.ii: +## int a; +## +## Debug information does not contain any address ranges. +## We crashed in that case. Check we don't. +# RUN: ld.lld --gdb-index %t1.o -o %t + +.section .debug_str,"MS",@progbits,1 +.Lskel_string0: + .asciz "t.dwo" +.Lskel_string1: + .asciz "path" + +.section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 0 # DW_CHILDREN_no + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .ascii "\260B" # DW_AT_GNU_dwo_name + .byte 14 # DW_FORM_strp + .byte 27 # DW_AT_comp_dir + .byte 14 # DW_FORM_strp + .ascii "\261B" # DW_AT_GNU_dwo_id + .byte 7 # DW_FORM_data8 + .ascii "\263B" # DW_AT_GNU_addr_base + .byte 23 # DW_FORM_sec_offset + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + +.section .debug_info,"",@progbits + .long 32 # Length of Unit + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x19 DW_TAG_compile_unit + .long 0 # DW_AT_stmt_list + .long .Lskel_string0 # DW_AT_GNU_dwo_name + .long .Lskel_string1 # DW_AT_comp_dir + .quad -3824446529333676116 # DW_AT_GNU_dwo_id + .long 0 # DW_AT_GNU_addr_base diff --git a/test/ELF/gdb-index-ranges.s b/test/ELF/gdb-index-ranges.s index 2dd158ee4a0a..c41be114f005 100644 --- a/test/ELF/gdb-index-ranges.s +++ b/test/ELF/gdb-index-ranges.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o # RUN: ld.lld --gdb-index -e main %t.o -o %t -# RUN: llvm-dwarfdump -debug-dump=gdb_index %t | FileCheck %s +# RUN: llvm-dwarfdump -gdb-index %t | FileCheck %s # CHECK: .gnu_index contents: # CHECK: Address area offset = 0x28, has 2 entries: diff --git a/test/ELF/gdb-index-tls.s b/test/ELF/gdb-index-tls.s new file mode 100644 index 000000000000..0fd7b6115676 --- /dev/null +++ b/test/ELF/gdb-index-tls.s @@ -0,0 +1,91 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld --gdb-index -shared %t.o -o %t + +# This used to fail trying to compute R_X86_64_DTPOFF64 + + .section .tdata,"awT",@progbits +PrettyStackTraceHead: + .long 42 # 0x2a + + .section .debug_str,"MS",@progbits,1 + .asciz "" + + .section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 14 # DW_FORM_strp + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 14 # DW_FORM_strp + .ascii "\264B" # DW_AT_GNU_pubnames + .byte 25 # DW_FORM_flag_present + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 52 # DW_TAG_variable + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 73 # DW_AT_type + .byte 19 # DW_FORM_ref4 + .byte 63 # DW_AT_external + .byte 25 # DW_FORM_flag_present + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 2 # DW_AT_location + .byte 24 # DW_FORM_exprloc + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 3 # Abbreviation Code + .byte 36 # DW_TAG_base_type + .byte 0 # DW_CHILDREN_no + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 62 # DW_AT_encoding + .byte 11 # DW_FORM_data1 + .byte 11 # DW_AT_byte_size + .byte 11 # DW_FORM_data1 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) + + .section .debug_info,"",@progbits +.Lcu_begin0: + .long 56 # Length of Unit + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x31 DW_TAG_compile_unit + .long .debug_str # DW_AT_producer + .short 4 # DW_AT_language + .long .debug_str # DW_AT_name + .long .debug_line # DW_AT_stmt_list + .long .debug_str # DW_AT_comp_dir + # DW_AT_GNU_pubnames + .byte 2 # Abbrev [2] 0x1e:0x16 DW_TAG_variable + .long .debug_str # DW_AT_name + .long 52 # DW_AT_type + # DW_AT_external + .byte 1 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .byte 10 # DW_AT_location + .byte 14 + .quad PrettyStackTraceHead@DTPOFF + .byte 224 + .byte 3 # Abbrev [3] 0x34:0x7 DW_TAG_base_type + .long .debug_str # DW_AT_name + .byte 5 # DW_AT_encoding + .byte 4 # DW_AT_byte_size + .byte 0 # End Of Children Mark + + .section .debug_line,"",@progbits diff --git a/test/ELF/gdb-index.s b/test/ELF/gdb-index.s index e04845e022c3..8fea83d145fa 100644 --- a/test/ELF/gdb-index.s +++ b/test/ELF/gdb-index.s @@ -1,12 +1,12 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/gdb-index.s -o %t2.o -# RUN: ld.lld --gdb-index -e main %t1.o %t2.o -o %t -# RUN: llvm-dwarfdump -debug-dump=gdb_index %t | FileCheck %s +# RUN: ld.lld --gdb-index %t1.o %t2.o -o %t +# RUN: llvm-dwarfdump -gdb-index %t | FileCheck %s # RUN: llvm-objdump -d %t | FileCheck %s --check-prefix=DISASM # DISASM: Disassembly of section .text: -# DISASM: main: +# DISASM: entrypoint: # DISASM-CHECK: 201000: 90 nop # DISASM-CHECK: 201001: cc int3 # DISASM-CHECK: 201002: cc int3 @@ -24,25 +24,29 @@ # CHECK-NEXT: Low/High address = [0x201000, 0x201001) (Size: 0x1), CU id = 0 # CHECK-NEXT: Low/High address = [0x201004, 0x201006) (Size: 0x2), CU id = 1 # CHECK: Symbol table offset = 0x60, size = 1024, filled slots: -# CHECK-NEXT: 489: Name offset = 0x1d, CU vector offset = 0x0 -# CHECK-NEXT: String name: main, CU vector index: 0 -# CHECK-NEXT: 754: Name offset = 0x22, CU vector offset = 0x8 -# CHECK-NEXT: String name: int, CU vector index: 1 -# CHECK-NEXT: 956: Name offset = 0x26, CU vector offset = 0x14 +# CHECK-NEXT: 754: Name offset = 0x27, CU vector offset = 0x8 +# CHECK-NEXT: String name: int, CU vector index: 1 +# CHECK-NEXT: 822: Name offset = 0x1c, CU vector offset = 0x0 +# CHECK-NEXT: String name: entrypoint, CU vector index: 0 +# CHECK-NEXT: 956: Name offset = 0x2b, CU vector offset = 0x14 # CHECK-NEXT: String name: main2, CU vector index: 2 # CHECK: Constant pool offset = 0x2060, has 3 CU vectors: # CHECK-NEXT: 0(0x0): 0x30000000 # CHECK-NEXT: 1(0x8): 0x90000000 0x90000001 # CHECK-NEXT: 2(0x14): 0x30000001 +# RUN: ld.lld --gdb-index --no-gdb-index %t1.o %t2.o -o %t2 +# RUN: llvm-readobj -sections %t2 | FileCheck -check-prefix=NOGDB %s +# NOGDB-NOT: Name: .gdb_index + ## The following section contents are created by this using gcc 7.1.0: -## echo 'int main() { return 0; }' | gcc -gsplit-dwarf -xc++ -S -o- - +## echo 'int entrypoint() { return 0; }' | gcc -gsplit-dwarf -xc++ -S -o- - .text .Ltext0: -.globl main -.type main, @function -main: +.globl entrypoint +.type entrypoint, @function +entrypoint: nop .Letext0: @@ -98,7 +102,7 @@ main: .long 0x33 .long 0x18 .byte 0x30 -.string "main" +.string "entrypoint" .long 0 .section .debug_gnu_pubtypes,"",@progbits diff --git a/test/ELF/global-offset-table-position-aarch64.s b/test/ELF/global-offset-table-position-aarch64.s index 624e9b516fed..68bc4a4254ed 100644 --- a/test/ELF/global-offset-table-position-aarch64.s +++ b/test/ELF/global-offset-table-position-aarch64.s @@ -1,5 +1,5 @@ // RUN: llvm-mc -filetype=obj -triple=aarch64-linux-gnu %s -o %t -// RUN: ld.lld -shared %t -o %t2 +// RUN: ld.lld --hash-style=sysv -shared %t -o %t2 // RUN: llvm-readobj -t %t2 | FileCheck %s // REQUIRES: aarch64 .globl a diff --git a/test/ELF/global-offset-table-position-arm.s b/test/ELF/global-offset-table-position-arm.s index 781d8ce5222f..19619b2cc9e8 100644 --- a/test/ELF/global-offset-table-position-arm.s +++ b/test/ELF/global-offset-table-position-arm.s @@ -1,5 +1,5 @@ // RUN: llvm-mc -filetype=obj -triple=armv7a-linux-gnueabihf %s -o %t -// RUN: ld.lld -shared %t -o %t2 +// RUN: ld.lld --hash-style=sysv -shared %t -o %t2 // RUN: llvm-readobj -t %t2 | FileCheck %s // REQUIRES: arm diff --git a/test/ELF/global-offset-table-position-i386.s b/test/ELF/global-offset-table-position-i386.s index 907105edcff0..9f778e1efb50 100644 --- a/test/ELF/global-offset-table-position-i386.s +++ b/test/ELF/global-offset-table-position-i386.s @@ -1,5 +1,5 @@ // RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %s -o %t -// RUN: ld.lld -shared %t -o %t2 +// RUN: ld.lld --hash-style=sysv -shared %t -o %t2 // RUN: llvm-readobj -t %t2 | FileCheck %s // REQUIRES: x86 diff --git a/test/ELF/global-offset-table-position.s b/test/ELF/global-offset-table-position.s index b3317c7edd8b..f1195b2cf674 100644 --- a/test/ELF/global-offset-table-position.s +++ b/test/ELF/global-offset-table-position.s @@ -1,5 +1,5 @@ // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t -// RUN: ld.lld -shared %t -o %t2 +// RUN: ld.lld --hash-style=sysv -shared %t -o %t2 // RUN: llvm-readobj -t %t2 | FileCheck %s // REQUIRES: x86 diff --git a/test/ELF/global_offset_table_shared.s b/test/ELF/global_offset_table_shared.s index 1ebc0110d4d7..03af02e5805e 100644 --- a/test/ELF/global_offset_table_shared.s +++ b/test/ELF/global_offset_table_shared.s @@ -1,5 +1,5 @@ // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t -// RUN: ld.lld -shared %t -o %t2 +// RUN: ld.lld --hash-style=sysv -shared %t -o %t2 // RUN: llvm-readobj -t %t2 | FileCheck %s .long _GLOBAL_OFFSET_TABLE_ - . diff --git a/test/ELF/gnu-hash-table-copy.s b/test/ELF/gnu-hash-table-copy.s new file mode 100644 index 000000000000..9d91163258ea --- /dev/null +++ b/test/ELF/gnu-hash-table-copy.s @@ -0,0 +1,30 @@ +# REQUIRES: x86 + +# RUN: echo ".global foo; .type foo, @object; .size foo, 4; foo:; .long 0" > %t.s +# RUN: echo ".global bar; .type bar, @object; .size bar, 4; bar:; .long 0" >> %t.s +# RUN: echo ".global zed; .type zed, @function; zed:" >> %t.s +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t.s -o %t1.o +# RUN: ld.lld %t1.o -o %t1.so -shared + +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t2.o +# RUN: ld.lld --hash-style=gnu %t2.o %t1.so -o %t2 + +# RUN: llvm-readelf --symbols --gnu-hash-table %t2 | FileCheck %s + +# CHECK: Symbol table '.dynsym' contains 4 entries: +# CHECK-NEXT: Num: Value Size Type Bind Vis Ndx Name +# CHECK-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND @ +# CHECK-NEXT: 1: 0000000000000000 0 OBJECT GLOBAL DEFAULT UND foo@ +# CHECK-DAG: : {{.*}} 4 OBJECT GLOBAL DEFAULT {{.*}} bar@ +# CHECK-DAG: : {{.*}} 0 FUNC GLOBAL DEFAULT UND zed@ + +# CHECK: First Hashed Symbol Index: 2 + +.global _start +_start: + +.quad bar +.quad zed + +.data +.quad foo diff --git a/test/ELF/gnu-hash-table-many.s b/test/ELF/gnu-hash-table-many.s new file mode 100644 index 000000000000..ab35a07981e7 --- /dev/null +++ b/test/ELF/gnu-hash-table-many.s @@ -0,0 +1,55 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld -hash-style=gnu %t.o -o %t.so -shared +# RUN: llvm-readelf --gnu-hash-table %t.so | FileCheck %s + +# CHECK: Num Buckets: 4 + +.global sym1 +sym1: + +.global sym2 +sym2: + +.global sym3 +sym3: + +.global sym4 +sym4: + +.global sym5 +sym5: + +.global sym6 +sym6: + +.global sym7 +sym7: + +.global sym8 +sym8: + +.global sym9 +sym9: + +.global sym10 +sym10: + +.global sym11 +sym11: + +.global sym12 +sym12: + +.global sym13 +sym13: + +.global sym14 +sym14: + +.global sym15 +sym15: + +.global sym16 +sym16: diff --git a/test/ELF/gnu-hash-table-rwsegment.s b/test/ELF/gnu-hash-table-rwsegment.s new file mode 100644 index 000000000000..b1a50fbde3a1 --- /dev/null +++ b/test/ELF/gnu-hash-table-rwsegment.s @@ -0,0 +1,20 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld -shared -hash-style=gnu --no-rosegment -o %t.so %t.o +# RUN: llvm-readobj -gnu-hash-table %t.so | FileCheck %s + +# CHECK: GnuHashTable { +# CHECK-NEXT: Num Buckets: 1 +# CHECK-NEXT: First Hashed Symbol Index: 1 +# CHECK-NEXT: Num Mask Words: 1 +# CHECK-NEXT: Shift Count: 6 +# CHECK-NEXT: Bloom Filter: [0x400000000004204] +# CHECK-NEXT: Buckets: [1] +# CHECK-NEXT: Values: [0xB8860BA, 0xB887389] +# CHECK-NEXT: } + +.globl foo, bar +foo: +bar: + ret diff --git a/test/ELF/gnu-hash-table.s b/test/ELF/gnu-hash-table.s index 0e37574aaa7c..fa68ba250131 100644 --- a/test/ELF/gnu-hash-table.s +++ b/test/ELF/gnu-hash-table.s @@ -1,15 +1,34 @@ # REQUIRES: x86,ppc -# RUN: echo ".globl foo" > %te.s +# RUN: echo ".globl foo; .data; .dc.a foo" > %te.s # RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %te.s -o %te-i386.o # RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %s -o %t-i386.o # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t-x86_64.o # RUN: llvm-mc -filetype=obj -triple=powerpc64-pc-linux %s -o %t-ppc64.o +# RUN: echo ".global zed; zed:" > %t2.s +# RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %t2.s -o %t2-i386.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t2.s -o %t2-x86_64.o +# RUN: llvm-mc -filetype=obj -triple=powerpc64-pc-linux %t2.s -o %t2-ppc64.o + +# RUN: rm -f %t2-i386.a %t2-x86_64.a %t2-ppc64.a +# RUN: llvm-ar rc %t2-i386.a %t2-i386.o +# RUN: llvm-ar rc %t2-x86_64.a %t2-x86_64.o +# RUN: llvm-ar rc %t2-ppc64.a %t2-ppc64.o + +# RUN: echo ".global xyz; xyz:" > %t3.s +# RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %t3.s -o %t3-i386.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t3.s -o %t3-x86_64.o +# RUN: llvm-mc -filetype=obj -triple=powerpc64-pc-linux %t3.s -o %t3-ppc64.o + +# RUN: ld.lld -shared %t3-i386.o -o %t3-i386.so +# RUN: ld.lld -shared %t3-x86_64.o -o %t3-x86_64.so +# RUN: ld.lld -shared %t3-ppc64.o -o %t3-ppc64.so + # RUN: ld.lld -shared --hash-style=gnu -o %te-i386.so %te-i386.o -# RUN: ld.lld -shared -hash-style=gnu -o %t-i386.so %t-i386.o -# RUN: ld.lld -shared -hash-style=gnu -o %t-x86_64.so %t-x86_64.o -# RUN: ld.lld -shared --hash-style both -o %t-ppc64.so %t-ppc64.o +# RUN: ld.lld -shared -hash-style=gnu -o %t-i386.so %t-i386.o %t2-i386.a %t3-i386.so +# RUN: ld.lld -shared -hash-style=gnu -o %t-x86_64.so %t-x86_64.o %t2-x86_64.a %t3-x86_64.so +# RUN: ld.lld -shared --hash-style both -o %t-ppc64.so %t-ppc64.o %t2-ppc64.a %t3-ppc64.so # RUN: llvm-readobj -dyn-symbols -gnu-hash-table %te-i386.so \ # RUN: | FileCheck %s -check-prefix=EMPTY @@ -70,6 +89,16 @@ # I386: Section: Undefined # I386: } # I386: Symbol { +# I386: Name: xyz@ +# I386: Binding: Global +# I386: Section: Undefined +# I386: } +# I386: Symbol { +# I386: Name: zed@ +# I386: Binding: Weak +# I386: Section: Undefined +# I386: } +# I386: Symbol { # I386: Name: bar@ # I386: Binding: Global # I386: Section: .text @@ -82,11 +111,11 @@ # I386: ] # I386: GnuHashTable { # I386-NEXT: Num Buckets: 1 -# I386-NEXT: First Hashed Symbol Index: 2 +# I386-NEXT: First Hashed Symbol Index: 4 # I386-NEXT: Num Mask Words: 1 # I386-NEXT: Shift Count: 5 # I386-NEXT: Bloom Filter: [0x14000220] -# I386-NEXT: Buckets: [2] +# I386-NEXT: Buckets: [4] # I386-NEXT: Values: [0xB8860BA, 0xB887389] # I386-NEXT: } @@ -120,6 +149,16 @@ # X86_64: Section: Undefined # X86_64: } # X86_64: Symbol { +# X86_64: Name: xyz@ +# X86_64: Binding: Global +# X86_64: Section: Undefined +# X86_64: } +# X86_64: Symbol { +# X86_64: Name: zed@ +# X86_64: Binding: Weak +# X86_64: Section: Undefined +# X86_64: } +# X86_64: Symbol { # X86_64: Name: bar@ # X86_64: Binding: Global # X86_64: Section: .text @@ -132,11 +171,11 @@ # X86_64: ] # X86_64: GnuHashTable { # X86_64-NEXT: Num Buckets: 1 -# X86_64-NEXT: First Hashed Symbol Index: 2 +# X86_64-NEXT: First Hashed Symbol Index: 4 # X86_64-NEXT: Num Mask Words: 1 # X86_64-NEXT: Shift Count: 6 # X86_64-NEXT: Bloom Filter: [0x400000000004204] -# X86_64-NEXT: Buckets: [2] +# X86_64-NEXT: Buckets: [4] # X86_64-NEXT: Values: [0xB8860BA, 0xB887389] # X86_64-NEXT: } @@ -149,10 +188,10 @@ # PPC64-NEXT: Flags [ # PPC64-NEXT: SHF_ALLOC # PPC64-NEXT: ] -# PPC64-NEXT: Address: 0x228 -# PPC64-NEXT: Offset: 0x228 +# PPC64-NEXT: Address: +# PPC64-NEXT: Offset: # PPC64-NEXT: Size: 36 -# PPC64-NEXT: Link: 1 +# PPC64-NEXT: Link: # PPC64-NEXT: Info: 0 # PPC64-NEXT: AddressAlignment: 8 # PPC64-NEXT: EntrySize: 0 @@ -170,6 +209,16 @@ # PPC64: Section: Undefined # PPC64: } # PPC64: Symbol { +# PPC64: Name: xyz@ +# PPC64: Binding: Global +# PPC64: Section: Undefined +# PPC64: } +# PPC64: Symbol { +# PPC64: Name: zed@ +# PPC64: Binding: Weak +# PPC64: Section: Undefined +# PPC64: } +# PPC64: Symbol { # PPC64: Name: bar@ # PPC64: Binding: Global # PPC64: Section: .text @@ -182,14 +231,18 @@ # PPC64: ] # PPC64: GnuHashTable { # PPC64-NEXT: Num Buckets: 1 -# PPC64-NEXT: First Hashed Symbol Index: 2 +# PPC64-NEXT: First Hashed Symbol Index: 4 # PPC64-NEXT: Num Mask Words: 1 # PPC64-NEXT: Shift Count: 6 # PPC64-NEXT: Bloom Filter: [0x400000000004204] -# PPC64-NEXT: Buckets: [2] +# PPC64-NEXT: Buckets: [4] # PPC64-NEXT: Values: [0xB8860BA, 0xB887389] # PPC64-NEXT: } .globl foo,bar,baz foo: bar: +.weak zed +.global xyz +.data + .dc.a baz diff --git a/test/ELF/gnu-ifunc-dynsym.s b/test/ELF/gnu-ifunc-dynsym.s new file mode 100644 index 000000000000..fca15462dcb1 --- /dev/null +++ b/test/ELF/gnu-ifunc-dynsym.s @@ -0,0 +1,19 @@ +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +// RUN: ld.lld -static -export-dynamic %t.o -o %tout +// RUN: llvm-nm -U %tout | FileCheck %s +// REQUIRES: x86 + +// CHECK: __rela_iplt_end +// CHECK: __rela_iplt_start + +.text +.type foo STT_GNU_IFUNC +.globl foo +foo: + ret + +.globl _start +_start: + call foo + movl $__rela_iplt_start,%edx + movl $__rela_iplt_end,%edx diff --git a/test/ELF/gnu-ifunc-gotpcrel.s b/test/ELF/gnu-ifunc-gotpcrel.s index 2a5814a98bc2..b506ffa8c390 100644 --- a/test/ELF/gnu-ifunc-gotpcrel.s +++ b/test/ELF/gnu-ifunc-gotpcrel.s @@ -2,7 +2,7 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/gnu-ifunc-gotpcrel.s -o %t2.o # RUN: ld.lld -shared %t2.o -o %t2.so # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -# RUN: ld.lld %t.o %t2.so -o %t +# RUN: ld.lld --hash-style=sysv %t.o %t2.so -o %t # RUN: llvm-readobj -dyn-relocations %t | FileCheck %s # CHECK: Dynamic Relocations { diff --git a/test/ELF/gnu-ifunc-i386.s b/test/ELF/gnu-ifunc-i386.s index 21f1313a9b05..559e98a3e625 100644 --- a/test/ELF/gnu-ifunc-i386.s +++ b/test/ELF/gnu-ifunc-i386.s @@ -15,7 +15,7 @@ // CHECK-NEXT: Address: [[RELA:.*]] // CHECK-NEXT: Offset: 0xD4 // CHECK-NEXT: Size: 16 -// CHECK-NEXT: Link: 6 +// CHECK-NEXT: Link: 0 // CHECK-NEXT: Info: 0 // CHECK-NEXT: AddressAlignment: 4 // CHECK-NEXT: EntrySize: 8 diff --git a/test/ELF/gnu-ifunc-plt-i386.s b/test/ELF/gnu-ifunc-plt-i386.s index 50f10c5fe6ca..243eff62fcbf 100644 --- a/test/ELF/gnu-ifunc-plt-i386.s +++ b/test/ELF/gnu-ifunc-plt-i386.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %S/Inputs/shared2-x86-64.s -o %t1.o // RUN: ld.lld %t1.o --shared -o %t.so // RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o -// RUN: ld.lld %t.so %t.o -o %tout +// RUN: ld.lld --hash-style=sysv %t.so %t.o -o %tout // RUN: llvm-objdump -d %tout | FileCheck %s --check-prefix=DISASM // RUN: llvm-objdump -s %tout | FileCheck %s --check-prefix=GOTPLT // RUN: llvm-readobj -r -dynamic-table %tout | FileCheck %s diff --git a/test/ELF/gnu-ifunc-plt.s b/test/ELF/gnu-ifunc-plt.s index cf46380d3894..88a09931853c 100644 --- a/test/ELF/gnu-ifunc-plt.s +++ b/test/ELF/gnu-ifunc-plt.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/shared2-x86-64.s -o %t1.o // RUN: ld.lld %t1.o --shared -o %t.so // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o -// RUN: ld.lld %t.so %t.o -o %tout +// RUN: ld.lld --hash-style=sysv %t.so %t.o -o %tout // RUN: llvm-objdump -d %tout | FileCheck %s --check-prefix=DISASM // RUN: llvm-objdump -s %tout | FileCheck %s --check-prefix=GOTPLT // RUN: llvm-readobj -r -dynamic-table %tout | FileCheck %s diff --git a/test/ELF/gnu-ifunc-shared.s b/test/ELF/gnu-ifunc-shared.s index aee870c28e11..bde6807e4b43 100644 --- a/test/ELF/gnu-ifunc-shared.s +++ b/test/ELF/gnu-ifunc-shared.s @@ -1,6 +1,6 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o -// RUN: ld.lld --shared -o %t.so %t.o +// RUN: ld.lld --hash-style=sysv --shared -o %t.so %t.o // RUN: llvm-objdump -d %t.so | FileCheck %s --check-prefix=DISASM // RUN: llvm-readobj -r %t.so | FileCheck %s diff --git a/test/ELF/gnu-ifunc.s b/test/ELF/gnu-ifunc.s index f86f0300baaf..17883a3209f5 100644 --- a/test/ELF/gnu-ifunc.s +++ b/test/ELF/gnu-ifunc.s @@ -15,7 +15,7 @@ // CHECK-NEXT: Address: [[RELA:.*]] // CHECK-NEXT: Offset: 0x158 // CHECK-NEXT: Size: 48 -// CHECK-NEXT: Link: 6 +// CHECK-NEXT: Link: 0 // CHECK-NEXT: Info: 0 // CHECK-NEXT: AddressAlignment: 8 // CHECK-NEXT: EntrySize: 24 diff --git a/test/ELF/got-aarch64.s b/test/ELF/got-aarch64.s index ef6943881edc..f46946c9f4aa 100644 --- a/test/ELF/got-aarch64.s +++ b/test/ELF/got-aarch64.s @@ -1,5 +1,5 @@ // RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-linux %s -o %t.o -// RUN: ld.lld -shared %t.o -o %t.so +// RUN: ld.lld --hash-style=sysv -shared %t.o -o %t.so // RUN: llvm-readobj -s -r %t.so | FileCheck %s // RUN: llvm-objdump -d %t.so | FileCheck --check-prefix=DISASM %s // REQUIRES: aarch64 diff --git a/test/ELF/got.s b/test/ELF/got.s index 57c1baddfd0c..f67ea13d3f4e 100644 --- a/test/ELF/got.s +++ b/test/ELF/got.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o // RUN: ld.lld -shared %t2.o -o %t2.so -// RUN: ld.lld %t.o %t2.so -o %t +// RUN: ld.lld --hash-style=sysv %t.o %t2.so -o %t // RUN: llvm-readobj -s -r %t | FileCheck %s // RUN: llvm-objdump -d %t | FileCheck --check-prefix=DISASM %s // REQUIRES: x86 diff --git a/test/ELF/got32-i386-pie-rw.s b/test/ELF/got32-i386-pie-rw.s new file mode 100644 index 000000000000..18b019c2cc9d --- /dev/null +++ b/test/ELF/got32-i386-pie-rw.s @@ -0,0 +1,17 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o +# RUN: ld.lld %t.o -o %t -pie +# RUN: llvm-readelf -r -s %t | FileCheck %s + +# Unlike bfd and gold we accept this. + +# CHECK: .foobar PROGBITS 00001000 +# CHECK: .got PROGBITS [[GOT:[0-9a-z]*]] +# CHECK: [[GOT]] 00000008 R_386_RELATIVE +# CHECK: 00001002 00000008 R_386_RELATIVE +foo: + +.section .foobar, "awx" +.global _start +_start: + movl foo@GOT, %ebx diff --git a/test/ELF/got32-i386.s b/test/ELF/got32-i386.s index 468aaf1f0d53..00c7c0d6d553 100644 --- a/test/ELF/got32-i386.s +++ b/test/ELF/got32-i386.s @@ -20,4 +20,4 @@ _start: # CHECK: .got 00000004 0000000000012000 # RUN: not ld.lld %t.o -o %t -pie 2>&1 | FileCheck %s --check-prefix=ERR -# ERR: relocation R_386_GOT32 against 'foo' without base register can not be used when PIC enabled +# ERR: error: can't create dynamic relocation R_386_GOT32 against symbol: foo in readonly segment; recompile object files with -fPIC diff --git a/test/ELF/got32x-i386.s b/test/ELF/got32x-i386.s index 9a67d1997f2b..1311472cc061 100644 --- a/test/ELF/got32x-i386.s +++ b/test/ELF/got32x-i386.s @@ -43,5 +43,5 @@ # RUN: not ld.lld %S/Inputs/i386-got32x-baseless.elf -o %t1 -pie 2>&1 | \ # RUN: FileCheck %s --check-prefix=ERR -# ERR: relocation R_386_GOT32X against 'foo' without base register can not be used when PIC enabled -# ERR: relocation R_386_GOT32X against 'foo' without base register can not be used when PIC enabled +# ERR: error: can't create dynamic relocation R_386_GOT32X against symbol: foo in readonly segment; recompile object files with -fPIC +# ERR: error: can't create dynamic relocation R_386_GOT32X against symbol: foo in readonly segment; recompile object files with -fPIC diff --git a/test/ELF/gotpc-relax-nopic.s b/test/ELF/gotpc-relax-nopic.s index dc7dcf2e91e7..e51b8bd9f4e9 100644 --- a/test/ELF/gotpc-relax-nopic.s +++ b/test/ELF/gotpc-relax-nopic.s @@ -1,6 +1,6 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -relax-relocations -triple=x86_64-unknown-linux %s -o %t.o -# RUN: ld.lld %t.o -o %t1 +# RUN: ld.lld --hash-style=sysv %t.o -o %t1 # RUN: llvm-readobj -symbols -r %t1 | FileCheck --check-prefix=SYMRELOC %s # RUN: llvm-objdump -d %t1 | FileCheck --check-prefix=DISASM %s @@ -25,7 +25,7 @@ # DISASM-NEXT: 201031: {{.*}} xorq $2105344, %r8 # DISASM-NEXT: 201038: {{.*}} testq $2105344, %r15 -# RUN: ld.lld -shared %t.o -o %t2 +# RUN: ld.lld --hash-style=sysv -shared %t.o -o %t2 # RUN: llvm-readobj -s -r -d %t2 | FileCheck --check-prefix=SEC-PIC %s # RUN: llvm-objdump -d %t2 | FileCheck --check-prefix=DISASM-PIC %s # SEC-PIC: Section { @@ -64,7 +64,7 @@ # DISASM-PIC-NEXT: 1023: {{.*}} sbbq 8310(%rip), %rsi # DISASM-PIC-NEXT: 102a: {{.*}} subq 8303(%rip), %rbp # DISASM-PIC-NEXT: 1031: {{.*}} xorq 8296(%rip), %r8 -# DISASM-PIC-NEXT: 1038: {{.*}} testq 8289(%rip), %r15 +# DISASM-PIC-NEXT: 1038: {{.*}} testq %r15, 8289(%rip) .data .type bar, @object diff --git a/test/ELF/gotpc-relax-und-dso.s b/test/ELF/gotpc-relax-und-dso.s index ed6c4bc9bb15..3c5c8ba8c49b 100644 --- a/test/ELF/gotpc-relax-und-dso.s +++ b/test/ELF/gotpc-relax-und-dso.s @@ -2,7 +2,7 @@ # RUN: llvm-mc -filetype=obj -relax-relocations -triple=x86_64-unknown-linux %s -o %t.o # RUN: llvm-mc -filetype=obj -relax-relocations -triple=x86_64-pc-linux %S/Inputs/gotpc-relax-und-dso.s -o %tdso.o # RUN: ld.lld -shared %tdso.o -o %t.so -# RUN: ld.lld -shared %t.o %t.so -o %tout +# RUN: ld.lld --hash-style=sysv -shared %t.o %t.so -o %tout # RUN: llvm-readobj -r -s %tout | FileCheck --check-prefix=RELOC %s # RUN: llvm-objdump -d %tout | FileCheck --check-prefix=DISASM %s diff --git a/test/ELF/gotpcrelx.s b/test/ELF/gotpcrelx.s index 95dbf663ffe8..3ccbc56aba94 100644 --- a/test/ELF/gotpcrelx.s +++ b/test/ELF/gotpcrelx.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -filetype=obj -relax-relocations -triple x86_64-pc-linux-gnu \ // RUN: %s -o %t.o // RUN: llvm-readobj -r %t.o | FileCheck --check-prefix=RELS %s -// RUN: ld.lld %t.o -o %t.so -shared +// RUN: ld.lld --hash-style=sysv %t.o -o %t.so -shared // RUN: llvm-readobj -s -r %t.so | FileCheck %s movq foo@GOTPCREL(%rip), %rax diff --git a/test/ELF/help.s b/test/ELF/help.s new file mode 100644 index 000000000000..2554531532b3 --- /dev/null +++ b/test/ELF/help.s @@ -0,0 +1,5 @@ +# RUN: ld.lld --help 2>&1 | FileCheck %s +# CHECK: OPTIONS: +# CHECK: --output=<value> Path to file to write output +# CHECK: --output <value> Path to file to write output +# CHECK: -o <path> Path to file to write output diff --git a/test/ELF/i386-debug-noabs.test b/test/ELF/i386-debug-noabs.test new file mode 100644 index 000000000000..712d0a59cecc --- /dev/null +++ b/test/ELF/i386-debug-noabs.test @@ -0,0 +1,33 @@ +# REQUIRES: x86 + +# RUN: yaml2obj %s -o %t.o +# RUN: ld.lld %t.o -o %t.exe + +## This is for https://bugs.llvm.org//show_bug.cgi?id=34852. GCC 8.0 or +## earlier have a bug which creates non-absolute R_386_GOTPC relocations +## in non-allocated sections. It is illegal, but we want to make sure that +## lld skips them instead of reporting errors. + +--- !ELF +FileHeader: + Class: ELFCLASS32 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_386 +Sections: + - Name: .debug_info + Type: SHT_PROGBITS + AddressAlign: 0x0000000000000001 + Content: 0000000000000000 + - Name: .rel.debug_info + Type: SHT_REL + Link: .symtab + AddressAlign: 0x0000000000000004 + Info: .debug_info + Relocations: + - Offset: 0x000000000000041F + Symbol: _GLOBAL_OFFSET_TABLE_ + Type: R_386_GOTPC +Symbols: + Global: + - Name: _GLOBAL_OFFSET_TABLE_ diff --git a/test/ELF/i386-got-and-copy.s b/test/ELF/i386-got-and-copy.s index f5b0b8ec5bb8..81bac22fd66a 100644 --- a/test/ELF/i386-got-and-copy.s +++ b/test/ELF/i386-got-and-copy.s @@ -9,7 +9,7 @@ # RUN: %S/Inputs/copy-in-shared.s -o %t.so.o # RUN: llvm-mc -filetype=obj -triple=i386-pc-linux %s -o %t.o # RUN: ld.lld %t.so.o -shared -o %t.so -# RUN: ld.lld %t.o %t.so -o %t.exe +# RUN: ld.lld --hash-style=sysv %t.o %t.so -o %t.exe # RUN: llvm-readobj -r %t.exe | FileCheck %s # CHECK: Relocations [ diff --git a/test/ELF/i386-got-value.s b/test/ELF/i386-got-value.s new file mode 100644 index 000000000000..f42555b79272 --- /dev/null +++ b/test/ELF/i386-got-value.s @@ -0,0 +1,36 @@ +# RUN: llvm-mc %s -o %t.o -filetype=obj -triple=i386-pc-linux +# RUN: ld.lld %t.o -o %t.so -shared +# RUN: llvm-readobj --relocations --symbols --sections --section-data %t.so | FileCheck %s + +# Check that the value of a preemptible symbol is written to the got +# entry when using Elf_Rel. It is not clear why that is required, but +# freebsd i386 seems to depend on it. + +# CHECK: Name: .got +# CHECK-NEXT: Type: SHT_PROGBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_ALLOC +# CHECK-NEXT: SHF_WRITE +# CHECK-NEXT: ] +# CHECK-NEXT: Address: +# CHECK-NEXT: Offset: +# CHECK-NEXT: Size: 4 +# CHECK-NEXT: Link: +# CHECK-NEXT: Info: +# CHECK-NEXT: AddressAlignment: +# CHECK-NEXT: EntrySize: +# CHECK-NEXT: SectionData ( +# CHECK-NEXT: 0000: 00200000 +# CHECK-NEXT: ) + +# CHECK: R_386_GLOB_DAT bar 0x0 + +# CHECK: Name: bar +# CHECK-NEXT: Value: 0x2000 + + movl bar@GOT(%eax), %eax + + .data + .globl bar +bar: + .long 42 diff --git a/test/ELF/i386-gotoff-shared.s b/test/ELF/i386-gotoff-shared.s index 01242ad01c35..c22bd6dd5d78 100644 --- a/test/ELF/i386-gotoff-shared.s +++ b/test/ELF/i386-gotoff-shared.s @@ -1,6 +1,6 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o -// RUN: ld.lld %t.o -o %t.so -shared +// RUN: ld.lld --hash-style=sysv %t.o -o %t.so -shared // RUN: llvm-readobj -s %t.so | FileCheck %s // RUN: llvm-objdump -d %t.so | FileCheck --check-prefix=DISASM %s diff --git a/test/ELF/i386-gotpc-dynamic.s b/test/ELF/i386-gotpc-dynamic.s index da8a607d5753..0ec737e701a6 100644 --- a/test/ELF/i386-gotpc-dynamic.s +++ b/test/ELF/i386-gotpc-dynamic.s @@ -1,6 +1,6 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o -# RUN: ld.lld %t.o -o %t.so -shared +# RUN: ld.lld --hash-style=sysv %t.o -o %t.so -shared # RUN: llvm-readobj -s %t.so | FileCheck %s # RUN: llvm-objdump -d %t.so | FileCheck --check-prefix=DISASM %s diff --git a/test/ELF/i386-gotpc.s b/test/ELF/i386-gotpc.s index 8222effd6655..d2c5ef3d469c 100644 --- a/test/ELF/i386-gotpc.s +++ b/test/ELF/i386-gotpc.s @@ -1,6 +1,6 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o -// RUN: ld.lld %t.o -o %t.so -shared +// RUN: ld.lld --hash-style=sysv %t.o -o %t.so -shared // RUN: llvm-readobj -s %t.so | FileCheck %s // RUN: llvm-objdump -d %t.so | FileCheck --check-prefix=DISASM %s diff --git a/test/ELF/i386-pc8-pc16-addend.s b/test/ELF/i386-pc8-pc16-addend.s index 9d6424df3600..fc648b035509 100644 --- a/test/ELF/i386-pc8-pc16-addend.s +++ b/test/ELF/i386-pc8-pc16-addend.s @@ -4,7 +4,7 @@ # RUN: ld.lld %t1.o -o %t.out # RUN: llvm-objdump -s -t %t.out | FileCheck %s # CHECK: Contents of section .text: -# CHECK-NEXT: 11000 020000 +# CHECK-NEXT: 11000 020000 ## 0x11003 - 0x11000 + addend(-1) = 0x02 ## 0x11003 - 0x11001 + addend(-2) = 0x0000 # CHECK: SYMBOL TABLE: diff --git a/test/ELF/i386-reloc-16.s b/test/ELF/i386-reloc-16.s index db9dc0b36908..d69e6fbc49a7 100644 --- a/test/ELF/i386-reloc-16.s +++ b/test/ELF/i386-reloc-16.s @@ -9,6 +9,6 @@ // CHECK-NEXT: 200000 42 // RUN: not ld.lld -shared %t %t2 -o %t4 2>&1 | FileCheck --check-prefix=ERROR %s -// ERROR: relocation R_386_16 out of range +// ERROR: relocation R_386_16 out of range: 65536 is not in [0, 65535] .short foo diff --git a/test/ELF/i386-reloc-8.s b/test/ELF/i386-reloc-8.s index b2e4426910e6..c6ae67120e22 100644 --- a/test/ELF/i386-reloc-8.s +++ b/test/ELF/i386-reloc-8.s @@ -9,6 +9,6 @@ // CHECK-NEXT: 200000 42 // RUN: not ld.lld -shared %t %t2 -o %t4 2>&1 | FileCheck --check-prefix=ERROR %s -// ERROR: relocation R_386_8 out of range +// ERROR: relocation R_386_8 out of range: 256 is not in [0, 255] .byte foo diff --git a/test/ELF/i386-reloc-range.s b/test/ELF/i386-reloc-range.s index 4fb5325e5434..6f72f7af73c7 100644 --- a/test/ELF/i386-reloc-range.s +++ b/test/ELF/i386-reloc-range.s @@ -16,7 +16,7 @@ // RUN: not ld.lld -Ttext 0x200 %t.o %t2.o -o %t2 2>&1 | FileCheck --check-prefix=ERR %s -// ERR: {{.*}}:(.text+0x1): relocation R_386_PC16 out of range +// ERR: {{.*}}:(.text+0x1): relocation R_386_PC16 out of range: 65536 is not in [-65536, 65535] .global _start _start: diff --git a/test/ELF/i386-reloc8-reloc16-addend.s b/test/ELF/i386-reloc8-reloc16-addend.s index 42a57cedbca3..16b953e87ca9 100644 --- a/test/ELF/i386-reloc8-reloc16-addend.s +++ b/test/ELF/i386-reloc8-reloc16-addend.s @@ -4,7 +4,7 @@ # RUN: ld.lld -Ttext=0x0 %t1.o -o %t.out # RUN: llvm-objdump -s -t %t.out | FileCheck %s # CHECK: Contents of section .text: -# CHECK-NEXT: 0000 020100 +# CHECK-NEXT: 0000 020100 ## 0x3 + addend(-1) = 0x02 ## 0x3 + addend(-2) = 0x0100 # CHECK: SYMBOL TABLE: diff --git a/test/ELF/i386-tls-ie-shared.s b/test/ELF/i386-tls-ie-shared.s index f419eb45dfb9..2b842a86eb0f 100644 --- a/test/ELF/i386-tls-ie-shared.s +++ b/test/ELF/i386-tls-ie-shared.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o // RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %p/Inputs/tls-opt-iele-i686-nopic.s -o %tso.o // RUN: ld.lld -shared %tso.o -o %tso -// RUN: ld.lld -shared %t.o %tso -o %t1 +// RUN: ld.lld --hash-style=sysv -shared %t.o %tso -o %t1 // RUN: llvm-readobj -s -r -d %t1 | FileCheck --check-prefix=GOTRELSHARED %s // RUN: llvm-objdump -d %t1 | FileCheck --check-prefix=DISASMSHARED %s diff --git a/test/ELF/icf-absolute.s b/test/ELF/icf-absolute.s index 601322477dae..09f6790907a1 100644 --- a/test/ELF/icf-absolute.s +++ b/test/ELF/icf-absolute.s @@ -2,7 +2,7 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-absolute.s -o %t2 -# RUN: ld.lld %t %t2 -o %t3 --icf=all --verbose | FileCheck %s +# RUN: ld.lld %t %t2 -o %t3 --icf=all --verbose 2>&1 | FileCheck %s # CHECK: selected .text.f1 # CHECK: removed .text.f2 diff --git a/test/ELF/icf-comdat.s b/test/ELF/icf-comdat.s index 28c0a586bf03..aab6a00f484d 100644 --- a/test/ELF/icf-comdat.s +++ b/test/ELF/icf-comdat.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t -# RUN: ld.lld %t -o %t2 --icf=all --verbose | FileCheck %s +# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s # CHECK: selected .text.f1 # CHECK: removed .text.f2 diff --git a/test/ELF/icf-i386.s b/test/ELF/icf-i386.s index 292883e16fe5..b01e0503d405 100644 --- a/test/ELF/icf-i386.s +++ b/test/ELF/icf-i386.s @@ -2,7 +2,7 @@ # This test is to make sure that we can handle implicit addends properly. # RUN: llvm-mc -filetype=obj -triple=i386-unknown-linux %s -o %t -# RUN: ld.lld %t -o %t2 --icf=all --verbose | FileCheck %s +# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s # CHECK: selected .text.f1 # CHECK: removed .text.f2 diff --git a/test/ELF/icf-merge-sec.s b/test/ELF/icf-merge-sec.s index 39f6a884fa93..1e866a0caa49 100644 --- a/test/ELF/icf-merge-sec.s +++ b/test/ELF/icf-merge-sec.s @@ -2,7 +2,7 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-merge-sec.s -o %t2 -# RUN: ld.lld %t %t2 -o %t3 --icf=all --verbose | FileCheck %s +# RUN: ld.lld %t %t2 -o %t3 --icf=all --verbose 2>&1 | FileCheck %s # CHECK: selected .text.f1 # CHECK: removed .text.f2 diff --git a/test/ELF/icf-merge.s b/test/ELF/icf-merge.s index 938b749da6b8..06e852fe9dd5 100644 --- a/test/ELF/icf-merge.s +++ b/test/ELF/icf-merge.s @@ -2,13 +2,13 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-merge.s -o %t1 -# RUN: ld.lld %t %t1 -o %t1.out --icf=all --verbose | FileCheck %s +# RUN: ld.lld %t %t1 -o %t1.out --icf=all --verbose 2>&1 | FileCheck %s # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-merge2.s -o %t2 -# RUN: ld.lld %t %t2 -o %t3.out --icf=all --verbose | FileCheck --check-prefix=NOMERGE %s +# RUN: ld.lld %t %t2 -o %t3.out --icf=all --verbose 2>&1 | FileCheck --check-prefix=NOMERGE %s # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/icf-merge3.s -o %t3 -# RUN: ld.lld %t %t3 -o %t3.out --icf=all --verbose | FileCheck --check-prefix=NOMERGE %s +# RUN: ld.lld %t %t3 -o %t3.out --icf=all --verbose 2>&1 | FileCheck --check-prefix=NOMERGE %s # CHECK: selected .text.f1 # CHECK: removed .text.f2 diff --git a/test/ELF/icf-non-mergeable.s b/test/ELF/icf-non-mergeable.s index 378c7b33696d..48ba2008cacc 100644 --- a/test/ELF/icf-non-mergeable.s +++ b/test/ELF/icf-non-mergeable.s @@ -1,14 +1,14 @@ // REQUIRES: x86 // This file contains two functions. They are themselves identical, -// but because they have reloactions against different data section, +// but because they have relocations against different data sections, // they are not mergeable. // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \ // RUN: %p/Inputs/icf-non-mergeable.s -o %t2 -// RUN: ld.lld %t1 %t2 -o %t3 --icf=all --verbose | FileCheck %s +// RUN: ld.lld %t1 %t2 -o %t3 --icf=all --verbose 2>&1 | FileCheck %s // CHECK-NOT: selected .text.f1 // CHECK-NOT: removed .text.f2 diff --git a/test/ELF/icf-none.s b/test/ELF/icf-none.s index 671f2085f669..9ec1406de8a4 100644 --- a/test/ELF/icf-none.s +++ b/test/ELF/icf-none.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t -# RUN: ld.lld %t -o %t2 --icf=all --icf=none --verbose | FileCheck %s +# RUN: ld.lld %t -o %t2 --icf=all --icf=none --verbose 2>&1 | FileCheck %s # CHECK-NOT: selected .text.f1 diff --git a/test/ELF/icf-symbol-type.s b/test/ELF/icf-symbol-type.s new file mode 100644 index 000000000000..9cc1c509689a --- /dev/null +++ b/test/ELF/icf-symbol-type.s @@ -0,0 +1,26 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld --hash-style=sysv %t.o -o %t --icf=all -shared +# RUN: llvm-readelf --dyn-symbols --sections %t | FileCheck %s + +# We used to mark bar as absolute. + +# CHECK: .text PROGBITS 0000000000001000 +# CHECK: 0000000000001001 0 NOTYPE GLOBAL DEFAULT 4 foo +# CHECK: 0000000000001001 0 NOTYPE GLOBAL DEFAULT 4 bar + +# The nop makes the test more interesting by making the offset of +# text.f non zero. + +nop + + .section .text.f,"ax",@progbits + .globl foo +foo: + retq + + .section .text.g,"ax",@progbits + .globl bar +bar: + retq diff --git a/test/ELF/icf1.s b/test/ELF/icf1.s index bb060078476e..e2562b5a83e7 100644 --- a/test/ELF/icf1.s +++ b/test/ELF/icf1.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t -# RUN: ld.lld %t -o %t2 --icf=all --verbose | FileCheck %s +# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s # CHECK: selected .text.f1 # CHECK: removed .text.f2 diff --git a/test/ELF/icf2.s b/test/ELF/icf2.s index be595112b7e7..fd0a311cbd1d 100644 --- a/test/ELF/icf2.s +++ b/test/ELF/icf2.s @@ -2,7 +2,7 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/icf2.s -o %t2 -# RUN: ld.lld %t1 %t2 -o %t --icf=all --verbose | FileCheck %s +# RUN: ld.lld %t1 %t2 -o %t --icf=all --verbose 2>&1 | FileCheck %s # CHECK: selected .text.f1 # CHECK: removed .text.f2 diff --git a/test/ELF/icf3.s b/test/ELF/icf3.s index 9f39ff6c7477..40067cefb200 100644 --- a/test/ELF/icf3.s +++ b/test/ELF/icf3.s @@ -2,7 +2,7 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/icf2.s -o %t2 -# RUN: ld.lld %t1 %t2 -o %t --icf=all --verbose | FileCheck %s +# RUN: ld.lld %t1 %t2 -o %t --icf=all --verbose 2>&1 | FileCheck %s # CHECK-NOT: Selected .text.f1 # CHECK-NOT: Selected .text.f2 diff --git a/test/ELF/icf4.s b/test/ELF/icf4.s index 08830c8e503c..b7f40e805733 100644 --- a/test/ELF/icf4.s +++ b/test/ELF/icf4.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t -# RUN: ld.lld %t -o %t2 --icf=all --verbose | FileCheck %s +# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s # CHECK-NOT: Selected .text.f1 # CHECK-NOT: Selected .text.f2 diff --git a/test/ELF/icf5.s b/test/ELF/icf5.s index 952fe3601a4d..749cc5e923a0 100644 --- a/test/ELF/icf5.s +++ b/test/ELF/icf5.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t -# RUN: ld.lld %t -o %t2 --icf=all --verbose | FileCheck %s +# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s # CHECK-NOT: Selected .text.f1 # CHECK-NOT: Selected .text.f2 diff --git a/test/ELF/icf6.s b/test/ELF/icf6.s index ecb62fee2a0c..6420868523bf 100644 --- a/test/ELF/icf6.s +++ b/test/ELF/icf6.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t -# RUN: ld.lld %t -o %t2 --icf=all --verbose | FileCheck %s +# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s # CHECK-NOT: Selected .text.f1 # CHECK-NOT: Selected .text.f2 diff --git a/test/ELF/icf7.s b/test/ELF/icf7.s index 8504ca2ac610..00fca793aeea 100644 --- a/test/ELF/icf7.s +++ b/test/ELF/icf7.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t -# RUN: ld.lld %t -o %t2 --icf=all --verbose | FileCheck %s +# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s # RUN: llvm-objdump -t %t2 | FileCheck -check-prefix=ALIGN %s # CHECK: selected .text.f1 diff --git a/test/ELF/icf9.s b/test/ELF/icf9.s index c5a532915cc7..de6db60f9684 100644 --- a/test/ELF/icf9.s +++ b/test/ELF/icf9.s @@ -2,19 +2,31 @@ ### Make sure that we do not merge data. # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t -# RUN: ld.lld %t -o %t2 --icf=all --verbose | FileCheck %s +# RUN: ld.lld %t -o %t2 --icf=all --verbose 2>&1 | FileCheck %s +# RUN: llvm-readelf -S -W %t2 | FileCheck --check-prefix=SEC %s -# CHECK-NOT: selected .data.d1 -# CHECK-NOT: selected .data.d2 +# SEC: .rodata PROGBITS 0000000000200120 000120 000002 00 A 0 0 1 + +# CHECK-NOT: selected .rodata.d1 +# CHECK-NOT: selected .rodata.d2 + +# We do merge rodata if passed --icf-data +# RUN: ld.lld %t -o %t2 --icf=all --verbose --icf-data 2>&1 | FileCheck --check-prefix=DATA %s +# RUN: llvm-readelf -S -W %t2 | FileCheck --check-prefix=DATA-SEC %s + +# DATA: selected .rodata.d1 +# DATA: removed .rodata.d2 + +# DATA-SEC: .rodata PROGBITS 0000000000200120 000120 000001 00 A 0 0 1 .globl _start, d1, d2 _start: ret -.section .data.f1, "a" +.section .rodata.d1, "a" d1: .byte 1 -.section .data.f2, "a" +.section .rodata.d2, "a" d2: .byte 1 diff --git a/test/ELF/image-base.s b/test/ELF/image-base.s index a6d160744b70..eb79acdced81 100644 --- a/test/ELF/image-base.s +++ b/test/ELF/image-base.s @@ -6,6 +6,9 @@ # RUN: ld.lld -image-base=0x1000 -z max-page-size=0x2000 %t -o %t1 2>&1 | FileCheck --check-prefix=WARN %s # WARN: warning: -image-base: address isn't multiple of page size: 0x1000 +# Check alias. +# RUN: ld.lld -image-base 0x1000000 %t -o %t1 +# RUN: llvm-readobj -program-headers %t1 | FileCheck %s .global _start _start: @@ -41,8 +44,8 @@ _start: # CHECK-NEXT: Offset: 0x1000 # CHECK-NEXT: VirtualAddress: 0x1001000 # CHECK-NEXT: PhysicalAddress: 0x1001000 -# CHECK-NEXT: FileSize: 1 -# CHECK-NEXT: MemSize: 1 +# CHECK-NEXT: FileSize: 4096 +# CHECK-NEXT: MemSize: 4096 # CHECK-NEXT: Flags [ (0x5) # CHECK-NEXT: PF_R (0x4) # CHECK-NEXT: PF_X (0x1) diff --git a/test/ELF/init_fini_priority.s b/test/ELF/init_fini_priority.s index 84e5dc35e9d2..b10b925063e5 100644 --- a/test/ELF/init_fini_priority.s +++ b/test/ELF/init_fini_priority.s @@ -1,34 +1,46 @@ // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +// RUN: llvm-objdump -section-headers %t | FileCheck %s --check-prefix=OBJ // RUN: ld.lld %t -o %t.exe // RUN: llvm-objdump -s %t.exe | FileCheck %s // REQUIRES: x86 +// OBJ: 3 .init_array +// OBJ-NEXT: 4 .init_array.100 +// OBJ-NEXT: 5 .init_array.5 +// OBJ-NEXT: 6 .init_array +// OBJ-NEXT: 7 .init_array +// OBJ-NEXT: 8 .fini_array +// OBJ-NEXT: 9 .fini_array.100 +// OBJ-NEXT: 10 .fini_array.5 +// OBJ-NEXT: 11 .fini_array +// OBJ-NEXT: 12 .fini_array + .globl _start _start: nop -.section .init_array, "aw", @init_array +.section .init_array, "aw", @init_array, unique, 0 .align 8 .byte 1 .section .init_array.100, "aw", @init_array .long 2 .section .init_array.5, "aw", @init_array .byte 3 -.section .init_array, "aw", @init_array +.section .init_array, "aw", @init_array, unique, 1 .byte 4 -.section .init_array, "aw", @init_array +.section .init_array, "aw", @init_array, unique, 2 .byte 5 -.section .fini_array, "aw", @fini_array +.section .fini_array, "aw", @fini_array, unique, 0 .align 8 .byte 0x11 .section .fini_array.100, "aw", @fini_array .long 0x12 .section .fini_array.5, "aw", @fini_array .byte 0x13 -.section .fini_array, "aw", @fini_array +.section .fini_array, "aw", @fini_array, unique, 1 .byte 0x14 -.section .fini_array, "aw", @fini_array +.section .fini_array, "aw", @fini_array, unique, 2 .byte 0x15 // CHECK: Contents of section .init_array: diff --git a/test/ELF/invalid-linkerscript.test b/test/ELF/invalid-linkerscript.test index 280686eff41b..f9fb8478251f 100644 --- a/test/ELF/invalid-linkerscript.test +++ b/test/ELF/invalid-linkerscript.test @@ -45,7 +45,7 @@ # RUN: echo "INCLUDE /no/such/file" > %t7 # RUN: not ld.lld %t7 no-such-file 2>&1 | FileCheck -check-prefix=ERR7 %s -# ERR7: cannot open /no/such/file +# ERR7: cannot find linker script /no/such/file # ERR7: cannot open no-such-file: # RUN: echo "OUTPUT_FORMAT(x y z)" > %t8 diff --git a/test/ELF/invalid-local-symbol-in-dso.s b/test/ELF/invalid-local-symbol-in-dso.s new file mode 100644 index 000000000000..dc6bff7bd792 --- /dev/null +++ b/test/ELF/invalid-local-symbol-in-dso.s @@ -0,0 +1,13 @@ +# REQUIRES: x86 + +# We used to crash on this +# RUN: ld.lld %p/Inputs/local-symbol-in-dso.so -o %t 2>&1 | \ +# RUN: FileCheck -check-prefix=WARN %s +# WARN: found local symbol 'foo' in global part of symbol table in file {{.*}}local-symbol-in-dso.so + +# RUN: llvm-mc %s -o %t.o -filetype=obj -triple x86_64-pc-linux +# RUN: not ld.lld %t.o %p/Inputs/local-symbol-in-dso.so -o %t + +.globl main +main: + movq foo@GOTTPOFF(%rip), %rax diff --git a/test/ELF/invalid-undef-section-symbol.test b/test/ELF/invalid-undef-section-symbol.test new file mode 100644 index 000000000000..f634d6ad8c63 --- /dev/null +++ b/test/ELF/invalid-undef-section-symbol.test @@ -0,0 +1,27 @@ +# RUN: yaml2obj %s -o %t.o +# RUN: not ld.lld -r %t.o -o %2.o 2>&1 | FileCheck %s + +# We used to crash at this. +# CHECK: STT_SECTION symbol should be defined + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + - Name: .rela.text + Type: SHT_RELA + AddressAlign: 0x0000000000000008 + Info: .text + Relocations: + - Offset: 0x0000000000000000 + Symbol: .text + Type: R_X86_64_NONE +Symbols: + Local: + - Name: .text + Type: STT_SECTION diff --git a/test/ELF/invalid/Inputs/section-index2.elf b/test/ELF/invalid/Inputs/section-index2.elf Binary files differdeleted file mode 100644 index 5d842880b375..000000000000 --- a/test/ELF/invalid/Inputs/section-index2.elf +++ /dev/null diff --git a/test/ELF/invalid/invalid-debug-relocations.test b/test/ELF/invalid/invalid-debug-relocations.test index 75e41d18514f..9c86b6743093 100644 --- a/test/ELF/invalid/invalid-debug-relocations.test +++ b/test/ELF/invalid/invalid-debug-relocations.test @@ -2,8 +2,7 @@ # RUN: yaml2obj %s -o %t.o # RUN: not ld.lld -gdb-index %t.o -o %t.exe 2>&1 | FileCheck %s -# CHECK: error: {{.*}}.o: error parsing DWARF data: -# CHECK-NEXT: >>> failed to compute relocation: Unknown, Invalid data was encountered while parsing the file +# CHECK: error: {{.*}}invalid-debug-relocations.test.tmp.o:(.debug_info+0x0): has non-ABS relocation Unknown (255) against symbol '_start' !ELF FileHeader: diff --git a/test/ELF/invalid/invalid-elf.test b/test/ELF/invalid/invalid-elf.test index e03450ed289c..8be0437c0680 100644 --- a/test/ELF/invalid/invalid-elf.test +++ b/test/ELF/invalid/invalid-elf.test @@ -20,10 +20,6 @@ # RUN: FileCheck --check-prefix=INVALID-SECTION-INDEX-LLD %s # INVALID-SECTION-INDEX-LLD: invalid section index -## section-index2.elf has local symbol with incorrect section index. -# RUN: not ld.lld %p/Inputs/section-index2.elf -o %t2 2>&1 | \ -# RUN: FileCheck --check-prefix=INVALID-SECTION-INDEX-LLD %s - # RUN: not ld.lld %p/Inputs/multiple-eh-relocs.elf -o %t2 2>&1 | \ # RUN: FileCheck --check-prefix=INVALID-EH-RELOCS %s # INVALID-EH-RELOCS: multiple relocation sections to one section are not supported diff --git a/test/ELF/invalid/invalid-relocation-x64.test b/test/ELF/invalid/invalid-relocation-x64.test index 9b8ebb59e474..a9b316415697 100644 --- a/test/ELF/invalid/invalid-relocation-x64.test +++ b/test/ELF/invalid/invalid-relocation-x64.test @@ -1,7 +1,10 @@ -# RUN: yaml2obj %s -o %t.o -# RUN: not ld.lld %t.o -o /dev/null 2>&1 | FileCheck %s -# CHECK: {{.*}}.o: unknown relocation type: Unknown (152) -# CHECK: {{.*}}.o: unknown relocation type: Unknown (153) +# REQUIRES: x86 +# RUN: yaml2obj %s -o %t1.o +# RUN: echo ".global foo; foo:" > %t2.s +# RUN: llvm-mc %t2.s -o %t2.o -filetype=obj -triple x86_64-pc-linux +# RUN: not ld.lld %t1.o %t2.o -o /dev/null 2>&1 | FileCheck %s +# CHECK: error: unrecognized reloc 152 +# CHECK: error: unrecognized reloc 153 !ELF FileHeader: @@ -20,8 +23,11 @@ Sections: Info: .text Relocations: - Offset: 0x0000000000000000 - Symbol: '' + Symbol: foo Type: 0x98 - Offset: 0x0000000000000000 - Symbol: '' + Symbol: foo Type: 0x99 +Symbols: + Global: + - Name: foo diff --git a/test/ELF/libsearch.s b/test/ELF/libsearch.s index 32be866a66a9..d21baf9dd95f 100644 --- a/test/ELF/libsearch.s +++ b/test/ELF/libsearch.s @@ -60,6 +60,7 @@ // Check long forms as well // RUN: ld.lld -o %t3 %t.o --library-path=%t.dir --library=ls +// RUN: ld.lld -o %t3 %t.o --library-path %t.dir --library ls // Should not search for dynamic libraries if -Bstatic is specified // RUN: ld.lld -o %t3 %t.o -L%t.dir -Bstatic -lls diff --git a/test/ELF/linkerscript/Inputs/common-filespec1.s b/test/ELF/linkerscript/Inputs/common-filespec1.s new file mode 100644 index 000000000000..9e25d1291354 --- /dev/null +++ b/test/ELF/linkerscript/Inputs/common-filespec1.s @@ -0,0 +1,2 @@ +.comm common_uniq_1,8,8 +.comm common_multiple,16,8 diff --git a/test/ELF/linkerscript/Inputs/common-filespec2.s b/test/ELF/linkerscript/Inputs/common-filespec2.s new file mode 100644 index 000000000000..ceac01793599 --- /dev/null +++ b/test/ELF/linkerscript/Inputs/common-filespec2.s @@ -0,0 +1,2 @@ +.comm common_uniq_2,16,16 +.comm common_multiple,32,8 diff --git a/test/ELF/linkerscript/Inputs/copy-rel-symbol-value.s b/test/ELF/linkerscript/Inputs/copy-rel-symbol-value.s new file mode 100644 index 000000000000..b10a698eac18 --- /dev/null +++ b/test/ELF/linkerscript/Inputs/copy-rel-symbol-value.s @@ -0,0 +1,5 @@ + .global bar + .type bar, @object + .size bar, 8 +bar: + .quad 0 diff --git a/test/ELF/linkerscript/Inputs/provide-shared.s b/test/ELF/linkerscript/Inputs/provide-shared.s new file mode 100644 index 000000000000..5ea4e952a766 --- /dev/null +++ b/test/ELF/linkerscript/Inputs/provide-shared.s @@ -0,0 +1,5 @@ + .global foo + .size foo, 8 + .type foo, @object +foo: + .quad 42 diff --git a/test/ELF/linkerscript/Inputs/symbol-reserved.script b/test/ELF/linkerscript/Inputs/symbol-reserved.script new file mode 100644 index 000000000000..269bb120de95 --- /dev/null +++ b/test/ELF/linkerscript/Inputs/symbol-reserved.script @@ -0,0 +1,5 @@ +SECTIONS +{ + .text : { *(.text) } + PROVIDE_HIDDEN(_end = .); +} diff --git a/test/ELF/linkerscript/absolute2.s b/test/ELF/linkerscript/absolute2.s new file mode 100644 index 000000000000..513468d25814 --- /dev/null +++ b/test/ELF/linkerscript/absolute2.s @@ -0,0 +1,17 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o + +# RUN: echo "SECTIONS { .text : { *(.text) } foo = ABSOLUTE(_start) + _start; };" > %t.script +# RUN: ld.lld -o %t --script %t.script %t.o +# RUN: llvm-objdump -t %t | FileCheck %s + +# RUN: echo "SECTIONS { .text : { *(.text) } foo = _start + ABSOLUTE(_start); };" > %t.script +# RUN: ld.lld -o %t --script %t.script %t.o +# RUN: llvm-objdump -t %t | FileCheck %s + +# CHECK: 0000000000000001 .text 00000000 _start +# CHECK: 0000000000000002 .text 00000000 foo + + .global _start + nop +_start: diff --git a/test/ELF/linkerscript/align-section-offset.s b/test/ELF/linkerscript/align-section-offset.s new file mode 100644 index 000000000000..9c1603a19853 --- /dev/null +++ b/test/ELF/linkerscript/align-section-offset.s @@ -0,0 +1,11 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: echo "SECTIONS { .foo : ALIGN(2M) { *(.foo) } }" > %t.script +# RUN: ld.lld -o %t --script %t.script %t.o -shared +# RUN: llvm-readelf -S -l %t | FileCheck %s + +# CHECK: .foo PROGBITS 0000000000200000 200000 000008 00 WA 0 0 2097152 +# CHECK: LOAD 0x200000 0x0000000000200000 0x0000000000200000 {{.*}} RW 0x200000 + + .section .foo, "aw" + .quad 42 diff --git a/test/ELF/linkerscript/align-section.s b/test/ELF/linkerscript/align-section.s new file mode 100644 index 000000000000..d26f15c87329 --- /dev/null +++ b/test/ELF/linkerscript/align-section.s @@ -0,0 +1,6 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: echo "SECTIONS { .foo : ALIGN(2M) { } }" > %t.script +# RUN: ld.lld -o %t --script %t.script %t.o -shared + +# We would crash if an empty section had an ALIGN. diff --git a/test/ELF/linkerscript/align.s b/test/ELF/linkerscript/align.s index 357f54ce1ca5..99e7382daa59 100644 --- a/test/ELF/linkerscript/align.s +++ b/test/ELF/linkerscript/align.s @@ -66,6 +66,51 @@ # SYMBOLS-NEXT: 0000000000011000 .bbb 00000000 __start_bbb # SYMBOLS-NEXT: 0000000000012000 .bbb 00000000 __end_bbb +## Check that ALIGN zero do nothing and does not crash #1. +# RUN: echo "SECTIONS { . = ALIGN(0x123, 0); .aaa : { *(.aaa) } }" > %t.script +# RUN: ld.lld -o %t4 --script %t.script %t +# RUN: llvm-objdump -section-headers %t4 | FileCheck %s -check-prefix=ZERO + +# ZERO: Sections: +# ZERO-NEXT: Idx Name Size Address Type +# ZERO-NEXT: 0 00000000 0000000000000000 +# ZERO-NEXT: 1 .aaa 00000008 0000000000000123 DATA + +## Check that ALIGN zero do nothing and does not crash #2. +# RUN: echo "SECTIONS { . = 0x123; . = ALIGN(0); .aaa : { *(.aaa) } }" > %t.script +# RUN: ld.lld -o %t5 --script %t.script %t +# RUN: llvm-objdump -section-headers %t5 | FileCheck %s -check-prefix=ZERO + +## Test we fail gracefuly when alignment value is not a power of 2 (#1). +# RUN: echo "SECTIONS { . = 0x123; . = ALIGN(0x123, 3); .aaa : { *(.aaa) } }" > %t.script +# RUN: not ld.lld -o %t6 --script %t.script %t 2>&1 | FileCheck -check-prefix=ERR %s +# ERR: {{.*}}.script:1: alignment must be power of 2 + +## Test we fail gracefuly when alignment value is not a power of 2 (#2). +# RUN: echo "SECTIONS { . = 0x123; . = ALIGN(3); .aaa : { *(.aaa) } }" > %t.script +# RUN: not ld.lld -o %t7 --script %t.script %t 2>&1 | FileCheck -check-prefix=ERR %s + +# RUN: echo "SECTIONS { \ +# RUN: . = 0xff8; \ +# RUN: .aaa : { \ +# RUN: *(.aaa) \ +# RUN: foo = ALIGN(., 0x100); \ +# RUN: bar = .; \ +# RUN: zed1 = ALIGN(., 0x100) + 1; \ +# RUN: zed2 = ALIGN(., 0x100) - 1; \ +# RUN: } \ +# RUN: .bbb : { *(.bbb); } \ +# RUN: .ccc : { *(.ccc); } \ +# RUN: .text : { *(.text); } \ +# RUN: }" > %t.script +# RUN: ld.lld -o %t1 --script %t.script %t +# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=OFFSET %s + +# OFFSET: 0000000000001000 .aaa 00000000 foo +# OFFSET: 0000000000001000 .aaa 00000000 bar +# OFFSET: 0000000000001001 .aaa 00000000 zed1 +# OFFSET: 0000000000000fff .aaa 00000000 zed2 + .global _start _start: nop diff --git a/test/ELF/linkerscript/arm-exidx-order.s b/test/ELF/linkerscript/arm-exidx-order.s new file mode 100644 index 000000000000..1ff1711e60be --- /dev/null +++ b/test/ELF/linkerscript/arm-exidx-order.s @@ -0,0 +1,19 @@ +# REQUIRES: arm +# RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o +# RUN: echo "SECTIONS { . = SIZEOF_HEADERS; \ +# RUN: .ARM.exidx : { *(.ARM.exidx*) } \ +# RUN: .foo : { _foo = 0; } }" > %t.script +# RUN: ld.lld -T %t.script %t.o -shared -o %t.so +# RUN: llvm-readobj -s %t.so | FileCheck %s + +# CHECK: Section { +# CHECK: Index: +# CHECK: Name: .foo +# CHECK-NEXT: Type: SHT_NOBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_ALLOC +# CHECK-NEXT: ] + +.fnstart +.cantunwind +.fnend diff --git a/test/ELF/linkerscript/arm-exidx-sentinel-and-assignment.s b/test/ELF/linkerscript/arm-exidx-sentinel-and-assignment.s new file mode 100644 index 000000000000..8cee22f7fed2 --- /dev/null +++ b/test/ELF/linkerscript/arm-exidx-sentinel-and-assignment.s @@ -0,0 +1,24 @@ +# REQUIRES: arm +# RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o +# RUN: echo "SECTIONS { \ +# RUN: .ARM.exidx 0x1000 : { *(.ARM.exidx*) foo = .; } \ +# RUN: .text 0x2000 : { *(.text*) } \ +# RUN: }" > %t.script +## We used to crash if the last output section command for .ARM.exidx +## was anything but an input section description. +# RUN: ld.lld --no-merge-exidx-entries -T %t.script %t.o -shared -o %t.so +# RUN: llvm-objdump -s -triple=armv7a-none-linux-gnueabi %t.so | FileCheck %s + + .syntax unified + .text + .global _start +_start: + .fnstart + .cantunwind + bx lr + .fnend + +// CHECK: Contents of section .ARM.exidx: +// 1000 + 1000 = 0x2000 = _start +// 1008 + 0ffc = 0x2004 = _start + sizeof(_start) +// CHECK-NEXT: 1000 00100000 01000000 fc0f0000 01000000 diff --git a/test/ELF/linkerscript/at-addr.s b/test/ELF/linkerscript/at-addr.s index 0eddf3d9e3fb..f0ab989c52c7 100644 --- a/test/ELF/linkerscript/at-addr.s +++ b/test/ELF/linkerscript/at-addr.s @@ -9,10 +9,6 @@ # RUN: llvm-readobj -program-headers %t2 | FileCheck %s # CHECK: Type: PT_LOAD -# CHECK-NEXT: Offset: 0x0 -# CHECK-NEXT: VirtualAddress: 0x0 -# CHECK-NEXT: PhysicalAddress: 0x0 -# CHECK: Type: PT_LOAD # CHECK-NEXT: Offset: 0x1000 # CHECK-NEXT: VirtualAddress: 0x1000 # CHECK-NEXT: PhysicalAddress: 0xB00 diff --git a/test/ELF/linkerscript/at.s b/test/ELF/linkerscript/at.s index 26441f1ffd9e..430e68a53d98 100644 --- a/test/ELF/linkerscript/at.s +++ b/test/ELF/linkerscript/at.s @@ -13,31 +13,6 @@ # CHECK: ProgramHeaders [ # CHECK-NEXT: ProgramHeader { -# CHECK-NEXT: Type: PT_PHDR -# CHECK-NEXT: Offset: 0x40 -# CHECK-NEXT: VirtualAddress: 0x40 -# CHECK-NEXT: PhysicalAddress: 0x40 -# CHECK-NEXT: FileSize: -# CHECK-NEXT: MemSize: -# CHECK-NEXT: Flags [ -# CHECK-NEXT: PF_R -# CHECK-NEXT: ] -# CHECK-NEXT: Alignment: 8 -# CHECK-NEXT: } -# CHECK-NEXT: ProgramHeader { -# CHECK-NEXT: Type: PT_LOAD -# CHECK-NEXT: Offset: 0x0 -# CHECK-NEXT: VirtualAddress: 0x0 -# CHECK-NEXT: PhysicalAddress: 0x0 -# CHECK-NEXT: FileSize: -# CHECK-NEXT: MemSize: -# CHECK-NEXT: Flags [ -# CHECK-NEXT: PF_R -# CHECK-NEXT: PF_X -# CHECK-NEXT: ] -# CHECK-NEXT: Alignment: -# CHECK-NEXT: } -# CHECK-NEXT: ProgramHeader { # CHECK-NEXT: Type: PT_LOAD # CHECK-NEXT: Offset: 0x1000 # CHECK-NEXT: VirtualAddress: 0x1000 diff --git a/test/ELF/linkerscript/common-exclude.s b/test/ELF/linkerscript/common-exclude.s new file mode 100644 index 000000000000..ef2d51b1b229 --- /dev/null +++ b/test/ELF/linkerscript/common-exclude.s @@ -0,0 +1,86 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %tfile0.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/common-filespec1.s -o %tfile1.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/common-filespec2.s -o %tfile2.o +# RUN: echo "SECTIONS { .common.incl : { *(EXCLUDE_FILE (*file2.o) COMMON) } .common.excl : { *(COMMON) } }" > %t.script +# RUN: ld.lld -o %t1 --script %t.script %tfile0.o %tfile1.o %tfile2.o +# RUN: llvm-readobj -s -t %t1 | FileCheck %s + +# Commons from file0 and file1 are not excluded, so they must be in .common.incl +# Commons from file2 are excluded from the first rule and should be caught by +# the second in .common.excl +# CHECK: Section { +# CHECK: Index: +# CHECK: Name: .common.incl +# CHECK-NEXT: Type: SHT_NOBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_ALLOC +# CHECK-NEXT: SHF_WRITE +# CHECK-NEXT: ] +# CHECK-NEXT: Address: 0x8 +# CHECK-NEXT: Offset: 0x +# CHECK-NEXT: Size: 16 +# CHECK-NEXT: Link: 0 +# CHECK-NEXT: Info: 0 +# CHECK-NEXT: AddressAlignment: 8 +# CHECK-NEXT: EntrySize: 0 +# CHECK-NEXT: } +# CHECK: Section { +# CHECK: Index: +# CHECK: Name: .common.excl +# CHECK-NEXT: Type: SHT_NOBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_ALLOC +# CHECK-NEXT: SHF_WRITE +# CHECK-NEXT: ] +# CHECK-NEXT: Address: 0x20 +# CHECK-NEXT: Offset: 0x +# CHECK-NEXT: Size: 48 +# CHECK-NEXT: Link: 0 +# CHECK-NEXT: Info: 0 +# CHECK-NEXT: AddressAlignment: 16 +# CHECK-NEXT: EntrySize: 0 +# CHECK-NEXT: } +# CHECK: Symbol { +# CHECK: Name: common_multiple +# CHECK-NEXT: Value: 0x20 +# CHECK-NEXT: Size: 32 +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: Object +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: .common.excl +# CHECK-NEXT: } +# CHECK: Symbol { +# CHECK: Name: common_uniq_0 +# CHECK-NEXT: Value: 0x8 +# CHECK-NEXT: Size: 4 +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: Object +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: .common.incl +# CHECK-NEXT: } +# CHECK: Symbol { +# CHECK: Name: common_uniq_1 +# CHECK-NEXT: Value: 0x10 +# CHECK-NEXT: Size: 8 +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: Object +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: .common.incl +# CHECK-NEXT: } +# CHECK: Symbol { +# CHECK: Name: common_uniq_2 +# CHECK-NEXT: Value: 0x40 +# CHECK-NEXT: Size: 16 +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: Object +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: .common.excl +# CHECK-NEXT: } + +.globl _start +_start: + jmp _start + +.comm common_uniq_0,4,4 +.comm common_multiple,8,8 diff --git a/test/ELF/linkerscript/common-filespec.s b/test/ELF/linkerscript/common-filespec.s new file mode 100644 index 000000000000..25bb486ed445 --- /dev/null +++ b/test/ELF/linkerscript/common-filespec.s @@ -0,0 +1,105 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %tfile0.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/common-filespec1.s -o %tfile1.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/common-filespec2.s -o %tfile2.o +# RUN: echo "SECTIONS { .common_0 : { *file0.o(COMMON) } .common_1 : { *file1.o(COMMON) } .common_2 : { *file2.o(COMMON) } }" > %t.script +# RUN: ld.lld -o %t1 --script %t.script %tfile0.o %tfile1.o %tfile2.o +# RUN: llvm-readobj -s -t %t1 | FileCheck %s + +# Make sure all 3 sections are allocated and they have sizes and alignments +# corresponding to the commons assigned to them +# CHECK: Section { +# CHECK: Index: +# CHECK: Name: .common_0 +# CHECK-NEXT: Type: SHT_NOBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_ALLOC +# CHECK-NEXT: SHF_WRITE +# CHECK-NEXT: ] +# CHECK-NEXT: Address: 0x4 +# CHECK-NEXT: Offset: 0x +# CHECK-NEXT: Size: 4 +# CHECK-NEXT: Link: 0 +# CHECK-NEXT: Info: 0 +# CHECK-NEXT: AddressAlignment: 4 +# CHECK-NEXT: EntrySize: 0 +# CHECK-NEXT: } +# CHECK: Section { +# CHECK: Index: +# CHECK: Name: .common_1 +# CHECK-NEXT: Type: SHT_NOBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_ALLOC +# CHECK-NEXT: SHF_WRITE +# CHECK-NEXT: ] +# CHECK-NEXT: Address: 0x8 +# CHECK-NEXT: Offset: 0x +# CHECK-NEXT: Size: 8 +# CHECK-NEXT: Link: 0 +# CHECK-NEXT: Info: 0 +# CHECK-NEXT: AddressAlignment: 8 +# CHECK-NEXT: EntrySize: 0 +# CHECK-NEXT: } +# CHECK: Section { +# CHECK: Index: +# CHECK: Name: .common_2 +# CHECK-NEXT: Type: SHT_NOBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_ALLOC +# CHECK-NEXT: SHF_WRITE +# CHECK-NEXT: ] +# CHECK-NEXT: Address: 0x10 +# CHECK-NEXT: Offset: 0x +# CHECK-NEXT: Size: 48 +# CHECK-NEXT: Link: 0 +# CHECK-NEXT: Info: 0 +# CHECK-NEXT: AddressAlignment: 16 +# CHECK-NEXT: EntrySize: 0 +# CHECK-NEXT: } + +# Commons with unique name in each file must be assigned to that file's section. +# For a common with multiple definitions, the largest one wins and it must be +# assigned to the section from the file which provided the winning def +# CHECK: Symbol { +# CHECK: Name: common_multiple +# CHECK-NEXT: Value: 0x10 +# CHECK-NEXT: Size: 32 +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: Object +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: .common_2 +# CHECK-NEXT: } +# CHECK: Symbol { +# CHECK: Name: common_uniq_0 +# CHECK-NEXT: Value: 0x4 +# CHECK-NEXT: Size: 4 +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: Object +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: .common_0 +# CHECK-NEXT: } +# CHECK: Symbol { +# CHECK: Name: common_uniq_1 +# CHECK-NEXT: Value: 0x8 +# CHECK-NEXT: Size: 8 +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: Object +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: .common_1 +# CHECK-NEXT: } +# CHECK: Symbol { +# CHECK: Name: common_uniq_2 +# CHECK-NEXT: Value: 0x30 +# CHECK-NEXT: Size: 16 +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: Object +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: .common_2 +# CHECK-NEXT: } + +.globl _start +_start: + jmp _start + +.comm common_uniq_0,4,4 +.comm common_multiple,8,8 diff --git a/test/ELF/linkerscript/common.s b/test/ELF/linkerscript/common.s index 2e5972d52379..52f0371526c4 100644 --- a/test/ELF/linkerscript/common.s +++ b/test/ELF/linkerscript/common.s @@ -4,8 +4,6 @@ # RUN: ld.lld -o %t1 --script %t.script %t # RUN: llvm-readobj -s -t %t1 | FileCheck %s -# q2 alignment is greater than q1, so it should have smaller offset -# because of sorting # CHECK: Section { # CHECK: Index: # CHECK: Name: .common @@ -16,7 +14,7 @@ # CHECK-NEXT: ] # CHECK-NEXT: Address: 0x200 # CHECK-NEXT: Offset: 0x -# CHECK-NEXT: Size: 256 +# CHECK-NEXT: Size: 384 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 # CHECK-NEXT: AddressAlignment: 256 @@ -24,7 +22,7 @@ # CHECK-NEXT: } # CHECK: Symbol { # CHECK: Name: q1 -# CHECK-NEXT: Value: 0x280 +# CHECK-NEXT: Value: 0x200 # CHECK-NEXT: Size: 128 # CHECK-NEXT: Binding: Global # CHECK-NEXT: Type: Object @@ -33,7 +31,7 @@ # CHECK-NEXT: } # CHECK-NEXT: Symbol { # CHECK-NEXT: Name: q2 -# CHECK-NEXT: Value: 0x200 +# CHECK-NEXT: Value: 0x300 # CHECK-NEXT: Size: 128 # CHECK-NEXT: Binding: Global # CHECK-NEXT: Type: Object diff --git a/test/ELF/linkerscript/compress-debug-sections.s b/test/ELF/linkerscript/compress-debug-sections.s index 6798a217b5ac..5e8cd004068d 100644 --- a/test/ELF/linkerscript/compress-debug-sections.s +++ b/test/ELF/linkerscript/compress-debug-sections.s @@ -10,12 +10,12 @@ # RUN: echo "SECTIONS { }" > %t.script # RUN: ld.lld -O0 %t1.o %t2.o %t.script -o %t1 --compress-debug-sections=zlib -# RUN: llvm-dwarfdump %t1 | FileCheck %s +# RUN: llvm-dwarfdump -a %t1 | FileCheck %s # RUN: llvm-readobj -s %t1 | FileCheck %s --check-prefix=ZLIBFLAGS # RUN: echo "SECTIONS { .debug_str 0 : { *(.debug_str) } }" > %t2.script # RUN: ld.lld -O0 %t1.o %t2.o %t2.script -o %t2 --compress-debug-sections=zlib -# RUN: llvm-dwarfdump %t2 | FileCheck %s +# RUN: llvm-dwarfdump -a %t2 | FileCheck %s # RUN: llvm-readobj -s %t2 | FileCheck %s --check-prefix=ZLIBFLAGS # CHECK: .debug_str contents: diff --git a/test/ELF/linkerscript/copy-rel-symbol-value-err.s b/test/ELF/linkerscript/copy-rel-symbol-value-err.s new file mode 100644 index 000000000000..f134edbb1d0c --- /dev/null +++ b/test/ELF/linkerscript/copy-rel-symbol-value-err.s @@ -0,0 +1,12 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/copy-rel-symbol-value.s -o %t2.o +# RUN: ld.lld %t2.o -o %t2.so -shared +# RUN: echo "SECTIONS { . = . + SIZEOF_HEADERS; foo = bar; }" > %t.script +# RUN: not ld.lld %t.o %t2.so --script %t.script -o %t 2>&1 | FileCheck %s + +# CHECK: symbol not found: bar + +.global _start +_start: +.quad bar@got diff --git a/test/ELF/linkerscript/copy-rel-symbol-value.s b/test/ELF/linkerscript/copy-rel-symbol-value.s new file mode 100644 index 000000000000..64627b42f885 --- /dev/null +++ b/test/ELF/linkerscript/copy-rel-symbol-value.s @@ -0,0 +1,27 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/copy-rel-symbol-value.s -o %t2.o +# RUN: ld.lld %t2.o -o %t2.so -shared +# RUN: echo "SECTIONS { . = . + SIZEOF_HEADERS; foo = bar; }" > %t.script +# RUN: ld.lld %t.o %t2.so --script %t.script -o %t +# RUN: llvm-readobj -t %t | FileCheck %s + +# CHECK: Name: bar +# CHECK-NEXT: Value: 0x[[VAL:.*]] +# CHECK-NEXT: Size: 8 +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: Object +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: .bss.rel.ro + +# CHECK: Name: foo +# CHECK-NEXT: Value: 0x[[VAL]] +# CHECK-NEXT: Size: +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: .bss.rel.ro + +.global _start +_start: +.quad bar diff --git a/test/ELF/linkerscript/data-segment-relro.s b/test/ELF/linkerscript/data-segment-relro.s index 7f69319dde7a..e835f42e22c6 100644 --- a/test/ELF/linkerscript/data-segment-relro.s +++ b/test/ELF/linkerscript/data-segment-relro.s @@ -19,9 +19,9 @@ ## With relro or without DATA_SEGMENT_RELRO_END just aligns to ## page boundary. -# RUN: ld.lld -z norelro %t1.o %t2.so --script %t.script -o %t +# RUN: ld.lld --hash-style=sysv -z norelro %t1.o %t2.so --script %t.script -o %t # RUN: llvm-readobj -s %t | FileCheck %s -# RUN: ld.lld -z relro %t1.o %t2.so --script %t.script -o %t2 +# RUN: ld.lld --hash-style=sysv -z relro %t1.o %t2.so --script %t.script -o %t2 # RUN: llvm-readobj -s %t2 | FileCheck %s # CHECK: Section { diff --git a/test/ELF/linkerscript/diagnostic.s b/test/ELF/linkerscript/diagnostic.s index bd1ebd01b5d2..af185729c430 100644 --- a/test/ELF/linkerscript/diagnostic.s +++ b/test/ELF/linkerscript/diagnostic.s @@ -50,9 +50,9 @@ # RUN: echo ".temp : { *(.temp) } }" >> %t.script # RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \ # RUN: FileCheck -check-prefix=ERR6 -strict-whitespace %s -# ERR6: error: {{.*}}.script:1: -# ERR6-NEXT: error: {{.*}}.script:1: UNKNOWN_TAG { -# ERR6-NEXT: error: {{.*}}.script:1: ^ +# ERR6: error: {{.*}}.script:1: unknown directive: UNKNOWN_TAG +# ERR6-NEXT: >>> UNKNOWN_TAG { +# ERR6-NEXT: >>> ^ ## One more check that text of lines and pointer to 'bad' token are working ok. # RUN: echo "SECTIONS {" > %t.script @@ -62,8 +62,8 @@ # RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \ # RUN: FileCheck -check-prefix=ERR7 -strict-whitespace %s # ERR7: error: {{.*}}.script:4: malformed number: .temp -# ERR7-NEXT: error: {{.*}}.script:4: boom .temp : { *(.temp) } } -# ERR7-NEXT: error: {{.*}}.script:4: ^ +# ERR7-NEXT: >>> boom .temp : { *(.temp) } } +# ERR7-NEXT: >>> ^ ## Check tokenize() error # RUN: echo "SECTIONS {}" > %t.script @@ -89,8 +89,8 @@ # RUN: not ld.lld -shared %t -o %t1 --script %t.script 2>&1 | \ # RUN: FileCheck -check-prefix=ERR10 -strict-whitespace %s # ERR10: error: {{.*}}.script.inc:4: malformed number: .temp -# ERR10-NEXT: error: {{.*}}.script.inc:4: boom .temp : { *(.temp) } } -# ERR10-NEXT: error: {{.*}}.script.inc:4: ^ +# ERR10-NEXT: >>> boom .temp : { *(.temp) } } +# ERR10-NEXT: >>> ^ ## Check error reporting in script with INCLUDE directive. # RUN: echo "SECTIONS {" > %t.script.inc diff --git a/test/ELF/linkerscript/discard-section-err.s b/test/ELF/linkerscript/discard-section-err.s index 5d9955545d92..8ad5b486cb39 100644 --- a/test/ELF/linkerscript/discard-section-err.s +++ b/test/ELF/linkerscript/discard-section-err.s @@ -21,3 +21,5 @@ # RUN: not ld.lld -pie -o %t --script %t.script %t.o 2>&1 | \ # RUN: FileCheck -check-prefix=DYNSTR %s # DYNSTR: discarding .dynstr section is not allowed + +.comm foo,4,4 diff --git a/test/ELF/linkerscript/early-assign-symbol.s b/test/ELF/linkerscript/early-assign-symbol.s index 0626e66e6fb6..5f6117863666 100644 --- a/test/ELF/linkerscript/early-assign-symbol.s +++ b/test/ELF/linkerscript/early-assign-symbol.s @@ -1,14 +1,28 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o -# RUN: echo "SECTIONS { aaa = 1 + ABSOLUTE(foo - 1); .text : { *(.text*) } }" > %t1.script -# RUN: not ld.lld -o %t --script %t1.script %t.o 2>&1 | FileCheck %s - -# RUN: echo "SECTIONS { aaa = ABSOLUTE(foo - 1) + 1; .text : { *(.text*) } }" > %t2.script -# RUN: not ld.lld -o %t --script %t2.script %t.o 2>&1 | FileCheck %s +# RUN: echo "SECTIONS { aaa = foo | 1; .text : { *(.text*) } }" > %t3.script +# RUN: not ld.lld -o %t --script %t3.script %t.o 2>&1 | FileCheck %s # CHECK: error: {{.*}}.script:1: unable to evaluate expression: input section .text has no output section assigned +# Simple cases that we can handle. + +# RUN: echo "SECTIONS { aaa = ABSOLUTE(foo - 1) + 1; .text : { *(.text*) } }" > %t.script +# RUN: ld.lld -o %t --script %t.script %t.o +# RUN: llvm-objdump -t %t | FileCheck --check-prefix=VAL %s + +# RUN: echo "SECTIONS { aaa = 1 + ABSOLUTE(foo - 1); .text : { *(.text*) } }" > %t.script +# RUN: ld.lld -o %t --script %t.script %t.o +# RUN: llvm-objdump -t %t | FileCheck --check-prefix=VAL %s + +# RUN: echo "SECTIONS { aaa = ABSOLUTE(foo); .text : { *(.text*) } }" > %t4.script +# RUN: ld.lld -o %t --script %t4.script %t.o +# RUN: llvm-objdump -t %t | FileCheck --check-prefix=VAL %s + +# VAL: 0000000000000000 .text 00000000 foo +# VAL: 0000000000000000 *ABS* 00000000 aaa + .section .text .globl foo foo: diff --git a/test/ELF/linkerscript/eh-frame-reloc-out-of-range.s b/test/ELF/linkerscript/eh-frame-reloc-out-of-range.s index 54c0cc74d394..817e458fa5ef 100644 --- a/test/ELF/linkerscript/eh-frame-reloc-out-of-range.s +++ b/test/ELF/linkerscript/eh-frame-reloc-out-of-range.s @@ -12,7 +12,7 @@ # RUN: }" > %t.script # RUN: not ld.lld %t.o -T %t.script -o %t 2>&1 | FileCheck %s -# CHECK: error: {{.*}}:(.eh_frame+0x20): relocation R_X86_64_PC32 out of range +# CHECK: error: {{.*}}:(.eh_frame+0x20): relocation R_X86_64_PC32 out of range: 64424443872 is not in [-2147483648, 2147483647] .text .globl _start diff --git a/test/ELF/linkerscript/emit-reloc-section-names.s b/test/ELF/linkerscript/emit-reloc-section-names.s new file mode 100644 index 000000000000..8661ff060a79 --- /dev/null +++ b/test/ELF/linkerscript/emit-reloc-section-names.s @@ -0,0 +1,22 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: echo "SECTIONS { .text.zed : { *(.text.foo) } \ +# RUN: .text.qux : { *(.text.bar) } }" > %t.script +# RUN: ld.lld -T %t.script --emit-relocs %t.o -o %t +# RUN: llvm-objdump -section-headers %t | FileCheck %s + +## Check we name relocation sections in according to +## their target sections names. + +# CHECK: .text.zed +# CHECK: .text.qux +# CHECK: .rela.text.zed +# CHECK: .rela.text.qux + +.section .text.foo,"ax" +foo: + mov $bar, %rax + +.section .text.bar,"ax" +bar: + mov $foo, %rax diff --git a/test/ELF/linkerscript/emit-reloc.s b/test/ELF/linkerscript/emit-reloc.s index 725f314a9772..2fe127af8590 100644 --- a/test/ELF/linkerscript/emit-reloc.s +++ b/test/ELF/linkerscript/emit-reloc.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o # RUN: echo "SECTIONS { .rela.dyn : { *(.rela.data) } }" > %t.script -# RUN: ld.lld -T %t.script --emit-relocs %t.o -o %t.so -shared +# RUN: ld.lld --hash-style=sysv -T %t.script --emit-relocs %t.o -o %t.so -shared # RUN: llvm-readobj -r %t.so | FileCheck %s .data diff --git a/test/ELF/linkerscript/emit-relocs-multiple.s b/test/ELF/linkerscript/emit-relocs-multiple.s index b04ca1be7a15..dcf40b3d9312 100644 --- a/test/ELF/linkerscript/emit-relocs-multiple.s +++ b/test/ELF/linkerscript/emit-relocs-multiple.s @@ -5,7 +5,7 @@ # RUN: llvm-readobj -r %t1 | FileCheck %s # CHECK: Relocations [ -# CHECK-NEXT: Section {{.*}} .rela.foo { +# CHECK-NEXT: Section {{.*}} .rela.zed { # CHECK-NEXT: 0x1 R_X86_64_32 .zed 0x0 # CHECK-NEXT: 0x6 R_X86_64_32 .zed 0x5 # CHECK-NEXT: } diff --git a/test/ELF/linkerscript/extend-pt-load.s b/test/ELF/linkerscript/extend-pt-load.s index f9a77c8c12bf..72740f1092ee 100644 --- a/test/ELF/linkerscript/extend-pt-load.s +++ b/test/ELF/linkerscript/extend-pt-load.s @@ -15,7 +15,7 @@ # RUN: . = ALIGN(0x1000); \ # RUN: .data.rel.ro : { *(.data.rel.ro) } \ # RUN: }" > %t.script -# RUN: ld.lld -o %t1 --script %t.script %t.o -shared +# RUN: ld.lld --hash-style=sysv -o %t1 --script %t.script %t.o -shared # RUN: llvm-readobj --elf-output-style=GNU -l -s %t1 | FileCheck --check-prefix=CHECK1 %s # CHECK1: .text PROGBITS 00000000000001bc 0001bc 000001 00 AX @@ -33,18 +33,17 @@ # RUN: .hash : { } \ # RUN: .dynstr : { } \ # RUN: .text : { *(.text) } \ -# RUN: . = ALIGN(0x1000); \ -# RUN: bar : { HIDDEN(bar_sym = .); } \ +# RUN: bar : { . = ALIGN(0x1000); } \ # RUN: .data.rel.ro : { *(.data.rel.ro) } \ # RUN: }" > %t.script -# RUN: ld.lld -o %t2 --script %t.script %t.o -shared +# RUN: ld.lld --hash-style=sysv -o %t2 --script %t.script %t.o -shared # RUN: llvm-readobj --elf-output-style=GNU -l -s %t2 | FileCheck --check-prefix=CHECK2 %s # CHECK2: .text PROGBITS 00000000000001bc 0001bc 000001 00 AX -# CHECK2-NEXT: bar PROGBITS 0000000000001000 001000 000000 00 AX +# CHECK2-NEXT: bar NOBITS 00000000000001bd 0001bd 000e43 00 AX # CHECK2-NEXT: .data.rel.ro PROGBITS 0000000000001000 001000 000001 00 WA -# CHECK2: LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x001000 0x001000 R E +# CHECK2: LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x0001bd 0x001000 R E # CHECK2-NEXT: LOAD 0x001000 0x0000000000001000 0x0000000000001000 0x000068 0x000068 RW # If the current behavior becomes a problem we should consider just moving the commands out @@ -60,7 +59,7 @@ # RUN: HIDDEN(bar_sym = .); \ # RUN: .data.rel.ro : { *(.data.rel.ro) } \ # RUN: }" > %t.script -# RUN: ld.lld -o %t3 --script %t.script %t.o -shared +# RUN: ld.lld --hash-style=sysv -o %t3 --script %t.script %t.o -shared # RUN: llvm-readobj --elf-output-style=GNU -l -s %t3 | FileCheck --check-prefix=CHECK1 %s nop diff --git a/test/ELF/linkerscript/filename-spec.s b/test/ELF/linkerscript/filename-spec.s index d4bc495efb81..5f075a8e5005 100644 --- a/test/ELF/linkerscript/filename-spec.s +++ b/test/ELF/linkerscript/filename-spec.s @@ -33,24 +33,63 @@ # RUN: ld.lld -o %t4 --script %t4.script %tfirst.o %tsecond.o # RUN: llvm-objdump -s %t4 | FileCheck --check-prefix=SECONDFIRST %s -# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %T/filename-spec1.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o filename-spec1.o # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \ -# RUN: %p/Inputs/filename-spec.s -o %T/filename-spec2.o +# RUN: %p/Inputs/filename-spec.s -o filename-spec2.o # RUN: echo "SECTIONS { .foo : { \ # RUN: filename-spec2.o(.foo) \ # RUN: filename-spec1.o(.foo) } }" > %t5.script # RUN: ld.lld -o %t5 --script %t5.script \ -# RUN: %T/filename-spec1.o %T/filename-spec2.o +# RUN: filename-spec1.o filename-spec2.o # RUN: llvm-objdump -s %t5 | FileCheck --check-prefix=SECONDFIRST %s # RUN: echo "SECTIONS { .foo : { \ # RUN: filename-spec1.o(.foo) \ # RUN: filename-spec2.o(.foo) } }" > %t6.script # RUN: ld.lld -o %t6 --script %t6.script \ -# RUN: %T/filename-spec1.o %T/filename-spec2.o +# RUN: filename-spec1.o filename-spec2.o # RUN: llvm-objdump -s %t6 | FileCheck --check-prefix=FIRSTSECOND %s +# RUN: mkdir -p %t.testdir1 %t.testdir2 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.testdir1/filename-spec1.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux \ +# RUN: %p/Inputs/filename-spec.s -o %t.testdir2/filename-spec2.o +# RUN: llvm-ar rsc %t.testdir1/lib1.a %t.testdir1/filename-spec1.o +# RUN: llvm-ar rsc %t.testdir2/lib2.a %t.testdir2/filename-spec2.o + +# Verify matching of archive library names. +# RUN: echo "SECTIONS { .foo : { \ +# RUN: *lib2*(.foo) \ +# RUN: *lib1*(.foo) } }" > %t7.script +# RUN: ld.lld -o %t7 --script %t7.script --whole-archive \ +# RUN: %t.testdir1/lib1.a %t.testdir2/lib2.a +# RUN: llvm-objdump -s %t7 | FileCheck --check-prefix=SECONDFIRST %s + +# Verify matching directories. +# RUN: echo "SECTIONS { .foo : { \ +# RUN: *testdir2*(.foo) \ +# RUN: *testdir1*(.foo) } }" > %t8.script +# RUN: ld.lld -o %t8 --script %t8.script --whole-archive \ +# RUN: %t.testdir1/lib1.a %t.testdir2/lib2.a +# RUN: llvm-objdump -s %t8 | FileCheck --check-prefix=SECONDFIRST %s + +# Verify matching of archive library names in KEEP. +# RUN: echo "SECTIONS { .foo : { \ +# RUN: KEEP(*lib2*(.foo)) \ +# RUN: KEEP(*lib1*(.foo)) } }" > %t9.script +# RUN: ld.lld -o %t9 --script %t9.script --whole-archive \ +# RUN: %t.testdir1/lib1.a %t.testdir2/lib2.a +# RUN: llvm-objdump -s %t9 | FileCheck --check-prefix=SECONDFIRST %s + +# Verify matching directories in KEEP. +# RUN: echo "SECTIONS { .foo : { \ +# RUN: KEEP(*testdir2*(.foo)) \ +# RUN: KEEP(*testdir1*(.foo)) } }" > %t10.script +# RUN: ld.lld -o %t10 --script %t10.script --whole-archive \ +# RUN: %t.testdir1/lib1.a %t.testdir2/lib2.a +# RUN: llvm-objdump -s %t10 | FileCheck --check-prefix=SECONDFIRST %s + .global _start _start: nop diff --git a/test/ELF/linkerscript/header-addr.s b/test/ELF/linkerscript/header-addr.s index f37d319aaabe..70e6f674bafb 100644 --- a/test/ELF/linkerscript/header-addr.s +++ b/test/ELF/linkerscript/header-addr.s @@ -2,20 +2,20 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o # RUN: echo "PHDRS {all PT_LOAD PHDRS;} \ # RUN: SECTIONS { \ -# RUN: . = 0x2000; \ +# RUN: . = 0x2000 + SIZEOF_HEADERS; \ # RUN: .text : {*(.text)} :all \ # RUN: }" > %t.script -# RUN: ld.lld -o %t.so --script %t.script %t.o -shared +# RUN: ld.lld --hash-style=sysv -o %t.so --script %t.script %t.o -shared # RUN: llvm-readobj -program-headers %t.so | FileCheck %s # CHECK: ProgramHeaders [ # CHECK-NEXT: ProgramHeader { # CHECK-NEXT: Type: PT_LOAD # CHECK-NEXT: Offset: 0x40 -# CHECK-NEXT: VirtualAddress: 0x1040 -# CHECK-NEXT: PhysicalAddress: 0x1040 -# CHECK-NEXT: FileSize: 4176 -# CHECK-NEXT: MemSize: 4176 +# CHECK-NEXT: VirtualAddress: 0x2040 +# CHECK-NEXT: PhysicalAddress: 0x2040 +# CHECK-NEXT: FileSize: 200 +# CHECK-NEXT: MemSize: 200 # CHECK-NEXT: Flags [ # CHECK-NEXT: PF_R (0x4) # CHECK-NEXT: PF_W (0x2) @@ -25,7 +25,7 @@ # CHECK-NEXT: } # CHECK-NEXT: ] -# RUN: ld.lld -o %t2.so --script %t.script %t.o -shared -z max-page-size=0x2000 +# RUN: ld.lld --hash-style=sysv -o %t2.so --script %t.script %t.o -shared -z max-page-size=0x2000 # RUN: llvm-readobj -program-headers %t2.so \ # RUN: | FileCheck --check-prefix=MAXPAGE %s @@ -33,10 +33,10 @@ # MAXPAGE-NEXT: ProgramHeader { # MAXPAGE-NEXT: Type: PT_LOAD # MAXPAGE-NEXT: Offset: 0x40 -# MAXPAGE-NEXT: VirtualAddress: 0x40 -# MAXPAGE-NEXT: PhysicalAddress: 0x40 -# MAXPAGE-NEXT: FileSize: 8272 -# MAXPAGE-NEXT: MemSize: 8272 +# MAXPAGE-NEXT: VirtualAddress: 0x2040 +# MAXPAGE-NEXT: PhysicalAddress: 0x2040 +# MAXPAGE-NEXT: FileSize: 200 +# MAXPAGE-NEXT: MemSize: 200 # MAXPAGE-NEXT: Flags [ # MAXPAGE-NEXT: PF_R # MAXPAGE-NEXT: PF_W diff --git a/test/ELF/linkerscript/header-phdr.s b/test/ELF/linkerscript/header-phdr.s new file mode 100644 index 000000000000..8c9097d8dfa5 --- /dev/null +++ b/test/ELF/linkerscript/header-phdr.s @@ -0,0 +1,13 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: echo "PHDRS { foobar PT_LOAD FILEHDR PHDRS; } \ +# RUN: SECTIONS { . = 0x1000; .abc : { *(.zed) } : foobar }" > %t.script +# RUN: ld.lld --script %t.script %t.o -o %t +# RUN: llvm-readelf -l -S -W %t | FileCheck %s + +.section .zed, "a" +.zero 4 + + +# CHECK: [ 1] .abc PROGBITS 0000000000001000 001000 000004 00 A 0 0 1 +# CHECK: LOAD 0x000000 0x0000000000000000 0x0000000000000000 0x001004 0x001004 R E 0x1000 diff --git a/test/ELF/linkerscript/image-base.s b/test/ELF/linkerscript/image-base.s new file mode 100644 index 000000000000..0ae463fce8a9 --- /dev/null +++ b/test/ELF/linkerscript/image-base.s @@ -0,0 +1,18 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: echo "SECTIONS { mysym = .; }" > %t.script + +# RUN: ld.lld %t.o -o %t-default.elf -T %t.script +# RUN: llvm-readobj --symbols %t-default.elf | FileCheck %s --check-prefix=DEFAULT +# DEFAULT: Name: mysym +# DEFAULT-NEXT: Value: 0x0 + +# RUN: ld.lld %t.o -o %t-switch.elf -T %t.script --image-base=0x100000 +# RUN: llvm-readobj --symbols %t-switch.elf | FileCheck %s --check-prefix=SWITCH +# SWITCH: Name: mysym +# SWITCH-NEXT: Value: 0x100000 + +.global _start +_start: + nop diff --git a/test/ELF/linkerscript/implicit-program-header.s b/test/ELF/linkerscript/implicit-program-header.s index 9598a6abebb0..95cdf142fe42 100644 --- a/test/ELF/linkerscript/implicit-program-header.s +++ b/test/ELF/linkerscript/implicit-program-header.s @@ -1,6 +1,6 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -# RUN: ld.lld -o %t1 --script %S/Inputs/implicit-program-header.script \ +# RUN: ld.lld --hash-style=sysv -o %t1 --script %S/Inputs/implicit-program-header.script \ # RUN: %t.o -shared # RUN: llvm-readobj -elf-output-style=GNU -l %t1 | FileCheck %s diff --git a/test/ELF/linkerscript/include-cycle.s b/test/ELF/linkerscript/include-cycle.s new file mode 100644 index 000000000000..e93ed904f05a --- /dev/null +++ b/test/ELF/linkerscript/include-cycle.s @@ -0,0 +1,15 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o + +# RUN: echo "INCLUDE \"%t1.script\"" > %t1.script +# RUN: not ld.lld %t.o %t1.script 2>&1 | FileCheck %s + +# RUN: echo "INCLUDE \"%t2.script\"" > %t1.script +# RUN: echo "INCLUDE \"%t1.script\"" > %t2.script +# RUN: not ld.lld %t.o %t1.script 2>&1 | FileCheck %s + +# CHECK: there is a cycle in linker script INCLUDEs + +.globl _start +_start: + ret diff --git a/test/ELF/linkerscript/linker-script-in-search-path.s b/test/ELF/linkerscript/linker-script-in-search-path.s new file mode 100644 index 000000000000..be83b55b8995 --- /dev/null +++ b/test/ELF/linkerscript/linker-script-in-search-path.s @@ -0,0 +1,19 @@ +# REQUIRES: x86 +# Check that we fall back to search paths if a linker script was not found +# This behaviour matches ld.bfd and various projects appear to rely on this + +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: mkdir -p %T/searchpath +# RUN: echo "OUTPUT(\"%t.out\")" > %T/searchpath/foo.script +# RUN: ld.lld -T%T/searchpath/foo.script %t.o +# RUN: llvm-readobj %t.out | FileCheck %s +# CHECK: Format: ELF64-x86-64 + +# If the linker script specified with -T is missing we should emit an error +# RUN: not ld.lld -Tfoo.script %t.o 2>&1 | FileCheck %s -check-prefix ERROR +# ERROR: error: cannot find linker script foo.script + +# But if it exists in the search path we should fall back to that instead: +# RUN: rm %t.out +# RUN: ld.lld -L %T/searchpath -Tfoo.script %t.o +# RUN: llvm-readobj %t.out | FileCheck %s diff --git a/test/ELF/linkerscript/linkerscript.s b/test/ELF/linkerscript/linkerscript.s index cac902af4270..6a239ea57c8d 100644 --- a/test/ELF/linkerscript/linkerscript.s +++ b/test/ELF/linkerscript/linkerscript.s @@ -37,8 +37,8 @@ # RUN: echo "OUTPUT(\"%t.out\")" > %T/foo.script # RUN: not ld.lld %t.script > %t.log 2>&1 # RUN: FileCheck -check-prefix=INCLUDE_ERR %s < %t.log -# INCLUDE_ERR: error: {{.+}}.script:1: cannot open foo.script -# INCLUDE_ERR-NEXT: error: {{.+}}.script:1: INCLUDE "foo.script" +# INCLUDE_ERR: error: {{.+}}.script:1: cannot find linker script foo.script +# INCLUDE_ERR-NEXT: INCLUDE "foo.script" # RUN: ld.lld -L %T %t.script %t # RUN: echo "FOO(BAR)" > %t.script diff --git a/test/ELF/linkerscript/memory-at.s b/test/ELF/linkerscript/memory-at.s new file mode 100644 index 000000000000..9e56dbdbd657 --- /dev/null +++ b/test/ELF/linkerscript/memory-at.s @@ -0,0 +1,46 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +# RUN: echo "MEMORY { \ +# RUN: FLASH (rx) : ORIGIN = 0x1000, LENGTH = 0x100 \ +# RUN: RAM (rwx) : ORIGIN = 0x2000, LENGTH = 0x100 } \ +# RUN: SECTIONS { \ +# RUN: .text : { *(.text*) } > FLASH \ +# RUN: __etext = .; \ +# RUN: .data : AT (__etext) { *(.data*) } > RAM \ +# RUN: }" > %t.script +# RUN: ld.lld %t --script %t.script -o %t2 +# RUN: llvm-readobj -program-headers %t2 | FileCheck %s + +# CHECK: ProgramHeaders [ +# CHECK-NEXT: ProgramHeader { +# CHECK-NEXT: Type: PT_LOAD +# CHECK-NEXT: Offset: 0x1000 +# CHECK-NEXT: VirtualAddress: 0x1000 +# CHECK-NEXT: PhysicalAddress: 0x1000 +# CHECK-NEXT: FileSize: 8 +# CHECK-NEXT: MemSize: 8 +# CHECK-NEXT: Flags [ +# CHECK-NEXT: PF_R +# CHECK-NEXT: PF_X +# CHECK-NEXT: ] +# CHECK-NEXT: Alignment: +# CHECK-NEXT: } +# CHECK-NEXT: ProgramHeader { +# CHECK-NEXT: Type: PT_LOAD +# CHECK-NEXT: Offset: 0x2000 +# CHECK-NEXT: VirtualAddress: 0x2000 +# CHECK-NEXT: PhysicalAddress: 0x1008 +# CHECK-NEXT: FileSize: 8 +# CHECK-NEXT: MemSize: 8 +# CHECK-NEXT: Flags [ +# CHECK-NEXT: PF_R +# CHECK-NEXT: PF_W +# CHECK-NEXT: ] +# CHECK-NEXT: Alignment: +# CHECK-NEXT: } + +.section .text, "ax" +.quad 0 + +.section .data, "aw" +.quad 0 diff --git a/test/ELF/linkerscript/memory-err.s b/test/ELF/linkerscript/memory-err.s new file mode 100644 index 000000000000..19517687b78d --- /dev/null +++ b/test/ELF/linkerscript/memory-err.s @@ -0,0 +1,16 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +# RUN: echo "MEMORY { name : ORIGIN = DATA_SEGMENT_RELRO_END; }" > %t.script +# RUN: not ld.lld -shared -o %t2 --script %t.script %t 2>&1 | FileCheck %s +# CHECK: error: {{.*}}.script:1: unable to calculate page size + +# RUN: echo "MEMORY { name : ORIGIN = CONSTANT(COMMONPAGESIZE); }" > %t.script +# RUN: not ld.lld -shared -o %t2 --script %t.script %t 2>&1 |\ +# RUN: FileCheck %s --check-prefix=ERR2 +# ERR2: error: {{.*}}.script:1: unable to calculate page size + +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +# RUN: echo "MEMORY { name : ORIGIN = .; }" > %t.script +# RUN: not ld.lld -shared -o %t2 --script %t.script %t 2>&1 |\ +# RUN: FileCheck %s --check-prefix=ERR3 +# ERR3: error: {{.*}}.script:1: unable to get location counter value diff --git a/test/ELF/linkerscript/memory.s b/test/ELF/linkerscript/memory.s index 774a6f92ab17..172768394d30 100644 --- a/test/ELF/linkerscript/memory.s +++ b/test/ELF/linkerscript/memory.s @@ -21,8 +21,8 @@ # RUN: rom (rx) : org = (0x80 * 0x1000 * 0x1000), len = 64M \ # RUN: } \ # RUN: SECTIONS { \ -# RUN: .text : { *(.text) } > rom \ -# RUN: .data : { *(.data) } > ram \ +# RUN: .text : { *(.text) } >rom \ +# RUN: .data : { *(.data) } >ram \ # RUN: }" > %t.script # RUN: ld.lld -o %t1 --script %t.script %t # RUN: llvm-objdump -section-headers %t1 | FileCheck -check-prefix=RAMROM %s diff --git a/test/ELF/linkerscript/memory2.s b/test/ELF/linkerscript/memory2.s new file mode 100644 index 000000000000..2e7381fb8914 --- /dev/null +++ b/test/ELF/linkerscript/memory2.s @@ -0,0 +1,14 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +# RUN: echo "MEMORY { ram (rwx) : ORIGIN = 0, LENGTH = 2K } \ +# RUN: SECTIONS { .text : { *(.text*) } > ram }" > %t.script +# RUN: ld.lld -o %t2 --script %t.script %t + +.text +.global _start +_start: + .zero 1024 + +.section .text.foo,"ax",%progbits +foo: + nop diff --git a/test/ELF/linkerscript/memory3.s b/test/ELF/linkerscript/memory3.s new file mode 100644 index 000000000000..6a24313f0621 --- /dev/null +++ b/test/ELF/linkerscript/memory3.s @@ -0,0 +1,23 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +# RUN: echo "MEMORY { ram2 (ax) : ORIGIN = 0x1000, LENGTH = 1K \ +# RUN: ram1 (ax) : ORIGIN = 0x4000, LENGTH = 1K } \ +# RUN: SECTIONS {}" > %t1.script +# RUN: ld.lld -o %t1 --script %t1.script %t +# RUN: llvm-objdump -section-headers %t1 | FileCheck %s + +# RUN: echo "MEMORY { ram1 (ax) : ORIGIN = 0x1000, LENGTH = 1K \ +# RUN: ram2 (ax) : ORIGIN = 0x4000, LENGTH = 1K } \ +# RUN: SECTIONS {}" > %t2.script +# RUN: ld.lld -o %t2 --script %t2.script %t +# RUN: llvm-objdump -section-headers %t2 | FileCheck %s + +## Check we place .text into first defined memory region with appropriate flags. +# CHECK: Sections: +# CHECK: Idx Name Size Address +# CHECK: 0 00000000 0000000000000000 +# CHECK: 1 .text 00000001 0000000000001000 + +.section .text.foo,"ax",%progbits +foo: + nop diff --git a/test/ELF/linkerscript/merge-sections.s b/test/ELF/linkerscript/merge-sections.s index 950d822ec403..2709bdaee444 100644 --- a/test/ELF/linkerscript/merge-sections.s +++ b/test/ELF/linkerscript/merge-sections.s @@ -36,7 +36,7 @@ # RUN: llvm-readobj -s -t %t2 | FileCheck %s --check-prefix=GC # GC: Name: .foo -# GC-NEXT: Type: SHT_PROGBITS +# GC-NEXT: Type: SHT_NOBITS # GC-NEXT: Flags [ # GC-NEXT: SHF_ALLOC # GC-NEXT: ] diff --git a/test/ELF/linkerscript/no-space.s b/test/ELF/linkerscript/no-space.s index fc9e5b13325f..21a38e42b2a3 100644 --- a/test/ELF/linkerscript/no-space.s +++ b/test/ELF/linkerscript/no-space.s @@ -2,11 +2,11 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o # RUN: echo "SECTIONS {foo 0 : {*(foo*)} }" > %t.script -# RUN: ld.lld -o %t --script %t.script %t.o -shared +# RUN: ld.lld --hash-style=sysv -o %t --script %t.script %t.o -shared # RUN: llvm-readobj -elf-output-style=GNU -l %t | FileCheck %s # RUN: echo "SECTIONS {foo : {*(foo*)} }" > %t.script -# RUN: ld.lld -o %t --script %t.script %t.o -shared +# RUN: ld.lld --hash-style=sysv -o %t --script %t.script %t.o -shared # RUN: llvm-readobj -elf-output-style=GNU -l %t | FileCheck %s # There is not enough address space available for the header, so just start the PT_LOAD diff --git a/test/ELF/linkerscript/noload.s b/test/ELF/linkerscript/noload.s index 9d0e085a0504..28be55df1f12 100644 --- a/test/ELF/linkerscript/noload.s +++ b/test/ELF/linkerscript/noload.s @@ -4,10 +4,10 @@ # RUN: .data_noload_a (NOLOAD) : { *(.data_noload_a) } \ # RUN: .data_noload_b (0x10000) (NOLOAD) : { *(.data_noload_b) } };" > %t.script # RUN: ld.lld -o %t --script %t.script %t.o -# RUN: llvm-readobj --symbols -sections %t +# RUN: llvm-readobj --symbols -sections %t | FileCheck %s # CHECK: Section { -# CHECK-NEXT: Index: 2 +# CHECK: Index: 2 # CHECK-NEXT: Name: .data_noload_a # CHECK-NEXT: Type: SHT_NOBITS # CHECK-NEXT: Flags [ diff --git a/test/ELF/linkerscript/non-alloc.s b/test/ELF/linkerscript/non-alloc.s index 861c74996b85..3257cb965565 100644 --- a/test/ELF/linkerscript/non-alloc.s +++ b/test/ELF/linkerscript/non-alloc.s @@ -2,7 +2,7 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t # RUN: echo "SECTIONS { .foo 0 : {*(foo)} }" > %t.script -# RUN: ld.lld -o %t1 --script %t.script %t -shared +# RUN: ld.lld --hash-style=sysv -o %t1 --script %t.script %t -shared # RUN: llvm-readobj -elf-output-style=GNU -s -l %t1 | FileCheck %s # Test that we create all necessary PT_LOAD. We use to stop at the first diff --git a/test/ELF/linkerscript/operators.s b/test/ELF/linkerscript/operators.s index 470558d29df1..868805b34c2e 100644 --- a/test/ELF/linkerscript/operators.s +++ b/test/ELF/linkerscript/operators.s @@ -25,6 +25,7 @@ # RUN: commonpagesize = CONSTANT (COMMONPAGESIZE); \ # RUN: . = 0xfff0; \ # RUN: datasegmentalign = DATA_SEGMENT_ALIGN (0xffff, 0); \ +# RUN: datasegmentalign2 = DATA_SEGMENT_ALIGN (0, 0); \ # RUN: }" > %t.script # RUN: ld.lld %t --script %t.script -o %t2 # RUN: llvm-objdump -t %t2 | FileCheck %s @@ -51,6 +52,7 @@ # CHECK: 00000000001000 *ABS* 00000000 maxpagesize # CHECK: 00000000001000 *ABS* 00000000 commonpagesize # CHECK: 0000000000ffff *ABS* 00000000 datasegmentalign +# CHECK: 0000000000fff0 *ABS* 00000000 datasegmentalign2 ## Mailformed number error. # RUN: echo "SECTIONS { . = 0x12Q41; }" > %t.script diff --git a/test/ELF/linkerscript/orphan-discard.s b/test/ELF/linkerscript/orphan-discard.s new file mode 100644 index 000000000000..6fd6fafcd7f4 --- /dev/null +++ b/test/ELF/linkerscript/orphan-discard.s @@ -0,0 +1,25 @@ +# REQUIRES: x86 +# RUN: llvm-mc -position-independent -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: echo "SECTIONS { \ +# RUN: . = 0xffffffff80000000; \ +# RUN: .text : ALIGN(4096) { *(.text) } \ +# RUN: .data : ALIGN(4096) { *(.data) } \ +# RUN: .bss : ALIGN(4096) { *(.bss); } \ +# RUN: . = ALIGN(4096); \ +# RUN: _end = .; \ +# RUN: /DISCARD/ : { *(.comment) } \ +# RUN: }" > %t.script +# RUN: ld.lld -o %t --script %t.script %t.o +# RUN: llvm-readelf -s -symbols %t | FileCheck %s + +# CHECK: .bss NOBITS ffffffff80002000 002008 000002 00 WA 0 0 4096 +# CHECK: ffffffff80003000 0 NOTYPE GLOBAL DEFAULT 3 _end + +.section .text, "ax" + ret + +.section .data, "aw" + .quad 0 + +.section .bss, "", @nobits + .short 0 diff --git a/test/ELF/linkerscript/orphan-end.s b/test/ELF/linkerscript/orphan-end.s new file mode 100644 index 000000000000..5f56d8f487a2 --- /dev/null +++ b/test/ELF/linkerscript/orphan-end.s @@ -0,0 +1,57 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o + +# Test that .orphan_rx is placed after __stack_end. This matches bfd's +# behavior when the orphan section is the last one. + +# RUN: echo "SECTIONS { \ +# RUN: __start_text = .; \ +# RUN: .text : { *(.text*) } \ +# RUN: __end_text = .; \ +# RUN: __stack_start = .; \ +# RUN: . = . + 0x1000; \ +# RUN: __stack_end = .; \ +# RUN: }" > %t.script +# RUN: ld.lld -o %t --script %t.script %t.o +# RUN: llvm-readelf -S --symbols %t | FileCheck %s + +# CHECK-DAG: .text PROGBITS 0000000000000000 +# CHECK-DAG: .orphan_rx PROGBITS 0000000000001004 + +# CHECK-DAG: 0000000000000000 {{.*}} __start_text +# CHECK-DAG: 0000000000000004 {{.*}} __end_text +# CHECK-DAG: 0000000000000004 {{.*}} __stack_start +# CHECK-DAG: 0000000000001004 {{.*}} __stack_end + +# Test that .orphan_rx is now placed before __stack_end. This matches bfd's +# behavior when the orphan section is not the last one. + +# RUN: echo "SECTIONS { \ +# RUN: __start_text = .; \ +# RUN: .text : { *(.text*) } \ +# RUN: __end_text = .; \ +# RUN: __stack_start = .; \ +# RUN: . = . + 0x1000; \ +# RUN: __stack_end = .; \ +# RUN: .orphan_rw : { *(.orphan_rw*) } \ +# RUN: }" > %t.script +# RUN: ld.lld -o %t --script %t.script %t.o +# RUN: llvm-readelf -S --symbols %t | FileCheck --check-prefix=MIDDLE %s + +# MIDDLE-DAG: .text PROGBITS 0000000000000000 +# MIDDLE-DAG: .orphan_rx PROGBITS 0000000000000004 + +# MIDDLE-DAG: 0000000000000000 {{.*}} __start_text +# MIDDLE-DAG: 0000000000000004 {{.*}} __end_text +# MIDDLE-DAG: 0000000000000004 {{.*}} __stack_start +# MIDDLE-DAG: 0000000000001008 {{.*}} __stack_end + + .global _start +_start: + .zero 4 + + .section .orphan_rx,"ax" + .zero 4 + + .section .orphan_rw,"aw" + .zero 4 diff --git a/test/ELF/linkerscript/orphan-phdrs.s b/test/ELF/linkerscript/orphan-phdrs.s new file mode 100644 index 000000000000..648911162e97 --- /dev/null +++ b/test/ELF/linkerscript/orphan-phdrs.s @@ -0,0 +1,34 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: echo "PHDRS { \ +# RUN: exec PT_LOAD FLAGS(0x4 | 0x1); \ +# RUN: rw PT_LOAD FLAGS(0x4 | 0x2); \ +# RUN: } \ +# RUN: SECTIONS { \ +# RUN: .text : { *(.text) } :exec \ +# RUN: .empty : { *(.empty) } :rw \ +# RUN: .rw : { *(.rw) } \ +# RUN: }" > %t.script +# RUN: ld.lld -o %t --script %t.script %t.o +# RUN: llvm-readobj -elf-output-style=GNU -s -l %t | FileCheck %s + +## Check that the orphan section is placed correctly and belongs to +## the correct segment. + +# CHECK: Section Headers +# CHECK: .text +# CHECK-NEXT: .orphan +# CHECK-NEXT: .rw + +# CHECK: Segment Sections +# CHECK-NEXT: .text .orphan +# CHECK-NEXT: .rw + +.section .text, "ax" + ret + +.section .rw, "aw" + .quad 0 + +.section .orphan, "ax" + ret diff --git a/test/ELF/linkerscript/orphan-report.s b/test/ELF/linkerscript/orphan-report.s new file mode 100644 index 000000000000..241857b239c4 --- /dev/null +++ b/test/ELF/linkerscript/orphan-report.s @@ -0,0 +1,54 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: echo "SECTIONS { .text : { *(.text.1) } }" > %t.script + +## Check we do not report orphans by default even with -verbose. +# RUN: ld.lld -shared -o %t.out --script %t.script %t.o 2>&1 -verbose \ +# RUN: | FileCheck %s --check-prefix=DEFAULT +# DEFAULT-NOT: placed + +## Check --orphan-handling=place has the same behavior as default. +# RUN: ld.lld -shared --orphan-handling=place -o %t.out --script %t.script \ +# RUN: %t.o 2>&1 -verbose -error-limit=0 | FileCheck %s --check-prefix=DEFAULT + +## Check --orphan-handling=error reports errors about orphans. +# RUN: not ld.lld -shared --orphan-handling=error -o %t.out --script %t.script \ +# RUN: %t.o 2>&1 -verbose -error-limit=0 | FileCheck %s --check-prefix=REPORT +# REPORT: {{.*}}.o:(.text) is being placed in '.text' +# REPORT-NEXT: {{.*}}.o:(.text.2) is being placed in '.text' +# REPORT-NEXT: <internal>:(.comment) is being placed in '.comment' +# REPORT-NEXT: <internal>:(.bss) is being placed in '.bss' +# REPORT-NEXT: <internal>:(.bss.rel.ro) is being placed in '.bss.rel.ro' +# REPORT-NEXT: <internal>:(.dynsym) is being placed in '.dynsym' +# REPORT-NEXT: <internal>:(.gnu.version) is being placed in '.gnu.version' +# REPORT-NEXT: <internal>:(.gnu.version_r) is being placed in '.gnu.version_r' +# REPORT-NEXT: <internal>:(.gnu.hash) is being placed in '.gnu.hash' +# REPORT-NEXT: <internal>:(.hash) is being placed in '.hash' +# REPORT-NEXT: <internal>:(.dynamic) is being placed in '.dynamic' +# REPORT-NEXT: <internal>:(.dynstr) is being placed in '.dynstr' +# REPORT-NEXT: <internal>:(.rela.dyn) is being placed in '.rela.dyn' +# REPORT-NEXT: <internal>:(.got) is being placed in '.got' +# REPORT-NEXT: <internal>:(.got.plt) is being placed in '.got.plt' +# REPORT-NEXT: <internal>:(.got.plt) is being placed in '.got.plt' +# REPORT-NEXT: <internal>:(.rela.plt) is being placed in '.rela.plt' +# REPORT-NEXT: <internal>:(.rela.plt) is being placed in '.rela.plt' +# REPORT-NEXT: <internal>:(.plt) is being placed in '.plt' +# REPORT-NEXT: <internal>:(.plt) is being placed in '.plt' +# REPORT-NEXT: <internal>:(.eh_frame) is being placed in '.eh_frame' +# REPORT-NEXT: <internal>:(.symtab) is being placed in '.symtab' +# REPORT-NEXT: <internal>:(.shstrtab) is being placed in '.shstrtab' +# REPORT-NEXT: <internal>:(.strtab) is being placed in '.strtab' + +## Check --orphan-handling=warn reports warnings about orphans. +# RUN: ld.lld -shared --orphan-handling=warn -o %t.out --script %t.script \ +# RUN: %t.o 2>&1 -verbose | FileCheck %s --check-prefix=REPORT + +# RUN: not ld.lld --orphan-handling=foo -o %t.out --script %t.script %t.o 2>&1 \ +# RUN: | FileCheck %s --check-prefix=UNKNOWN +# UNKNOWN: unknown --orphan-handling mode: foo + +.section .text.1,"a" + nop + +.section .text.2,"a" + nop diff --git a/test/ELF/linkerscript/out-of-order.s b/test/ELF/linkerscript/out-of-order.s index 6cfd533c4e14..c43df43e5002 100644 --- a/test/ELF/linkerscript/out-of-order.s +++ b/test/ELF/linkerscript/out-of-order.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-linux %s -o %t.o # RUN: echo "SECTIONS { .data 0x4000 : { *(.data) } .text 0x2000 : { *(.text) } }" > %t.script -# RUN: ld.lld -o %t.so --script %t.script %t.o -shared +# RUN: ld.lld --hash-style=sysv -o %t.so --script %t.script %t.o -shared # RUN: llvm-objdump -section-headers %t.so | FileCheck %s # CHECK: Sections: diff --git a/test/ELF/linkerscript/phdr-check.s b/test/ELF/linkerscript/phdr-check.s index c7229ed3312c..b35256be6b71 100644 --- a/test/ELF/linkerscript/phdr-check.s +++ b/test/ELF/linkerscript/phdr-check.s @@ -1,14 +1,14 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t -# RUN: echo "SECTIONS { . = 0x10000000; .text : {*(.text.*)} }" > %t.script +# RUN: echo "SECTIONS { . = 0x10000000 + SIZEOF_HEADERS; .text : {*(.text.*)} }" > %t.script # RUN: ld.lld -o %t1 --script %t.script %t # RUN: llvm-readobj -program-headers %t1 | FileCheck %s # CHECK: ProgramHeaders [ # CHECK-NEXT: ProgramHeader { # CHECK-NEXT: Type: PT_PHDR (0x6) # CHECK-NEXT: Offset: 0x40 -# CHECK-NEXT: VirtualAddress: 0xFFFF040 +# CHECK-NEXT: VirtualAddress: 0x10000040 .global _start _start: diff --git a/test/ELF/linkerscript/phdrs.s b/test/ELF/linkerscript/phdrs.s index 025ced95b30a..b65015994533 100644 --- a/test/ELF/linkerscript/phdrs.s +++ b/test/ELF/linkerscript/phdrs.s @@ -39,9 +39,9 @@ # RUN: ld.lld -o %t1 --script %t.script %t # RUN: llvm-readobj -program-headers %t1 | FileCheck --check-prefix=DEFHDR %s -## Check that error is reported when trying to use phdr which is not listed +## Check that error is reported when trying to use phdr which is not listed ## inside PHDRS {} block -## TODO: If script doesn't contain PHDRS {} block then default phdr is always +## TODO: If script doesn't contain PHDRS {} block then default phdr is always ## created and error is not reported. # RUN: echo "PHDRS { all PT_LOAD; } \ # RUN: SECTIONS { .baz : {*(.foo.*)} :bar }" > %t.script diff --git a/test/ELF/linkerscript/provide-shared.s b/test/ELF/linkerscript/provide-shared.s new file mode 100644 index 000000000000..e3f1bdb2ea3d --- /dev/null +++ b/test/ELF/linkerscript/provide-shared.s @@ -0,0 +1,13 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/provide-shared.s -o %t2.o +# RUN: ld.lld %t2.o -o %t2.so -shared +# RUN: echo "SECTIONS { . = . + SIZEOF_HEADERS; PROVIDE(foo = 42);}" > %t.script +# RUN: ld.lld -o %t --script %t.script %t.o %t2.so +# RUN: llvm-objdump -t %t | FileCheck %s + +# CHECK: 000000000000002a *ABS* 00000000 foo + +.global _start +_start: +.quad foo diff --git a/test/ELF/linkerscript/region-alias.s b/test/ELF/linkerscript/region-alias.s new file mode 100644 index 000000000000..8a88f6f5ad9f --- /dev/null +++ b/test/ELF/linkerscript/region-alias.s @@ -0,0 +1,54 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +# RUN: echo "MEMORY { \ +# RUN: ROM (rwx): ORIGIN = 0x1000, LENGTH = 0x100 \ +# RUN: RAM (rwx): ORIGIN = 0x2000, LENGTH = 0x100 \ +# RUN: } \ +# RUN: INCLUDE \"%t.script.inc\" \ +# RUN: SECTIONS { \ +# RUN: .text : { *(.text*) } > ALIAS_TEXT \ +# RUN: .data : { *(.data*) } > ALIAS_DATA \ +# RUN: }" > %t.script + +## .text to ROM, .data to RAM. +# RUN: echo "REGION_ALIAS (\"ALIAS_TEXT\", ROM);" > %t.script.inc +# RUN: echo "REGION_ALIAS (\"ALIAS_DATA\", RAM);" >> %t.script.inc +# RUN: ld.lld %t --script %t.script -o %t2 +# RUN: llvm-objdump -section-headers %t2 | FileCheck %s +# CHECK: .text 00000001 0000000000001000 TEXT DATA +# CHECK: .data 00000008 0000000000002000 DATA + +## All to ROM. +# RUN: echo "REGION_ALIAS (\"ALIAS_TEXT\", ROM);" > %t.script.inc +# RUN: echo "REGION_ALIAS (\"ALIAS_DATA\", ROM);" >> %t.script.inc +# RUN: ld.lld %t --script %t.script -o %t2 +# RUN: llvm-objdump -section-headers %t2 | FileCheck %s --check-prefix=RAM +# RAM: .text 00000001 0000000000001000 TEXT DATA +# RAM: .data 00000008 0000000000001001 DATA + +## Redefinition of region. +# RUN: echo "REGION_ALIAS (\"ROM\", ROM);" > %t.script.inc +# RUN: not ld.lld %t --script %t.script -o %t2 2>&1 | \ +# RUN: FileCheck %s --check-prefix=ERR1 +# ERR1: {{.*}}script.inc:1: redefinition of memory region 'ROM' + +## Redefinition of alias. +# RUN: echo "REGION_ALIAS (\"ALIAS_TEXT\", ROM);" > %t.script.inc +# RUN: echo "REGION_ALIAS (\"ALIAS_TEXT\", ROM);" >> %t.script.inc +# RUN: not ld.lld %t --script %t.script -o %t2 2>&1 | \ +# RUN: FileCheck %s --check-prefix=ERR2 +# ERR2: {{.*}}script.inc:2: redefinition of memory region 'ALIAS_TEXT' + +## Attemp to create an alias for undefined region. +# RUN: echo "REGION_ALIAS (\"ALIAS_TEXT\", FOO);" > %t.script.inc +# RUN: not ld.lld %t --script %t.script -o %t2 2>&1 | \ +# RUN: FileCheck %s --check-prefix=ERR3 +# ERR3: {{.*}}script.inc:1: memory region 'FOO' is not defined + +.text +.global _start +_start: + nop + +.section .data,"aw" +.quad 0 diff --git a/test/ELF/linkerscript/repsection-symbol.s b/test/ELF/linkerscript/repsection-symbol.s index d2d8c9dd56ef..195380be9ff8 100644 --- a/test/ELF/linkerscript/repsection-symbol.s +++ b/test/ELF/linkerscript/repsection-symbol.s @@ -6,7 +6,7 @@ # RUN: .text : { *(.text) } \ # RUN: .foo : {foo1 = .; *(.foo.*) foo2 = .; *(.bar) foo3 = .;} \ # RUN: }" > %t.script -# RUN: ld.lld -o %t1 --script %t.script %t -shared +# RUN: ld.lld --hash-style=sysv -o %t1 --script %t.script %t -shared # RUN: llvm-readobj -t %t1 | FileCheck %s # CHECK: Name: foo1 diff --git a/test/ELF/linkerscript/sections-sort.s b/test/ELF/linkerscript/sections-sort.s index 0e99851910f4..99bbbead925c 100644 --- a/test/ELF/linkerscript/sections-sort.s +++ b/test/ELF/linkerscript/sections-sort.s @@ -2,7 +2,7 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o # RUN: echo "SECTIONS { .text : {*(.text)} foo : {*(foo)}}" > %t.script -# RUN: ld.lld -o %t --script %t.script %t.o -shared +# RUN: ld.lld --hash-style=sysv -o %t --script %t.script %t.o -shared # RUN: llvm-objdump --section-headers %t | FileCheck %s # Test the section order. This is a case where at least with libstdc++'s diff --git a/test/ELF/linkerscript/segment-headers.s b/test/ELF/linkerscript/segment-headers.s new file mode 100644 index 000000000000..b3bdad9ea08b --- /dev/null +++ b/test/ELF/linkerscript/segment-headers.s @@ -0,0 +1,26 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: echo "SECTIONS { . = 0x2000; .text : AT(0x100000) { *(.text) } }" > %t.script +# RUN: ld.lld -o %t --script %t.script %t.o +# RUN: llvm-readobj -l %t | FileCheck %s + +# CHECK: ProgramHeaders [ +# CHECK-NEXT: ProgramHeader { +# CHECK-NEXT: Type: PT_LOAD (0x1) +# CHECK-NEXT: Offset: 0x1000 +# CHECK-NEXT: VirtualAddress: 0x2000 +# CHECK-NEXT: PhysicalAddress: 0x100000 +# CHECK-NEXT: FileSize: 1 +# CHECK-NEXT: MemSize: 1 +# CHECK-NEXT: Flags [ (0x5) +# CHECK-NEXT: PF_R (0x4) +# CHECK-NEXT: PF_X (0x1) +# CHECK-NEXT: ] +# CHECK-NEXT: Alignment: 4096 +# CHECK-NEXT: } + +.section .text +.global _start + +_start: + ret diff --git a/test/ELF/linkerscript/segment-start.s b/test/ELF/linkerscript/segment-start.s index e46c398f63f9..69897d604b3b 100644 --- a/test/ELF/linkerscript/segment-start.s +++ b/test/ELF/linkerscript/segment-start.s @@ -1,6 +1,6 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -// RUN: ld.lld %t.o %S/Inputs/segment-start.script -shared -o %t.so +// RUN: ld.lld --hash-style=sysv %t.o %S/Inputs/segment-start.script -shared -o %t.so // RUN: llvm-readobj --dyn-symbols %t.so | FileCheck %s // CHECK: Name: foobar1 diff --git a/test/ELF/linkerscript/sort-non-script.s b/test/ELF/linkerscript/sort-non-script.s index b0517608d51b..4611b18d55ef 100644 --- a/test/ELF/linkerscript/sort-non-script.s +++ b/test/ELF/linkerscript/sort-non-script.s @@ -2,7 +2,7 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t # RUN: echo "SECTIONS { foo : {*(foo)} }" > %t.script -# RUN: ld.lld -o %t1 --script %t.script %t -shared +# RUN: ld.lld --hash-style=sysv -o %t1 --script %t.script %t -shared # RUN: llvm-readobj -elf-output-style=GNU -s %t1 | FileCheck %s # CHECK: .text {{.*}} AX diff --git a/test/ELF/linkerscript/subalign.s b/test/ELF/linkerscript/subalign.s index 8b441d440b0e..1396798c82f6 100644 --- a/test/ELF/linkerscript/subalign.s +++ b/test/ELF/linkerscript/subalign.s @@ -22,6 +22,23 @@ # SUBALIGN: 01000000 00000000 02000000 00000000 # SUBALIGN: 03000000 00000000 04000000 00000000 +## Test we do not assert or crash when dot(.) is used inside SUBALIGN. +## ld.bfd does not allow to use dot in such expressions, our behavior is +## different for simplicity of implementation. Value of dot is undefined. +# RUN: echo "SECTIONS { . = 0x32; .aaa : SUBALIGN(.) { *(.aaa*) } }" > %t3.script +# RUN: ld.lld %t1.o --script %t3.script -o %t3 +# RUN: llvm-objdump -s %t3 > /dev/null + +## Test we are able to link with zero alignment, this is consistent with bfd 2.26.1. +# RUN: echo "SECTIONS { .aaa : SUBALIGN(0) { *(.aaa*) } }" > %t4.script +# RUN: ld.lld %t1.o --script %t4.script -o %t4 +# RUN: llvm-objdump -s %t4 | FileCheck -check-prefix=SUBALIGN %s + +## Test we fail gracefuly when alignment value is not a power of 2. +# RUN: echo "SECTIONS { .aaa : SUBALIGN(3) { *(.aaa*) } }" > %t5.script +# RUN: not ld.lld %t1.o --script %t5.script -o %t5 2>&1 | FileCheck -check-prefix=ERR %s +# ERR: {{.*}}.script:1: alignment must be power of 2 + .global _start _start: nop diff --git a/test/ELF/linkerscript/symbol-assignexpr.s b/test/ELF/linkerscript/symbol-assignexpr.s index 14a1f0890ca6..9ab03a173f1c 100644 --- a/test/ELF/linkerscript/symbol-assignexpr.s +++ b/test/ELF/linkerscript/symbol-assignexpr.s @@ -6,7 +6,7 @@ # RUN: symbol2 = symbol + 0x1234; \ # RUN: symbol3 = symbol2; \ # RUN: symbol4 = symbol + -4; \ -# RUN: symbol5 = symbol - ~ 0xfffb; \ +# RUN: symbol5 = symbol - ~0xfffb; \ # RUN: symbol6 = symbol - ~(0xfff0 + 0xb); \ # RUN: symbol7 = symbol - ~ 0xfffb + 4; \ # RUN: symbol8 = ~ 0xffff + 4; \ @@ -15,6 +15,9 @@ # RUN: symbol11 = ((0x28000 + 0x1fff) & ~(0x1000 + -1)); \ # RUN: symbol12 = 0x1234; \ # RUN: symbol12 += 1; \ +# RUN: symbol13 = !1; \ +# RUN: symbol14 = !0; \ +# RUN: symbol15 = 0!=1; \ # RUN: bar = 0x5678; \ # RUN: baz = 0x9abc; \ # RUN: }" > %t.script @@ -39,6 +42,9 @@ # CHECK-NEXT: fedcba9876543210 *ABS* 00000000 symbol10 # CHECK-NEXT: 0000000000029000 *ABS* 00000000 symbol11 # CHECK-NEXT: 0000000000001235 *ABS* 00000000 symbol12 +# CHECK-NEXT: 0000000000000000 *ABS* 00000000 symbol13 +# CHECK-NEXT: 0000000000000001 *ABS* 00000000 symbol14 +# CHECK-NEXT: 0000000000000001 *ABS* 00000000 symbol15 # RUN: echo "SECTIONS { symbol2 = symbol; }" > %t2.script # RUN: not ld.lld -o %t2 --script %t2.script %t 2>&1 \ diff --git a/test/ELF/linkerscript/symbol-only-flags.s b/test/ELF/linkerscript/symbol-only-flags.s new file mode 100644 index 000000000000..300d8d88da97 --- /dev/null +++ b/test/ELF/linkerscript/symbol-only-flags.s @@ -0,0 +1,20 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: echo "SECTIONS { . = SIZEOF_HEADERS; \ +# RUN: .tbss : { *(.tbss) } \ +# RUN: .foo : { bar = .; } }" > %t.script +# RUN: ld.lld -o %t --script %t.script %t.o +# RUN: llvm-readobj -s %t | FileCheck %s + +## Check .foo does not get SHF_TLS flag. +# CHECK: Section { +# CHECK: Index: +# CHECK: Name: .foo +# CHECK-NEXT: Type: SHT_NOBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_ALLOC +# CHECK-NEXT: SHF_WRITE +# CHECK-NEXT: ] + +.section .tbss,"awT",@nobits +.quad 0 diff --git a/test/ELF/linkerscript/symbol-only.s b/test/ELF/linkerscript/symbol-only.s index 2fb57260b333..76d54f01cdc7 100644 --- a/test/ELF/linkerscript/symbol-only.s +++ b/test/ELF/linkerscript/symbol-only.s @@ -12,7 +12,7 @@ # CHECK: Sections: # CHECK-NEXT: Idx Name Size Address # CHECK-NEXT: 0 00000000 0000000000000000 -# CHECK: abc 00000000 [[ADDR:[0-9a-f]*]] DATA +# CHECK: abc 00000000 [[ADDR:[0-9a-f]*]] BSS # CHECK-NEXT: bar 00000000 0000000000001000 DATA # CHECK: SYMBOL TABLE: diff --git a/test/ELF/linkerscript/symbol-ordering-file.s b/test/ELF/linkerscript/symbol-ordering-file.s new file mode 100644 index 000000000000..be686c420887 --- /dev/null +++ b/test/ELF/linkerscript/symbol-ordering-file.s @@ -0,0 +1,23 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: echo "SECTIONS { .foo : { *(.foo) } }" > %t.script + +# RUN: ld.lld %t.o --script %t.script -o %t.out +# RUN: llvm-objdump -s %t.out| FileCheck %s --check-prefix=BEFORE +# BEFORE: Contents of section .foo: +# BEFORE-NEXT: 1122 + +# RUN: echo "_foo2" > %t.ord +# RUN: echo "_foo1" >> %t.ord +# RUN: ld.lld --symbol-ordering-file %t.ord %t.o --script %t.script -o %t2.out +# RUN: llvm-objdump -s %t2.out| FileCheck %s --check-prefix=AFTER +# AFTER: Contents of section .foo: +# AFTER-NEXT: 2211 + +.section .foo,"ax",@progbits,unique,1 +_foo1: + .byte 0x11 + +.section .foo,"ax",@progbits,unique,2 +_foo2: + .byte 0x22 diff --git a/test/ELF/linkerscript/symbol-reserved.s b/test/ELF/linkerscript/symbol-reserved.s index e0b259597381..8ae9d0cd661a 100644 --- a/test/ELF/linkerscript/symbol-reserved.s +++ b/test/ELF/linkerscript/symbol-reserved.s @@ -17,6 +17,34 @@ # ALIGNED: 0000000000200005 .text 00000000 .hidden newsym +# RUN: echo "PROVIDE_HIDDEN(newsym = ALIGN(3, 8) + 10);" > %t.script +# RUN: ld.lld -o %t1 %t.script %t +# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=ALIGN-ADD %s +# ALIGN-ADD: 0000000000000012 *ABS* 00000000 .hidden newsym + +# RUN: echo "PROVIDE_HIDDEN(newsym = ALIGN(11, 8) - 10);" > %t.script +# RUN: ld.lld -o %t1 %t.script %t +# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=ALIGN-SUB %s +# ALIGN-SUB: 0000000000000006 *ABS* 00000000 .hidden newsym + +# RUN: echo "PROVIDE_HIDDEN(newsym = ALIGN(_end, CONSTANT(MAXPAGESIZE)) + 5);" > %t.script +# RUN: ld.lld -o %t1 %t %t.script +# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=RELATIVE %s +# RELATIVE: 0000000000202005 .text 00000000 .hidden newsym +# RELATIVE: 0000000000201007 .text 00000000 _end + +# RUN: echo "PROVIDE_HIDDEN(newsym = ALIGN(_end, CONSTANT(MAXPAGESIZE)) + 5);" > %t.script +# RUN: ld.lld -o %t1 --script %p/Inputs/symbol-reserved.script %t %t.script +# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=RELATIVE-ADD %s +# RELATIVE-ADD: 0000000000001005 .text 00000000 .hidden newsym +# RELATIVE-ADD: 0000000000000007 .text 00000000 .hidden _end + +# RUN: echo "PROVIDE_HIDDEN(newsym = ALIGN(_end, CONSTANT(MAXPAGESIZE)) - 5);" > %t.script +# RUN: ld.lld -o %t1 --script %p/Inputs/symbol-reserved.script %t %t.script +# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=RELATIVE-SUB %s +# RELATIVE-SUB: 0000000000000ffb .text 00000000 .hidden newsym +# RELATIVE-SUB: 0000000000000007 .text 00000000 .hidden _end + .global _start _start: lea newsym(%rip),%rax diff --git a/test/ELF/linkerscript/symbols.s b/test/ELF/linkerscript/symbols.s index 4656635171c8..a6d797584417 100644 --- a/test/ELF/linkerscript/symbols.s +++ b/test/ELF/linkerscript/symbols.s @@ -12,14 +12,13 @@ # The symbol is not referenced. Don't provide it. # RUN: echo "SECTIONS { PROVIDE(newsym = 1);}" > %t.script # RUN: ld.lld -o %t1 --script %t.script %t -# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=PROVIDE1 %s -# PROVIDE1-NOT: 0000000000000001 *ABS* 00000000 newsym +# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=DONTPROVIDE %s +# DONTPROVIDE-NOT: newsym # The symbol is not referenced. Don't provide it. # RUN: echo "SECTIONS { PROVIDE_HIDDEN(newsym = 1);}" > %t.script # RUN: ld.lld -o %t1 --script %t.script %t -# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=HIDDEN1 %s -# HIDDEN1-NOT: 0000000000000001 *ABS* 00000000 .hidden newsym +# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=DONTPROVIDE %s # Provide existing symbol. The value should be 0, even though we # have value of 1 in PROVIDE() @@ -44,14 +43,12 @@ # The symbol is not referenced. Don't provide it. # RUN: echo "PROVIDE(newsym = 1);" > %t.script # RUN: ld.lld -o %t1 --script %t.script %t -# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=PROVIDE4 %s -# PROVIDE4-NOT: 0000000000000001 *ABS* 00000000 newsym +# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=DONTPROVIDE %s # The symbol is not referenced. Don't provide it. # RUN: echo "PROVIDE_HIDDEN(newsym = 1);" > %t.script # RUN: ld.lld -o %t1 --script %t.script %t -# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=HIDDEN4 %s -# HIDDEN4-NOT: 0000000000000001 *ABS* 00000000 .hidden newsym +# RUN: llvm-objdump -t %t1 | FileCheck --check-prefix=DONTPROVIDE %s # Provide existing symbol. The value should be 0, even though we # have value of 1 in PROVIDE() diff --git a/test/ELF/linkerscript/thunk-gen-mips.s b/test/ELF/linkerscript/thunk-gen-mips.s new file mode 100644 index 000000000000..97d06d0ee654 --- /dev/null +++ b/test/ELF/linkerscript/thunk-gen-mips.s @@ -0,0 +1,40 @@ +# REQUIRES: mips +# RUN: llvm-mc -filetype=obj -defsym=MAIN=1 -triple=mips-unknown-freebsd %s -o %t +# RUN: llvm-mc -filetype=obj -defsym=TARGET=1 -triple=mips-unknown-freebsd %s -o %t1 + +# SECTIONS command with the first pattern that does not match. +# Linking a PIC and non-PIC object files triggers the LA25 thunk generation. +# RUN: echo "SECTIONS { \ +# RUN: .text : { \ +# RUN: *(.nomatch) \ +# RUN: %t(.text) \ +# RUN: . = . + 0x100000 ; \ +# RUN: %t1(.text) \ +# RUN: } \ +# RUN: }" > %t.script +# RUN: ld.lld -o %t.exe --script %t.script %t %t1 +# RUN: llvm-objdump -t %t.exe | FileCheck %s +# CHECK: SYMBOL TABLE: +# CHECK-ANY: 00000000 .text 00000000 _start +# CHECK-ANY: 0010000c l F .text 00000010 __LA25Thunk_too_far +# CHECK-ANY: 00100020 g F .text 00000024 too_far + +.ifdef MAIN +.global _start +_start: + j too_far + nop +.endif + +.ifdef TARGET + .text + .abicalls + .set noreorder + .globl too_far + .ent too_far +too_far: + nop + jr $ra + nop + .end too_far +.endif diff --git a/test/ELF/linkerscript/unused-synthetic.s b/test/ELF/linkerscript/unused-synthetic.s index c9295fff7b59..b7cedbc8e09c 100644 --- a/test/ELF/linkerscript/unused-synthetic.s +++ b/test/ELF/linkerscript/unused-synthetic.s @@ -13,6 +13,16 @@ # CHECK: .text # CHECK-NEXT: .dynsym +# Test that the size of a removed unused synthetic input section is not added +# to the output section size. Adding a symbol assignment prevents removal of +# the output section, but does not cause the section size to be recomputed. +# RUN: echo "SECTIONS { \ +# RUN: .got.plt : { a_sym = .; *(.got.plt) } \ +# RUN: }" > %t2.script +# RUN: ld.lld -shared -o %t2.so --script %t2.script %t.o +# RUN: llvm-objdump -section-headers %t2.so | FileCheck %s --check-prefix=CHECK2 +# CHECK2: .got.plt 00000000 + .global _start _start: nop diff --git a/test/ELF/linkerscript/version-linker-symbol.s b/test/ELF/linkerscript/version-linker-symbol.s new file mode 100644 index 000000000000..de30cf5c2ed5 --- /dev/null +++ b/test/ELF/linkerscript/version-linker-symbol.s @@ -0,0 +1,28 @@ +# REQUIRES: x86 + +# RUN: echo "VER1 { global: _end; foo ; local: * ; } ;" > %t.script +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld --version-script %t.script -shared %t.o -o %t.so +# RUN: llvm-readobj -dyn-symbols %t.so | FileCheck %s + +# CHECK: Name: _end@@VER1 +# CHECK-NEXT: Value: 0 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: None +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: .dynamic + +# CHECK: Name: foo@@VER1 +# CHECK-NEXT: Value: 0 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: None +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: .text + +.global foo +foo: + .data + .quad _end + .quad foo diff --git a/test/ELF/lit.local.cfg b/test/ELF/lit.local.cfg index b93a36d2b50b..284077d687fa 100644 --- a/test/ELF/lit.local.cfg +++ b/test/ELF/lit.local.cfg @@ -1,2 +1 @@ config.suffixes = ['.test', '.s', '.ll'] - diff --git a/test/ELF/local-got-pie.s b/test/ELF/local-got-pie.s index 417f9d002034..b1b213af6659 100644 --- a/test/ELF/local-got-pie.s +++ b/test/ELF/local-got-pie.s @@ -1,5 +1,5 @@ // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o -// RUN: ld.lld %t.o -o %t -pie +// RUN: ld.lld --hash-style=sysv %t.o -o %t -pie // RUN: llvm-readobj -s -r -d %t | FileCheck %s // RUN: llvm-objdump -d %t | FileCheck --check-prefix=DISASM %s diff --git a/test/ELF/local-got-shared.s b/test/ELF/local-got-shared.s index e4fd46997517..c858424cfd96 100644 --- a/test/ELF/local-got-shared.s +++ b/test/ELF/local-got-shared.s @@ -1,5 +1,5 @@ // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o -// RUN: ld.lld %t.o -o %t -shared +// RUN: ld.lld --hash-style=sysv %t.o -o %t -shared // RUN: llvm-readobj -s -r -d %t | FileCheck %s // RUN: llvm-objdump -d %t | FileCheck --check-prefix=DISASM %s diff --git a/test/ELF/local-got.s b/test/ELF/local-got.s index 7e6ef9e0be7e..17517f6a70ea 100644 --- a/test/ELF/local-got.s +++ b/test/ELF/local-got.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o // RUN: ld.lld -shared %t2.o -o %t2.so -// RUN: ld.lld %t.o %t2.so -o %t +// RUN: ld.lld --hash-style=sysv %t.o %t2.so -o %t // RUN: llvm-readobj -s -r -section-data %t | FileCheck %s // RUN: llvm-objdump -d %t | FileCheck --check-prefix=DISASM %s diff --git a/test/ELF/lto-plugin-ignore.s b/test/ELF/lto-plugin-ignore.s new file mode 100644 index 000000000000..2f45a43b2428 --- /dev/null +++ b/test/ELF/lto-plugin-ignore.s @@ -0,0 +1,11 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +# RUN: ld.lld %t -plugin-opt=/foo/bar -plugin-opt=-fresolution=zed \ +# RUN: -plugin-opt=-pass-through=-lgcc -plugin-opt=-function-sections \ +# RUN: -plugin-opt=-data-sections -o /dev/null + +# RUN: not ld.lld %t -plugin-opt=-data-sectionssss \ +# RUN: -plugin-opt=-function-sectionsss 2>&1 | FileCheck %s +# CHECK: unknown option: -data-sectionsss +# CHECK: unknown option: -function-sectionsss diff --git a/test/ELF/lto/Inputs/data-ordering-lto.ll b/test/ELF/lto/Inputs/data-ordering-lto.ll new file mode 100644 index 000000000000..a95fa6d5a58a --- /dev/null +++ b/test/ELF/lto/Inputs/data-ordering-lto.ll @@ -0,0 +1,6 @@ +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-scei-ps4" + +@pat = global i32 33, align 4 +@tin = global i32 33, align 4 +@dipsy = global i32 33, align 4 diff --git a/test/ELF/lto/Inputs/linker-script-symbols-ipo.ll b/test/ELF/lto/Inputs/linker-script-symbols-ipo.ll new file mode 100644 index 000000000000..c872f9e1dd52 --- /dev/null +++ b/test/ELF/lto/Inputs/linker-script-symbols-ipo.ll @@ -0,0 +1,9 @@ +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +declare i32 @bar() + +define i32 @_start() { + %1 = tail call i32 @bar() + ret i32 %1 +} diff --git a/test/ELF/lto/Inputs/symbol-ordering-lto.ll b/test/ELF/lto/Inputs/symbol-ordering-lto.ll new file mode 100644 index 000000000000..164659ce27ba --- /dev/null +++ b/test/ELF/lto/Inputs/symbol-ordering-lto.ll @@ -0,0 +1,10 @@ +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-scei-ps4" + +define i32 @tin() { + ret i32 22 +} + +define i32 @pat() { + ret i32 42 +} diff --git a/test/ELF/lto/cache.ll b/test/ELF/lto/cache.ll index 6731f522606f..5ab74f5c5457 100644 --- a/test/ELF/lto/cache.ll +++ b/test/ELF/lto/cache.ll @@ -7,7 +7,7 @@ ; Create two files that would be removed by cache pruning due to age. ; We should only remove files matching the pattern "llvmcache-*". ; RUN: touch -t 197001011200 %t.cache/llvmcache-foo %t.cache/foo -; RUN: ld.lld --thinlto-cache-dir=%t.cache --thinlto-cache-policy prune_after=1h -o %t3 %t2.o %t.o +; RUN: ld.lld --thinlto-cache-dir=%t.cache --thinlto-cache-policy prune_after=1h:prune_interval=0s -o %t3 %t2.o %t.o ; Two cached objects, plus a timestamp file and "foo", minus the file we removed. ; RUN: ls %t.cache | count 4 @@ -16,13 +16,21 @@ ; RUN: %python -c "print(' ' * 65536)" > %t.cache/llvmcache-foo ; This should leave the file in place. -; RUN: ld.lld --thinlto-cache-dir=%t.cache --thinlto-cache-policy cache_size_bytes=128k -o %t3 %t2.o %t.o +; RUN: ld.lld --thinlto-cache-dir=%t.cache --thinlto-cache-policy cache_size_bytes=128k:prune_interval=0s -o %t3 %t2.o %t.o ; RUN: ls %t.cache | count 5 ; This should remove it. -; RUN: ld.lld --thinlto-cache-dir=%t.cache --thinlto-cache-policy cache_size_bytes=32k -o %t3 %t2.o %t.o +; RUN: ld.lld --thinlto-cache-dir=%t.cache --thinlto-cache-policy cache_size_bytes=32k:prune_interval=0s -o %t3 %t2.o %t.o ; RUN: ls %t.cache | count 4 +; Setting max number of files to 0 should disable the limit, not delete everything. +; RUN: ld.lld --thinlto-cache-dir=%t.cache --thinlto-cache-policy prune_after=0s:cache_size=0%:cache_size_files=0:prune_interval=0s -o %t3 %t2.o %t.o +; RUN: ls %t.cache | count 4 + +; Delete everything except for the timestamp, "foo" and one cache file. +; RUN: ld.lld --thinlto-cache-dir=%t.cache --thinlto-cache-policy prune_after=0s:cache_size=0%:cache_size_files=1:prune_interval=0s -o %t3 %t2.o %t.o +; RUN: ls %t.cache | count 3 + target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" diff --git a/test/ELF/lto/data-ordering-lto.s b/test/ELF/lto/data-ordering-lto.s new file mode 100644 index 000000000000..0364e587b908 --- /dev/null +++ b/test/ELF/lto/data-ordering-lto.s @@ -0,0 +1,27 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-scei-ps4 %s -o %t.o +# RUN: llvm-as %p/Inputs/data-ordering-lto.ll -o %t.bc + +# Set up the symbol file +# RUN: echo "tin " > %t_order_lto.txt +# RUN: echo "dipsy " >> %t_order_lto.txt +# RUN: echo "pat " >> %t_order_lto.txt + +# RUN: ld.lld --symbol-ordering-file %t_order_lto.txt %t.o %t.bc -o %t2.out +# RUN: llvm-readobj -elf-output-style=GNU -t %t2.out| FileCheck %s + +# Check that the order is tin -> dipsy -> pat. + +# CHECK: Symbol table '.symtab' contains 5 entries: +# CHECK-NEXT: Num: Value Size Type Bind Vis Ndx Name +# CHECK-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND +# CHECK-NEXT: 1: 0000000000201000 0 NOTYPE GLOBAL DEFAULT 1 _start +# CHECK-NEXT: 2: 0000000000202004 4 OBJECT GLOBAL DEFAULT 2 dipsy +# CHECK-NEXT: 3: 0000000000202008 4 OBJECT GLOBAL DEFAULT 2 pat +# CHECK-NEXT: 4: 0000000000202000 4 OBJECT GLOBAL DEFAULT 2 tin + +.globl _start +_start: + movl $pat, %ecx + movl $dipsy, %ebx + movl $tin, %eax diff --git a/test/ELF/lto/keep-undefined.ll b/test/ELF/lto/keep-undefined.ll new file mode 100644 index 000000000000..cb0f4ce491f9 --- /dev/null +++ b/test/ELF/lto/keep-undefined.ll @@ -0,0 +1,20 @@ +; REQUIRES: x86 +; This test checks that symbols which are specified in "-u" switches +; are kept over LTO if we link an executable. +; RUN: llvm-as %s -o %t.o +; RUN: ld.lld -m elf_x86_64 %t.o -o %tout -u foo +; RUN: llvm-nm %tout | FileCheck %s + +; CHECK: T foo + +target triple = "x86_64-unknown-linux-gnu" +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" + +define void @foo() { + ret void +} + +define void @_start() { + call void @foo() + ret void +} diff --git a/test/ELF/lto/linker-script-symbols-assign.ll b/test/ELF/lto/linker-script-symbols-assign.ll new file mode 100644 index 000000000000..2ffdc823a484 --- /dev/null +++ b/test/ELF/lto/linker-script-symbols-assign.ll @@ -0,0 +1,48 @@ +; REQUIRES: x86 +; RUN: llvm-as %s -o %t.o + +; RUN: echo "foo = 1;" > %t.script +; RUN: ld.lld -m elf_x86_64 %t.o -o %t2 --script %t.script -save-temps +; RUN: llvm-readobj -symbols %t2.lto.o | FileCheck %s + +; CHECK-NOT: bar +; CHECK: Symbol { +; CHECK: Name: foo +; CHECK-NEXT: Value: 0x0 +; CHECK-NEXT: Size: 4 +; CHECK-NEXT: Binding: Weak +; CHECK-NEXT: Type: Object +; CHECK-NEXT: Other: 0 +; CHECK-NEXT: Section: .bss.foo +; CHECK-NEXT: } +; CHECK-NEXT:] + +; RUN: llvm-readobj -symbols %t2 | FileCheck %s --check-prefix=VAL +; VAL: Symbol { +; VAL: Name: foo +; VAL-NEXT: Value: 0x1 +; VAL-NEXT: Size: +; VAL-NEXT: Binding: Global +; VAL-NEXT: Type: None +; VAL-NEXT: Other: +; VAL-NEXT: Section: Absolute +; VAL-NEXT: } + +; RUN: echo "zed = 1;" > %t2.script +; RUN: ld.lld -m elf_x86_64 %t.o -o %t3 --script %t2.script +; RUN: llvm-readobj -symbols %t3 | FileCheck %s --check-prefix=ABS +; ABS: Symbol { +; ABS: Name: zed +; ABS-NEXT: Value: 0x1 +; ABS-NEXT: Size: 0 +; ABS-NEXT: Binding: Global +; ABS-NEXT: Type: None +; ABS-NEXT: Other: 0 +; ABS-NEXT: Section: Absolute +; ABS-NEXT: } + +target triple = "x86_64-unknown-linux-gnu" +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" + +@foo = global i32 0 +@bar = global i32 0 diff --git a/test/ELF/lto/linker-script-symbols-ipo.ll b/test/ELF/lto/linker-script-symbols-ipo.ll new file mode 100644 index 000000000000..6ac1a83e1ec0 --- /dev/null +++ b/test/ELF/lto/linker-script-symbols-ipo.ll @@ -0,0 +1,32 @@ +; REQUIRES: x86 +; RUN: llvm-as %s -o %t1.o +; RUN: llvm-as %S/Inputs/linker-script-symbols-ipo.ll -o %t2.o +; RUN: echo "bar = foo;" > %t.script + +;; Check that without linkerscript bar is inlined. +; RUN: ld.lld -m elf_x86_64 %t1.o %t2.o -o %t3 -save-temps +; RUN: llvm-objdump -d %t3 | FileCheck %s --check-prefix=IPO +; IPO: Disassembly of section .text: +; IPO: _start: +; IPO-NEXT: 201000: {{.*}} movl $1, %eax +; IPO-NEXT: 201005: {{.*}} retq + +;; Check that LTO does not do IPO for symbols assigned by script. +; RUN: ld.lld -m elf_x86_64 %t1.o %t2.o -o %t4 --script %t.script -save-temps +; RUN: llvm-objdump -d %t4 | FileCheck %s --check-prefix=NOIPO +; NOIPO: Disassembly of section .text: +; NOIPO: foo: +; NOIPO-NEXT: 201010: {{.*}} movl $2, %eax +; NOIPO: _start: +; NOIPO-NEXT: 201020: {{.*}} jmp -21 <foo> + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define i32 @bar() { + ret i32 1 +} + +define i32 @foo() { + ret i32 2 +} diff --git a/test/ELF/lto/linker-script-symbols.ll b/test/ELF/lto/linker-script-symbols.ll new file mode 100644 index 000000000000..c2a58b6e841d --- /dev/null +++ b/test/ELF/lto/linker-script-symbols.ll @@ -0,0 +1,29 @@ +; REQUIRES: x86 +; RUN: llvm-as %s -o %t.o +; RUN: echo "foo = bar;" > %t.script + +; RUN: ld.lld -m elf_x86_64 %t.o -o %t2 --script %t.script -save-temps +; RUN: llvm-readobj -symbols %t2.lto.o | FileCheck %s + +; CHECK-NOT: zed +; CHECK: Symbol { +; CHECK: Name: bar +; CHECK-NEXT: Value: +; CHECK-NEXT: Size: +; CHECK-NEXT: Binding: Global +; CHECK-NEXT: Type: Function +; CHECK-NEXT: Other: +; CHECK-NEXT: Section: +; CHECK-NEXT: } +; CHECK-NOT: zed + +target triple = "x86_64-unknown-linux-gnu" +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" + +define void @bar() { + ret void +} + +define void @zed() { + ret void +} diff --git a/test/ELF/lto/opt-level.ll b/test/ELF/lto/opt-level.ll index 1065ca775751..57fa3041ac65 100644 --- a/test/ELF/lto/opt-level.ll +++ b/test/ELF/lto/opt-level.ll @@ -2,18 +2,31 @@ ; RUN: llvm-as -o %t.o %s ; RUN: ld.lld -o %t0 -m elf_x86_64 -e main --lto-O0 %t.o ; RUN: llvm-nm %t0 | FileCheck --check-prefix=CHECK-O0 %s +; RUN: ld.lld -o %t0 -m elf_x86_64 -e main --plugin-opt=O0 %t.o +; RUN: llvm-nm %t0 | FileCheck --check-prefix=CHECK-O0 %s ; RUN: ld.lld -o %t2 -m elf_x86_64 -e main --lto-O2 %t.o ; RUN: llvm-nm %t2 | FileCheck --check-prefix=CHECK-O2 %s ; RUN: ld.lld -o %t2a -m elf_x86_64 -e main %t.o ; RUN: llvm-nm %t2a | FileCheck --check-prefix=CHECK-O2 %s +; RUN: ld.lld -o %t2 -m elf_x86_64 -e main --plugin-opt=O2 %t.o +; RUN: llvm-nm %t2 | FileCheck --check-prefix=CHECK-O2 %s ; Reject invalid optimization levels. ; RUN: not ld.lld -o %t3 -m elf_x86_64 -e main --lto-O6 %t.o 2>&1 | \ -; RUN: FileCheck --check-prefix=INVALID %s -; INVALID: invalid optimization level for LTO: 6 +; RUN: FileCheck --check-prefix=INVALID1 %s +; INVALID1: invalid optimization level for LTO: 6 +; RUN: not ld.lld -o %t3 -m elf_x86_64 -e main --plugin-opt=O6 %t.o 2>&1 | \ +; RUN: FileCheck --check-prefix=INVALID1 %s +; RUN: not ld.lld -o %t3 -m elf_x86_64 -e main --plugin-opt=Ofoo %t.o 2>&1 | \ +; RUN: FileCheck --check-prefix=INVALID2 %s +; INVALID2: --plugin-opt: number expected, but got 'foo' + ; RUN: not ld.lld -o %t3 -m elf_x86_64 -e main --lto-O-1 %t.o 2>&1 | \ -; RUN: FileCheck --check-prefix=INVALIDNEGATIVE %s -; INVALIDNEGATIVE: invalid optimization level for LTO: -1 +; RUN: FileCheck --check-prefix=INVALIDNEGATIVE1 %s +; INVALIDNEGATIVE1: invalid optimization level for LTO: 4294967295 +; RUN: not ld.lld -o %t3 -m elf_x86_64 -e main --plugin-opt=O-1 %t.o 2>&1 | \ +; RUN: FileCheck --check-prefix=INVALIDNEGATIVE2 %s +; INVALIDNEGATIVE2: invalid optimization level for LTO: 4294967295 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64-unknown-linux-gnu" diff --git a/test/ELF/lto/opt-remarks.ll b/test/ELF/lto/opt-remarks.ll index e29cc72bb3cc..19b141feb258 100644 --- a/test/ELF/lto/opt-remarks.ll +++ b/test/ELF/lto/opt-remarks.ll @@ -15,13 +15,13 @@ ; CHECK-NEXT: ret i32 %a.i ; CHECK-NEXT: } -; YAML: --- !Analysis +; YAML: --- !Passed ; YAML-NEXT: Pass: inline -; YAML-NEXT: Name: CanBeInlined +; YAML-NEXT: Name: Inlined ; YAML-NEXT: Function: main ; YAML-NEXT: Args: ; YAML-NEXT: - Callee: tinkywinky -; YAML-NEXT: - String: ' can be inlined into ' +; YAML-NEXT: - String: ' inlined into ' ; YAML-NEXT: - Caller: main ; YAML-NEXT: - String: ' with cost=' ; YAML-NEXT: - Cost: '0' @@ -29,19 +29,9 @@ ; YAML-NEXT: - Threshold: '337' ; YAML-NEXT: - String: ')' ; YAML-NEXT: ... -; YAML-NEXT: --- !Passed -; YAML-NEXT: Pass: inline -; YAML-NEXT: Name: Inlined -; YAML-NEXT: Function: main -; YAML-NEXT: Args: -; YAML-NEXT: - Callee: tinkywinky -; YAML-NEXT: - String: ' inlined into ' -; YAML-NEXT: - Caller: main -; YAML-NEXT: ... -; YAML-HOT: ... -; YAML-HOT: --- !Passed -; YAML-HOT: Pass: inline +; YAML-HOT: --- !Passed +; YAML-HOT-NEXT: Pass: inline ; YAML-HOT-NEXT: Name: Inlined ; YAML-HOT-NEXT: Function: main ; YAML-HOT-NEXT: Hotness: 300 @@ -49,6 +39,11 @@ ; YAML-HOT-NEXT: - Callee: tinkywinky ; YAML-HOT-NEXT: - String: ' inlined into ' ; YAML-HOT-NEXT: - Caller: main +; YAML-HOT-NEXT: - String: ' with cost=' +; YAML-HOT-NEXT: - Cost: '0' +; YAML-HOT-NEXT: - String: ' (threshold=' +; YAML-HOT-NEXT: - Threshold: '337' +; YAML-HOT-NEXT: - String: ')' ; YAML-HOT-NEXT: ... target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/test/ELF/lto/relocatable.ll b/test/ELF/lto/relocatable.ll new file mode 100644 index 000000000000..ef21f84a621a --- /dev/null +++ b/test/ELF/lto/relocatable.ll @@ -0,0 +1,55 @@ +; REQUIRES: x86 +; RUN: llvm-as %s -o %t1.o +; RUN: ld.lld %t1.o -r -o %t +; RUN: llvm-readobj -symbols %t | FileCheck %s + +; CHECK: Symbols [ +; CHECK-NEXT: Symbol { +; CHECK-NEXT: Name: +; CHECK-NEXT: Value: 0x0 +; CHECK-NEXT: Size: 0 +; CHECK-NEXT: Binding: Local +; CHECK-NEXT: Type: None +; CHECK-NEXT: Other: 0 +; CHECK-NEXT: Section: Undefined +; CHECK-NEXT: } +; CHECK-NEXT: Symbol { +; CHECK-NEXT: Name: +; CHECK-NEXT: Value: 0x0 +; CHECK-NEXT: Size: 0 +; CHECK-NEXT: Binding: Local +; CHECK-NEXT: Type: Section +; CHECK-NEXT: Other: 0 +; CHECK-NEXT: Section: .text +; CHECK-NEXT: } +; CHECK-NEXT: Symbol { +; CHECK-NEXT: Name: +; CHECK-NEXT: Value: 0x0 +; CHECK-NEXT: Size: 0 +; CHECK-NEXT: Binding: Local +; CHECK-NEXT: Type: Section +; CHECK-NEXT: Other: 0 +; CHECK-NEXT: Section: .text.foo +; CHECK-NEXT: } +; CHECK-NEXT: Symbol { +; CHECK-NEXT: Name: foo +; CHECK-NEXT: Value: 0x0 +; CHECK-NEXT: Size: 1 +; CHECK-NEXT: Binding: Global +; CHECK-NEXT: Type: Function +; CHECK-NEXT: Other: 0 +; CHECK-NEXT: Section: .text.foo +; CHECK-NEXT: } +; CHECK-NEXT: ] + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define void @foo() { + call void @bar() + ret void +} + +define internal void @bar() { + ret void +} diff --git a/test/ELF/lto/save-temps.ll b/test/ELF/lto/save-temps.ll index f7af99ed40af..c8e52ff4b4ec 100644 --- a/test/ELF/lto/save-temps.ll +++ b/test/ELF/lto/save-temps.ll @@ -9,6 +9,13 @@ ; RUN: llvm-nm a.out.lto.o | FileCheck %s ; RUN: llvm-dis a.out.0.0.preopt.bc +; RUN: rm -f a.out a.out.lto.bc a.out.lto.o +; RUN: ld.lld -shared -m elf_x86_64 %t.o %t2.o --plugin-opt=save-temps +; RUN: llvm-nm a.out | FileCheck %s +; RUN: llvm-nm a.out.0.0.preopt.bc | FileCheck %s +; RUN: llvm-nm a.out.lto.o | FileCheck %s +; RUN: llvm-dis a.out.0.0.preopt.bc + target triple = "x86_64-unknown-linux-gnu" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/test/ELF/lto/section-name.ll b/test/ELF/lto/section-name.ll new file mode 100644 index 000000000000..483184716a07 --- /dev/null +++ b/test/ELF/lto/section-name.ll @@ -0,0 +1,35 @@ +; REQUIRES: x86 +; RUN: llvm-as %s -o %t.o +; RUN: ld.lld %t.o -o %t.so -shared +; RUN: llvm-readelf -s %t.so | FileCheck %s +; RUN: ld.lld %t.o -o %t.so -shared --gc-sections +; RUN: llvm-readelf -s %t.so | FileCheck --check-prefix=GC %s + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +@foo = hidden global i32 42, section "foo_section" +@bar = hidden global i32 42, section "bar_section" +@zed = hidden global i32 42, section "zed_section" + +@__start_foo_section = external global i32 +@__stop_bar_section = external global i32 + +define hidden i32* @use1() { + ret i32* @__start_foo_section +} + +define i32* @use2() { + ret i32* @__stop_bar_section +} + +; CHECK-NOT: zed_section +; CHECK: foo_section PROGBITS +; CHECK-NEXT: bar_section PROGBITS +; CHECK-NOT: zed_section + +; GC-NOT: zed_section +; GC-NOT: foo_section +; GC: bar_section PROGBITS +; GC-NOT: zed_section +; GC-NOT: foo_section diff --git a/test/ELF/lto/shlib-undefined.ll b/test/ELF/lto/shlib-undefined.ll index 0250ed761927..6d37bfa6b304 100644 --- a/test/ELF/lto/shlib-undefined.ll +++ b/test/ELF/lto/shlib-undefined.ll @@ -1,6 +1,6 @@ ; REQUIRES: x86 ; RUN: llvm-as %s -o %t.o -; RUN: echo .global __progname > %t2.s +; RUN: echo ".global __progname; .data; .dc.a __progname" > %t2.s ; RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t2.s -o %t2.o ; RUN: ld.lld -shared %t2.o -o %t2.so ; RUN: ld.lld -o %t %t.o %t2.so diff --git a/test/ELF/lto/symbol-ordering-lto.s b/test/ELF/lto/symbol-ordering-lto.s new file mode 100644 index 000000000000..4c29e54c476e --- /dev/null +++ b/test/ELF/lto/symbol-ordering-lto.s @@ -0,0 +1,25 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-scei-ps4 %s -o %t.o +# RUN: llvm-as %p/Inputs/symbol-ordering-lto.ll -o %t.bc + +# Set up the symbol file +# RUN: echo "tin " > %t_order_lto.txt +# RUN: echo "_start " >> %t_order_lto.txt +# RUN: echo "pat " >> %t_order_lto.txt + +# RUN: ld.lld --symbol-ordering-file %t_order_lto.txt %t.o %t.bc -o %t2.out +# RUN: llvm-readobj -elf-output-style=GNU -t %t2.out| FileCheck %s + +# Check that the order is tin -> _start -> pat. + +# CHECK: Symbol table '.symtab' contains 4 entries: +# CHECK-NEXT: Num: Value Size Type Bind Vis Ndx Name +# CHECK-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND +# CHECK-NEXT: 1: 0000000000201008 0 NOTYPE GLOBAL DEFAULT 1 _start +# CHECK-NEXT: 2: 0000000000201020 6 FUNC GLOBAL DEFAULT 1 pat +# CHECK-NEXT: 3: 0000000000201000 6 FUNC GLOBAL DEFAULT 1 tin + +.globl _start +_start: + call pat + call tin diff --git a/test/ELF/lto/thinlto.ll b/test/ELF/lto/thinlto.ll index 99dd19130d28..37d2b88131f6 100644 --- a/test/ELF/lto/thinlto.ll +++ b/test/ELF/lto/thinlto.ll @@ -6,14 +6,14 @@ ; First force single-threaded mode ; RUN: rm -f %t.lto.o %t1.lto.o ; RUN: ld.lld -save-temps --thinlto-jobs=1 -shared %t.o %t2.o -o %t -; RUN: llvm-nm %t.lto.o | FileCheck %s --check-prefix=NM1 -; RUN: llvm-nm %t1.lto.o | FileCheck %s --check-prefix=NM2 +; RUN: llvm-nm %t1.lto.o | FileCheck %s --check-prefix=NM1 +; RUN: llvm-nm %t2.lto.o | FileCheck %s --check-prefix=NM2 ; Next force multi-threaded mode ; RUN: rm -f %t2.lto.o %t21.lto.o ; RUN: ld.lld -save-temps --thinlto-jobs=2 -shared %t.o %t2.o -o %t2 -; RUN: llvm-nm %t2.lto.o | FileCheck %s --check-prefix=NM1 -; RUN: llvm-nm %t21.lto.o | FileCheck %s --check-prefix=NM2 +; RUN: llvm-nm %t21.lto.o | FileCheck %s --check-prefix=NM1 +; RUN: llvm-nm %t22.lto.o | FileCheck %s --check-prefix=NM2 ; NM1: T f ; NM1-NOT: U g diff --git a/test/ELF/lto/verify-invalid.ll b/test/ELF/lto/verify-invalid.ll index 16d6a3e54f12..e6138a3cca62 100644 --- a/test/ELF/lto/verify-invalid.ll +++ b/test/ELF/lto/verify-invalid.ll @@ -4,6 +4,8 @@ ; RUN: 2>&1 | FileCheck -check-prefix=DEFAULT %s ; RUN: ld.lld -m elf_x86_64 %t.o -o %t2 -mllvm -debug-pass=Arguments \ ; RUN: -disable-verify 2>&1 | FileCheck -check-prefix=DISABLE %s +; RUN: ld.lld -m elf_x86_64 %t.o -o %t2 -mllvm -debug-pass=Arguments \ +; RUN: --plugin-opt=disable-verify 2>&1 | FileCheck -check-prefix=DISABLE %s target triple = "x86_64-unknown-linux-gnu" target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" diff --git a/test/ELF/lto/wrap-1.ll b/test/ELF/lto/wrap-1.ll index 1dd9139808b6..83e09493fb5d 100644 --- a/test/ELF/lto/wrap-1.ll +++ b/test/ELF/lto/wrap-1.ll @@ -19,7 +19,7 @@ ; Make sure that the 'r' (linker redefined) bit is set for bar and __wrap_bar ; in the resolutions file. -; RESOLS: ,bar,r +; RESOLS: ,bar,xr ; RESOLS: ,__wrap_bar,px ; RESOLS: ,__real_bar,pxr diff --git a/test/ELF/lto/wrap-2.ll b/test/ELF/lto/wrap-2.ll index 06ef4064e4d1..4e82d4a0e8b0 100644 --- a/test/ELF/lto/wrap-2.ll +++ b/test/ELF/lto/wrap-2.ll @@ -28,11 +28,11 @@ ; THIN-NEXT: jmp{{.*}}<bar> ; Check that bar and __wrap_bar retain their original binding. -; BIND: Name: bar +; BIND: Name: __wrap_bar ; BIND-NEXT: Value: ; BIND-NEXT: Size: ; BIND-NEXT: Binding: Local -; BIND: Name: __wrap_bar +; BIND: Name: bar ; BIND-NEXT: Value: ; BIND-NEXT: Size: ; BIND-NEXT: Binding: Local diff --git a/test/ELF/many-alloc-sections.s b/test/ELF/many-alloc-sections.s index 648ab8250286..a022b9275d9f 100644 --- a/test/ELF/many-alloc-sections.s +++ b/test/ELF/many-alloc-sections.s @@ -1,8 +1,7 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o %t.o // RUN: echo "SECTIONS { . = SIZEOF_HEADERS; .text : { *(.text) } }" > %t.script -// FIXME: threads are disable because the test is too slow with them (PR32942). -// RUN: ld.lld -T %t.script %t.o -o %t --no-threads +// RUN: ld.lld -T %t.script %t.o -o %t // RUN: llvm-readobj -t %t | FileCheck %s // Test that _start is in the correct section. diff --git a/test/ELF/many-sections.s b/test/ELF/many-sections.s index 7ef0f7ceaac4..e3b845f305a8 100644 --- a/test/ELF/many-sections.s +++ b/test/ELF/many-sections.s @@ -11,15 +11,12 @@ // CHECK-NEXT: Other: 0 // CHECK-NEXT: Section: dm (0xFF00) - -// FIXME: threads are disable because the test is too slow with them (PR32942). -// RUN: ld.lld %t -o %t2 --no-threads +// RUN: ld.lld %t -o %t2 // RUN: llvm-readobj -t %t2 | FileCheck --check-prefix=LINKED %s // Test also with a linker script. // RUN: echo "SECTIONS { . = SIZEOF_HEADERS; .text : { *(.text) } }" > %t.script -// FIXME: threads are disable because the test is too slow with them (PR32942). -// RUN: ld.lld -T %t.script %t -o %t2 --no-threads +// RUN: ld.lld -T %t.script %t -o %t2 // RUN: llvm-readobj -t %t2 | FileCheck --check-prefix=LINKED %s // Test that _start is in the correct section. diff --git a/test/ELF/map-file.s b/test/ELF/map-file.s index 9dbbda0ff0e9..d1acabe28126 100644 --- a/test/ELF/map-file.s +++ b/test/ELF/map-file.s @@ -4,15 +4,21 @@ // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/map-file2.s -o %t2.o // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/map-file3.s -o %t3.o // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/map-file4.s -o %t4.o +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/map-file5.s -o %t5.o +// RUN: ld.lld -shared %t5.o -o %t5.so -soname dso // RUN: rm -f %t4.a // RUN: llvm-ar rc %t4.a %t4.o -// RUN: ld.lld %t1.o %t2.o %t3.o %t4.a -o %t -M | FileCheck -strict-whitespace %s -// RUN: ld.lld %t1.o %t2.o %t3.o %t4.a -o %t -print-map | FileCheck -strict-whitespace %s -// RUN: ld.lld %t1.o %t2.o %t3.o %t4.a -o %t -Map=%t.map +// RUN: ld.lld %t1.o %t2.o %t3.o %t4.a %t5.so -o %t -M | FileCheck -strict-whitespace %s +// RUN: ld.lld %t1.o %t2.o %t3.o %t4.a %t5.so -o %t -print-map | FileCheck -strict-whitespace %s +// RUN: ld.lld %t1.o %t2.o %t3.o %t4.a %t5.so -o %t -Map=%t.map // RUN: FileCheck -strict-whitespace %s < %t.map .global _start _start: + .quad sharedFoo + .quad sharedBar + callq sharedFunc1 + callq sharedFunc2 call baz .global _Z1fi _Z1fi: @@ -25,34 +31,62 @@ bar: .long zed - . local: .comm common,4,16 +.global abs +abs = 0xAB5 +labs = 0x1AB5 // CHECK: Address Size Align Out In Symbol -// CHECK-NEXT: 0000000000200158 0000000000000030 8 .eh_frame -// CHECK-NEXT: 0000000000200158 0000000000000030 8 <internal>:(.eh_frame) -// CHECK-NEXT: 0000000000201000 0000000000000015 4 .text -// CHECK-NEXT: 0000000000201000 000000000000000e 4 {{.*}}{{/|\\}}map-file.s.tmp1.o:(.text) +// CHECK-NEXT: 00000000002001c8 0000000000000078 8 .dynsym +// CHECK-NEXT: 00000000002001c8 0000000000000078 8 <internal>:(.dynsym) +// CHECK-NEXT: 0000000000200240 000000000000002c 8 .gnu.hash +// CHECK-NEXT: 0000000000200240 000000000000002c 8 <internal>:(.gnu.hash) +// CHECK-NEXT: 000000000020026c 0000000000000030 4 .hash +// CHECK-NEXT: 000000000020026c 0000000000000030 4 <internal>:(.hash) +// CHECK-NEXT: 000000000020029c 0000000000000031 1 .dynstr +// CHECK-NEXT: 000000000020029c 0000000000000031 1 <internal>:(.dynstr) +// CHECK-NEXT: 00000000002002d0 0000000000000030 8 .rela.dyn +// CHECK-NEXT: 00000000002002d0 0000000000000030 8 <internal>:(.rela.dyn) +// CHECK-NEXT: 0000000000200300 0000000000000030 8 .rela.plt +// CHECK-NEXT: 0000000000200300 0000000000000030 8 <internal>:(.rela.plt) +// CHECK-NEXT: 0000000000200330 0000000000000030 8 .eh_frame +// CHECK-NEXT: 0000000000200330 0000000000000030 8 <internal>:(.eh_frame) +// CHECK-NEXT: 0000000000201000 000000000000002d 4 .text +// CHECK-NEXT: 0000000000201000 0000000000000028 4 {{.*}}{{/|\\}}map-file.s.tmp1.o:(.text) // CHECK-NEXT: 0000000000201000 0000000000000000 0 _start -// CHECK-NEXT: 0000000000201005 0000000000000000 0 f(int) -// CHECK-NEXT: 000000000020100e 0000000000000000 0 local -// CHECK-NEXT: 0000000000201010 0000000000000002 4 {{.*}}{{/|\\}}map-file.s.tmp2.o:(.text) -// CHECK-NEXT: 0000000000201010 0000000000000000 0 foo -// CHECK-NEXT: 0000000000201011 0000000000000000 0 bar -// CHECK-NEXT: 0000000000201012 0000000000000000 1 {{.*}}{{/|\\}}map-file.s.tmp2.o:(.text.zed) -// CHECK-NEXT: 0000000000201012 0000000000000000 0 zed -// CHECK-NEXT: 0000000000201014 0000000000000000 4 {{.*}}{{/|\\}}map-file.s.tmp3.o:(.text) -// CHECK-NEXT: 0000000000201014 0000000000000000 0 bah -// CHECK-NEXT: 0000000000201014 0000000000000001 4 {{.*}}{{/|\\}}map-file.s.tmp4.a(map-file.s.tmp4.o):(.text) -// CHECK-NEXT: 0000000000201014 0000000000000000 0 baz -// CHECK-NEXT: 0000000000202000 0000000000000004 16 .bss -// CHECK-NEXT: 0000000000202000 0000000000000004 16 <internal>:(COMMON) +// CHECK-NEXT: 000000000020101f 0000000000000000 0 f(int) +// CHECK-NEXT: 0000000000201028 0000000000000000 0 local +// CHECK-NEXT: 0000000000201028 0000000000000002 4 {{.*}}{{/|\\}}map-file.s.tmp2.o:(.text) +// CHECK-NEXT: 0000000000201028 0000000000000000 0 foo +// CHECK-NEXT: 0000000000201029 0000000000000000 0 bar +// CHECK-NEXT: 000000000020102a 0000000000000000 1 {{.*}}{{/|\\}}map-file.s.tmp2.o:(.text.zed) +// CHECK-NEXT: 000000000020102a 0000000000000000 0 zed +// CHECK-NEXT: 000000000020102c 0000000000000000 4 {{.*}}{{/|\\}}map-file.s.tmp3.o:(.text) +// CHECK-NEXT: 000000000020102c 0000000000000000 0 bah +// CHECK-NEXT: 000000000020102c 0000000000000001 4 {{.*}}{{/|\\}}map-file.s.tmp4.a(map-file.s.tmp4.o):(.text) +// CHECK-NEXT: 000000000020102c 0000000000000000 0 baz +// CHECK-NEXT: 0000000000201030 0000000000000030 16 .plt +// CHECK-NEXT: 0000000000201030 0000000000000030 16 <internal>:(.plt) +// CHECK-NEXT: 0000000000201040 0000000000000000 0 sharedFunc1 +// CHECK-NEXT: 0000000000201050 0000000000000000 0 sharedFunc2 +// CHECK-NEXT: 0000000000202000 0000000000000028 8 .got.plt +// CHECK-NEXT: 0000000000202000 0000000000000028 8 <internal>:(.got.plt) +// CHECK-NEXT: 0000000000203000 0000000000000100 8 .dynamic +// CHECK-NEXT: 0000000000203000 0000000000000100 8 <internal>:(.dynamic) +// CHECK-NEXT: 0000000000204000 0000000000000010 16 .bss +// CHECK-NEXT: 0000000000204000 0000000000000004 16 {{.*}}{{/|\\}}map-file.s.tmp1.o:(COMMON) +// CHECK-NEXT: 0000000000204000 0000000000000004 0 common +// CHECK-NEXT: 0000000000204004 0000000000000004 1 <internal>:(.bss) +// CHECK-NEXT: 0000000000204004 0000000000000004 0 sharedFoo +// CHECK-NEXT: 0000000000204008 0000000000000008 1 <internal>:(.bss) +// CHECK-NEXT: 0000000000204008 0000000000000008 0 sharedBar // CHECK-NEXT: 0000000000000000 0000000000000008 1 .comment // CHECK-NEXT: 0000000000000000 0000000000000008 1 <internal>:(.comment) -// CHECK-NEXT: 0000000000000000 00000000000000f0 8 .symtab -// CHECK-NEXT: 0000000000000000 00000000000000f0 8 <internal>:(.symtab) -// CHECK-NEXT: 0000000000000000 0000000000000039 1 .shstrtab -// CHECK-NEXT: 0000000000000000 0000000000000039 1 <internal>:(.shstrtab) -// CHECK-NEXT: 0000000000000000 000000000000002f 1 .strtab -// CHECK-NEXT: 0000000000000000 000000000000002f 1 <internal>:(.strtab) +// CHECK-NEXT: 0000000000000000 0000000000000198 8 .symtab +// CHECK-NEXT: 0000000000000000 0000000000000198 8 <internal>:(.symtab) +// CHECK-NEXT: 0000000000000000 0000000000000084 1 .shstrtab +// CHECK-NEXT: 0000000000000000 0000000000000084 1 <internal>:(.shstrtab) +// CHECK-NEXT: 0000000000000000 000000000000006d 1 .strtab +// CHECK-NEXT: 0000000000000000 000000000000006d 1 <internal>:(.strtab) // RUN: not ld.lld %t1.o %t2.o %t3.o %t4.a -o %t -Map=/ 2>&1 \ // RUN: | FileCheck -check-prefix=FAIL %s diff --git a/test/ELF/merge-align.s b/test/ELF/merge-align.s new file mode 100644 index 000000000000..dea2fc2086e4 --- /dev/null +++ b/test/ELF/merge-align.s @@ -0,0 +1,34 @@ +// REQUIRES: x86 +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +// RUN: ld.lld %t.o -o %t.so -shared +// RUN: llvm-readobj -s -section-data %t.so | FileCheck %s + + .section .rodata.foo,"aM",@progbits,1 + .align 16 + .byte 0x42 + + .section .rodata.bar,"aM",@progbits,1 + .align 16 + .byte 0x42 + + .section .rodata.zed,"aM",@progbits,1 + .align 16 + .byte 0x41 + +// CHECK: Name: .rodata ( +// CHECK-NEXT: Type: SHT_PROGBITS +// CHECK-NEXT: Flags [ +// CHECK-NEXT: SHF_ALLOC +// CHECK-NEXT: SHF_MERGE +// CHECK-NEXT: ] +// CHECK-NEXT: Address: +// CHECK-NEXT: Offset: +// CHECK-NEXT: Size: 17 +// CHECK-NEXT: Link: 0 +// CHECK-NEXT: Info: 0 +// CHECK-NEXT: AddressAlignment: 16 +// CHECK-NEXT: EntrySize: 1 +// CHECK-NEXT: SectionData ( +// CHECK-NEXT: 0000: 42000000 00000000 00000000 00000000 | +// CHECK-NEXT: 0010: 41 | +// CHECK-NEXT: ) diff --git a/test/ELF/merge-entsize.s b/test/ELF/merge-entsize.s new file mode 100644 index 000000000000..c2e41ccf185a --- /dev/null +++ b/test/ELF/merge-entsize.s @@ -0,0 +1,27 @@ +// REQUIRES: x86 +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +// RUN: ld.lld %t.o -o %t +// RUN: llvm-readobj -s %t | FileCheck %s + + .section .rodata.1,"aM",@progbits,1 + .byte 0x42 + + .section .rodata.2,"aM",@progbits,2 + .short 0x42 + +// Since the output section has both .rodata.1 and .rodata.2, it +// contains elements of different sizes and we use an entsize of 0. + +// CHECK: Name: .rodata ( +// CHECK-NEXT: Type: SHT_PROGBITS +// CHECK-NEXT: Flags [ +// CHECK-NEXT: SHF_ALLOC +// CHECK-NEXT: SHF_MERGE +// CHECK-NEXT: ] +// CHECK-NEXT: Address: +// CHECK-NEXT: Offset: +// CHECK-NEXT: Size: +// CHECK-NEXT: Link: +// CHECK-NEXT: Info: +// CHECK-NEXT: AddressAlignment: +// CHECK-NEXT: EntrySize: 0 diff --git a/test/ELF/merge-reloc.s b/test/ELF/merge-reloc.s index 934ac3b9384e..3dde6aa35297 100644 --- a/test/ELF/merge-reloc.s +++ b/test/ELF/merge-reloc.s @@ -3,14 +3,13 @@ # RUN: ld.lld %t.o -r -o %t-rel # RUN: llvm-readobj -s -section-data %t-rel | FileCheck %s -# When linker generates a relocatable object it should keep "merge" -# sections as-is: do not merge content, do not join regular and -# "merge" sections, do not joint "merge" sections with different -# entry size. +# When linker generates a relocatable object it does string merging in the same +# way as for regular link. It should keep SHF_MERGE flag and set proper sh_entsize +# value so that final link can perform the final merging optimization. # CHECK: Section { # CHECK: Index: -# CHECK: Name: .rodata +# CHECK: Name: .rodata.1 ( # CHECK-NEXT: Type: SHT_PROGBITS # CHECK-NEXT: Flags [ # CHECK-NEXT: SHF_ALLOC @@ -18,18 +17,18 @@ # CHECK-NEXT: ] # CHECK-NEXT: Address: # CHECK-NEXT: Offset: -# CHECK-NEXT: Size: 12 +# CHECK-NEXT: Size: 4 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 # CHECK-NEXT: AddressAlignment: 4 # CHECK-NEXT: EntrySize: 4 # CHECK-NEXT: SectionData ( -# CHECK-NEXT: 0000: 42000000 42000000 42000000 +# CHECK-NEXT: 0000: 42000000 # CHECK-NEXT: ) # CHECK-NEXT: } # CHECK: Section { # CHECK: Index: -# CHECK: Name: .rodata +# CHECK: Name: .rodata.2 ( # CHECK-NEXT: Type: SHT_PROGBITS # CHECK-NEXT: Flags [ # CHECK-NEXT: SHF_ALLOC @@ -37,13 +36,13 @@ # CHECK-NEXT: ] # CHECK-NEXT: Address: # CHECK-NEXT: Offset: -# CHECK-NEXT: Size: 16 +# CHECK-NEXT: Size: 8 # CHECK-NEXT: Link: 0 # CHECK-NEXT: Info: 0 # CHECK-NEXT: AddressAlignment: 8 # CHECK-NEXT: EntrySize: 8 # CHECK-NEXT: SectionData ( -# CHECK-NEXT: 0000: 42000000 42000000 42000000 42000000 +# CHECK-NEXT: 0000: 42000000 42000000 # CHECK-NEXT: ) # CHECK-NEXT: } # CHECK: Section { diff --git a/test/ELF/merge-string.s b/test/ELF/merge-string.s index 13c89f029711..d284d0ab523c 100644 --- a/test/ELF/merge-string.s +++ b/test/ELF/merge-string.s @@ -1,10 +1,10 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -// RUN: ld.lld -O2 %t.o -o %t.so -shared +// RUN: ld.lld -O 2 %t.o -o %t.so -shared // RUN: llvm-readobj -s -section-data -t %t.so | FileCheck %s -// RUN: ld.lld -O1 %t.o -o %t.so -shared +// RUN: ld.lld -O 1 %t.o -o %t.so -shared // RUN: llvm-readobj -s -section-data -t %t.so | FileCheck --check-prefix=NOTAIL %s -// RUN: ld.lld -O0 %t.o -o %t.so -shared +// RUN: ld.lld -O 0 %t.o -o %t.so -shared // RUN: llvm-readobj -s -section-data -t %t.so | FileCheck --check-prefix=NOMERGE %s .section .rodata1,"aMS",@progbits,1 @@ -34,7 +34,7 @@ zed: // CHECK-NEXT: Link: 0 // CHECK-NEXT: Info: 0 // CHECK-NEXT: AddressAlignment: 1 -// CHECK-NEXT: EntrySize: 0 +// CHECK-NEXT: EntrySize: 1 // CHECK-NEXT: SectionData ( // CHECK-NEXT: 0000: 61626300 |abc.| // CHECK-NEXT: ) @@ -52,9 +52,9 @@ zed: // NOTAIL-NEXT: Link: 0 // NOTAIL-NEXT: Info: 0 // NOTAIL-NEXT: AddressAlignment: 1 -// NOTAIL-NEXT: EntrySize: 0 +// NOTAIL-NEXT: EntrySize: 1 // NOTAIL-NEXT: SectionData ( -// NOTAIL-NEXT: 0000: 61626300 626300 |abc.bc.| +// NOTAIL-NEXT: 0000: 62630061 626300 |bc.abc.| // NOTAIL-NEXT: ) // NOMERGE: Name: .rodata1 @@ -88,7 +88,7 @@ zed: // CHECK-NEXT: Link: 0 // CHECK-NEXT: Info: 0 // CHECK-NEXT: AddressAlignment: 2 -// CHECK-NEXT: EntrySize: 0 +// CHECK-NEXT: EntrySize: 2 // CHECK-NEXT: SectionData ( // CHECK-NEXT: 0000: 14000000 |....| // CHECK-NEXT: ) diff --git a/test/ELF/merge.s b/test/ELF/merge.s index fba41346c536..b84d33a3411e 100644 --- a/test/ELF/merge.s +++ b/test/ELF/merge.s @@ -29,7 +29,7 @@ zed: // CHECK-NEXT: Link: 0 // CHECK-NEXT: Info: 0 // CHECK-NEXT: AddressAlignment: 4 -// CHECK-NEXT: EntrySize: 0 +// CHECK-NEXT: EntrySize: 4 // CHECK-NEXT: SectionData ( // CHECK-NEXT: 0000: 10000000 42000000 // CHECK-NEXT: ) diff --git a/test/ELF/mips-26-n32-n64.s b/test/ELF/mips-26-n32-n64.s new file mode 100644 index 000000000000..2e24873332a7 --- /dev/null +++ b/test/ELF/mips-26-n32-n64.s @@ -0,0 +1,35 @@ +# Check R_MIPS_26 relocation handling in case of N64 ABIs. + +# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux \ +# RUN: %S/Inputs/mips-dynamic.s -o %t-so.o +# RUN: ld.lld %t-so.o -shared -o %t.so +# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t.o +# RUN: ld.lld %t.o %t.so -o %t.exe +# RUN: llvm-objdump -d %t.exe | FileCheck %s + +# REQUIRES: mips + +# CHECK: Disassembly of section .text: +# CHECK-NEXT: __start: +# CHECK-NEXT: 20000: 0c 00 80 0c jal 131120 +# CHECK-NEXT: 20004: 00 00 00 00 nop +# CHECK-NEXT: Disassembly of section .plt: +# CHECK-NEXT: .plt: +# CHECK-NEXT: 20010: 3c 0e 00 03 lui $14, 3 +# CHECK-NEXT: 20014: dd d9 00 08 ld $25, 8($14) +# CHECK-NEXT: 20018: 25 ce 00 08 addiu $14, $14, 8 +# CHECK-NEXT: 2001c: 03 0e c0 23 subu $24, $24, $14 +# CHECK-NEXT: 20020: 03 e0 78 25 move $15, $ra +# CHECK-NEXT: 20024: 00 18 c0 c2 srl $24, $24, 3 +# CHECK-NEXT: 20028: 03 20 f8 09 jalr $25 +# CHECK-NEXT: 2002c: 27 18 ff fe addiu $24, $24, -2 +# CHECK-NEXT: 20030: 3c 0f 00 03 lui $15, 3 +# CHECK-NEXT: 20034: 8d f9 00 18 lw $25, 24($15) +# CHECK-NEXT: 20038: 03 20 00 08 jr $25 +# CHECK-NEXT: 2003c: 25 f8 00 18 addiu $24, $15, 24 + + .text + .option pic0 + .global __start +__start: + jal foo0 diff --git a/test/ELF/mips-64-gprel-so.s b/test/ELF/mips-64-gprel-so.s index a390ec082b1b..437238ef5f26 100644 --- a/test/ELF/mips-64-gprel-so.s +++ b/test/ELF/mips-64-gprel-so.s @@ -12,7 +12,7 @@ # CHECK-NEXT: 10004: 03 99 e0 2d daddu $gp, $gp, $25 # CHECK-NEXT: 10008: 67 9c 7f f0 daddiu $gp, $gp, 32752 -# CHECK: 0000000000027ff0 *ABS* 00000000 .hidden _gp +# CHECK: 0000000000027ff0 .got 00000000 .hidden _gp # CHECK: 0000000000010000 .text 00000000 foo .text diff --git a/test/ELF/mips-64-rels.s b/test/ELF/mips-64-rels.s index 93d893aacbde..78671554b1cb 100644 --- a/test/ELF/mips-64-rels.s +++ b/test/ELF/mips-64-rels.s @@ -20,11 +20,11 @@ # ^-- %lo(0x17ff0) # CHECK: Contents of section .rodata: -# CHECK-NEXT: 10158 ffffffff fffe8014 -# ^-- 0x20004 - 0x37ff0 = 0xfffffffffffe8014 +# CHECK-NEXT: {{[0-9a-f]+}} ffffffff fffe8014 +# ^-- 0x20004 - 0x37ff0 = 0xfffffffffffe8014 # CHECK: 0000000000020004 .text 00000000 loc -# CHECK: 0000000000037ff0 *ABS* 00000000 .hidden _gp +# CHECK: 0000000000037ff0 .got 00000000 .hidden _gp # CHECK: 0000000000020000 .text 00000000 __start # REL: Relocations [ diff --git a/test/ELF/mips-align-err.s b/test/ELF/mips-align-err.s index 0c71ffba8cb9..a3bf134e4386 100644 --- a/test/ELF/mips-align-err.s +++ b/test/ELF/mips-align-err.s @@ -4,7 +4,7 @@ # RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ # RUN: -mcpu=mips32r6 %S/Inputs/mips-align-err.s -o %t2.o # RUN: not ld.lld %t.o %t2.o -o %t.exe 2>&1 | FileCheck %s -# CHECK: {{.*}}:(.text+0x1): improper alignment for relocation R_MIPS_PC16 +# CHECK: {{.*}}:(.text+0x1): improper alignment for relocation R_MIPS_PC16: 0xB is not aligned to 4 bytes .globl __start __start: diff --git a/test/ELF/mips-elf-flags-err.s b/test/ELF/mips-elf-flags-err.s index 28d93eb6bea7..e1ac8c5e015e 100644 --- a/test/ELF/mips-elf-flags-err.s +++ b/test/ELF/mips-elf-flags-err.s @@ -71,8 +71,14 @@ __start: # R1R2-NEXT: EF_MIPS_CPIC # R1R2-NEXT: ] -# R3R32: target ISA 'mips3' is incompatible with 'mips32': {{.*}}mips-elf-flags-err.s.tmp2.o -# R6OCTEON: target ISA 'mips64r6' is incompatible with 'octeon': {{.*}}mips-elf-flags-err.s.tmp2.o +# R3R32: error: incompatible target ISA: +# R3R32-NEXT: >>> {{.+}}mips-elf-flags-err.s.tmp1.o: mips3 +# R3R32-NEXT: >>> {{.+}}mips-elf-flags-err.s.tmp2.o: mips32 + +# R6OCTEON: error: incompatible target ISA: +# R6OCTEON-NEXT: >>> {{.+}}mips-elf-flags-err.s.tmp1.o: mips64r6 +# R6OCTEON-NEXT: >>> {{.+}}mips-elf-flags-err.s.tmp2.o: mips64r2 (octeon) + # FPABI: target floating point ABI '-mdouble-float' is incompatible with '-mgp32 -mfp64': {{.*}}mips-elf-flags-err.s.tmp2.o # OCTEON: Flags [ diff --git a/test/ELF/mips-elf-flags.s b/test/ELF/mips-elf-flags.s index f8f916c9353d..d2b3d929e2f5 100644 --- a/test/ELF/mips-elf-flags.s +++ b/test/ELF/mips-elf-flags.s @@ -35,6 +35,12 @@ # RUN: llvm-readobj -h -mips-abi-flags %t.exe \ # RUN: | FileCheck -check-prefix=OCTEON %s +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ +# RUN: -mattr=micromips %S/Inputs/mips-fpic.s -o %t-mm.o +# RUN: ld.lld %t.o %t-mm.o -o %t.exe +# RUN: llvm-readobj -h -mips-abi-flags %t.exe | FileCheck -check-prefix=MICRO %s + # REQUIRES: mips .text @@ -170,3 +176,26 @@ __start: # OCTEON-NEXT: ] # OCTEON-NEXT: Flags 2: 0x0 # OCTEON-NEXT: } + +# MICRO: Flags [ +# MICRO-NEXT: EF_MIPS_ABI_O32 +# MICRO-NEXT: EF_MIPS_ARCH_32 +# MICRO-NEXT: EF_MIPS_CPIC +# MICRO-NEXT: EF_MIPS_MICROMIPS +# MICRO-NEXT: ] +# MICRO: MIPS ABI Flags { +# MICRO-NEXT: Version: 0 +# MICRO-NEXT: ISA: MIPS32 +# MICRO-NEXT: ISA Extension: None +# MICRO-NEXT: ASEs [ +# MICRO-NEXT: microMIPS +# MICRO-NEXT: ] +# MICRO-NEXT: FP ABI: Hard float (double precision) +# MICRO-NEXT: GPR size: 32 +# MICRO-NEXT: CPR1 size: 32 +# MICRO-NEXT: CPR2 size: 0 +# MICRO-NEXT: Flags 1 [ +# MICRO-NEXT: ODDSPREG +# MICRO-NEXT: ] +# MICRO-NEXT: Flags 2: 0x0 +# MICRO-NEXT: } diff --git a/test/ELF/mips-got-page-script.s b/test/ELF/mips-got-page-script.s new file mode 100644 index 000000000000..056e4fda77c2 --- /dev/null +++ b/test/ELF/mips-got-page-script.s @@ -0,0 +1,65 @@ +# Check calculation of MIPS GOT page address entries number +# when a linker script is provided. + +# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux -o %t.o %s +# RUN: echo "SECTIONS { \ +# RUN: .text : { *(.text) } \ +# RUN: .data 0x10000 : { *(.data) } }" > %t.script +# RUN: ld.lld -shared --script %t.script -o %t.so %t.o +# RUN: llvm-readobj -t -mips-plt-got %t.so | FileCheck %s + +# REQUIRES: mips + +# CHECK: Name: foo1 +# CHECK-NEXT: Value: 0x10000 +# CHECK: Name: foo2 +# CHECK-NEXT: Value: 0x20000 +# CHECK: Name: foo3 +# CHECK-NEXT: Value: 0x30000 +# CHECK: Name: foo4 +# CHECK-NEXT: Value: 0x40000 + +# CHECK: Local entries [ +# CHECK-BEXT: Entry { +# CHECK-BEXT: Address: +# CHECK-BEXT: Access: +# CHECK-BEXT: Initial: 0x10000 +# CHECK-BEXT: } +# CHECK-BEXT: Entry { +# CHECK-BEXT: Address: +# CHECK-BEXT: Access: +# CHECK-BEXT: Initial: 0x20000 +# CHECK-BEXT: } +# CHECK-BEXT: Entry { +# CHECK-BEXT: Address: +# CHECK-BEXT: Access: +# CHECK-BEXT: Initial: 0x30000 +# CHECK-BEXT: } +# CHECK-BEXT: Entry { +# CHECK-BEXT: Address: +# CHECK-BEXT: Access: +# CHECK-BEXT: Initial: 0x40000 +# CHECK-BEXT: } +# CHECK-BEXT: Entry { +# CHECK-BEXT: Address: +# CHECK-BEXT: Access: +# CHECK-BEXT: Initial: 0x50000 +# CHECK-BEXT: } +# CHECK-BEXT: ] + + .option pic2 + .text + ld $v0,%got_page(foo1)($gp) + ld $v0,%got_page(foo2)($gp) + ld $v0,%got_page(foo3)($gp) + ld $v0,%got_page(foo4)($gp) + + .data +foo1: + .space 0x10000 +foo2: + .space 0x10000 +foo3: + .space 0x10000 +foo4: + .word 0 diff --git a/test/ELF/mips-got-relocs.s b/test/ELF/mips-got-relocs.s index 4471bc210e2d..5b443e51938a 100644 --- a/test/ELF/mips-got-relocs.s +++ b/test/ELF/mips-got-relocs.s @@ -47,7 +47,7 @@ v1: # EXE_SYM: Sections: # EXE_SYM: .got 0000000c 0000000000030010 DATA # EXE_SYM: SYMBOL TABLE: -# EXE_SYM: 00038000 *ABS* 00000000 .hidden _gp +# EXE_SYM: 00038000 .got 00000000 .hidden _gp # ^-- .got + GP offset (0x7ff0) # EXE_SYM: 00030000 g .data 00000004 v1 @@ -71,7 +71,7 @@ v1: # DSO_SYM: Sections: # DSO_SYM: .got 0000000c 0000000000020010 DATA # DSO_SYM: SYMBOL TABLE: -# DSO_SYM: 00028000 *ABS* 00000000 .hidden _gp +# DSO_SYM: 00028000 .got 00000000 .hidden _gp # ^-- .got + GP offset (0x7ff0) # DSO_SYM: 00020000 g .data 00000004 v1 diff --git a/test/ELF/mips-got-script.s b/test/ELF/mips-got-script.s new file mode 100644 index 000000000000..da1858469863 --- /dev/null +++ b/test/ELF/mips-got-script.s @@ -0,0 +1,47 @@ +# Check number of got entries is adjusted for linker script-added space. + +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t.o +# RUN: echo "SECTIONS { .data : { *(.data.1); . += 0x10000; *(.data.2) } }" > %t.script +# RUN: ld.lld %t.o -shared -o %t.so -T %t.script +# RUN: llvm-readobj -mips-plt-got -dynamic-table %t.so | FileCheck %s + +# REQUIRES: mips + +# CHECK: 0x7000000A MIPS_LOCAL_GOTNO 5 +# ^-- 2 * header + 3 local entries +# CHECK: Local entries [ +# CHECK-NEXT: Entry { +# CHECK-NEXT: Address: +# CHECK-NEXT: Access: -32744 +# CHECK-NEXT: Initial: 0x0 +# ^-- loc1 +# CHECK-NEXT: } +# CHECK-NEXT: Entry { +# CHECK-NEXT: Address: +# CHECK-NEXT: Access: -32740 +# CHECK-NEXT: Initial: 0x10000 +# ^-- loc2 +# CHECK-NEXT: } +# CHECK-NEXT: Entry { +# CHECK-NEXT: Address: +# CHECK-NEXT: Access: -32736 +# CHECK-NEXT: Initial: 0x20000 +# ^-- redundant +# CHECK-NEXT: } +# CHECK-NEXT: ] + + .text + .globl foo +foo: + lw $t0, %got(loc1)($gp) + addi $t0, $t0, %lo(loc1) + lw $t0, %got(loc2)($gp) + addi $t0, $t0, %lo(loc2) + + .section .data.1,"aw",%progbits +loc1: + .word 0 + + .section .data.2,"aw",%progbits +loc2: + .word 0 diff --git a/test/ELF/mips-gp-disp.s b/test/ELF/mips-gp-disp.s index 62a2b1084530..7a0fd6409d18 100644 --- a/test/ELF/mips-gp-disp.s +++ b/test/ELF/mips-gp-disp.s @@ -24,7 +24,7 @@ # DIS-NEXT: 10000: 3c 08 00 01 lui $8, 1 # DIS-NEXT: 10004: 21 08 7f f0 addi $8, $8, 32752 # ^-- 0x37ff0 & 0xffff -# DIS: 00027ff0 *ABS* 00000000 .hidden _gp +# DIS: 00027ff0 .got 00000000 .hidden _gp # REL: Relocations [ # REL-NEXT: ] diff --git a/test/ELF/mips-gp-ext.s b/test/ELF/mips-gp-ext.s index 98b9cbc06d28..2fd21b7a9818 100644 --- a/test/ELF/mips-gp-ext.s +++ b/test/ELF/mips-gp-ext.s @@ -12,6 +12,13 @@ # RUN: echo "SECTIONS { \ # RUN: .text : { *(.text) } \ +# RUN: _gp = 0x100 + ABSOLUTE(.); \ +# RUN: .got : { *(.got) } }" > %t.rel.script +# RUN: ld.lld -shared -o %t.rel.so --script %t.rel.script %t.o +# RUN: llvm-objdump -s -t %t.rel.so | FileCheck --check-prefix=REL %s + +# RUN: echo "SECTIONS { \ +# RUN: .text : { *(.text) } \ # RUN: _gp = 0x200; \ # RUN: .got : { *(.got) } }" > %t.abs.script # RUN: ld.lld -shared -o %t.abs.so --script %t.abs.script %t.o diff --git a/test/ELF/mips-gp-local.s b/test/ELF/mips-gp-local.s index b77dbb8367ae..8bb3c236edf0 100644 --- a/test/ELF/mips-gp-local.s +++ b/test/ELF/mips-gp-local.s @@ -11,7 +11,7 @@ # CHECK-NEXT: 20000: 3c 08 00 03 lui $8, 3 # CHECK-NEXT: 20004: 21 08 7f f0 addi $8, $8, 32752 -# CHECK: 00037ff0 *ABS* 00000000 .hidden _gp +# CHECK: 00037ff0 .got 00000000 .hidden _gp .text .globl __start diff --git a/test/ELF/mips-gprel32-relocs-gp0.s b/test/ELF/mips-gprel32-relocs-gp0.s index 4f1962bd683b..507224e05d15 100644 --- a/test/ELF/mips-gprel32-relocs-gp0.s +++ b/test/ELF/mips-gprel32-relocs-gp0.s @@ -22,14 +22,14 @@ # DSO: GP: 0x27FF0 # DUMP: Contents of section .rodata: -# DUMP: 00f4 ffff0004 ffff0008 -# ^ 0x10004 + 0x7ff0 - 0x27ff0 -# ^ 0x10008 + 0x7ff0 - 0x27ff0 +# DUMP: {{[0-9a-f]+}} ffff0004 ffff0008 +# ^ 0x10004 + 0x7ff0 - 0x27ff0 +# ^ 0x10008 + 0x7ff0 - 0x27ff0 # DUMP: SYMBOL TABLE: # DUMP: 00010008 .text 00000000 bar # DUMP: 00010004 .text 00000000 foo -# DUMP: 00027ff0 *ABS* 00000000 .hidden _gp +# DUMP: 00027ff0 .got 00000000 .hidden _gp # ERR: error: {{.*}}mips-gp0-non-zero.o: unsupported non-zero ri_gp_value diff --git a/test/ELF/mips-gprel32-relocs.s b/test/ELF/mips-gprel32-relocs.s index 1c877b12b297..047165f19ae4 100644 --- a/test/ELF/mips-gprel32-relocs.s +++ b/test/ELF/mips-gprel32-relocs.s @@ -21,11 +21,11 @@ v1: .gpword bar # CHECK: Contents of section .rodata: -# CHECK: 00f4 fffe8014 fffe8018 -# ^ 0x10004 - 0x27ff0 -# ^ 0x10008 - 0x27ff0 +# CHECK: {{[0-9a-f]+}} fffe8014 fffe8018 +# ^ 0x10004 - 0x27ff0 +# ^ 0x10008 - 0x27ff0 # CHECK: SYMBOL TABLE: # CHECK: 00010008 .text 00000000 bar # CHECK: 00010004 .text 00000000 foo -# CHECK: 00027ff0 *ABS* 00000000 .hidden _gp +# CHECK: 00027ff0 .got 00000000 .hidden _gp diff --git a/test/ELF/mips-hilo-gp-disp.s b/test/ELF/mips-hilo-gp-disp.s index 62e03c7b6760..c7229ee0da25 100644 --- a/test/ELF/mips-hilo-gp-disp.s +++ b/test/ELF/mips-hilo-gp-disp.s @@ -34,7 +34,7 @@ bar: # EXE: SYMBOL TABLE: # EXE: 0002000c .text 00000000 bar -# EXE: 00038000 *ABS* 00000000 .hidden _gp +# EXE: 00038000 .got 00000000 .hidden _gp # EXE: 00020000 .text 00000000 __start # SO: Disassembly of section .text: @@ -51,5 +51,5 @@ bar: # SO: SYMBOL TABLE: # SO: 0001000c .text 00000000 bar -# SO: 00028000 *ABS* 00000000 .hidden _gp +# SO: 00028000 .got 00000000 .hidden _gp # SO: 00010000 .text 00000000 __start diff --git a/test/ELF/mips-hilo-hi-only.s b/test/ELF/mips-hilo-hi-only.s index 97808b515da5..0858e3f6cd17 100644 --- a/test/ELF/mips-hilo-hi-only.s +++ b/test/ELF/mips-hilo-hi-only.s @@ -18,7 +18,7 @@ _label: # CHECK: Disassembly of section .text: # CHECK-NEXT: __start: -# CHECK-NEXT: 20000: 3c 08 00 02 lui $8, 2 +# CHECK-NEXT: 20000: 3c 08 00 03 lui $8, 3 # ^-- %hi(__start) w/o addend # CHECK-NEXT 20004: 21 08 00 08 addi $8, $8, 8 # ^-- %lo(_label) diff --git a/test/ELF/mips-micro-got.s b/test/ELF/mips-micro-got.s new file mode 100644 index 000000000000..8d077f2800f1 --- /dev/null +++ b/test/ELF/mips-micro-got.s @@ -0,0 +1,46 @@ +# Check microMIPS GOT relocations for O32 ABI. + +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux -mattr=micromips \ +# RUN: %s -o %t1.o +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux -mattr=micromips \ +# RUN: %S/Inputs/mips-dynamic.s -o %t2.o +# RUN: ld.lld %t2.o -shared -o %t.so +# RUN: ld.lld %t1.o %t.so -o %t.exe +# RUN: llvm-readobj -mips-plt-got %t.exe | FileCheck %s + +# REQUIRES: mips + +# CHECK: Local entries [ +# CHECK-NEXT: Entry { +# CHECK-NEXT: Address: +# CHECK-NEXT: Access: -32744 +# CHECK-NEXT: Initial: 0x30000 +# CHECK-NEXT: } +# CHECK-NEXT: Entry { +# CHECK-NEXT: Address: +# CHECK-NEXT: Access: -32740 +# CHECK-NEXT: Initial: 0x40000 +# CHECK-NEXT: } +# CHECK-NEXT: ] +# CHECK-NEXT: Global entries [ +# CHECK-NEXT: Entry { +# CHECK-NEXT: Address: +# CHECK-NEXT: Access: -32736 +# CHECK-NEXT: Initial: 0x0 +# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: Type: Function +# CHECK-NEXT: Section: Undefined +# CHECK-NEXT: Name: foo0 +# CHECK-NEXT: } +# CHECK-NEXT: ] + + .text + .global __start +__start: + lw $4, %got(data)($28) + addiu $4, $4, %lo(data) + lw $25, %call16(foo0)($28) + + .data +data: + .word 0 diff --git a/test/ELF/mips-micro-got64.s b/test/ELF/mips-micro-got64.s new file mode 100644 index 000000000000..653bfbfbe8ce --- /dev/null +++ b/test/ELF/mips-micro-got64.s @@ -0,0 +1,48 @@ +# Check microMIPS GOT relocations for N64 ABI. + +# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux -mattr=micromips \ +# RUN: %s -o %t1.o +# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux -mattr=micromips \ +# RUN: %S/Inputs/mips-dynamic.s -o %t2.o +# RUN: ld.lld %t2.o -shared -o %t.so +# RUN: ld.lld %t1.o %t.so -o %t.exe +# RUN: llvm-readobj -mips-plt-got %t.exe | FileCheck %s + +# REQUIRES: mips + +# CHECK: Local entries [ +# CHECK-NEXT: Entry { +# CHECK-NEXT: Address: +# CHECK-NEXT: Access: -32736 +# CHECK-NEXT: Initial: 0x30000 +# CHECK-NEXT: } +# CHECK-NEXT: Entry { +# CHECK-NEXT: Address: +# CHECK-NEXT: Access: -32728 +# CHECK-NEXT: Initial: 0x40000 +# CHECK-NEXT: } +# CHECK-NEXT: ] +# CHECK-NEXT: Global entries [ +# CHECK-NEXT: Entry { +# CHECK-NEXT: Address: +# CHECK-NEXT: Access: -32720 +# CHECK-NEXT: Initial: 0x0 +# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: Type: Function +# CHECK-NEXT: Section: Undefined +# CHECK-NEXT: Name: foo0 +# CHECK-NEXT: } +# CHECK-NEXT: ] + + .text + .global __start +__start: + lui $28, %hi(%neg(%gp_rel(foo0))) + addiu $28, $28, %lo(%neg(%gp_rel(foo0))) + lw $4, %got_page(data)($28) + addiu $4, $4, %got_ofst(data) + lw $25, %call16(foo0)($28) + + .data +data: + .word 0 diff --git a/test/ELF/mips-micro-jal.s b/test/ELF/mips-micro-jal.s new file mode 100644 index 000000000000..83826126f766 --- /dev/null +++ b/test/ELF/mips-micro-jal.s @@ -0,0 +1,155 @@ +# Check PLT creation for microMIPS to microMIPS calls. + +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ +# RUN: -mattr=micromips %S/Inputs/mips-micro.s -o %t1eb.o +# RUN: ld.lld -shared -o %teb.so %t1eb.o +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ +# RUN: -mattr=micromips %s -o %t2eb.o +# RUN: ld.lld -o %teb.exe %t2eb.o %teb.so +# RUN: llvm-objdump -d -mattr=micromips %teb.exe | FileCheck --check-prefix=EB %s +# RUN: llvm-readobj -mips-plt-got %teb.exe | FileCheck --check-prefix=PLT %s + +# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \ +# RUN: -mattr=micromips %S/Inputs/mips-micro.s -o %t1el.o +# RUN: ld.lld -shared -o %tel.so %t1el.o +# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \ +# RUN: -mattr=micromips %s -o %t2el.o +# RUN: ld.lld -o %tel.exe %t2el.o %tel.so +# RUN: llvm-objdump -d -mattr=micromips %tel.exe | FileCheck --check-prefix=EL %s +# RUN: llvm-readobj -mips-plt-got %tel.exe | FileCheck --check-prefix=PLT %s + +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ +# RUN: -mattr=micromips -mcpu=mips32r6 %S/Inputs/mips-micro.s -o %t1eb.o +# RUN: ld.lld -shared -o %teb.so %t1eb.o +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ +# RUN: -mattr=micromips -mcpu=mips32r6 %s -o %t2eb.o +# RUN: ld.lld -o %teb.exe %t2eb.o %teb.so +# RUN: llvm-objdump -d -mattr=micromips %teb.exe | FileCheck --check-prefix=EBR6 %s + +# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \ +# RUN: -mattr=micromips -mcpu=mips32r6 %S/Inputs/mips-micro.s -o %t1el.o +# RUN: ld.lld -shared -o %tel.so %t1el.o +# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \ +# RUN: -mattr=micromips -mcpu=mips32r6 %s -o %t2el.o +# RUN: ld.lld -o %tel.exe %t2el.o %tel.so +# RUN: llvm-objdump -d -mattr=micromips %tel.exe | FileCheck --check-prefix=ELR6 %s + +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ +# RUN: -mattr=micromips %S/Inputs/mips-micro.s -o %t1eb.o +# RUN: ld.lld -shared -o %teb.so %t1eb.o +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ +# RUN: %S/Inputs/mips-fpic.s -o %t-reg.o +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ +# RUN: -mattr=micromips %s -o %t2eb.o +# RUN: ld.lld --no-threads -o %teb.exe %t-reg.o %t2eb.o %teb.so +# RUN: llvm-objdump -d -mattr=micromips %teb.exe \ +# RUN: | FileCheck --check-prefix=MIXED %s + +# REQUIRES: mips + +# EB: Disassembly of section .plt: +# EB-NEXT: .plt: +# EB-NEXT: 20010: 79 80 3f fd addiupc $3, 65524 +# EB-NEXT: 20014: ff 23 00 00 lw $25, 0($3) +# EB-NEXT: 20018: 05 35 subu16 $2, $2, $3 +# EB-NEXT: 2001a: 25 25 srl16 $2, $2, 2 +# EB-NEXT: 2001c: 33 02 ff fe addiu $24, $2, -2 +# EB-NEXT: 20020: 0d ff move $15, $ra +# EB-NEXT: 20022: 45 f9 jalrs16 $25 +# EB-NEXT: 20024: 0f 83 move $gp, $3 +# EB-NEXT: 20026: 0c 00 nop +# EB-NEXT: 20028: 00 00 00 00 nop +# EB-NEXT: 2002c: 00 00 00 00 nop + +# EB-NEXT: 20030: 79 00 3f f7 addiupc $2, 65500 +# EB-NEXT: 20034: ff 22 00 00 lw $25, 0($2) +# EB-NEXT: 20038: 45 99 jr16 $25 +# EB-NEXT: 2003a: 0f 02 move $24, $2 + +# EL: Disassembly of section .plt: +# EL-NEXT: .plt: +# EL-NEXT: 20010: 80 79 fd 3f addiupc $3, 65524 +# EL-NEXT: 20014: 23 ff 00 00 lw $25, 0($3) +# EL-NEXT: 20018: 35 05 subu16 $2, $2, $3 +# EL-NEXT: 2001a: 25 25 srl16 $2, $2, 2 +# EL-NEXT: 2001c: 02 33 fe ff addiu $24, $2, -2 +# EL-NEXT: 20020: ff 0d move $15, $ra +# EL-NEXT: 20022: f9 45 jalrs16 $25 +# EL-NEXT: 20024: 83 0f move $gp, $3 +# EL-NEXT: 20026: 00 0c nop +# EL-NEXT: 20028: 00 00 00 00 nop +# EL-NEXT: 2002c: 00 00 00 00 nop + +# EL-NEXT: 20030: 00 79 f7 3f addiupc $2, 65500 +# EL-NEXT: 20034: 22 ff 00 00 lw $25, 0($2) +# EL-NEXT: 20038: 99 45 jr16 $25 +# EL-NEXT: 2003a: 02 0f move $24, $2 + +# EBR6: Disassembly of section .plt: +# EBR6-NEXT: .plt: +# EBR6-NEXT: 20010: 78 60 3f fd lapc $3, 65524 +# EBR6-NEXT: 20014: ff 23 00 00 lw $25, 0($3) +# EBR6-NEXT: 20018: 05 35 subu16 $2, $2, $3 +# EBR6-NEXT: 2001a: 25 25 srl16 $2, $2, 2 +# EBR6-NEXT: 2001c: 33 02 ff fe addiu $24, $2, -2 +# EBR6-NEXT: 20020: 0d ff move16 $15, $ra +# EBR6-NEXT: 20022: 0f 83 move16 $gp, $3 +# EBR6-NEXT: 20024: 47 2b jalr $25 + +# EBR6: 20030: 78 40 3f f7 lapc $2, 65500 +# EBR6-NEXT: 20034: ff 22 00 00 lw $25, 0($2) +# EBR6-NEXT: 20038: 0f 02 move16 $24, $2 +# EBR6-NEXT: 2003a: 47 23 jrc16 $25 + +# ELR6: Disassembly of section .plt: +# ELR6-NEXT: .plt: +# ELR6-NEXT: 20010: 60 78 fd 3f lapc $3, 65524 +# ELR6-NEXT: 20014: 23 ff 00 00 lw $25, 0($3) +# ELR6-NEXT: 20018: 35 05 subu16 $2, $2, $3 +# ELR6-NEXT: 2001a: 25 25 srl16 $2, $2, 2 +# ELR6-NEXT: 2001c: 02 33 fe ff addiu $24, $2, -2 +# ELR6-NEXT: 20020: ff 0d move16 $15, $ra +# ELR6-NEXT: 20022: 83 0f move16 $gp, $3 +# ELR6-NEXT: 20024: 2b 47 jalr $25 + +# ELR6: 20030: 40 78 f7 3f lapc $2, 65500 +# ELR6-NEXT: 20034: 22 ff 00 00 lw $25, 0($2) +# ELR6-NEXT: 20038: 02 0f move16 $24, $2 +# ELR6-NEXT: 2003a: 23 47 jrc16 $25 + +# MIXED: Disassembly of section .plt: +# MIXED-NEXT: .plt: +# MIXED-NEXT: 20020: 79 80 3f f9 addiupc $3, 65508 +# MIXED-NEXT: 20024: ff 23 00 00 lw $25, 0($3) +# MIXED-NEXT: 20028: 05 35 subu16 $2, $2, $3 +# MIXED-NEXT: 2002a: 25 25 srl16 $2, $2, 2 +# MIXED-NEXT: 2002c: 33 02 ff fe addiu $24, $2, -2 +# MIXED-NEXT: 20030: 0d ff move $15, $ra +# MIXED-NEXT: 20032: 45 f9 jalrs16 $25 +# MIXED-NEXT: 20034: 0f 83 move $gp, $3 +# MIXED-NEXT: 20036: 0c 00 nop +# MIXED-NEXT: 20038: 00 00 00 00 nop +# MIXED-NEXT: 2003c: 00 00 00 00 nop + +# MIXED-NEXT: 20040: 79 00 3f f3 addiupc $2, 65484 +# MIXED-NEXT: 20044: ff 22 00 00 lw $25, 0($2) +# MIXED-NEXT: 20048: 45 99 jr16 $25 +# MIXED-NEXT: 2004a: 0f 02 move $24, $2 + +# PLT: Entries [ +# PLT-NEXT: Entry { +# PLT-NEXT: Address: 0x3000C +# ^ 0x20030 + 65500 +# PLT-NEXT: Initial: +# PLT-NEXT: Value: 0x0 +# PLT-NEXT: Type: Function +# PLT-NEXT: Section: Undefined +# PLT-NEXT: Name: foo +# PLT-NEXT: } +# PLT-NEXT: ] + + .text + .set micromips + .global __start +__start: + jal foo diff --git a/test/ELF/mips-micro-plt.s b/test/ELF/mips-micro-plt.s new file mode 100644 index 000000000000..5671dc420c55 --- /dev/null +++ b/test/ELF/mips-micro-plt.s @@ -0,0 +1,91 @@ +# Check less-significant bit setup for microMIPS PLT. + +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ +# RUN: -mattr=micromips %S/Inputs/mips-dynamic.s -o %t-dso.o +# RUN: ld.lld %t-dso.o -shared -o %t.so +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ +# RUN: -mattr=micromips %s -o %t-exe.o +# RUN: ld.lld %t-exe.o %t.so -o %t.exe +# RUN: llvm-readobj -t -dt -mips-plt-got %t.exe | FileCheck %s + +# REQUIRES: mips + +# CHECK: Symbols [ +# CHECK: Symbol { +# CHECK: Name: foo +# CHECK-NEXT: Value: 0x20008 +# CHECK-NEXT: Size: +# CHECK-NEXT: Binding: Local +# CHECK-NEXT: Type: None +# CHECK-NEXT: Other [ +# CHECK-NEXT: STO_MIPS_MICROMIPS +# CHECK-NEXT: STV_HIDDEN +# CHECK-NEXT: ] +# CHECK-NEXT: Section: .text +# CHECK-NEXT: } +# CHECK: Symbol { +# CHECK: Name: __start +# CHECK-NEXT: Value: 0x20000 +# CHECK-NEXT: Size: +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: None +# CHECK-NEXT: Other [ +# CHECK-NEXT: STO_MIPS_MICROMIPS +# CHECK-NEXT: ] +# CHECK-NEXT: Section: .text +# CHECK-NEXT: } +# CHECK: Symbol { +# CHECK: Name: foo0 +# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: Size: +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: Function +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: Undefined +# CHECK-NEXT: } +# CHECK-NEXT: ] +# CHECK: DynamicSymbols [ +# CHECK: Symbol { +# CHECK: Name: foo0 +# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: Size: +# CHECK-NEXT: Binding: Global +# CHECK-NEXT: Type: Function +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: Undefined +# CHECK-NEXT: } +# CHECK-NEXT: ] + +# CHECK: Primary GOT { +# CHECK: Local entries [ +# CHECK-NEXT: Entry { +# CHECK-NEXT: Address: +# CHECK-NEXT: Access: +# CHECK-NEXT: Initial: 0x20009 +# CHECK-NEXT: } +# CHECK: ] +# CHECK: } + +# CHECK: PLT GOT { +# CHECK: Entries [ +# CHECK-NEXT: Entry { +# CHECK-NEXT: Address: +# CHECK-NEXT: Initial: 0x20011 +# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: Type: Function +# CHECK-NEXT: Section: Undefined +# CHECK-NEXT: Name: foo0@ +# CHECK-NEXT: } +# CHECK-NEXT: ] +# CHECK-NEXT: } + + .text + .set micromips + .global foo + .hidden foo + .global __start +__start: + lw $t0,%got(foo)($gp) + addi $t0,$t0,%lo(foo) +foo: + jal foo0 diff --git a/test/ELF/mips-micro-relocs.s b/test/ELF/mips-micro-relocs.s new file mode 100644 index 000000000000..3986711cc7f7 --- /dev/null +++ b/test/ELF/mips-micro-relocs.s @@ -0,0 +1,59 @@ +# Check handling of microMIPS relocations. + +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ +# RUN: -mattr=micromips %S/Inputs/mips-micro.s -o %t1eb.o +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ +# RUN: -mattr=micromips %s -o %t2eb.o +# RUN: ld.lld -o %teb.exe %t1eb.o %t2eb.o +# RUN: llvm-objdump -d -t -mattr=micromips %teb.exe \ +# RUN: | FileCheck --check-prefixes=EB,SYM %s + +# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \ +# RUN: -mattr=micromips %S/Inputs/mips-micro.s -o %t1el.o +# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \ +# RUN: -mattr=micromips %s -o %t2el.o +# RUN: ld.lld -o %tel.exe %t1el.o %t2el.o +# RUN: llvm-objdump -d -t -mattr=micromips %tel.exe \ +# RUN: | FileCheck --check-prefixes=EL,SYM %s + +# REQUIRES: mips + +# EB: __start: +# EB-NEXT: 20010: 41 a3 00 01 lui $3, 1 +# EB-NEXT: 20014: 30 63 7f df addiu $3, $3, 32735 +# EB-NEXT: 20018: fc 7c 80 18 lw $3, -32744($gp) +# EB-NEXT: 2001c: fc 63 80 18 lw $3, -32744($3) +# EB-NEXT: 20020: 8f 70 beqz16 $6, -32 +# EB-NEXT: 20022: 00 7e 00 00 sll $3, $fp, 0 +# EB-NEXT: 20026: cf ec b16 -40 +# EB-NEXT: 20028: 00 00 00 00 nop +# EB-NEXT: 2002c: 94 00 ff e8 b -44 + +# EL: __start: +# EL-NEXT: 20010: a3 41 01 00 lui $3, 1 +# EL-NEXT: 20014: 63 30 df 7f addiu $3, $3, 32735 +# EL-NEXT: 20018: 7c fc 18 80 lw $3, -32744($gp) +# EL-NEXT: 2001c: 63 fc 18 80 lw $3, -32744($3) +# EL-NEXT: 20020: 70 8f beqz16 $6, -32 +# EL-NEXT: 20022: 7e 00 00 00 sll $3, $fp, 0 +# EL-NEXT: 20026: ec cf b16 -40 +# EL-NEXT: 20028: 00 00 00 00 nop +# EL-NEXT: 2002c: 00 94 e8 ff b -44 + +# SYM: 00037ff0 .got 00000000 .hidden _gp +# SYM: 00020000 g F .text 00000000 foo +# SYM: 00020010 .text 00000000 __start + + .text + .set micromips + .global __start +__start: + lui $3, %hi(_gp_disp) # R_MICROMIPS_HI16 + addiu $3, $3, %lo(_gp_disp) # R_MICROMIPS_LO16 + + lw $3, %call16(foo)($gp) # R_MICROMIPS_CALL16 + lw $3, %got(foo)($3) # R_MICROMIPS_GOT16 + + beqz16 $6, foo # R_MICROMIPS_PC7_S1 + b16 foo # R_MICROMIPS_PC10_S1 + b foo # R_MICROMIPS_PC16_S1 diff --git a/test/ELF/mips-micro-thunks.s b/test/ELF/mips-micro-thunks.s new file mode 100644 index 000000000000..18a8fc33f53c --- /dev/null +++ b/test/ELF/mips-micro-thunks.s @@ -0,0 +1,47 @@ +# Check microMIPS thunk generation. + +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ +# RUN: -mattr=micromips %s -o %t-eb.o +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ +# RUN: -position-independent -mattr=micromips \ +# RUN: %S/Inputs/mips-micro.s -o %t-eb-pic.o +# RUN: ld.lld -o %t-eb.exe %t-eb.o %t-eb-pic.o +# RUN: llvm-objdump -d -mattr=+micromips %t-eb.exe \ +# RUN: | FileCheck --check-prefix=EB %s + +# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \ +# RUN: -mattr=micromips %s -o %t-el.o +# RUN: llvm-mc -filetype=obj -triple=mipsel-unknown-linux \ +# RUN: -position-independent -mattr=micromips \ +# RUN: %S/Inputs/mips-micro.s -o %t-el-pic.o +# RUN: ld.lld -o %t-el.exe %t-el.o %t-el-pic.o +# RUN: llvm-objdump -d -mattr=+micromips %t-el.exe \ +# RUN: | FileCheck --check-prefix=EL %s + +# REQUIRES: mips + +# EB: __start: +# EB-NEXT: 20000: f4 01 00 04 jal 131080 <__microLA25Thunk_foo> +# EB-NEXT: 20004: 00 00 00 00 nop + +# EB: __microLA25Thunk_foo: +# EB-NEXT: 20008: 41 b9 00 02 lui $25, 2 +# EB-NEXT: 2000c: d4 01 00 10 j 131104 +# EB-NEXT: 20010: 33 39 00 21 addiu $25, $25, 33 +# EB-NEXT: 20014: 0c 00 nop + +# EL: __start: +# EL-NEXT: 20000: 01 f4 04 00 jal 131080 <__microLA25Thunk_foo> +# EL-NEXT: 20004: 00 00 00 00 nop + +# EL: __microLA25Thunk_foo: +# EL-NEXT: 20008: b9 41 02 00 lui $25, 2 +# EL-NEXT: 2000c: 01 d4 10 00 j 131104 +# EL-NEXT: 20010: 39 33 21 00 addiu $25, $25, 33 +# EL-NEXT: 20014: 00 0c nop + + .text + .set micromips + .global __start +__start: + jal foo diff --git a/test/ELF/mips-n32-rels.s b/test/ELF/mips-n32-rels.s index 7706e2591a33..954d4c30a157 100644 --- a/test/ELF/mips-n32-rels.s +++ b/test/ELF/mips-n32-rels.s @@ -38,11 +38,11 @@ # ^-- %lo(0x17ff0) # CHECK: Contents of section .rodata: -# CHECK-NEXT: 100d4 00020004 -# ^-- loc +# CHECK-NEXT: {{[0-9a-f]+}} 00020004 +# ^-- loc # CHECK: 00020004 .text 00000000 loc -# CHECK: 00037ff0 *ABS* 00000000 .hidden _gp +# CHECK: 00037ff0 .got 00000000 .hidden _gp # CHECK: 00020000 g F .text 00000000 __start # ELF: Format: ELF32-mips diff --git a/test/ELF/mips-out-of-bounds-call16-reloc.s b/test/ELF/mips-out-of-bounds-call16-reloc.s new file mode 100644 index 000000000000..64e9ab3aa7e2 --- /dev/null +++ b/test/ELF/mips-out-of-bounds-call16-reloc.s @@ -0,0 +1,29 @@ +# Check that we create an error on an out-of-bounds R_MIPS_CALL_16 + +# REQUIRES: mips +# RUN: llvm-mc -filetype=obj -triple=mips64-unknown-linux %s -o %t1.o +# RUN: not ld.lld %t1.o -o %t.exe 2>&1 | FileCheck %s + +# CHECK: relocation R_MIPS_CALL16 out of range: 32768 is not in [-32768, 32767] + +.macro generate_values + .irp i, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + .irp j, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + .irp k, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + .irp l, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, + .text + .globl sym_\i\j\k\l + sym_\i\j\k\l: + nop + lw $25,%call16(sym_\i\j\k\l)($28) + .endr + .endr + .endr + .endr +.endm + +generate_values + +.globl __start +__start: + nop diff --git a/test/ELF/no-inhibit-exec.s b/test/ELF/no-inhibit-exec.s index d0970d93f21e..afb7aed94c12 100644 --- a/test/ELF/no-inhibit-exec.s +++ b/test/ELF/no-inhibit-exec.s @@ -2,12 +2,16 @@ # RUN: not ld.lld %t -o %t2 # RUN: ld.lld %t --noinhibit-exec -o %t2 # RUN: llvm-objdump -d %t2 | FileCheck %s +# RUN: llvm-readobj -r %t2 | FileCheck %s --check-prefix=RELOC # REQUIRES: x86 # CHECK: Disassembly of section .text: # CHECK-NEXT: _start # CHECK-NEXT: 201000: {{.*}} callq -2101253 +# RELOC: Relocations [ +# RELOC-NEXT: ] + # next code will not link without noinhibit-exec flag # because of undefined symbol _bar .globl _start diff --git a/test/ELF/non-abs-reloc.s b/test/ELF/non-abs-reloc.s index ef9ba4466133..454104cca076 100644 --- a/test/ELF/non-abs-reloc.s +++ b/test/ELF/non-abs-reloc.s @@ -1,7 +1,7 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o // RUN: not ld.lld %t.o -o %t.so -shared 2>&1 | FileCheck %s -// CHECK: {{.*}}:(.dummy+0x0): has non-ABS reloc +// CHECK: {{.*}}:(.dummy+0x0): has non-ABS relocation R_X86_64_GOTPCREL against symbol 'foo' .globl _start _start: diff --git a/test/ELF/noplt-pie.s b/test/ELF/noplt-pie.s index 81e4410ac2c2..7f6ccf23d5cc 100644 --- a/test/ELF/noplt-pie.s +++ b/test/ELF/noplt-pie.s @@ -2,7 +2,7 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o # RUN: ld.lld -shared %t2.o -o %t2.so -# RUN: ld.lld %t1.o %t2.so -o %t.out +# RUN: ld.lld --hash-style=sysv %t1.o %t2.so -o %t.out # RUN: llvm-readobj -s -r %t.out | FileCheck %s # CHECK: Section { diff --git a/test/ELF/pack-dyn-relocs.s b/test/ELF/pack-dyn-relocs.s new file mode 100644 index 000000000000..cb8674318ec6 --- /dev/null +++ b/test/ELF/pack-dyn-relocs.s @@ -0,0 +1,210 @@ +// REQUIRES: arm, aarch64 + +// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %p/Inputs/arm-shared.s -o %t.a32.so.o +// RUN: ld.lld -shared %t.a32.so.o -o %t.a32.so +// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.a32 +// RUN: ld.lld -pie --pack-dyn-relocs=none %t.a32 %t.a32.so -o %t2.a32 +// RUN: llvm-readobj -relocations %t2.a32 | FileCheck --check-prefix=UNPACKED32 %s +// RUN: ld.lld -pie --pack-dyn-relocs=android %t.a32 %t.a32.so -o %t3.a32 +// RUN: llvm-readobj -s -dynamic-table %t3.a32 | FileCheck --check-prefix=PACKED32-HEADERS %s +// RUN: llvm-readobj -relocations %t3.a32 | FileCheck --check-prefix=PACKED32 %s + +// Unpacked should have the relative relocations in their natural order. +// UNPACKED32: 0x1000 R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x1004 R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x1008 R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x100C R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x1010 R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x1014 R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x1018 R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x101C R_ARM_RELATIVE - 0x0 + +// UNPACKED32-NEXT: 0x1024 R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x1028 R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x102C R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x1030 R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x1034 R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x1038 R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x103C R_ARM_RELATIVE - 0x0 + +// UNPACKED32-NEXT: 0x1044 R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x1048 R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x104C R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x1050 R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x1054 R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x1058 R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x105C R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x1060 R_ARM_RELATIVE - 0x0 +// UNPACKED32-NEXT: 0x1064 R_ARM_RELATIVE - 0x0 + +// UNPACKED32-NEXT: 0x1020 R_ARM_ABS32 bar2 0x0 +// UNPACKED32-NEXT: 0x1040 R_ARM_ABS32 zed2 0x0 + +// PACKED32-HEADERS: Index: 1 +// PACKED32-HEADERS-NEXT: Name: .dynsym + +// PACKED32-HEADERS: Name: .rel.dyn +// PACKED32-HEADERS-NEXT: Type: SHT_ANDROID_REL +// PACKED32-HEADERS-NEXT: Flags [ (0x2) +// PACKED32-HEADERS-NEXT: SHF_ALLOC (0x2) +// PACKED32-HEADERS-NEXT: ] +// PACKED32-HEADERS-NEXT: Address: [[ADDR:.*]] +// PACKED32-HEADERS-NEXT: Offset: [[ADDR]] +// PACKED32-HEADERS-NEXT: Size: [[SIZE:.*]] +// PACKED32-HEADERS-NEXT: Link: 1 +// PACKED32-HEADERS-NEXT: Info: 0 +// PACKED32-HEADERS-NEXT: AddressAlignment: 4 +// PACKED32-HEADERS-NEXT: EntrySize: 1 + +// PACKED32-HEADERS: 0x6000000F ANDROID_REL [[ADDR]] +// PACKED32-HEADERS: 0x60000010 ANDROID_RELSZ [[SIZE]] + +// Packed should have the larger groups of relative relocations first, +// i.e. the 8 and 9 followed by the 7. +// PACKED32: 0x1000 R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x1004 R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x1008 R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x100C R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x1010 R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x1014 R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x1018 R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x101C R_ARM_RELATIVE - 0x0 + +// PACKED32-NEXT: 0x1044 R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x1048 R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x104C R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x1050 R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x1054 R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x1058 R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x105C R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x1060 R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x1064 R_ARM_RELATIVE - 0x0 + +// PACKED32-NEXT: 0x1024 R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x1028 R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x102C R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x1030 R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x1034 R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x1038 R_ARM_RELATIVE - 0x0 +// PACKED32-NEXT: 0x103C R_ARM_RELATIVE - 0x0 + +// PACKED32-NEXT: 0x1020 R_ARM_ABS32 bar2 0x0 +// PACKED32-NEXT: 0x1040 R_ARM_ABS32 zed2 0x0 + +// RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-linux %p/Inputs/shared2.s -o %t.a64.so.o +// RUN: ld.lld -shared %t.a64.so.o -o %t.a64.so +// RUN: llvm-mc -filetype=obj -triple=aarch64-unknown-linux %s -o %t.a64 +// RUN: ld.lld -pie --pack-dyn-relocs=none %t.a64 %t.a64.so -o %t2.a64 +// RUN: llvm-readobj -relocations %t2.a64 | FileCheck --check-prefix=UNPACKED64 %s +// RUN: ld.lld -pie --pack-dyn-relocs=android %t.a64 %t.a64.so -o %t3.a64 +// RUN: llvm-readobj -s -dynamic-table %t3.a64 | FileCheck --check-prefix=PACKED64-HEADERS %s +// RUN: llvm-readobj -relocations %t3.a64 | FileCheck --check-prefix=PACKED64 %s + +// UNPACKED64: 0x10000 R_AARCH64_RELATIVE - 0x1 +// UNPACKED64-NEXT: 0x10008 R_AARCH64_RELATIVE - 0x2 +// UNPACKED64-NEXT: 0x10010 R_AARCH64_RELATIVE - 0x3 +// UNPACKED64-NEXT: 0x10018 R_AARCH64_RELATIVE - 0x4 +// UNPACKED64-NEXT: 0x10020 R_AARCH64_RELATIVE - 0x5 +// UNPACKED64-NEXT: 0x10028 R_AARCH64_RELATIVE - 0x6 +// UNPACKED64-NEXT: 0x10030 R_AARCH64_RELATIVE - 0x7 +// UNPACKED64-NEXT: 0x10038 R_AARCH64_RELATIVE - 0x8 + +// UNPACKED64-NEXT: 0x10048 R_AARCH64_RELATIVE - 0x1 +// UNPACKED64-NEXT: 0x10050 R_AARCH64_RELATIVE - 0x2 +// UNPACKED64-NEXT: 0x10058 R_AARCH64_RELATIVE - 0x3 +// UNPACKED64-NEXT: 0x10060 R_AARCH64_RELATIVE - 0x4 +// UNPACKED64-NEXT: 0x10068 R_AARCH64_RELATIVE - 0x5 +// UNPACKED64-NEXT: 0x10070 R_AARCH64_RELATIVE - 0x6 +// UNPACKED64-NEXT: 0x10078 R_AARCH64_RELATIVE - 0x7 + +// UNPACKED64-NEXT: 0x10088 R_AARCH64_RELATIVE - 0x1 +// UNPACKED64-NEXT: 0x10090 R_AARCH64_RELATIVE - 0x2 +// UNPACKED64-NEXT: 0x10098 R_AARCH64_RELATIVE - 0x3 +// UNPACKED64-NEXT: 0x100A0 R_AARCH64_RELATIVE - 0x4 +// UNPACKED64-NEXT: 0x100A8 R_AARCH64_RELATIVE - 0x5 +// UNPACKED64-NEXT: 0x100B0 R_AARCH64_RELATIVE - 0x6 +// UNPACKED64-NEXT: 0x100B8 R_AARCH64_RELATIVE - 0x7 +// UNPACKED64-NEXT: 0x100C0 R_AARCH64_RELATIVE - 0x8 +// UNPACKED64-NEXT: 0x100C8 R_AARCH64_RELATIVE - 0x9 + +// UNPACKED64-NEXT: 0x10040 R_AARCH64_ABS64 bar2 0x1 +// UNPACKED64-NEXT: 0x10080 R_AARCH64_ABS64 zed2 0x0 + +// PACKED64: 0x10000 R_AARCH64_RELATIVE - 0x1 +// PACKED64-NEXT: 0x10008 R_AARCH64_RELATIVE - 0x2 +// PACKED64-NEXT: 0x10010 R_AARCH64_RELATIVE - 0x3 +// PACKED64-NEXT: 0x10018 R_AARCH64_RELATIVE - 0x4 +// PACKED64-NEXT: 0x10020 R_AARCH64_RELATIVE - 0x5 +// PACKED64-NEXT: 0x10028 R_AARCH64_RELATIVE - 0x6 +// PACKED64-NEXT: 0x10030 R_AARCH64_RELATIVE - 0x7 +// PACKED64-NEXT: 0x10038 R_AARCH64_RELATIVE - 0x8 + +// PACKED64-NEXT: 0x10088 R_AARCH64_RELATIVE - 0x1 +// PACKED64-NEXT: 0x10090 R_AARCH64_RELATIVE - 0x2 +// PACKED64-NEXT: 0x10098 R_AARCH64_RELATIVE - 0x3 +// PACKED64-NEXT: 0x100A0 R_AARCH64_RELATIVE - 0x4 +// PACKED64-NEXT: 0x100A8 R_AARCH64_RELATIVE - 0x5 +// PACKED64-NEXT: 0x100B0 R_AARCH64_RELATIVE - 0x6 +// PACKED64-NEXT: 0x100B8 R_AARCH64_RELATIVE - 0x7 +// PACKED64-NEXT: 0x100C0 R_AARCH64_RELATIVE - 0x8 +// PACKED64-NEXT: 0x100C8 R_AARCH64_RELATIVE - 0x9 + +// PACKED64-NEXT: 0x10048 R_AARCH64_RELATIVE - 0x1 +// PACKED64-NEXT: 0x10050 R_AARCH64_RELATIVE - 0x2 +// PACKED64-NEXT: 0x10058 R_AARCH64_RELATIVE - 0x3 +// PACKED64-NEXT: 0x10060 R_AARCH64_RELATIVE - 0x4 +// PACKED64-NEXT: 0x10068 R_AARCH64_RELATIVE - 0x5 +// PACKED64-NEXT: 0x10070 R_AARCH64_RELATIVE - 0x6 +// PACKED64-NEXT: 0x10078 R_AARCH64_RELATIVE - 0x7 + +// PACKED64-NEXT: 0x10040 R_AARCH64_ABS64 bar2 0x1 +// PACKED64-NEXT: 0x10080 R_AARCH64_ABS64 zed2 0x0 + +// PACKED64-HEADERS: Index: 1 +// PACKED64-HEADERS-NEXT: Name: .dynsym + +// PACKED64-HEADERS: Name: .rela.dyn +// PACKED64-HEADERS-NEXT: Type: SHT_ANDROID_RELA +// PACKED64-HEADERS-NEXT: Flags [ (0x2) +// PACKED64-HEADERS-NEXT: SHF_ALLOC (0x2) +// PACKED64-HEADERS-NEXT: ] +// PACKED64-HEADERS-NEXT: Address: [[ADDR:.*]] +// PACKED64-HEADERS-NEXT: Offset: [[ADDR]] +// PACKED64-HEADERS-NEXT: Size: [[SIZE:.*]] +// PACKED64-HEADERS-NEXT: Link: 1 +// PACKED64-HEADERS-NEXT: Info: 0 +// PACKED64-HEADERS-NEXT: AddressAlignment: 8 +// PACKED64-HEADERS-NEXT: EntrySize: 1 + +// PACKED64-HEADERS: 0x0000000060000011 ANDROID_RELA [[ADDR]] +// PACKED64-HEADERS: 0x0000000060000012 ANDROID_RELASZ [[SIZE]] + +.data +.dc.a __ehdr_start + 1 +.dc.a __ehdr_start + 2 +.dc.a __ehdr_start + 3 +.dc.a __ehdr_start + 4 +.dc.a __ehdr_start + 5 +.dc.a __ehdr_start + 6 +.dc.a __ehdr_start + 7 +.dc.a __ehdr_start + 8 +.dc.a bar2 + 1 + +.dc.a __ehdr_start + 1 +.dc.a __ehdr_start + 2 +.dc.a __ehdr_start + 3 +.dc.a __ehdr_start + 4 +.dc.a __ehdr_start + 5 +.dc.a __ehdr_start + 6 +.dc.a __ehdr_start + 7 +.dc.a zed2 + +.dc.a __ehdr_start + 1 +.dc.a __ehdr_start + 2 +.dc.a __ehdr_start + 3 +.dc.a __ehdr_start + 4 +.dc.a __ehdr_start + 5 +.dc.a __ehdr_start + 6 +.dc.a __ehdr_start + 7 +.dc.a __ehdr_start + 8 +.dc.a __ehdr_start + 9 diff --git a/test/ELF/pie-weak.s b/test/ELF/pie-weak.s index 99dbd47488fc..c4d64e3ff287 100644 --- a/test/ELF/pie-weak.s +++ b/test/ELF/pie-weak.s @@ -1,10 +1,13 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -relax-relocations=false -triple=x86_64-unknown-linux %s -o %t.o -# RUN: ld.lld -pie %t.o -o %t +# RUN: ld.lld --hash-style=sysv -pie %t.o -o %t # RUN: llvm-readobj -r %t | FileCheck --check-prefix=RELOCS %s # RUN: llvm-objdump -d %t | FileCheck --check-prefix=DISASM %s # RELOCS: Relocations [ +# RELOCS-NEXT: Section ({{.*}}) .rela.dyn { +# RELOCS-NEXT: R_X86_64_GLOB_DAT foo 0x0 +# RELOCS-NEXT: } # RELOCS-NEXT: ] .weak foo @@ -12,6 +15,6 @@ .globl _start _start: # DISASM: _start: -# DISASM-NEXT: 1000: 48 8b 05 69 10 00 00 movq 4201(%rip), %rax +# DISASM-NEXT: 1000: 48 8b 05 99 10 00 00 movq 4249(%rip), %rax # ^ .got - (.text + 7) mov foo@gotpcrel(%rip), %rax diff --git a/test/ELF/ppc-relocs.s b/test/ELF/ppc-relocs.s index 78542dd64a4c..5aa3474e6339 100644 --- a/test/ELF/ppc-relocs.s +++ b/test/ELF/ppc-relocs.s @@ -17,6 +17,20 @@ msg: # CHECK: msg: # CHECK: 11004: 66 6f 6f 00 oris 15, 19, 28416 +.section .R_PPC_ADDR16_HI,"ax",@progbits +.globl _starti +_starti: + lis 4,msgi@h +msgi: + .string "foo" + leni = . - msgi + +# CHECK: Disassembly of section .R_PPC_ADDR16_HI: +# CHECK: _starti: +# CHECK: 11008: 3c 80 00 01 lis 4, 1 +# CHECK: msgi: +# CHECK: 1100c: 66 6f 6f 00 oris 15, 19, 28416 + .section .R_PPC_ADDR16_LO,"ax",@progbits addi 4, 4, msg@l mystr: @@ -25,9 +39,9 @@ mystr: # CHECK: Disassembly of section .R_PPC_ADDR16_LO: # CHECK: .R_PPC_ADDR16_LO: -# CHECK: 11008: 38 84 10 04 addi 4, 4, 4100 +# CHECK: 11010: 38 84 10 04 addi 4, 4, 4100 # CHECK: mystr: -# CHECK: 1100c: 62 6c 61 68 ori 12, 19, 24936 +# CHECK: 11014: 62 6c 61 68 ori 12, 19, 24936 .align 2 .section .R_PPC_REL24,"ax",@progbits @@ -39,7 +53,7 @@ mystr: # CHECK: Disassembly of section .R_PPC_REL24: # CHECK: .FR_PPC_REL24: -# CHECK: 11014: 48 00 00 04 b .+4 +# CHECK: 1101c: 48 00 00 04 b .+4 .section .R_PPC_REL32,"ax",@progbits .globl .FR_PPC_REL32 @@ -50,7 +64,7 @@ mystr: # CHECK: Disassembly of section .R_PPC_REL32: # CHECK: .FR_PPC_REL32: -# CHECK: 11018: 00 00 00 04 +# CHECK: 11020: 00 00 00 04 .section .R_PPC_ADDR32,"ax",@progbits .globl .FR_PPC_ADDR32 @@ -61,4 +75,16 @@ mystr: # CHECK: Disassembly of section .R_PPC_ADDR32: # CHECK: .FR_PPC_ADDR32: -# CHECK: 1101c: 00 01 10 20 +# CHECK: 11024: 00 01 10 28 + +.align 2 +.section .R_PPC_PLTREL24,"ax",@progbits +.globl .R_PPC_PLTREL24 +.FR_PPC_PLTREL24: + b .Lfoox4@PLT +.section .R_PPC_PLTREL24_2,"ax",@progbits +.Lfoox4: + +# CHECK: Disassembly of section .R_PPC_PLTREL24: +# CHECK: .R_PPC_PLTREL24: +# CHECK: 11028: 48 00 00 04 b .+4 diff --git a/test/ELF/ppc64-addr16-error.s b/test/ELF/ppc64-addr16-error.s index 2bc8ef2ae4d7..f16ca69957a3 100644 --- a/test/ELF/ppc64-addr16-error.s +++ b/test/ELF/ppc64-addr16-error.s @@ -5,4 +5,4 @@ .short sym+65539 -// CHECK: relocation R_PPC64_ADDR16 out of range +// CHECK: relocation R_PPC64_ADDR16 out of range: 65539 is not in [-32768, 32767] diff --git a/test/ELF/pr34660.s b/test/ELF/pr34660.s new file mode 100644 index 000000000000..7c78bbc11c7b --- /dev/null +++ b/test/ELF/pr34660.s @@ -0,0 +1,25 @@ +# REQUIRES: aarch64 + +# RUN: llvm-mc -filetype=obj -triple=aarch64-linux-none %s -o %t.o +# RUN: ld.lld --hash-style=sysv -shared %t.o -o %t +# RUN: llvm-objdump %t -d | FileCheck %s --check-prefix=DISASM +# RUN: llvm-readobj -elf-output-style=GNU %t -t | FileCheck %s --check-prefix=SYM + +# It would be much easier to understand/read this test if llvm-objdump would print +# the immediates in hex. +# IMM = hex(65540) = 0x10004 +# PC = 0x10000 +# As the relocation is PC-relative, IMM + PC = 0x20004 which is the VA of the +# correct symbol. + +# DISASM: Disassembly of section .text: +# DISASM-NEXT: $x.0: +# DISASM-NEXT: 10000: 28 00 08 58 ldr x8, #65540 + +# SYM: Symbol table '.symtab' +# SYM: 0000000000020004 0 NOTYPE LOCAL DEFAULT 5 patatino + + ldr x8, patatino + .data + .zero 4 +patatino: diff --git a/test/ELF/pr34872.s b/test/ELF/pr34872.s new file mode 100644 index 000000000000..c656be2a9279 --- /dev/null +++ b/test/ELF/pr34872.s @@ -0,0 +1,14 @@ +# RUN: llvm-mc %s -filetype=obj -triple=x86_64-pc-linux -o %t.o +# RUN: llvm-mc %p/Inputs/undefined-error.s -filetype=obj \ +# RUN: -triple=x86_64-pc-linux -o %t2.o +# RUN: ld.lld -shared %t2.o -o %t2.so +# RUN: not ld.lld %t2.so %t.o 2>&1 | FileCheck %s + +# CHECK: undefined symbol: fmod +# Check we're not emitting other diagnostics for this symbol. +# CHECK-NOT: fmod + +.global main + +main: + callq fmod diff --git a/test/ELF/progname.s b/test/ELF/progname.s index be8ab9e31c4f..ecd0fd872347 100644 --- a/test/ELF/progname.s +++ b/test/ELF/progname.s @@ -1,6 +1,6 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -// RUN: echo .global __progname > %t2.s +// RUN: echo ".global __progname; .data; .dc.a __progname" > %t2.s // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t2.s -o %t2.o // RUN: ld.lld -shared %t2.o -o %t2.so // RUN: ld.lld -o %t %t.o %t2.so diff --git a/test/ELF/relocatable-comdat2.s b/test/ELF/relocatable-comdat2.s new file mode 100644 index 000000000000..2643e645fda9 --- /dev/null +++ b/test/ELF/relocatable-comdat2.s @@ -0,0 +1,35 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld -r %t.o -o %t +# RUN: llvm-readobj -elf-section-groups -s %t | FileCheck %s + +## Check .foo was not merged. +# CHECK: Sections [ +# CHECK: Name: .foo +# CHECK: Name: .foo +# CHECK: Name: .foo + +# CHECK: Groups { +# CHECK-NEXT: Group { +# CHECK-NEXT: Name: .group +# CHECK-NEXT: Index: 2 +# CHECK-NEXT: Type: COMDAT +# CHECK-NEXT: Signature: bar +# CHECK-NEXT: Section(s) in group [ +# CHECK-NEXT: .foo (3) +# CHECK-NEXT: ] +# CHECK-NEXT: } +# CHECK-NEXT: Group { +# CHECK-NEXT: Name: .group +# CHECK-NEXT: Index: 4 +# CHECK-NEXT: Type: COMDAT +# CHECK-NEXT: Signature: zed +# CHECK-NEXT: Section(s) in group [ +# CHECK-NEXT: .foo (5) +# CHECK-NEXT: ] +# CHECK-NEXT: } +# CHECK-NEXT: } + +.section .foo,"axG",@progbits,bar,comdat +.section .foo,"axG",@progbits,zed,comdat +.section .foo,"ax",@progbits diff --git a/test/ELF/relocatable-common.s b/test/ELF/relocatable-common.s index 3ead775492fc..698380b650fc 100644 --- a/test/ELF/relocatable-common.s +++ b/test/ELF/relocatable-common.s @@ -30,7 +30,10 @@ # DEFCOMM-NEXT: Binding: Global # DEFCOMM-NEXT: Type: Object # DEFCOMM-NEXT: Other: 0 -# DEFCOMM-NEXT: Section: COMMON (0x2) +# DEFCOMM-NEXT: Section: COMMON # DEFCOMM-NEXT: } +# RUN: not ld.lld -shared --no-define-common %t1.o -o %t 2>&1 | FileCheck --check-prefix=ERROR %s +# ERROR: error: -no-define-common not supported in non relocatable output + .comm common,4,4 diff --git a/test/ELF/relocatable-compressed-input.s b/test/ELF/relocatable-compressed-input.s index 3c0199c33f7d..47d8c111452d 100644 --- a/test/ELF/relocatable-compressed-input.s +++ b/test/ELF/relocatable-compressed-input.s @@ -24,11 +24,11 @@ # CHECK-NEXT: AddressAlignment: 1 # CHECK-NEXT: EntrySize: 1 # CHECK-NEXT: SectionData ( -# CHECK-NEXT: 0000: {{.*}} |short unsigned i| -# CHECK-NEXT: 0010: {{.*}} |nt.unsigned int.| -# CHECK-NEXT: 0020: {{.*}} |long unsigned in| -# CHECK-NEXT: 0030: {{.*}} |t.char.unsigned | -# CHECK-NEXT: 0040: {{.*}} |char.| +# CHECK-NEXT: 0000: {{.*}} |long unsigned in| +# CHECK-NEXT: 0010: {{.*}} |t.unsigned char.| +# CHECK-NEXT: 0020: {{.*}} |unsigned int.cha| +# CHECK-NEXT: 0030: {{.*}} |r.short unsigned| +# CHECK-NEXT: 0040: {{.*}} | int.| # CHECK-NEXT: ) # CHECK-NEXT: } diff --git a/test/ELF/relocatable.s b/test/ELF/relocatable.s index 00572d07cbb9..7cb2a084c935 100644 --- a/test/ELF/relocatable.s +++ b/test/ELF/relocatable.s @@ -81,7 +81,7 @@ # CHECKEXE-NEXT: Version: 1 # CHECKEXE-NEXT: Entry: 0x201000 # CHECKEXE-NEXT: ProgramHeaderOffset: 0x40 -# CHECKEXE-NEXT: SectionHeaderOffset: 0x11F8 +# CHECKEXE-NEXT: SectionHeaderOffset: 0x21A0 # CHECKEXE-NEXT: Flags [ # CHECKEXE-NEXT: ] # CHECKEXE-NEXT: HeaderSize: 64 diff --git a/test/ELF/relocation-b-aarch64.test b/test/ELF/relocation-b-aarch64.test new file mode 100644 index 000000000000..24bf4b74ef92 --- /dev/null +++ b/test/ELF/relocation-b-aarch64.test @@ -0,0 +1,48 @@ +# REQUIRES: aarch64 + +# RUN: yaml2obj %s -o %t.o +# RUN: ld.lld %t.o -o %t.out +# RUN: llvm-objdump -d -triple=aarch64-none-linux %t.out | FileCheck %s + +# Check that the R_AARCH64_JUMP26 writes the branch opcode as well as the +# immediate. We use this property to overwrite instructions with a branch. + +# CHECK: Disassembly of section .text: +# CHECK-NEXT: foo: +# CHECK-NEXT: 20000: 01 00 00 14 b #4 +# CHECK: bar: +# CHECK-NEXT: 20004: ff ff ff 17 b #-4 + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_AARCH64 +Sections: + - Type: SHT_PROGBITS + Name: .text + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Content: "0000000000000000" + - Type: SHT_RELA + Name: .rela.text + Link: .symtab + Info: .text + Relocations: + - Offset: 0 + Symbol: bar + Type: R_AARCH64_JUMP26 + - Offset: 4 + Symbol: foo + Type: R_AARCH64_JUMP26 + +Symbols: + Local: + - Type: STT_FUNC + Section: .text + Name: foo + Value: 0 + - Type: STT_FUNC + Section: .text + Name: bar + Value: 4 diff --git a/test/ELF/relocation-copy-alias.s b/test/ELF/relocation-copy-alias.s index 15712e39bc93..f2251bbeefc2 100644 --- a/test/ELF/relocation-copy-alias.s +++ b/test/ELF/relocation-copy-alias.s @@ -1,8 +1,10 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/relocation-copy-alias.s -o %t2.o -// RUN: ld.lld -shared %t2.o -o %t.so -// RUN: ld.lld %t.o %t.so -o %t3 +// RUN: ld.lld --hash-style=sysv -shared %t2.o -o %t.so +// RUN: ld.lld --hash-style=sysv %t.o %t.so -o %t3 +// RUN: llvm-readobj --dyn-symbols -r --expand-relocs %t3 | FileCheck %s +// RUN: ld.lld --hash-style=sysv --gc-sections %t.o %t.so -o %t3 // RUN: llvm-readobj --dyn-symbols -r --expand-relocs %t3 | FileCheck %s .global _start @@ -61,7 +63,7 @@ movl $5, b2 // CHECK: Name: b3 // CHECK-NEXT: Value: [[B]] // CHECK-NEXT: Size: 1 -// CHECK-NEXT: Binding: Weak +// CHECK-NEXT: Binding: Global // CHECK-NEXT: Type: Object (0x1) // CHECK-NEXT: Other: 0 // CHECK-NEXT: Section: .bss diff --git a/test/ELF/relocation-copy-align-common.s b/test/ELF/relocation-copy-align-common.s index a94c208a8b22..56eab76cbf81 100644 --- a/test/ELF/relocation-copy-align-common.s +++ b/test/ELF/relocation-copy-align-common.s @@ -3,7 +3,7 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux \ # RUN: %p/Inputs/relocation-copy-align-common.s -o %t2.o # RUN: ld.lld -shared %t2.o -o %t.so -# RUN: ld.lld %t.o %t.so -o %t3 +# RUN: ld.lld --hash-style=sysv %t.o %t.so -o %t3 # RUN: llvm-readobj -s -r --expand-relocs %t3 | FileCheck %s # CHECK: Section { diff --git a/test/ELF/relocation-copy-flags.s b/test/ELF/relocation-copy-flags.s index 4d97e3d95d24..3f74bade3347 100644 --- a/test/ELF/relocation-copy-flags.s +++ b/test/ELF/relocation-copy-flags.s @@ -3,7 +3,7 @@ // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/relocation-copy.s -o %t2.o // RUN: ld.lld %t2.o -o %t2.so -shared -// RUN: ld.lld %t.o %t2.so -o %t.exe +// RUN: ld.lld --hash-style=sysv %t.o %t2.so -o %t.exe // RUN: llvm-readobj -s -section-data -r %t.exe | FileCheck %s .global _start diff --git a/test/ELF/relocation-copy-relro.s b/test/ELF/relocation-copy-relro.s index 1684c409e349..947c6c73f674 100644 --- a/test/ELF/relocation-copy-relro.s +++ b/test/ELF/relocation-copy-relro.s @@ -2,7 +2,7 @@ // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/relocation-copy-relro.s -o %t2.o // RUN: ld.lld -shared %t2.o -o %t.so -// RUN: ld.lld %t.o %t.so -o %t3 +// RUN: ld.lld --hash-style=sysv %t.o %t.so -o %t3 // RUN: llvm-readobj -program-headers -s -r %t3 | FileCheck %s // CHECK: Name: .bss.rel.ro (48) diff --git a/test/ELF/relocation-i686.s b/test/ELF/relocation-i686.s index 4bb55d9684b0..3986357d66f2 100644 --- a/test/ELF/relocation-i686.s +++ b/test/ELF/relocation-i686.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t // RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %p/Inputs/shared.s -o %t2.o // RUN: ld.lld -shared %t2.o -o %t2.so -// RUN: ld.lld %t %t2.so -o %t2 +// RUN: ld.lld --hash-style=sysv %t %t2.so -o %t2 // RUN: llvm-readobj -s %t2 | FileCheck --check-prefix=ADDR %s // RUN: llvm-objdump -d %t2 | FileCheck %s // REQUIRES: x86 diff --git a/test/ELF/relocation-relative-weak.s b/test/ELF/relocation-relative-weak.s index c525012acf67..7f28fced7116 100644 --- a/test/ELF/relocation-relative-weak.s +++ b/test/ELF/relocation-relative-weak.s @@ -4,6 +4,7 @@ # RUN: llvm-readobj -dyn-relocations %t | FileCheck %s # CHECK: Dynamic Relocations { +# CHECK-NEXT: 0x2018 R_X86_64_JUMP_SLOT w 0x0 # CHECK-NEXT: } .globl _start diff --git a/test/ELF/relocation.s b/test/ELF/relocation.s index 77c766960f46..3359a8badda6 100644 --- a/test/ELF/relocation.s +++ b/test/ELF/relocation.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/shared.s -o %t2 // RUN: ld.lld %t2 -o %t2.so -shared -// RUN: ld.lld %t %t2.so -o %t3 +// RUN: ld.lld --hash-style=sysv %t %t2.so -o %t3 // RUN: llvm-readobj -s %t3 | FileCheck --check-prefix=SEC %s // RUN: llvm-objdump -s -d %t3 | FileCheck %s // REQUIRES: x86 diff --git a/test/ELF/relro-copyrel-bss-script.s b/test/ELF/relro-copyrel-bss-script.s new file mode 100644 index 000000000000..5f3b981cae98 --- /dev/null +++ b/test/ELF/relro-copyrel-bss-script.s @@ -0,0 +1,40 @@ +// REQUIRES: x86 +// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t.o +// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/copy-in-shared.s -o %t2.o +// RUN: ld.lld -shared %t.o %t2.o -o %t.so + +// A linker script that will map .bss.rel.ro into .bss. +// RUN: echo "SECTIONS { \ +// RUN: .bss : { *(.bss) *(.bss.*) } \ +// RUN: } " > %t.script + +// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t3.o +// RUN: ld.lld %t3.o %t.so -z relro -o %t --script=%t.script 2>&1 +// RUN: llvm-readobj --program-headers %t | FileCheck %s + .section .text, "ax", @progbits + .global bar + .global foo + .global _start +_start: + callq bar + // Will produce .bss.rel.ro that will match in .bss, this will lose + // the relro property of the copy relocation. + .quad foo + + // Non relro bss + .bss + // make large enough to affect PT_GNU_RELRO MemSize if this was marked + // as relro. + .space 0x2000 + +// CHECK: Type: PT_GNU_RELRO (0x6474E552) +// CHECK-NEXT: Offset: +// CHECK-NEXT: VirtualAddress: +// CHECK-NEXT: PhysicalAddress: +// CHECK-NEXT: FileSize: +// CHECK-NEXT: MemSize: 4096 +// CHECK-NEXT: Flags [ (0x4) +// CHECK-NEXT: PF_R (0x4) +// CHECK-NEXT: ] +// CHECK-NEXT: Alignment: 1 +// CHECK-NEXT: } diff --git a/test/ELF/relro-non-contiguous-script-data.s b/test/ELF/relro-non-contiguous-script-data.s new file mode 100644 index 000000000000..c2332d14a982 --- /dev/null +++ b/test/ELF/relro-non-contiguous-script-data.s @@ -0,0 +1,25 @@ +// REQUIRES: x86 + +// RUN: echo "SECTIONS { \ +// RUN: .dynamic : { *(.dynamic) } \ +// RUN: .non_ro : { . += 1; } \ +// RUN: .jcr : { *(.jcr) } \ +// RUN: } " > %t.script +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +// RUN: not ld.lld --export-dynamic %t.o -o %t --script=%t.script 2>&1 | FileCheck %s + +// RUN: echo "SECTIONS { \ +// RUN: .dynamic : { *(.dynamic) } \ +// RUN: .non_ro : { BYTE(1); } \ +// RUN: .jcr : { *(.jcr) } \ +// RUN: } " > %t2.script +// RUN: not ld.lld --export-dynamic %t.o -o %t --script=%t2.script 2>&1 | FileCheck %s + +// CHECK: error: section: .jcr is not contiguous with other relro sections + +.global _start +_start: + + // non-empty relro section + .section .jcr, "aw", @progbits + .quad 0 diff --git a/test/ELF/relro-non-contiguous.s b/test/ELF/relro-non-contiguous.s new file mode 100644 index 000000000000..ce6680860edf --- /dev/null +++ b/test/ELF/relro-non-contiguous.s @@ -0,0 +1,28 @@ +// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t.o +// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/copy-in-shared.s -o %t2.o +// RUN: ld.lld -shared %t.o %t2.o -o %t.so + +// Place the .got.plt (non relro) immediately after .dynamic. This is the +// reverse order of the non-linker script case. The linker created .bss.rel.ro +// section will be placed after .got.plt causing the relro to be non-contiguous. +// RUN: echo "SECTIONS { \ +// RUN: .dynamic : { *(.dynamic) } \ +// RUN: .got.plt : { *(.got.plt) } \ +// RUN: } " > %t.script +// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t3.o + +// Expect error for non-contiguous relro +// RUN: not ld.lld %t3.o %t.so -z relro -o %t --script=%t.script 2>&1 | FileCheck %s +// No error when we do not request relro. +// RUN: ld.lld %t3.o %t.so -z norelro -o %t --script=%t.script +// REQUIRES: x86 + +// CHECK: error: section: .bss.rel.ro is not contiguous with other relro sections + .section .text, "ax", @progbits + .global _start + .global bar + .global foo +_start: + .quad bar + .quad foo + diff --git a/test/ELF/relro-omagic.s b/test/ELF/relro-omagic.s index 6e9d59a35279..97c3a812406d 100644 --- a/test/ELF/relro-omagic.s +++ b/test/ELF/relro-omagic.s @@ -1,7 +1,7 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t2.o # RUN: ld.lld -shared %t2.o -o %t2.so -soname relro-omagic.s.tmp2.so -# RUN: ld.lld -N %t.o %t2.so -o %t +# RUN: ld.lld --hash-style=sysv -N %t.o %t2.so -o %t # RUN: llvm-objdump -section-headers %t | FileCheck --check-prefix=NORELRO %s # RUN: llvm-readobj --program-headers %t | FileCheck --check-prefix=NOPHDRS %s diff --git a/test/ELF/relro-script.s b/test/ELF/relro-script.s new file mode 100644 index 000000000000..f0dca67a3422 --- /dev/null +++ b/test/ELF/relro-script.s @@ -0,0 +1,29 @@ +// REQUIRES: x86 +// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/shared.s -o %t.o +// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/copy-in-shared.s -o %t2.o +// RUN: ld.lld -shared %t.o %t2.o -o %t.so + +// ld.bfd and gold use .data.rel.ro rather than .bss.rel.ro. When a linker +// script, such as ld.bfd's internal linker script has a .data.rel.ro +// OutputSection we rename .bss.rel.ro to .data.rel.ro.bss in order to match in +// .data.rel.ro. This keeps the relro sections contiguous. + +// Use the same sections and ordering as the ld.bfd internal linker script. +// RUN: echo "SECTIONS { \ +// RUN: .data.rel.ro : { *(.data.rel.ro .data.rel.ro.*) } \ +// RUN: .dynamic : { *(.dynamic) } \ +// RUN: .got : { *(.got) } \ +// RUN: .got.plt : { *(.got.plt) } \ +// RUN: } " > %t.script +// RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t3.o +// RUN: ld.lld %t3.o %t.so -o %t --script=%t.script --print-map | FileCheck %s + +// CHECK: .data.rel.ro +// CHECK-NEXT: <internal>:(.bss.rel.ro) + .section .text, "ax", @progbits + .global _start + .global bar + .global foo +_start: + .quad bar + .quad foo diff --git a/test/ELF/reproduce-thin-archive.s b/test/ELF/reproduce-thin-archive.s index 2de88d77f51b..c3e6e88757eb 100644 --- a/test/ELF/reproduce-thin-archive.s +++ b/test/ELF/reproduce-thin-archive.s @@ -5,11 +5,17 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.dir/foo.o # RUN: cd %t.dir # RUN: llvm-ar --format=gnu rcT foo.a foo.o + # RUN: ld.lld -m elf_x86_64 foo.a -o bar --reproduce repro.tar # RUN: tar xf repro.tar # RUN: diff foo.a repro/%:t.dir/foo.a # RUN: diff foo.o repro/%:t.dir/foo.o +# RUN: ld.lld -m elf_x86_64 --whole-archive foo.a -o bar --reproduce repro2.tar +# RUN: tar xf repro2.tar +# RUN: diff foo.a repro2/%:t.dir/foo.a +# RUN: diff foo.o repro2/%:t.dir/foo.o + .globl _start _start: nop diff --git a/test/ELF/reproduce.s b/test/ELF/reproduce.s index 0a93be08d040..69671a088473 100644 --- a/test/ELF/reproduce.s +++ b/test/ELF/reproduce.s @@ -33,27 +33,36 @@ # RUN: echo "{};" > dyn # RUN: echo > file # RUN: echo > file2 +# RUN: echo "_start" > order +# RUN: mkdir "sysroot with spaces" # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o 'foo bar' # RUN: ld.lld --reproduce repro2.tar 'foo bar' -L"foo bar" -Lfile -Tfile2 \ -# RUN: --dynamic-list dyn -rpath file --script=file --version-script ver \ -# RUN: --dynamic-linker "some unusual/path" -soname 'foo bar' -soname='foo bar' +# RUN: --dynamic-list dyn -rpath file --script=file --symbol-ordering-file order \ +# RUN: --sysroot "sysroot with spaces" --sysroot="sysroot with spaces" \ +# RUN: --version-script ver --dynamic-linker "some unusual/path" -soname 'foo bar' \ +# RUN: -soname='foo bar' # RUN: tar xf repro2.tar # RUN: FileCheck %s --check-prefix=RSP2 < repro2/response.txt +# RSP2: --chroot . # RSP2: "{{.*}}foo bar" -# RSP2-NEXT: -L "{{.*}}foo bar" -# RSP2-NEXT: -L {{.+}}file -# RSP2-NEXT: --script {{.+}}file2 -# RSP2-NEXT: --dynamic-list {{.+}}dyn -# RSP2-NEXT: -rpath {{.+}}file -# RSP2-NEXT: --script {{.+}}file -# RSP2-NEXT: --version-script [[PATH:.*]]ver +# RSP2-NEXT: --library-path "[[BASEDIR:.+]]/foo bar" +# RSP2-NEXT: --library-path [[BASEDIR]]/file +# RSP2-NEXT: --script [[BASEDIR]]/file2 +# RSP2-NEXT: --dynamic-list [[BASEDIR]]/dyn +# RSP2-NEXT: -rpath [[BASEDIR]]/file +# RSP2-NEXT: --script [[BASEDIR]]/file +# RSP2-NEXT: --symbol-ordering-file [[BASEDIR]]/order +# RSP2-NEXT: --sysroot "[[BASEDIR]]/sysroot with spaces" +# RSP2-NEXT: --sysroot "[[BASEDIR]]/sysroot with spaces" +# RSP2-NEXT: --version-script [[BASEDIR]]/ver # RSP2-NEXT: --dynamic-linker "some unusual/path" -# RSP2-NEXT: -soname="foo bar" -# RSP2-NEXT: -soname="foo bar" +# RSP2-NEXT: -soname "foo bar" +# RSP2-NEXT: -soname "foo bar" # RUN: tar tf repro2.tar | FileCheck %s # CHECK: repro2/response.txt # CHECK-NEXT: repro2/version.txt +# CHECK-NEXT: repro2/{{.*}}/order # CHECK-NEXT: repro2/{{.*}}/dyn # CHECK-NEXT: repro2/{{.*}}/ver # CHECK-NEXT: repro2/{{.*}}/foo bar diff --git a/test/ELF/resolution-end.s b/test/ELF/resolution-end.s index aa1c999fb79a..26858372ce09 100644 --- a/test/ELF/resolution-end.s +++ b/test/ELF/resolution-end.s @@ -1,7 +1,7 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/resolution-end.s -o %t2.o # RUN: ld.lld -shared -o %t2.so %t2.o -# RUN: ld.lld %t1.o %t2.so -o %t +# RUN: ld.lld --hash-style=sysv %t1.o %t2.so -o %t # RUN: llvm-readobj -t -s -section-data %t | FileCheck %s # REQUIRES: x86 diff --git a/test/ELF/retain-symbols-file.s b/test/ELF/retain-symbols-file.s index aa7d35d914eb..79d569d69cdb 100644 --- a/test/ELF/retain-symbols-file.s +++ b/test/ELF/retain-symbols-file.s @@ -2,11 +2,11 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t # RUN: echo "bar" > %t_retain.txt # RUN: echo "foo" >> %t_retain.txt -# RUN: ld.lld -shared --retain-symbols-file=%t_retain.txt %t -o %t2 +# RUN: ld.lld --hash-style=sysv -shared --retain-symbols-file=%t_retain.txt %t -o %t2 # RUN: llvm-readobj --dyn-symbols %t2 | FileCheck %s ## Check separate form. -# RUN: ld.lld -shared --retain-symbols-file %t_retain.txt %t -o %t2 +# RUN: ld.lld --hash-style=sysv -shared --retain-symbols-file %t_retain.txt %t -o %t2 # RUN: llvm-readobj --dyn-symbols %t2 | FileCheck %s # CHECK: DynamicSymbols [ diff --git a/test/ELF/section-metadata-err.s b/test/ELF/section-metadata-err.s index f3b5842945cb..1bcbedfbab71 100644 --- a/test/ELF/section-metadata-err.s +++ b/test/ELF/section-metadata-err.s @@ -3,7 +3,7 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o # RUN: not ld.lld %t.o -o %t 2>&1 | FileCheck %s -# CHECK: error: Merge and .eh_frame sections are not supported with SHF_LINK_ORDER {{.*}}section-metadata-err.s.tmp.o:(.foo) +# CHECK: error: a section with SHF_LINK_ORDER should not refer a non-regular section: {{.*}}section-metadata-err.s.tmp.o:(.foo) .global _start _start: diff --git a/test/ELF/segments.s b/test/ELF/segments.s index 9307ba39fe46..4648ba97a854 100644 --- a/test/ELF/segments.s +++ b/test/ELF/segments.s @@ -1,7 +1,10 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t + # RUN: ld.lld %t -o %t1 # RUN: llvm-readobj --program-headers %t1 | FileCheck --check-prefix=ROSEGMENT %s +# RUN: ld.lld --omagic --no-omagic %t -o %t1 +# RUN: llvm-readobj --program-headers %t1 | FileCheck --check-prefix=ROSEGMENT %s # ROSEGMENT: ProgramHeader { # ROSEGMENT: Type: PT_LOAD @@ -76,6 +79,8 @@ # RUN: ld.lld -N %t -o %t3 # RUN: llvm-readobj --program-headers %t3 | FileCheck --check-prefix=OMAGIC %s +# RUN: ld.lld --omagic %t -o %t3 +# RUN: llvm-readobj --program-headers %t3 | FileCheck --check-prefix=OMAGIC %s # OMAGIC: ProgramHeader { # OMAGIC: Type: PT_LOAD diff --git a/test/ELF/shared-lazy.s b/test/ELF/shared-lazy.s new file mode 100644 index 000000000000..bc1e61c3c949 --- /dev/null +++ b/test/ELF/shared-lazy.s @@ -0,0 +1,16 @@ +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o +// RUN: rm -f %t1.a +// RUN: llvm-ar rc %t1.a %t1.o +// RUN: ld.lld %t1.o -o %t1.so -shared +// RUN: echo ".global foo" > %t2.s +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %t2.s -o %t2.o +// RUN: ld.lld %t1.a %t1.so %t2.o -o %t.so -shared +// RUN: llvm-readelf --dyn-symbols %t.so | FileCheck %s + +// Test that 'foo' from %t1.so is used and we don't fetch a member +// from the archive. + +// CHECK: 0000000000000000 0 NOTYPE GLOBAL DEFAULT UND foo + +.global foo +foo: diff --git a/test/ELF/shared.s b/test/ELF/shared.s index d4c79d914ffb..65ad2c61359b 100644 --- a/test/ELF/shared.s +++ b/test/ELF/shared.s @@ -1,10 +1,10 @@ // RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %s -o %t.o // RUN: llvm-mc -filetype=obj -triple=i686-unknown-linux %p/Inputs/shared.s -o %t2.o -// RUN: ld.lld -shared %t2.o -o %t2.so +// RUN: ld.lld --hash-style=sysv -shared %t2.o -o %t2.so // RUN: llvm-readobj -s %t2.so | FileCheck --check-prefix=SO %s -// RUN: ld.lld -dynamic-linker /lib64/ld-linux-x86-64.so.2 -rpath foo -rpath bar --export-dynamic %t.o %t2.so -o %t +// RUN: ld.lld --hash-style=sysv -dynamic-linker /lib64/ld-linux-x86-64.so.2 -rpath foo -rpath bar --export-dynamic %t.o %t2.so -o %t // RUN: llvm-readobj --program-headers --dynamic-table -t -s -dyn-symbols -section-data -hash-table %t | FileCheck %s -// RUN: ld.lld %t.o %t2.so %t2.so -o %t2 +// RUN: ld.lld --hash-style=sysv %t.o %t2.so %t2.so -o %t2 // RUN: llvm-readobj -dyn-symbols %t2 | FileCheck --check-prefix=DONT_EXPORT %s // REQUIRES: x86 diff --git a/test/ELF/silent-ignore.test b/test/ELF/silent-ignore.test new file mode 100644 index 000000000000..6655754ace58 --- /dev/null +++ b/test/ELF/silent-ignore.test @@ -0,0 +1,20 @@ +RUN: ld.lld --version \ +RUN: -allow-shlib-undefined \ +RUN: -cref \ +RUN: -g \ +RUN: -no-add-needed \ +RUN: -no-allow-shlib-undefined \ +RUN: -no-copy-dt-needed-entries \ +RUN: -no-ctors-in-init-array \ +RUN: -no-keep-memory \ +RUN: -no-warn-common \ +RUN: -no-warn-mismatch \ +RUN: -sort-common \ +RUN: -stats \ +RUN: -warn-execstack \ +RUN: -warn-once \ +RUN: -warn-shared-textrel \ +RUN: -EB \ +RUN: -EL \ +RUN: -Qy +RUN: not ld.lld --version --not-an-ignored-argument diff --git a/test/ELF/sort-norosegment.s b/test/ELF/sort-norosegment.s index c5a759a08a77..bd74f2eb330a 100644 --- a/test/ELF/sort-norosegment.s +++ b/test/ELF/sort-norosegment.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t -# RUN: ld.lld -no-rosegment -o %t1 %t -shared +# RUN: ld.lld --hash-style=sysv -no-rosegment -o %t1 %t -shared # RUN: llvm-readobj -elf-output-style=GNU -s %t1 | FileCheck %s # CHECK: .text {{.*}} AX diff --git a/test/ELF/startstop-gccollect.s b/test/ELF/startstop-gccollect.s index daff08187cdf..cb0009c54bec 100644 --- a/test/ELF/startstop-gccollect.s +++ b/test/ELF/startstop-gccollect.s @@ -11,21 +11,27 @@ # RUN: ld.lld %t --gc-sections -o %tout # RUN: llvm-objdump -d %tout | FileCheck -check-prefix=DISASM %s +# RUN: echo ".global __start_foo; __start_foo:" > %t2.s +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t2.s -o %t2.o +# RUN: ld.lld -shared %t2.o -o %t2.so +# RUN: ld.lld %t --gc-sections -o %tout %t2.so +# RUN: llvm-objdump -d %tout | FileCheck -check-prefix=DISASM %s + # DISASM: _start: # DISASM-NEXT: 201000: e8 05 00 00 00 callq 5 <__start_foo> -# DISASM-NEXT: 201005: e8 01 00 00 00 callq 1 <__start_bar> +# DISASM-NEXT: 201005: e8 02 00 00 00 callq 2 <__stop_bar> # DISASM-NEXT: Disassembly of section foo: # DISASM-NEXT: __start_foo: # DISASM-NEXT: 20100a: 90 nop # DISASM-NEXT: Disassembly of section bar: -# DISASM-NEXT: __start_bar: +# DISASM-NEXT: bar: # DISASM-NEXT: 20100b: 90 nop .global _start .text _start: callq __start_foo - callq __start_bar + callq __stop_bar .section foo,"ax" nop diff --git a/test/ELF/startstop.s b/test/ELF/startstop.s index 250fb2cb3f5c..1e75042a0c8c 100644 --- a/test/ELF/startstop.s +++ b/test/ELF/startstop.s @@ -1,6 +1,6 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t -// RUN: ld.lld %t -o %tout -shared +// RUN: ld.lld --hash-style=sysv %t -o %tout -shared // RUN: llvm-objdump -d %tout | FileCheck -check-prefix=DISASM %s // RUN: llvm-readobj -symbols -r %tout | FileCheck -check-prefix=SYMBOL %s diff --git a/test/ELF/string-gc.s b/test/ELF/string-gc.s index 3157a79a65cd..96c75e9236f4 100644 --- a/test/ELF/string-gc.s +++ b/test/ELF/string-gc.s @@ -14,7 +14,7 @@ // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: s3 -// CHECK-NEXT: Value: 0x200125 +// CHECK-NEXT: Value: 0x200120 // CHECK-NEXT: Size: 0 // CHECK-NEXT: Binding: Local (0x0) // CHECK-NEXT: Type: Object (0x1) @@ -23,7 +23,7 @@ // CHECK-NEXT: } // CHECK-NEXT: Symbol { // CHECK-NEXT: Name: s1 -// CHECK-NEXT: Value: 0x200120 +// CHECK-NEXT: Value: 0x200125 // CHECK-NEXT: Size: 0 // CHECK-NEXT: Binding: Local (0x0) // CHECK-NEXT: Type: Object (0x1) diff --git a/test/ELF/strip-debug.s b/test/ELF/strip-debug.s index 81f7572aa7c5..8005cfacee6c 100644 --- a/test/ELF/strip-debug.s +++ b/test/ELF/strip-debug.s @@ -1,25 +1,14 @@ # REQUIRES: x86 - -# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux -g %s -o %t -# RUN: ld.lld %t -o %t2 -# RUN: llvm-readobj -sections -symbols %t2 | FileCheck -check-prefix=DEFAULT %s +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t # RUN: ld.lld %t -o %t2 --strip-debug -# RUN: llvm-readobj -sections -symbols %t2 | FileCheck -check-prefix=STRIP %s +# RUN: llvm-readobj -sections %t2 | FileCheck %s # RUN: ld.lld %t -o %t2 -S -# RUN: llvm-readobj -sections -symbols %t2 | FileCheck -check-prefix=STRIP %s +# RUN: llvm-readobj -sections %t2 | FileCheck %s # RUN: ld.lld %t -o %t2 --strip-all -# RUN: llvm-readobj -sections -symbols %t2 | FileCheck -check-prefix=STRIP %s - -# DEFAULT: Name: .debug_info -# DEFAULT: Name: .debug_abbrev -# DEFAULT: Name: .debug_aranges -# DEFAULT: Name: .debug_line +# RUN: llvm-readobj -sections %t2 | FileCheck %s -# STRIP-NOT: Name: .debug_info -# STRIP-NOT: Name: .debug_abbrev -# STRIP-NOT: Name: .debug_aranges -# STRIP-NOT: Name: .debug_line +# CHECK-NOT: Foo +# CHECK-NOT: Bar -.globl _start -_start: - ret +.section .debug_Foo,"",@progbits +.section .zdebug_Bar,"",@progbits diff --git a/test/ELF/symbol-ordering-file2.s b/test/ELF/symbol-ordering-file2.s new file mode 100644 index 000000000000..723eef1dfb72 --- /dev/null +++ b/test/ELF/symbol-ordering-file2.s @@ -0,0 +1,21 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: echo "bar" > %t.order +# RUN: ld.lld --symbol-ordering-file %t.order -shared %t.o -o %t.so +# RUN: llvm-nm %t.so | FileCheck %s + +# CHECK: 0000000000002000 d _DYNAMIC +# CHECK-NEXT: 0000000000001000 T bar +# CHECK-NEXT: 0000000000001004 T foo + + .section .text.foo,"ax",@progbits + .align 4 + .global foo +foo: + retq + + .section .text.bar,"ax",@progbits + .align 4 + .global bar +bar: + retq diff --git a/test/ELF/synthetic-got.s b/test/ELF/synthetic-got.s index 8d82f3177f80..375a4387f1c8 100644 --- a/test/ELF/synthetic-got.s +++ b/test/ELF/synthetic-got.s @@ -1,7 +1,7 @@ # REQUIRES: x86 # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o # RUN: echo "SECTIONS { }" > %t0.script -# RUN: ld.lld -shared %t.o -o %t0.out --script %t0.script +# RUN: ld.lld --hash-style=sysv -shared %t.o -o %t0.out --script %t0.script # RUN: llvm-objdump -section-headers %t0.out | FileCheck %s --check-prefix=GOT # RUN: llvm-objdump -s -section=.got -section=.got.plt %t0.out \ # RUN: | FileCheck %s --check-prefix=GOTDATA @@ -16,7 +16,7 @@ # GOTDATA-NEXT: 01d0 00000000 00000000 # RUN: echo "SECTIONS { .mygot : { *(.got) *(.got.plt) } }" > %t1.script -# RUN: ld.lld -shared %t.o -o %t1.out --script %t1.script +# RUN: ld.lld --hash-style=sysv -shared %t.o -o %t1.out --script %t1.script # RUN: llvm-objdump -section-headers %t1.out | FileCheck %s --check-prefix=MYGOT # RUN: llvm-objdump -s -section=.mygot %t1.out | FileCheck %s --check-prefix=MYGOTDATA diff --git a/test/ELF/sysroot.s b/test/ELF/sysroot.s index 358b4d9dfa5b..6b40c7d3952a 100644 --- a/test/ELF/sysroot.s +++ b/test/ELF/sysroot.s @@ -28,6 +28,8 @@ // Should substitute SysRoot if specified // RUN: ld.lld -o %t/r %t/m.o --sysroot=%t -L=lib -l:libls.a // RUN: ld.lld -o %t/r %t/m.o --sysroot=%t -L=/lib -l:libls.a +// Check alias. +// RUN: ld.lld -o %t/r %t/m.o --sysroot %t -L=lib -l:libls.a // Should not substitute SysRoot if the directory name does not start with '=' // RUN: not ld.lld -o %t/r %r/m.o --sysroot=%t -Llib -l:libls.a diff --git a/test/ELF/tls-dynamic-i686.s b/test/ELF/tls-dynamic-i686.s index ac88e6eaed31..1b13f26cc134 100644 --- a/test/ELF/tls-dynamic-i686.s +++ b/test/ELF/tls-dynamic-i686.s @@ -1,6 +1,6 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t -// RUN: ld.lld -shared %t -o %tout +// RUN: ld.lld --hash-style=sysv -shared %t -o %tout // RUN: llvm-readobj -sections -relocations %tout | FileCheck %s // RUN: llvm-objdump -d %tout | FileCheck %s --check-prefix=DIS diff --git a/test/ELF/tls-dynamic.s b/test/ELF/tls-dynamic.s index 05473d4b5b18..167f7687451e 100644 --- a/test/ELF/tls-dynamic.s +++ b/test/ELF/tls-dynamic.s @@ -1,6 +1,6 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t -// RUN: ld.lld -shared %t -o %tout +// RUN: ld.lld --hash-style=sysv -shared %t -o %tout // RUN: llvm-readobj -sections -relocations %tout | FileCheck %s // RUN: llvm-objdump -d %tout | FileCheck %s --check-prefix=DIS diff --git a/test/ELF/tls-got.s b/test/ELF/tls-got.s index 450dd634d7a9..b1686cd6d5f4 100644 --- a/test/ELF/tls-got.s +++ b/test/ELF/tls-got.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t1.o // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/tls-got.s -o %t2.o // RUN: ld.lld -shared %t2.o -o %t2.so -// RUN: ld.lld -e main %t1.o %t2.so -o %t3 +// RUN: ld.lld --hash-style=sysv -e main %t1.o %t2.so -o %t3 // RUN: llvm-readobj -s -r %t3 | FileCheck %s // RUN: llvm-objdump -d %t3 | FileCheck --check-prefix=DISASM %s diff --git a/test/ELF/tls-i686.s b/test/ELF/tls-i686.s index 7f2dd605cacd..c411fc74cd68 100644 --- a/test/ELF/tls-i686.s +++ b/test/ELF/tls-i686.s @@ -1,7 +1,7 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t // RUN: ld.lld %t -o %tout -// RUN: ld.lld %t -shared -o %tsharedout +// RUN: ld.lld --hash-style=sysv %t -shared -o %tsharedout // RUN: llvm-objdump -d %tout | FileCheck %s --check-prefix=DIS // RUN: llvm-readobj -r %tout | FileCheck %s --check-prefix=RELOC // RUN: llvm-objdump -d %tsharedout | FileCheck %s --check-prefix=DISSHARED diff --git a/test/ELF/tls-initial-exec-local.s b/test/ELF/tls-initial-exec-local.s index 0aef3c8237b6..e65fb294bc17 100644 --- a/test/ELF/tls-initial-exec-local.s +++ b/test/ELF/tls-initial-exec-local.s @@ -1,6 +1,6 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -// RUN: ld.lld -shared %t.o -o %t +// RUN: ld.lld --hash-style=sysv -shared %t.o -o %t // RUN: llvm-readobj -r -s %t | FileCheck %s // RUN: llvm-objdump -d %t | FileCheck --check-prefix=DISASM %s diff --git a/test/ELF/tls-opt-gdie.s b/test/ELF/tls-opt-gdie.s index c423a3e0f246..6e8531257714 100644 --- a/test/ELF/tls-opt-gdie.s +++ b/test/ELF/tls-opt-gdie.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/tls-opt-gdie.s -o %tso.o // RUN: ld.lld -shared %tso.o -o %t.so -// RUN: ld.lld %t.o %t.so -o %t1 +// RUN: ld.lld --hash-style=sysv %t.o %t.so -o %t1 // RUN: llvm-readobj -s -r %t1 | FileCheck --check-prefix=RELOC %s // RUN: llvm-objdump -d %t1 | FileCheck --check-prefix=DISASM %s diff --git a/test/ELF/tls-opt-gdiele-i686.s b/test/ELF/tls-opt-gdiele-i686.s index 1432a9607da9..2dc3731eba57 100644 --- a/test/ELF/tls-opt-gdiele-i686.s +++ b/test/ELF/tls-opt-gdiele-i686.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %p/Inputs/tls-opt-gdiele-i686.s -o %tso.o // RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o // RUN: ld.lld -shared %tso.o -o %tso -// RUN: ld.lld %t.o %tso -o %tout +// RUN: ld.lld --hash-style=sysv %t.o %tso -o %tout // RUN: llvm-readobj -r %tout | FileCheck --check-prefix=NORELOC %s // RUN: llvm-objdump -d %tout | FileCheck --check-prefix=DISASM %s diff --git a/test/ELF/tls-opt-iele-i686-nopic.s b/test/ELF/tls-opt-iele-i686-nopic.s index b6608c16551c..02148b5dbff9 100644 --- a/test/ELF/tls-opt-iele-i686-nopic.s +++ b/test/ELF/tls-opt-iele-i686-nopic.s @@ -1,7 +1,7 @@ // RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %s -o %t.o // RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %p/Inputs/tls-opt-iele-i686-nopic.s -o %tso.o // RUN: ld.lld -shared %tso.o -o %tso -// RUN: ld.lld %t.o %tso -o %t1 +// RUN: ld.lld --hash-style=sysv %t.o %tso -o %t1 // RUN: llvm-readobj -s -r %t1 | FileCheck --check-prefix=GOTREL %s // RUN: llvm-objdump -d %t1 | FileCheck --check-prefix=DISASM %s diff --git a/test/ELF/tls-static.s b/test/ELF/tls-static.s index 81ecc82758d7..338d95c817ee 100644 --- a/test/ELF/tls-static.s +++ b/test/ELF/tls-static.s @@ -3,12 +3,20 @@ // RUN: ld.lld -static %t -o %tout // RUN: ld.lld %t -o %tout // RUN: ld.lld -shared %tso -o %tshared -// RUN: not ld.lld -static %t %tshared -o %tout 2>&1 | FileCheck %s +// RUN: ld.lld -static %t %tshared -o %tout // REQUIRES: x86 .global _start _start: - call __tls_get_addr + data16 + leaq foobar@TLSGD(%rip), %rdi + data16 + data16 + rex64 + callq __tls_get_addr@PLT -// CHECK: error: undefined symbol: __tls_get_addr -// CHECK: >>> referenced by {{.*}}:(.text+0x1) + +.section .tdata,"awT",@progbits +.global foobar +foobar: + .long 42 diff --git a/test/ELF/tls-two-relocs.s b/test/ELF/tls-two-relocs.s index 7c5d6abf77f4..d5687e9bf862 100644 --- a/test/ELF/tls-two-relocs.s +++ b/test/ELF/tls-two-relocs.s @@ -1,6 +1,6 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t -// RUN: ld.lld %t -o %tout -shared +// RUN: ld.lld --hash-style=sysv %t -o %tout -shared // RUN: llvm-readobj -r %tout | FileCheck %s data16 diff --git a/test/ELF/trace-symbols.s b/test/ELF/trace-symbols.s index eb8e17c709a5..c8ba9b21bcdb 100644 --- a/test/ELF/trace-symbols.s +++ b/test/ELF/trace-symbols.s @@ -31,19 +31,23 @@ # RUN: %t %t2 %t1 -o %t4 2>&1 | FileCheck -check-prefix=OBJECTD2FOO %s # RUN: ld.lld -y foo -y common %t %t1.so %t2 -o %t3 2>&1 | \ # RUN: FileCheck -check-prefix=OBJECTD2FOO %s -# RUN: ld.lld -y foo -y common %t %t2 %t1.a -o %t3 2>&1 | \ -# RUN: FileCheck -check-prefix=OBJECTD2FOO %s # OBJECTD2FOO: trace-symbols.s.tmp2: definition of foo +# RUN: ld.lld -y foo -y common %t %t2 %t1.a -o %t3 2>&1 | \ +# RUN: FileCheck -check-prefix=FOO_AND_COMMON %s +# FOO_AND_COMMON: trace-symbols.s.tmp: reference to foo +# FOO_AND_COMMON: trace-symbols.s.tmp2: definition of foo +# FOO_AND_COMMON: trace-symbols.s.tmp1.a: lazy definition of common + # RUN: ld.lld -y foo -y common %t %t1.so %t2 -o %t3 2>&1 | \ # RUN: FileCheck -check-prefix=SHLIBDCOMMON %s -# SHLIBDCOMMON: trace-symbols.s.tmp1.so: definition of common +# SHLIBDCOMMON: trace-symbols.s.tmp1.so: shared definition of common # RUN: ld.lld -y foo -y common %t %t2.so %t1.so -o %t3 2>&1 | \ # RUN: FileCheck -check-prefix=SHLIBD2FOO %s # RUN: ld.lld -y foo %t %t1.a %t2.so -o %t3 | \ # RUN: FileCheck -check-prefix=NO-SHLIBD2FOO %s -# SHLIBD2FOO: trace-symbols.s.tmp2.so: definition of foo +# SHLIBD2FOO: trace-symbols.s.tmp2.so: shared definition of foo # NO-SHLIBD2FOO-NOT: trace-symbols.s.tmp2.so: definition of foo # RUN: ld.lld -y foo -y common %t %t2 %t1.a -o %t3 2>&1 | \ @@ -61,7 +65,7 @@ # RUN: ld.lld -y bar %t %t1.so %t2.so -o %t3 | \ # RUN: FileCheck -check-prefix=SHLIBDBAR %s -# SHLIBDBAR: trace-symbols.s.tmp2.so: definition of bar +# SHLIBDBAR: trace-symbols.s.tmp2.so: shared definition of bar # RUN: ld.lld -y foo -y bar %t %t1.so %t2.so -o %t3 | \ # RUN: FileCheck -check-prefix=SHLIBRBAR %s diff --git a/test/ELF/typed-undef.s b/test/ELF/typed-undef.s new file mode 100644 index 000000000000..d00e07f82518 --- /dev/null +++ b/test/ELF/typed-undef.s @@ -0,0 +1,11 @@ +# REQUIRES: x86 + +# We used to crash on this, check that we don't + +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld %t.o -o %t -pie --unresolved-symbols=ignore-all + + .global _start +_start: + .quad foo - . + .type foo, @object diff --git a/test/ELF/undef-broken-debug.test b/test/ELF/undef-broken-debug.test new file mode 100644 index 000000000000..1238ebe70aca --- /dev/null +++ b/test/ELF/undef-broken-debug.test @@ -0,0 +1,47 @@ +# REQUIRES: x86 +# RUN: yaml2obj %s -o %t.o +# RUN: not ld.lld %t.o -o %t.exe 2>&1 | FileCheck %s + +# The debug info has a broken relocation. Check that we don't crash +# and still report the undefined symbol. + +# CHECK: error: unsupported relocation target while parsing debug info +# CHECK: error: undefined symbol: bar + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Content: '0000000000000000' + - Name: .rela.text + Type: SHT_RELA + AddressAlign: 8 + Link: .symtab + Info: .text + Relocations: + - Offset: 0x0000000000000000 + Symbol: bar + Type: R_X86_64_64 + - Name: .debug_line + Type: SHT_PROGBITS + Content: 3300000002001C0000000101FB0E0D000101010100000001000001006162632E7300000000000009020000000000000000140208000101 + - Name: .rela.debug_line + AddressAlign: 8 + Type: SHT_RELA + Link: .symtab + Info: .debug_line + Relocations: + - Offset: 0x0000000000000029 + Symbol: bar + Type: R_X86_64_64 +Symbols: + Global: + - Name: _start + Section: .text + - Name: bar diff --git a/test/ELF/undef-version-script.s b/test/ELF/undef-version-script.s index 529728328747..024ac1dc0727 100644 --- a/test/ELF/undef-version-script.s +++ b/test/ELF/undef-version-script.s @@ -3,9 +3,6 @@ # RUN: ld.lld --version-script %t.script -shared %t.o -o %t.so # RUN: llvm-readobj -dyn-symbols %t.so | FileCheck %s -# This does not match gold's behavior because gold does not create undefined -# symbols in dynsym without an appropriate (e.g. PLT) relocation in the input. - # CHECK: DynamicSymbols [ # CHECK-NEXT: Symbol { # CHECK-NEXT: Name: @ @@ -38,3 +35,6 @@ .global foo .weak bar +.data + .dc.a foo + .dc.a bar diff --git a/test/ELF/unresolved-symbols.s b/test/ELF/unresolved-symbols.s index 18656dcceca3..97ecd5014b12 100644 --- a/test/ELF/unresolved-symbols.s +++ b/test/ELF/unresolved-symbols.s @@ -13,6 +13,9 @@ # RUN: not ld.lld %t1.o %t2.o -o %t --unresolved-symbols=xxx 2>&1 | \ # RUN: FileCheck -check-prefix=ERR1 %s # ERR1: unknown --unresolved-symbols value: xxx +## Check alias. +# RUN: not ld.lld %t1.o %t2.o -o %t --unresolved-symbols xxx 2>&1 | \ +# RUN: FileCheck -check-prefix=ERR1 %s ## Ignore all should not produce error for symbols from object except ## case when --no-undefined specified. diff --git a/test/ELF/verdef-defaultver.s b/test/ELF/verdef-defaultver.s index c37c90a66d92..496a29e3db5a 100644 --- a/test/ELF/verdef-defaultver.s +++ b/test/ELF/verdef-defaultver.s @@ -3,7 +3,7 @@ # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %p/Inputs/verdef-defaultver.s -o %t1 # RUN: echo "V1 { global: a; local: *; };" > %t.script # RUN: echo "V2 { global: b; c; } V1;" >> %t.script -# RUN: ld.lld -shared -soname shared %t1 --version-script %t.script -o %t.so +# RUN: ld.lld --hash-style=sysv -shared -soname shared %t1 --version-script %t.script -o %t.so # RUN: llvm-readobj -V -dyn-symbols %t.so | FileCheck --check-prefix=DSO %s # DSO: DynamicSymbols [ @@ -107,7 +107,7 @@ ## Check that we can link against DSO produced. # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t2 -# RUN: ld.lld %t2 %t.so -o %t3 +# RUN: ld.lld --hash-style=sysv %t2 %t.so -o %t3 # RUN: llvm-readobj -V -dyn-symbols %t3 | FileCheck --check-prefix=EXE %s # EXE: DynamicSymbols [ diff --git a/test/ELF/verdef.s b/test/ELF/verdef.s index 7fd60a95d1df..b5d12ee3884f 100644 --- a/test/ELF/verdef.s +++ b/test/ELF/verdef.s @@ -3,7 +3,7 @@ # RUN: echo "LIBSAMPLE_1.0 { global: a; local: *; };" > %t.script # RUN: echo "LIBSAMPLE_2.0 { global: b; local: *; };" >> %t.script # RUN: echo "LIBSAMPLE_3.0 { global: c; local: *; };" >> %t.script -# RUN: ld.lld --version-script %t.script -shared -soname shared %t.o -o %t.so +# RUN: ld.lld --hash-style=sysv --version-script %t.script -shared -soname shared %t.o -o %t.so # RUN: llvm-readobj -V -dyn-symbols %t.so | FileCheck --check-prefix=DSO %s # DSO: Version symbols { @@ -65,7 +65,7 @@ ## Check that we can link agains DSO we produced. # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %S/Inputs/verdef.s -o %tmain.o -# RUN: ld.lld %tmain.o %t.so -o %tout +# RUN: ld.lld --hash-style=sysv %tmain.o %t.so -o %tout # RUN: llvm-readobj -V %tout | FileCheck --check-prefix=MAIN %s # MAIN: Version symbols { @@ -100,7 +100,7 @@ # RUN: echo "LIBSAMPLE_2.0 { global: b; local: *; };" >> %t.script # RUN: echo "LIBSAMPLE_3.0 { global: c; local: *; };" >> %t.script # RUN: echo "}" >> %t.script -# RUN: ld.lld --script %t.script -shared -soname shared %t.o -o %t2.so +# RUN: ld.lld --hash-style=sysv --script %t.script -shared -soname shared %t.o -o %t2.so # RUN: llvm-readobj -V -dyn-symbols %t2.so | FileCheck --check-prefix=DSO %s .globl a diff --git a/test/ELF/verneed-as-needed-weak.s b/test/ELF/verneed-as-needed-weak.s index a8efdc42d6d4..df15bc78ca6c 100644 --- a/test/ELF/verneed-as-needed-weak.s +++ b/test/ELF/verneed-as-needed-weak.s @@ -1,6 +1,10 @@ # REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/verneed1.s -o %t1.o +# RUN: echo "v1 {}; v2 {}; v3 { local: *; };" > %t.script +# RUN: ld.lld -shared %t1.o --version-script %t.script -o %t.so + # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -# RUN: ld.lld %t.o --as-needed %S/Inputs/verneed1.so -o %t +# RUN: ld.lld %t.o --as-needed %t.so -o %t # RUN: llvm-readobj -V %t | FileCheck %s # CHECK: SHT_GNU_verneed { diff --git a/test/ELF/verneed-local.s b/test/ELF/verneed-local.s index 9ab6cd791484..208d8ecf8f62 100644 --- a/test/ELF/verneed-local.s +++ b/test/ELF/verneed-local.s @@ -1,6 +1,10 @@ # REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/verneed1.s -o %t1.o +# RUN: echo "v1 {}; v2 {}; v3 { local: *; };" > %t.script +# RUN: ld.lld -shared %t1.o --version-script %t.script -o %t.so + # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -# RUN: not ld.lld %t.o %S/Inputs/verneed1.so -o %t 2>&1 | FileCheck %s +# RUN: not ld.lld %t.o %t.so -o %t 2>&1 | FileCheck %s # CHECK: error: undefined symbol: f3 # CHECK: >>> referenced by {{.*}}:(.text+0x1) diff --git a/test/ELF/verneed.s b/test/ELF/verneed.s index d0d0067250aa..27ab047e8222 100644 --- a/test/ELF/verneed.s +++ b/test/ELF/verneed.s @@ -1,6 +1,12 @@ # REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/verneed1.s -o %t1.o +# RUN: echo "v1 {}; v2 {}; v3 { local: *; };" > %t.script +# RUN: ld.lld -shared %t1.o --version-script %t.script -o %t1.so -soname verneed1.so.0 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/verneed2.s -o %t2.o +# RUN: ld.lld -shared %t2.o --version-script %t.script -o %t2.so -soname verneed2.so.0 + # RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o -# RUN: ld.lld %t.o %S/Inputs/verneed1.so %S/Inputs/verneed2.so -o %t +# RUN: ld.lld --hash-style=sysv %t.o %t1.so %t2.so -o %t # RUN: llvm-readobj -V -sections -section-data -dyn-symbols -dynamic-table %t | FileCheck %s # CHECK: Section { diff --git a/test/ELF/version-script-err.s b/test/ELF/version-script-err.s index ea3f664ea6ce..bd786d913369 100644 --- a/test/ELF/version-script-err.s +++ b/test/ELF/version-script-err.s @@ -8,4 +8,3 @@ // RUN: not ld.lld --version-script %terr1.script -shared %t.o -o %t.so 2>&1 | \ // RUN: FileCheck -check-prefix=ERR1 %s // ERR1: {{.*}}:1: unclosed quote -// ERR1-NEXT: {{.*}}: unexpected EOF diff --git a/test/ELF/version-script-extern.s b/test/ELF/version-script-extern.s index 2b89839c369a..c63ff817fb40 100644 --- a/test/ELF/version-script-extern.s +++ b/test/ELF/version-script-extern.s @@ -7,7 +7,7 @@ # RUN: echo "LIBSAMPLE_2.0 { global:" >> %t.script # RUN: echo ' extern "C" { _Z3bari; };' >> %t.script # RUN: echo "};" >> %t.script -# RUN: ld.lld --version-script %t.script -shared %t.o -o %t.so +# RUN: ld.lld --hash-style=sysv --version-script %t.script -shared %t.o -o %t.so # RUN: llvm-readobj -V -dyn-symbols %t.so | FileCheck --check-prefix=DSO %s # DSO: DynamicSymbols [ diff --git a/test/ELF/version-script-twice.s b/test/ELF/version-script-twice.s index 3aeedd5b5ddc..1227dcd50f1d 100644 --- a/test/ELF/version-script-twice.s +++ b/test/ELF/version-script-twice.s @@ -7,7 +7,11 @@ .weak openat openat: + + .global openat@FBSD_1.1 openat@FBSD_1.1 = openat + + .global openat@@FBSD_1.2 openat@@FBSD_1.2 = openat # CHECK-DAG: openat@FBSD_1.1 diff --git a/test/ELF/version-script.s b/test/ELF/version-script.s index 72f9eeb944d1..abc716250eba 100644 --- a/test/ELF/version-script.s +++ b/test/ELF/version-script.s @@ -42,6 +42,12 @@ # RUN: ld.lld --version-script %t.script --dynamic-list %t.list %t.o %t2.so -o %t2 # RUN: llvm-readobj %t2 > /dev/null +## Check that we can handle multiple "--version-script" options. +# RUN: echo "VERSION_1.0 { global : foo1; local : *; };" > %t7a.script +# RUN: echo "VERSION_2.0 { global: foo3; local: *; };" > %t7b.script +# RUN: ld.lld --version-script %t7a.script --version-script %t7b.script -shared %t.o %t2.so -o %t7.so +# RUN: llvm-readobj -dyn-symbols %t7.so | FileCheck --check-prefix=VERDSO %s + # DSO: DynamicSymbols [ # DSO-NEXT: Symbol { # DSO-NEXT: Name: @ @@ -142,12 +148,12 @@ # VERDSO-NEXT: ] # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o -# RUN: ld.lld -shared %t.o %t2.so -o %t.so +# RUN: ld.lld --hash-style=sysv -shared %t.o %t2.so -o %t.so # RUN: llvm-readobj -dyn-symbols %t.so | FileCheck --check-prefix=ALL %s # RUN: echo "{ global: foo1; foo3; };" > %t2.script # RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o -# RUN: ld.lld --version-script %t2.script -shared %t.o %t2.so -o %t.so +# RUN: ld.lld --hash-style=sysv --version-script %t2.script -shared %t.o %t2.so -o %t.so # RUN: llvm-readobj -dyn-symbols %t.so | FileCheck --check-prefix=ALL %s # ALL: DynamicSymbols [ diff --git a/test/ELF/weak-entry.s b/test/ELF/weak-entry.s new file mode 100644 index 000000000000..427230ab82c6 --- /dev/null +++ b/test/ELF/weak-entry.s @@ -0,0 +1,13 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t +# RUN: ld.lld %t -o %tout +# RUN: llvm-nm %tout | FileCheck %s + +# CHECK: w _start +# CHECK-NEXT: T foo + +.global foo +.weak _start +.text +foo: + .dc.a _start diff --git a/test/ELF/weak-undef-export.s b/test/ELF/weak-undef-export.s new file mode 100644 index 000000000000..164bc1730832 --- /dev/null +++ b/test/ELF/weak-undef-export.s @@ -0,0 +1,31 @@ +# REQUIRES: x86 + +# Test that we don't fail with foo being undefined. + +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld --export-dynamic %t.o -o %t +# RUN: llvm-readobj -dyn-symbols %t | FileCheck %s + +# CHECK: DynamicSymbols [ +# CHECK-NEXT: Symbol { +# CHECK-NEXT: Name: @ (0) +# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Local (0x0) +# CHECK-NEXT: Type: None (0x0) +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: Undefined (0x0) +# CHECK-NEXT: } +# CHECK-NEXT: Symbol { +# CHECK-NEXT: Name: foo@ (1) +# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Weak (0x2) +# CHECK-NEXT: Type: None (0x0) +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: Undefined (0x0) +# CHECK-NEXT: } +# CHECK-NEXT: ] + + .weak foo + .quad foo diff --git a/test/ELF/weak-undef-lazy.s b/test/ELF/weak-undef-lazy.s new file mode 100644 index 000000000000..113013ea2e0f --- /dev/null +++ b/test/ELF/weak-undef-lazy.s @@ -0,0 +1,11 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/weak-undef-lazy.s -o %t2.o +# RUN: rm -f %t2.a +# RUN: llvm-ar rc %t2.a %t2.o +# RUN: ld.lld %t.o %t2.a -o %t --export-dynamic + + .global _start +_start: + .weak foobar + .quad foobar diff --git a/test/ELF/weak-undef-val.s b/test/ELF/weak-undef-val.s new file mode 100644 index 000000000000..acd42f4845de --- /dev/null +++ b/test/ELF/weak-undef-val.s @@ -0,0 +1,26 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: ld.lld %t.o -o %t --export-dynamic +# RUN: llvm-readobj -s -section-data %t | FileCheck %s + +# CHECK: Name: .text +# CHECK-NEXT: Type: SHT_PROGBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_ALLOC +# CHECK-NEXT: SHF_EXECINSTR +# CHECK-NEXT: ] +# CHECK-NEXT: Address: 0x201000 +# CHECK-NEXT: Offset: +# CHECK-NEXT: Size: +# CHECK-NEXT: Link: +# CHECK-NEXT: Info: +# CHECK-NEXT: AddressAlignment: +# CHECK-NEXT: EntrySize: +# CHECK-NEXT: SectionData ( +# CHECK-NEXT: 0000: 00F0DFFF | +# CHECK-NEXT: ) + + .global _start +_start: + .weak foobar + .long foobar - . diff --git a/test/ELF/weak-undef.s b/test/ELF/weak-undef.s index b6340339ebac..09c2a4c4440f 100644 --- a/test/ELF/weak-undef.s +++ b/test/ELF/weak-undef.s @@ -13,9 +13,21 @@ # CHECK-NEXT: Other: 0 # CHECK-NEXT: Section: Undefined (0x0) # CHECK-NEXT: } +# CHECK-NEXT: Symbol { +# CHECK-NEXT: Name: foo@ +# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Weak +# CHECK-NEXT: Type: None +# CHECK-NEXT: Other: 0 +# CHECK-NEXT: Section: Undefined +# CHECK-NEXT: } # CHECK-NEXT: ] .weak foo .globl _start _start: + +.data + .dc.a foo diff --git a/test/ELF/wrap-no-real.s b/test/ELF/wrap-no-real.s new file mode 100644 index 000000000000..100efa6bbc28 --- /dev/null +++ b/test/ELF/wrap-no-real.s @@ -0,0 +1,77 @@ +// REQUIRES: x86 +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t1.o +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/wrap-no-real.s -o %t2.o +// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/wrap-no-real2.s -o %t3.o +// RUN: ld.lld -o %t3.so -shared %t3.o + +// RUN: ld.lld -o %t %t1.o %t2.o -wrap foo +// RUN: llvm-objdump -d -print-imm-hex %t | FileCheck %s + +// RUN: ld.lld -o %t %t1.o %t2.o %t3.so -wrap foo +// RUN: llvm-objdump -d -print-imm-hex %t | FileCheck %s + +// CHECK: _start: +// CHECK-NEXT: movl $0x11010, %edx +// CHECK-NEXT: movl $0x11010, %edx +// CHECK-NEXT: movl $0x11000, %edx + +// RUN: llvm-readobj -t %t | FileCheck -check-prefix=SYM %s + +// Test the full symbol table. It is verbose, but lld at times +// produced duplicated symbols which are hard to test otherwise. + +// SYM: Symbols [ +// SYM-NEXT: Symbol { +// SYM-NEXT: Name: (0) +// SYM-NEXT: Value: +// SYM-NEXT: Size: +// SYM-NEXT: Binding: +// SYM-NEXT: Type +// SYM-NEXT: Other: +// SYM-NEXT: Section: +// SYM-NEXT: } +// SYM-NEXT: Symbol { +// SYM-NEXT: Name: _DYNAMIC +// SYM-NEXT: Value: +// SYM-NEXT: Size: +// SYM-NEXT: Binding: +// SYM-NEXT: Type: +// SYM-NEXT: Other [ +// SYM-NEXT: STV_HIDDEN +// SYM-NEXT: ] +// SYM-NEXT: Section: .dynamic +// SYM-NEXT: } +// SYM-NEXT: Symbol { +// SYM-NEXT: Name: foo +// SYM-NEXT: Value: 0x11000 +// SYM-NEXT: Size: +// SYM-NEXT: Binding: +// SYM-NEXT: Type: +// SYM-NEXT: Other: +// SYM-NEXT: Section: +// SYM-NEXT: } +// SYM-NEXT: Symbol { +// SYM-NEXT: Name: _start +// SYM-NEXT: Value: +// SYM-NEXT: Size: +// SYM-NEXT: Binding: +// SYM-NEXT: Type +// SYM-NEXT: Other: +// SYM-NEXT: Section: +// SYM-NEXT: } +// SYM-NEXT: Symbol { +// SYM-NEXT: Name: __wrap_foo +// SYM-NEXT: Value: 0x11010 +// SYM-NEXT: Size: +// SYM-NEXT: Binding: +// SYM-NEXT: Type: +// SYM-NEXT: Other: +// SYM-NEXT: Section: +// SYM-NEXT: } +// SYM-NEXT: ] + +.global _start +_start: + movl $foo, %edx + movl $__wrap_foo, %edx + movl $__real_foo, %edx diff --git a/test/ELF/wrap.s b/test/ELF/wrap.s index 3e75fdbad811..b96917b7be49 100644 --- a/test/ELF/wrap.s +++ b/test/ELF/wrap.s @@ -12,17 +12,31 @@ // CHECK-NEXT: movl $0x11010, %edx // CHECK-NEXT: movl $0x11000, %edx -// This shows an oddity of our implementation. The symbol foo gets -// mapped to __wrap_foo, but stays in the symbol table. This results -// in it showing up twice in the output. +// RUN: llvm-readobj -t %t3 > %t4.dump +// RUN: FileCheck --check-prefix=SYM1 %s < %t4.dump +// RUN: FileCheck --check-prefix=SYM2 %s < %t4.dump +// RUN: FileCheck --check-prefix=SYM3 %s < %t4.dump -// RUN: llvm-readobj -t -s %t3 | FileCheck -check-prefix=SYM %s -// SYM: Name: foo -// SYM-NEXT: Value: 0x11000 -// SYM: Name: __wrap_foo -// SYM-NEXT: Value: 0x11010 -// SYM: Name: __wrap_foo -// SYM-NEXT: Value: 0x11010 +// SYM1: Name: foo +// SYM1-NEXT: Value: 0x11000 +// SYM1-NEXT: Size: +// SYM1-NEXT: Binding: Global +// SYM1-NEXT: Type: None +// SYM1-NEXT: Other: 0 +// SYM2: Name: __wrap_foo +// SYM2-NEXT: Value: 0x11010 +// SYM2-NEXT: Size: +// SYM2-NEXT: Binding: Weak +// SYM2-NEXT: Type: None +// SYM2-NEXT: Other [ +// SYM2-NEXT: STV_PROTECTED +// SYM2-NEXT: ] +// SYM3: Name: __real_foo +// SYM3-NEXT: Value: 0x11020 +// SYM3-NEXT: Size: +// SYM3-NEXT: Binding: Global +// SYM3-NEXT: Type: None +// SYM3-NEXT: Other: 0 .global _start _start: diff --git a/test/ELF/x86-64-dyn-rel-error.s b/test/ELF/x86-64-dyn-rel-error.s index ee39e2cb83fd..f479eca2e778 100644 --- a/test/ELF/x86-64-dyn-rel-error.s +++ b/test/ELF/x86-64-dyn-rel-error.s @@ -10,3 +10,5 @@ _start: .long bar // CHECK: relocation R_X86_64_32 cannot be used against shared object; recompile with -fPIC + +// RUN: ld.lld --noinhibit-exec %t.o %t2.so -o %t 2>&1 | FileCheck %s diff --git a/test/ELF/x86-64-relax-got-abs.s b/test/ELF/x86-64-relax-got-abs.s index c4291202f035..0caf6dcec1fa 100644 --- a/test/ELF/x86-64-relax-got-abs.s +++ b/test/ELF/x86-64-relax-got-abs.s @@ -1,7 +1,7 @@ // REQUIRES: x86 // RUN: llvm-mc -filetype=obj -relax-relocations -triple=x86_64-pc-linux %s \ // RUN: -o %t.o -// RUN: ld.lld %t.o -o %t.so -shared +// RUN: ld.lld --hash-style=sysv %t.o -o %t.so -shared // RUN: llvm-objdump -d %t.so | FileCheck %s // We used to fail trying to relax this into a pc relocation to an absolute diff --git a/test/ELF/x86-64-reloc-16.s b/test/ELF/x86-64-reloc-16.s index 2954d9900cfa..4822ec71757b 100644 --- a/test/ELF/x86-64-reloc-16.s +++ b/test/ELF/x86-64-reloc-16.s @@ -9,6 +9,6 @@ // CHECK-NEXT: 200000 42 // RUN: not ld.lld -shared %t %t2 -o %t4 2>&1 | FileCheck --check-prefix=ERROR %s -// ERROR: relocation R_X86_64_16 out of range +// ERROR: relocation R_X86_64_16 out of range: 65536 is not in [0, 65535] .short foo diff --git a/test/ELF/x86-64-reloc-8.s b/test/ELF/x86-64-reloc-8.s index 1c3831fafa20..8f6ba5aa14bb 100644 --- a/test/ELF/x86-64-reloc-8.s +++ b/test/ELF/x86-64-reloc-8.s @@ -9,6 +9,6 @@ // CHECK-NEXT: 200000 42 // RUN: not ld.lld -shared %t %t2 -o %t4 2>&1 | FileCheck --check-prefix=ERROR %s -// ERROR: relocation R_X86_64_8 out of range +// ERROR: relocation R_X86_64_8 out of range: 256 is not in [0, 255] .byte foo diff --git a/test/ELF/x86-64-reloc-error.s b/test/ELF/x86-64-reloc-error.s index ece1bd45aa4f..cb600d9bf1e3 100644 --- a/test/ELF/x86-64-reloc-error.s +++ b/test/ELF/x86-64-reloc-error.s @@ -6,5 +6,5 @@ movl $big, %edx movq $foo - 0x1000000000000, %rdx -# CHECK: {{.*}}:(.text+0x1): relocation R_X86_64_32 out of range -# CHECK: {{.*}}:(.text+0x8): relocation R_X86_64_32S out of range +# CHECK: {{.*}}:(.text+0x1): relocation R_X86_64_32 out of range: 68719476736 is not in [0, 4294967295] +# CHECK: {{.*}}:(.text+0x8): relocation R_X86_64_32S out of range: -281474976710656 is not in [-2147483648, 2147483647] diff --git a/test/ELF/x86-64-reloc-range.s b/test/ELF/x86-64-reloc-range.s index 08f604ee6a30..2913458ab5cb 100644 --- a/test/ELF/x86-64-reloc-range.s +++ b/test/ELF/x86-64-reloc-range.s @@ -1,7 +1,7 @@ // RUN: llvm-mc %s -o %t.o -triple x86_64-pc-linux -filetype=obj // RUN: not ld.lld %t.o -o %t.so -shared 2>&1 | FileCheck %s -// CHECK: {{.*}}:(.text+0x3): relocation R_X86_64_PC32 out of range +// CHECK: {{.*}}:(.text+0x3): relocation R_X86_64_PC32 out of range: 2147483648 is not in [-2147483648, 2147483647] // CHECK-NOT: relocation lea foo(%rip), %rax diff --git a/test/ELF/x86-64-tls-gd-local.s b/test/ELF/x86-64-tls-gd-local.s index ec6115dc2f75..8879737ad3fb 100644 --- a/test/ELF/x86-64-tls-gd-local.s +++ b/test/ELF/x86-64-tls-gd-local.s @@ -1,6 +1,6 @@ // REQUIRES: x86 // RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux -// RUN: ld.lld %t.o -o %t.so -shared +// RUN: ld.lld --hash-style=sysv %t.o -o %t.so -shared // RUN: llvm-readobj -r -s -section-data %t.so | FileCheck %s .byte 0x66 diff --git a/test/MinGW/driver.test b/test/MinGW/driver.test new file mode 100644 index 000000000000..8bf70a9b24fa --- /dev/null +++ b/test/MinGW/driver.test @@ -0,0 +1,126 @@ +RUN: ld.lld -### foo.o -m i386pe | FileCheck -check-prefix=X86 %s +X86: -out:a.exe +X86-SAME: -machine:x86 +X86-SAME: -alternatename:__image_base__=___ImageBase +X86-SAME: foo.o + +RUN: ld.lld -### foo.o -m i386pep | FileCheck -check-prefix=X64 %s +X64: -out:a.exe +X64-SAME: -machine:x64 +X64-SAME: -alternatename:__image_base__=__ImageBase +X64-SAME: foo.o + +RUN: ld.lld -### foo.o -m thumb2pe | FileCheck -check-prefix=ARM %s +ARM: -out:a.exe +ARM-SAME: -machine:arm +ARM-SAME: -alternatename:__image_base__=__ImageBase +ARM-SAME: foo.o + +RUN: ld.lld -### foo.o -m arm64pe | FileCheck -check-prefix=ARM64 %s +ARM64: -out:a.exe +ARM64-SAME: -machine:arm64 +ARM64-SAME: -alternatename:__image_base__=__ImageBase +ARM64-SAME: foo.o + +RUN: ld.lld -### foo.o -m i386pep -shared | FileCheck -check-prefix=SHARED %s +RUN: ld.lld -### foo.o -m i386pep --shared | FileCheck -check-prefix=SHARED %s +SHARED: -out:a.dll +SHARED-SAME: -dll + +RUN: ld.lld -### foo.o -m i386pep -shared foo.def | FileCheck -check-prefix=DEF1 %s +DEF1: -def:foo.def + +RUN: ld.lld -### foo.o -m i386pep -shared FOO.DEF | FileCheck -check-prefix=DEF2 %s +DEF2: -def:FOO.DEF + +RUN: ld.lld -### foo.o -m i386pep -obar.exe | FileCheck -check-prefix=OUT %s +RUN: ld.lld -### foo.o -m i386pep -o bar.exe | FileCheck -check-prefix=OUT %s +OUT: -out:bar.exe + +RUN: ld.lld -### foo.o -m i386pep --out-implib bar | FileCheck -check-prefix=IMPLIB %s +RUN: ld.lld -### foo.o -m i386pep --out-implib=bar | FileCheck -check-prefix=IMPLIB %s +IMPLIB: -implib:bar + +RUN: ld.lld -### foo.o -m i386pep -out-implib bar | FileCheck -check-prefix=NOIMPLIB %s +NOIMPLIB: -out:ut-implib + +RUN: ld.lld -### foo.o -m i386pep -e bar | FileCheck -check-prefix=ENTRY %s +RUN: ld.lld -### foo.o -m i386pep -entry bar | FileCheck -check-prefix=ENTRY %s +RUN: ld.lld -### foo.o -m i386pep --entry bar | FileCheck -check-prefix=ENTRY %s +ENTRY: -entry:bar + +RUN: ld.lld -### foo.o -m i386pep -mllvm bar -mllvm baz | FileCheck -check-prefix=MLLVM %s +MLLVM: -mllvm:bar -mllvm:baz + +RUN: ld.lld -### foo.o -m i386pep -subsystem console | FileCheck -check-prefix=SUBSYSTEM %s +RUN: ld.lld -### foo.o -m i386pep --subsystem console | FileCheck -check-prefix=SUBSYSTEM %s +SUBSYSTEM: -subsystem:console + +RUN: ld.lld -### foo.o -m i386pep -stack 4194304,8192 | FileCheck -check-prefix=STACK %s +RUN: ld.lld -### foo.o -m i386pep --stack 4194304,8192 | FileCheck -check-prefix=STACK %s +STACK: -stack:4194304,8192 + +RUN: ld.lld -### foo.o -m i386pep -verbose | FileCheck -check-prefix=VERBOSE %s +RUN: ld.lld -### foo.o -m i386pep --verbose | FileCheck -check-prefix=VERBOSE %s +VERBOSE: -verbose + +RUN: ld.lld -### -shared -m i386pe -e _DllMainCRTStartup@12 foo.o | FileCheck -check-prefix I386-ENTRY %s +I386-ENTRY: -entry:DllMainCRTStartup@12 + +RUN: ld.lld -### -m i386pep foo.o --whole-archive bar.a --no-whole-archive baz.a | FileCheck -check-prefix WHOLE-ARCHIVE %s +RUN: ld.lld -### -m i386pep foo.o -whole-archive bar.a -no-whole-archive baz.a | FileCheck -check-prefix WHOLE-ARCHIVE %s +WHOLE-ARCHIVE: foo.o -wholearchive:bar.a baz.a + +RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix MINGW-FLAG %s +MINGW-FLAG: -lldmingw + +RUN: ld.lld -### -m i386pep foo.o --export-all-symbols | FileCheck -check-prefix EXPORT-ALL %s +EXPORT-ALL: -export-all-symbols + +RUN: ld.lld -### -m i386pep foo.o --output-def out.def | FileCheck -check-prefix OUTPUT-DEF %s +OUTPUT-DEF: -output-def:out.def + +RUN: ld.lld -### -m i386pep foo.o -Xlink=-lldmap | FileCheck -check-prefix XLINK %s +XLINK: -lldmap + +RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix DEBUG %s +DEBUG: -debug:dwarf + +RUN: ld.lld -### -m i386pep foo.o -s | FileCheck -check-prefix STRIP %s +RUN: ld.lld -### -m i386pep foo.o --strip-all | FileCheck -check-prefix STRIP %s +STRIP-NOT: -debug:dwarf + +RUN: ld.lld -### -m i386pep foo.o --large-address-aware | FileCheck -check-prefix LARGE-ADDRESS-AWARE %s +LARGE-ADDRESS-AWARE: -largeaddressaware + +RUN: ld.lld -### -m i386pe foo.o | FileCheck -check-prefix DEFAULT-DISABLE-FLAGS %s +RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix DEFAULT-DISABLE-FLAGS %s +DEFAULT-DISABLE-FLAGS: -dynamicbase:no +RUN: ld.lld -### -m i386pe --dynamicbase foo.o | FileCheck -check-prefix NO-DEFAULT-DISABLE-FLAGS %s +RUN: ld.lld -### -m i386pep -dynamicbase foo.o | FileCheck -check-prefix NO-DEFAULT-DISABLE-FLAGS %s +RUN: ld.lld -### -m thumb2pe foo.o | FileCheck -check-prefix NO-DEFAULT-DISABLE-FLAGS %s +RUN: ld.lld -### -m arm64pe foo.o | FileCheck -check-prefix NO-DEFAULT-DISABLE-FLAGS %s +NO-DEFAULT-DISABLE-FLAGS-NOT: -dynamicbase:no + +RUN: ld.lld -### -m i386pep foo.o --image-base 0x1230000 | FileCheck -check-prefix IMAGE-BASE %s +RUN: ld.lld -### -m i386pep foo.o -image-base 0x1230000 | FileCheck -check-prefix IMAGE-BASE %s +IMAGE-BASE: -base:0x1230000 + +RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix NO-GC-SECTIONS %s +RUN: ld.lld -### -m i386pep foo.o --gc-sections --no-gc-sections | FileCheck -check-prefix NO-GC-SECTIONS %s +NO-GC-SECTIONS: -opt:noref + +RUN: ld.lld -### -m i386pep foo.o --gc-sections | FileCheck -check-prefix GC-SECTIONS %s +RUN: ld.lld -### -m i386pep foo.o -gc-sections | FileCheck -check-prefix GC-SECTIONS %s +GC-SECTIONS: -opt:ref + +RUN: ld.lld -### -m i386pep foo.o | FileCheck -check-prefix ICF-NONE %s +RUN: ld.lld -### -m i386pep foo.o --icf=none | FileCheck -check-prefix ICF-NONE %s +RUN: ld.lld -### -m i386pep foo.o -icf=none | FileCheck -check-prefix ICF-NONE %s +RUN: ld.lld -### -m i386pep foo.o --icf=safe | FileCheck -check-prefix ICF-NONE %s +RUN: ld.lld -### -m i386pep foo.o -icf=safe | FileCheck -check-prefix ICF-NONE %s +ICF-NONE: -opt:noicf + +RUN: ld.lld -### -m i386pep foo.o --icf=all | FileCheck -check-prefix ICF %s +RUN: ld.lld -### -m i386pep foo.o -icf=all | FileCheck -check-prefix ICF %s +ICF: -opt:icf diff --git a/test/MinGW/lib.test b/test/MinGW/lib.test new file mode 100644 index 000000000000..56104d6d907a --- /dev/null +++ b/test/MinGW/lib.test @@ -0,0 +1,21 @@ +RUN: rm -rf %t/lib +RUN: mkdir -p %t/lib +RUN: not ld.lld -### -m i386pep -lfoo -L%t/lib 2>&1 | FileCheck -check-prefix=LIB1 %s +LIB1: unable to find library -lfoo + +RUN: echo > %t/lib/libfoo.dll.a +RUN: ld.lld -### -m i386pep -lfoo -L%t/lib | FileCheck -check-prefix=LIB2 %s +LIB2: libfoo.dll.a + +RUN: not ld.lld -### -m i386pep -Bstatic -lfoo -L%t/lib 2>&1 | FileCheck -check-prefix=LIB3 %s +LIB3: unable to find library -lfoo + +RUN: echo > %t/lib/libfoo.a +RUN: ld.lld -### -m i386pep -Bstatic -lfoo -L%t/lib | FileCheck -check-prefix=LIB4 %s +LIB4: libfoo.a + +RUN: echo > %t/lib/libbar.dll.a +RUN: echo > %t/lib/libbar.a +RUN: ld.lld -### -m i386pep -Bstatic -lfoo -Bdynamic -lbar -L%t/lib | FileCheck -check-prefix=LIB5 %s +LIB5: libfoo.a +LIB5-SAME: libbar.dll.a diff --git a/test/Unit/lit.cfg b/test/Unit/lit.cfg.py index 4bc973a58edd..dac9f5dc6c33 100644 --- a/test/Unit/lit.cfg +++ b/test/Unit/lit.cfg.py @@ -17,7 +17,21 @@ config.suffixes = [] config.test_source_root = os.path.join(config.lld_obj_root, 'unittests') config.test_exec_root = config.test_source_root + +# Tweak the PATH to include the tools dir. +path = os.path.pathsep.join((config.lld_tools_dir, config.llvm_tools_dir, config.environment['PATH'])) +config.environment['PATH'] = path + +path = os.path.pathsep.join((config.lld_libs_dir, config.llvm_libs_dir, + config.environment.get('LD_LIBRARY_PATH',''))) +config.environment['LD_LIBRARY_PATH'] = path + +# Propagate LLVM_SRC_ROOT into the environment. +config.environment['LLVM_SRC_ROOT'] = config.llvm_src_root + +# Propagate PYTHON_EXECUTABLE into the environment +config.environment['PYTHON_EXECUTABLE'] = sys.executable + + # testFormat: The test format to use to interpret tests. -if not hasattr(config, 'llvm_build_mode'): - lit_config.fatal("unable to find llvm_build_mode value on config") config.test_format = lit.formats.GoogleTest(config.llvm_build_mode, 'Tests') diff --git a/test/Unit/lit.site.cfg.in b/test/Unit/lit.site.cfg.py.in index c2f3054a2d59..cc12117ad0bf 100644 --- a/test/Unit/lit.site.cfg.in +++ b/test/Unit/lit.site.cfg.py.in @@ -8,6 +8,8 @@ config.llvm_build_mode = "@LLVM_BUILD_MODE@" config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" config.lld_obj_root = "@LLD_BINARY_DIR@" config.lld_src_root = "@LLD_SOURCE_DIR@" +config.lld_libs_dir = "@LLVM_LIBRARY_OUTPUT_INTDIR@" +config.lld_tools_dir = "@LLVM_RUNTIME_OUTPUT_INTDIR@" config.target_triple = "@TARGET_TRIPLE@" config.python_executable = "@PYTHON_EXECUTABLE@" @@ -22,4 +24,4 @@ except KeyError as e: lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key)) # Let the main config do the real work. -lit_config.load_config(config, "@LLD_SOURCE_DIR@/test/Unit/lit.cfg") +lit_config.load_config(config, "@LLD_SOURCE_DIR@/test/Unit/lit.cfg.py") diff --git a/test/lit.cfg b/test/lit.cfg deleted file mode 100644 index 95bf3c0dc434..000000000000 --- a/test/lit.cfg +++ /dev/null @@ -1,270 +0,0 @@ -# -*- Python -*- - -import os -import platform -import re -import subprocess -import locale - -import lit.formats -import lit.util - -# Configuration file for the 'lit' test runner. - -# name: The name of this test suite. -config.name = 'lld' - -# Tweak PATH for Win32 -if sys.platform in ['win32']: - # Seek sane tools in directories and set to $PATH. - path = getattr(config, 'lit_tools_dir', None) - path = lit_config.getToolsPath(path, - config.environment['PATH'], - ['cmp.exe', 'grep.exe', 'sed.exe']) - if path is not None: - path = os.path.pathsep.join((path, - config.environment['PATH'])) - config.environment['PATH'] = path - -# Choose between lit's internal shell pipeline runner and a real shell. If -# LIT_USE_INTERNAL_SHELL is in the environment, we use that as an override. -use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL") -if use_lit_shell: - # 0 is external, "" is default, and everything else is internal. - execute_external = (use_lit_shell == "0") -else: - # Otherwise we default to internal on Windows and external elsewhere, as - # bash on Windows is usually very slow. - execute_external = (not sys.platform in ['win32']) - - -# testFormat: The test format to use to interpret tests. -# -# For now we require '&&' between commands, until they get globally killed and -# the test runner updated. -config.test_format = lit.formats.ShTest(execute_external) - -# suffixes: A list of file extensions to treat as test files. -config.suffixes = ['.ll', '.s', '.test', '.yaml', '.objtxt'] - -# excludes: A list of directories to exclude from the testsuite. The 'Inputs' -# subdirectories contain auxiliary inputs for various tests in their parent -# directories. -config.excludes = ['Inputs'] - -# test_source_root: The root path where tests are located. -config.test_source_root = os.path.dirname(__file__) - -# test_exec_root: The root path where tests should be run. -lld_obj_root = getattr(config, 'lld_obj_root', None) -if lld_obj_root is not None: - config.test_exec_root = os.path.join(lld_obj_root, 'test') - -# Set llvm_{src,obj}_root for use by others. -config.llvm_src_root = getattr(config, 'llvm_src_root', None) -config.llvm_obj_root = getattr(config, 'llvm_obj_root', None) - -# Tweak the PATH to include the tools dir and the scripts dir. -if lld_obj_root is not None: - lld_tools_dir = getattr(config, 'lld_tools_dir', None) - if not lld_tools_dir: - lit_config.fatal('No LLD tools dir set!') - llvm_tools_dir = getattr(config, 'llvm_tools_dir', None) - if not llvm_tools_dir: - lit_config.fatal('No LLVM tools dir set!') - path = os.path.pathsep.join((lld_tools_dir, llvm_tools_dir, config.environment['PATH'])) - path = os.path.pathsep.join((os.path.join(getattr(config, 'llvm_src_root', None),'test','Scripts'),path)) - - config.environment['PATH'] = path - - lld_libs_dir = getattr(config, 'lld_libs_dir', None) - if not lld_libs_dir: - lit_config.fatal('No LLD libs dir set!') - llvm_libs_dir = getattr(config, 'llvm_libs_dir', None) - if not llvm_libs_dir: - lit_config.fatal('No LLVM libs dir set!') - path = os.path.pathsep.join((lld_libs_dir, llvm_libs_dir, - config.environment.get('LD_LIBRARY_PATH',''))) - config.environment['LD_LIBRARY_PATH'] = path - - # Propagate LLVM_SRC_ROOT into the environment. - config.environment['LLVM_SRC_ROOT'] = getattr(config, 'llvm_src_root', '') - - # Propagate PYTHON_EXECUTABLE into the environment - config.environment['PYTHON_EXECUTABLE'] = getattr(config, 'python_executable', - '') -### - -# Check that the object root is known. -if config.test_exec_root is None: - # Otherwise, we haven't loaded the site specific configuration (the user is - # probably trying to run on a test file directly, and either the site - # configuration hasn't been created by the build system, or we are in an - # out-of-tree build situation). - - # Check for 'lld_site_config' user parameter, and use that if available. - site_cfg = lit_config.params.get('lld_site_config', None) - if site_cfg and os.path.exists(site_cfg): - lit_config.load_config(config, site_cfg) - raise SystemExit - - # Try to detect the situation where we are using an out-of-tree build by - # looking for 'llvm-config'. - # - # FIXME: I debated (i.e., wrote and threw away) adding logic to - # automagically generate the lit.site.cfg if we are in some kind of fresh - # build situation. This means knowing how to invoke the build system though, - # and I decided it was too much magic. We should solve this by just having - # the .cfg files generated during the configuration step. - - llvm_config = lit.util.which('llvm-config', config.environment['PATH']) - if not llvm_config: - lit_config.fatal('No site specific configuration available!') - - # Get the source and object roots. - llvm_src_root = subprocess.check_output(['llvm-config', '--src-root']).strip() - llvm_obj_root = subprocess.check_output(['llvm-config', '--obj-root']).strip() - lld_src_root = os.path.join(llvm_src_root, "tools", "lld") - lld_obj_root = os.path.join(llvm_obj_root, "tools", "lld") - - # Validate that we got a tree which points to here, using the standard - # tools/lld layout. - this_src_root = os.path.dirname(config.test_source_root) - if os.path.realpath(lld_src_root) != os.path.realpath(this_src_root): - lit_config.fatal('No site specific configuration available!') - - # Check that the site specific configuration exists. - site_cfg = os.path.join(lld_obj_root, 'test', 'lit.site.cfg') - if not os.path.exists(site_cfg): - lit_config.fatal( - 'No site specific configuration available! You may need to ' - 'run "make test" in your lld build directory.') - - # Okay, that worked. Notify the user of the automagic, and reconfigure. - lit_config.note('using out-of-tree build at %r' % lld_obj_root) - lit_config.load_config(config, site_cfg) - raise SystemExit - -# For each occurrence of a lld tool name as its own word, replace it -# with the full path to the build directory holding that tool. This -# ensures that we are testing the tools just built and not some random -# tools that might happen to be in the user's PATH. - -# Regex assertions to reject neighbor hyphens/dots (seen in some tests). -# For example, we want to prefix 'lld' and 'ld.lld' but not the 'lld' inside -# of 'ld.lld'. -NoPreJunk = r"(?<!(-|\.|/))" -NoPostJunk = r"(?!(-|\.))" - -config.substitutions.append( (r"\bld.lld\b", 'ld.lld --full-shutdown') ) - -tool_patterns = [r"\bFileCheck\b", - r"\bnot\b", - NoPreJunk + r"\blld\b" + NoPostJunk, - r"\bld.lld\b", - r"\blld-link\b", - r"\bllvm-as\b", - r"\bllvm-mc\b", - r"\bllvm-nm\b", - r"\bllvm-objdump\b", - r"\bllvm-pdbutil\b", - r"\bllvm-readobj\b", - r"\bobj2yaml\b", - r"\byaml2obj\b"] - -for pattern in tool_patterns: - # Extract the tool name from the pattern. This relies on the tool - # name being surrounded by \b word match operators. If the - # pattern starts with "| ", include it in the string to be - # substituted. - tool_match = re.match(r"^(\\)?((\| )?)\W+b([0-9A-Za-z-_\.]+)\\b\W*$", - pattern) - tool_pipe = tool_match.group(2) - tool_name = tool_match.group(4) - tool_path = lit.util.which(tool_name, config.environment['PATH']) - if not tool_path: - # Warn, but still provide a substitution. - lit_config.note('Did not find ' + tool_name + ' in ' + path) - tool_path = llvm_tools_dir + '/' + tool_name - config.substitutions.append((pattern, tool_pipe + tool_path)) - -# Add site-specific substitutions. -config.substitutions.append( ('%python', config.python_executable) ) - -### - -# When running under valgrind, we mangle '-vg' onto the end of the triple so we -# can check it with XFAIL and XTARGET. -if lit_config.useValgrind: - config.target_triple += '-vg' - -# Shell execution -if execute_external: - config.available_features.add('shell') - -# zlib compression library -if config.have_zlib: - config.available_features.add("zlib") - -# Running on Darwin OS -if platform.system() in ['Darwin']: - config.available_features.add('system-linker-mach-o') - -# Running on ELF based *nix -if platform.system() in ['FreeBSD', 'Linux']: - config.available_features.add('system-linker-elf') - -# Running on Windows -if platform.system() in ['Windows']: - config.available_features.add('system-windows') - -# Set if host-cxxabi's demangler can handle target's symbols. -if platform.system() not in ['Windows']: - config.available_features.add('demangler') - -# llvm-config knows whether it is compiled with asserts (and) -# whether we are operating in release/debug mode. -import subprocess -try: - llvm_config_cmd = \ - subprocess.Popen([os.path.join(llvm_tools_dir, 'llvm-config'), - '--build-mode', '--assertion-mode', '--targets-built'], - stdout = subprocess.PIPE) -except OSError as why: - print("Could not find llvm-config in " + llvm_tools_dir) - exit(42) - -llvm_config_output = llvm_config_cmd.stdout.read().decode('utf_8') -llvm_config_output_list = llvm_config_output.split("\n") - -if re.search(r'DEBUG', llvm_config_output_list[0]): - config.available_features.add('debug') -if re.search(r'ON', llvm_config_output_list[1]): - config.available_features.add('asserts') - -archs = llvm_config_output_list[2] -if re.search(r'AArch64', archs): - config.available_features.add('aarch64') -if re.search(r'AMDGPU', archs): - config.available_features.add('amdgpu') -if re.search(r'ARM', archs): - config.available_features.add('arm') -if re.search(r'AVR', archs): - config.available_features.add('avr') -if re.search(r'Mips', archs): - config.available_features.add('mips') -if re.search(r'PowerPC', archs): - config.available_features.add('ppc') -if re.search(r'Sparc', archs): - config.available_features.add('sparc') -if re.search(r'X86', archs): - config.available_features.add('x86') -llvm_config_cmd.wait() - -# Set a fake constant version so that we get consitent output. -config.environment['LLD_VERSION'] = 'LLD 1.0' - -# Indirectly check if the mt.exe Microsoft utility exists by searching for -# cvtres, which always accompanies it. -if lit.util.which('cvtres', config.environment['PATH']): - config.available_features.add('win_mt') diff --git a/test/lit.cfg.py b/test/lit.cfg.py new file mode 100644 index 000000000000..ae0dd187c607 --- /dev/null +++ b/test/lit.cfg.py @@ -0,0 +1,93 @@ +# -*- Python -*- + +import os +import platform +import re +import subprocess +import locale + +import lit.formats +import lit.util + +from lit.llvm import llvm_config + +# Configuration file for the 'lit' test runner. + +# name: The name of this test suite. +config.name = 'lld' + +# testFormat: The test format to use to interpret tests. +# +# For now we require '&&' between commands, until they get globally killed and +# the test runner updated. +config.test_format = lit.formats.ShTest(not llvm_config.use_lit_shell) + +# suffixes: A list of file extensions to treat as test files. +config.suffixes = ['.ll', '.s', '.test', '.yaml', '.objtxt'] + +# excludes: A list of directories to exclude from the testsuite. The 'Inputs' +# subdirectories contain auxiliary inputs for various tests in their parent +# directories. +config.excludes = ['Inputs'] + +# test_source_root: The root path where tests are located. +config.test_source_root = os.path.dirname(__file__) + +config.test_exec_root = os.path.join(config.lld_obj_root, 'test') + +llvm_config.use_default_substitutions() +llvm_config.use_lld() + +tool_patterns = [ + 'llc', 'llvm-as', 'llvm-mc', 'llvm-nm', + 'llvm-objdump', 'llvm-pdbutil', 'llvm-readobj', 'obj2yaml', 'yaml2obj'] + +llvm_config.add_tool_substitutions(tool_patterns) + +# When running under valgrind, we mangle '-vg' onto the end of the triple so we +# can check it with XFAIL and XTARGET. +if lit_config.useValgrind: + config.target_triple += '-vg' + +# Running on ELF based *nix +if platform.system() in ['FreeBSD', 'Linux']: + config.available_features.add('system-linker-elf') + +# Set if host-cxxabi's demangler can handle target's symbols. +if platform.system() not in ['Windows']: + config.available_features.add('demangler') + +llvm_config.feature_config( + [('--build-mode', {'DEBUG': 'debug'}), + ('--assertion-mode', {'ON': 'asserts'}), + ('--targets-built', {'AArch64': 'aarch64', + 'AMDGPU': 'amdgpu', + 'ARM': 'arm', + 'AVR': 'avr', + 'Mips': 'mips', + 'PowerPC': 'ppc', + 'Sparc': 'sparc', + 'WebAssembly': 'wasm', + 'X86': 'x86'}) + ]) + +# Set a fake constant version so that we get consitent output. +config.environment['LLD_VERSION'] = 'LLD 1.0' + +# Indirectly check if the mt.exe Microsoft utility exists by searching for +# cvtres, which always accompanies it. Alternatively, check if we can use +# libxml2 to merge manifests. +if (lit.util.which('cvtres', config.environment['PATH'])) or \ + (config.llvm_libxml2_enabled == '1'): + config.available_features.add('manifest_tool') + +if (config.llvm_libxml2_enabled == '1'): + config.available_features.add('libxml2') + +tar_executable = lit.util.which('tar', config.environment['PATH']) +if tar_executable: + tar_version = subprocess.Popen( + [tar_executable, '--version'], stdout=subprocess.PIPE, env={'LANG': 'C'}) + if 'GNU tar' in tar_version.stdout.read().decode(): + config.available_features.add('gnutar') + tar_version.wait() diff --git a/test/lit.site.cfg.in b/test/lit.site.cfg.py.in index 1fb8d3690708..50593f7d01bd 100644 --- a/test/lit.site.cfg.in +++ b/test/lit.site.cfg.py.in @@ -4,6 +4,7 @@ config.llvm_src_root = "@LLVM_SOURCE_DIR@" config.llvm_obj_root = "@LLVM_BINARY_DIR@" config.llvm_tools_dir = "@LLVM_TOOLS_DIR@" config.llvm_libs_dir = "@LLVM_LIBS_DIR@" +config.llvm_libxml2_enabled = "@LLVM_LIBXML2_ENABLED@" config.lit_tools_dir = "@LLVM_LIT_TOOLS_DIR@" config.lld_obj_root = "@LLD_BINARY_DIR@" config.lld_libs_dir = "@LLVM_LIBRARY_OUTPUT_INTDIR@" @@ -21,5 +22,7 @@ except KeyError as e: key, = e.args lit_config.fatal("unable to find %r parameter, use '--param=%s=VALUE'" % (key,key)) +@LIT_SITE_CFG_IN_FOOTER@ + # Let the main config do the real work. -lit_config.load_config(config, "@LLD_SOURCE_DIR@/test/lit.cfg") +lit_config.load_config(config, "@LLD_SOURCE_DIR@/test/lit.cfg.py") diff --git a/test/wasm/Inputs/archive1.ll b/test/wasm/Inputs/archive1.ll new file mode 100644 index 000000000000..c942fa2c1b55 --- /dev/null +++ b/test/wasm/Inputs/archive1.ll @@ -0,0 +1,7 @@ +declare i32 @bar() local_unnamed_addr #1 + +define i32 @foo() local_unnamed_addr #0 { +entry: + %call = tail call i32 @bar() #2 + ret i32 %call +} diff --git a/test/wasm/Inputs/archive2.ll b/test/wasm/Inputs/archive2.ll new file mode 100644 index 000000000000..35534dc9e076 --- /dev/null +++ b/test/wasm/Inputs/archive2.ll @@ -0,0 +1,7 @@ +declare i32 @foo() local_unnamed_addr #1 + +define i32 @bar() local_unnamed_addr #0 { +entry: + %call = tail call i32 @foo() #2 + ret i32 %call +} diff --git a/test/wasm/Inputs/call-indirect.ll b/test/wasm/Inputs/call-indirect.ll new file mode 100644 index 000000000000..388ea60c3a07 --- /dev/null +++ b/test/wasm/Inputs/call-indirect.ll @@ -0,0 +1,17 @@ +@indirect_bar = internal local_unnamed_addr global i32 ()* @bar, align 4 +@indirect_foo = internal local_unnamed_addr global i32 ()* @foo, align 4 + +declare i32 @foo() local_unnamed_addr + +define i32 @bar() { +entry: + ret i32 1 +} + +define void @call_bar_indirect() local_unnamed_addr #1 { +entry: + %0 = load i32 ()*, i32 ()** @indirect_bar, align 4 + %1 = load i32 ()*, i32 ()** @indirect_foo, align 4 + %call = tail call i32 %0() #2 + ret void +} diff --git a/test/wasm/Inputs/hello.ll b/test/wasm/Inputs/hello.ll new file mode 100644 index 000000000000..93df0f559809 --- /dev/null +++ b/test/wasm/Inputs/hello.ll @@ -0,0 +1,15 @@ +; Wasm module generated from the following C code: +; void puts(const char*); +; void hello() { puts("hello\n"); } + +@hello_str = unnamed_addr constant [7 x i8] c"hello\0A\00", align 1 + +; Function Attrs: nounwind +define hidden void @hello() local_unnamed_addr #0 { +entry: + tail call void @puts(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @hello_str, i32 0, i32 0)) + ret void +} + +; Function Attrs: nounwind +declare void @puts(i8* nocapture readonly) local_unnamed_addr #1 diff --git a/test/wasm/Inputs/hidden.ll b/test/wasm/Inputs/hidden.ll new file mode 100644 index 000000000000..25890e9f03f2 --- /dev/null +++ b/test/wasm/Inputs/hidden.ll @@ -0,0 +1,11 @@ +; Function Attrs: norecurse nounwind readnone +define hidden i32 @archiveHidden() #0 { +entry: + ret i32 0 +} + +; Function Attrs: norecurse nounwind readnone +define i32 @archiveDefault() #1 { +entry: + ret i32 0 +} diff --git a/test/wasm/Inputs/many-funcs.ll b/test/wasm/Inputs/many-funcs.ll new file mode 100644 index 000000000000..b8daab23638d --- /dev/null +++ b/test/wasm/Inputs/many-funcs.ll @@ -0,0 +1,776 @@ +@g0 = global i32 1, align 4 +@foo = global i32 1, align 4 + +define i32 @f1() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f2() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f3() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f4() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f5() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f6() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f7() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f8() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f9() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f10() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f11() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f12() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f13() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f14() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f15() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f16() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f17() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f18() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f19() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f20() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f21() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f22() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f23() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f24() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f25() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f26() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f27() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f28() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f29() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f30() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f31() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f32() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f33() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f34() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f35() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f36() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f37() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f38() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f39() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f40() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f41() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f42() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f43() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f44() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f45() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f46() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f47() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f48() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f49() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f50() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f51() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f52() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f53() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f54() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f55() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f56() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f57() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f58() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f59() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f60() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f61() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f62() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f63() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f64() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f65() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f66() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f67() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f68() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f69() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f70() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f71() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f72() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f73() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f74() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f75() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f76() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f77() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f78() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f79() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f80() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f81() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f82() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f83() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f84() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f85() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f86() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f87() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f88() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f89() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f90() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f91() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f92() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f93() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f94() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f95() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f96() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f97() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f98() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f99() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f100() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f101() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f102() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f103() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f104() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f105() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f106() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f107() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f108() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f109() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f110() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f111() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f112() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f113() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f114() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f115() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f116() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f117() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f118() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f119() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f120() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f121() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f122() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f123() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f124() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f125() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f126() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f127() { +entry: + %0 = load i32, i32* @foo, align 4 + ret i32 %0 +} + +define i32 @f128() { +entry: + %0 = load i32, i32* @g0, align 4 + ret i32 %0 +} + +define i32 @f129() { +entry: + %0 = load i32, i32* @g0, align 4 + ret i32 %0 +} diff --git a/test/wasm/Inputs/ret32.ll b/test/wasm/Inputs/ret32.ll new file mode 100644 index 000000000000..a4565288f08b --- /dev/null +++ b/test/wasm/Inputs/ret32.ll @@ -0,0 +1,6 @@ +; Function Attrs: norecurse nounwind readnone +define i32 @ret32(float %arg) #0 { +entry: + ret i32 0 + ; ptrtoint (i32 (float)* @ret32 to i32) +} diff --git a/test/wasm/Inputs/ret64.ll b/test/wasm/Inputs/ret64.ll new file mode 100644 index 000000000000..6a9de0dace1d --- /dev/null +++ b/test/wasm/Inputs/ret64.ll @@ -0,0 +1,4 @@ +define i64 @ret64(double %arg) local_unnamed_addr #0 { +entry: + ret i64 1 +} diff --git a/test/wasm/Inputs/weak-alias.ll b/test/wasm/Inputs/weak-alias.ll new file mode 100644 index 000000000000..079e68e3ce7a --- /dev/null +++ b/test/wasm/Inputs/weak-alias.ll @@ -0,0 +1,13 @@ +; Function Attrs: norecurse nounwind readnone +define i32 @foo() #0 { +entry: + ret i32 0 +} + +@bar = weak alias i32 (), i32 ()* @foo + +define i32 @call_bar() #0 { +entry: + %call = call i32 @bar() + ret i32 %call +} diff --git a/test/wasm/Inputs/weak-symbol1.ll b/test/wasm/Inputs/weak-symbol1.ll new file mode 100644 index 000000000000..2d561716f825 --- /dev/null +++ b/test/wasm/Inputs/weak-symbol1.ll @@ -0,0 +1,9 @@ +define weak i32 @weakFn() #0 { +entry: + ret i32 1 +} + +define i32 @exportWeak1() { +entry: + ret i32 ptrtoint (i32 ()* @weakFn to i32) +} diff --git a/test/wasm/Inputs/weak-symbol2.ll b/test/wasm/Inputs/weak-symbol2.ll new file mode 100644 index 000000000000..f43ea96673b9 --- /dev/null +++ b/test/wasm/Inputs/weak-symbol2.ll @@ -0,0 +1,9 @@ +define weak i32 @weakFn() #0 { +entry: + ret i32 2 +} + +define i32 @exportWeak2() { +entry: + ret i32 ptrtoint (i32 ()* @weakFn to i32) +} diff --git a/test/wasm/archive.ll b/test/wasm/archive.ll new file mode 100644 index 000000000000..18f35330d1e9 --- /dev/null +++ b/test/wasm/archive.ll @@ -0,0 +1,31 @@ +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %s -o %t.o +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %S/Inputs/archive1.ll -o %t.a1.o +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %S/Inputs/archive2.ll -o %t.a2.o +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %S/Inputs/hello.ll -o %t.a3.o +; RUN: llvm-ar rcs %t.a %t.a1.o %t.a2.o %t.a3.o +; RUN: lld -flavor wasm %t.a %t.o -o %t.wasm +; RUN: llvm-nm -a %t.wasm | FileCheck %s + +declare i32 @foo() local_unnamed_addr #1 + +define i32 @_start() local_unnamed_addr #0 { +entry: + %call = tail call i32 @foo() #2 + ret i32 %call +} + +; Verify that multually dependant object files in an archive is handled +; correctly. + +; CHECK: 00000002 T _start +; CHECK-NEXT: 00000002 T _start +; CHECK-NEXT: 00000000 T bar +; CHECK-NEXT: 00000000 T bar +; CHECK-NEXT: 00000001 T foo +; CHECK-NEXT: 00000001 T foo + +; Verify that symbols from unused objects don't appear in the symbol table +; CHECK-NOT: hello + +; Specifying the same archive twice is allowed. +; RUN: lld -flavor wasm %t.a %t.a %t.o -o %t.wasm diff --git a/test/wasm/call-indirect.ll b/test/wasm/call-indirect.ll new file mode 100644 index 000000000000..14845eb50f83 --- /dev/null +++ b/test/wasm/call-indirect.ll @@ -0,0 +1,112 @@ +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %p/Inputs/call-indirect.ll -o %t2.o +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %s -o %t.o +; RUN: lld -flavor wasm -o %t.wasm %t2.o %t.o +; RUN: obj2yaml %t.wasm | FileCheck %s + +; bitcode generated from the following C code: +; int foo(void) { return 1; } +; int (*indirect_func)(void) = &foo; +; void _start(void) { indirect_func(); } + +@indirect_func = local_unnamed_addr global i32 ()* @foo, align 4 + +; Function Attrs: norecurse nounwind readnone +define i32 @foo() #0 { +entry: + ret i32 2 +} + +; Function Attrs: nounwind +define i32 @_start() local_unnamed_addr #1 { +entry: + %0 = load i32 ()*, i32 ()** @indirect_func, align 4 + %call = tail call i32 %0() #2 + ret i32 0 +} + +; CHECK: !WASM +; CHECK-NEXT: FileHeader: +; CHECK-NEXT: Version: 0x00000001 +; CHECK-NEXT: Sections: +; CHECK-NEXT: - Type: TYPE +; CHECK-NEXT: Signatures: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ParamTypes: +; CHECK-NEXT: - Index: 1 +; CHECK-NEXT: ReturnType: NORESULT +; CHECK-NEXT: ParamTypes: +; CHECK-NEXT: - Type: FUNCTION +; CHECK-NEXT: FunctionTypes: [ 0, 1, 0, 0 ] +; CHECK-NEXT: - Type: TABLE +; CHECK-NEXT: Tables: +; CHECK-NEXT: - ElemType: ANYFUNC +; CHECK-NEXT: Limits: +; CHECK-NEXT: Flags: [ HAS_MAX ] +; CHECK-NEXT: Initial: 0x00000003 +; CHECK-NEXT: Maximum: 0x00000003 +; CHECK-NEXT: - Type: MEMORY +; CHECK-NEXT: Memories: +; CHECK-NEXT: - Initial: 0x00000002 +; CHECK-NEXT: - Type: GLOBAL +; CHECK-NEXT: Globals: +; CHECK-NEXT: - Type: I32 +; CHECK-NEXT: Mutable: true +; CHECK-NEXT: InitExpr: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 66576 +; CHECK-NEXT: - Type: EXPORT +; CHECK-NEXT: Exports: +; CHECK-NEXT: - Name: memory +; CHECK-NEXT: Kind: MEMORY +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: - Name: _start +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 3 +; CHECK-NEXT: - Name: foo +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 2 +; CHECK-NEXT: - Name: bar +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: - Name: call_bar_indirect +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 1 +; CHECK-NEXT: - Type: ELEM +; CHECK-NEXT: Segments: +; CHECK-NEXT: - Offset: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 1 +; CHECK-NEXT: Functions: [ 0, 2 ] +; CHECK-NEXT: - Type: CODE +; CHECK-NEXT: Functions: +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 41010B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 410028028088808000118080808000001A0B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 41020B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 410028028888808000118080808000001A41000B +; CHECK-NEXT: - Type: DATA +; CHECK-NEXT: Segments: +; CHECK-NEXT: - SectionOffset: 7 +; CHECK-NEXT: MemoryIndex: 0 +; CHECK-NEXT: Offset: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 1024 +; CHECK-NEXT: Content: '010000000200000002000000' +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: linking +; CHECK-NEXT: DataSize: 12 +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: name +; CHECK-NEXT: FunctionNames: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: Name: bar +; CHECK-NEXT: - Index: 1 +; CHECK-NEXT: Name: call_bar_indirect +; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: Name: foo +; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: Name: _start diff --git a/test/wasm/conflict.test b/test/wasm/conflict.test new file mode 100644 index 000000000000..a0a2eb4e3b3a --- /dev/null +++ b/test/wasm/conflict.test @@ -0,0 +1,6 @@ +# RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %p/Inputs/ret32.ll -o %t.ret32.o +# RUN: not lld -flavor wasm -o %t.wasm %t.ret32.o %t.ret32.o 2>&1 | FileCheck %s + +# CHECK: duplicate symbol: ret32 +# CHECK-NEXT: >>> defined in {{.*}}conflict.test.tmp.ret32.o +# CHECK-NEXT: >>> defined in {{.*}}conflict.test.tmp.ret32.o diff --git a/test/wasm/data-layout.ll b/test/wasm/data-layout.ll new file mode 100644 index 000000000000..0b2c61da5547 --- /dev/null +++ b/test/wasm/data-layout.ll @@ -0,0 +1,61 @@ +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %p/Inputs/hello.ll -o %t.hello.o +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %s -o %t.o +; RUN: lld -flavor wasm --emit-relocs --allow-undefined --no-entry -o %t.wasm %t.o %t.hello.o +; RUN: obj2yaml %t.wasm | FileCheck %s + +@foo = hidden global i32 1, align 4 +@aligned_bar = hidden global i32 3, align 16 + +@hello_str = external global i8* +@external_ref = global i8** @hello_str, align 8 + +; CHECK: - Type: GLOBAL +; CHECK-NEXT: Globals: +; CHECK-NEXT: - Type: I32 +; CHECK-NEXT: Mutable: true +; CHECK-NEXT: InitExpr: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 66608 +; CHECK-NEXT: - Type: I32 +; CHECK-NEXT: Mutable: false +; CHECK-NEXT: InitExpr: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 1024 +; CHECK-NEXT: - Type: I32 +; CHECK-NEXT: Mutable: false +; CHECK-NEXT: InitExpr: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 1040 +; CHECK-NEXT: - Type: I32 +; CHECK-NEXT: Mutable: false +; CHECK-NEXT: InitExpr: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 1048 +; CHECK-NEXT: - Type: I32 +; CHECK-NEXT: Mutable: false +; CHECK-NEXT: InitExpr: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 1052 + +; CHECK: - Type: DATA +; CHECK-NEXT: Relocations: +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 +; CHECK-NEXT: Index: 4 +; CHECK-NEXT: Offset: 0x0000001F +; CHECK-NEXT: Segments: +; CHECK-NEXT: - SectionOffset: 7 +; CHECK-NEXT: MemoryIndex: 0 +; CHECK-NEXT: Offset: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 1024 +; CHECK-NEXT: Content: 0100000000000000000000000000000003000000000000001C040000 +; CHECK-NEXT: - SectionOffset: 41 +; CHECK-NEXT: MemoryIndex: 0 +; CHECK-NEXT: Offset: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 1052 +; CHECK-NEXT: Content: 68656C6C6F0A00 + +; CHECK: - Type: CUSTOM +; CHECK-NEXT: Name: linking +; CHECK-NEXT: DataSize: 35 diff --git a/test/wasm/entry.ll b/test/wasm/entry.ll new file mode 100644 index 000000000000..e51c7055b80e --- /dev/null +++ b/test/wasm/entry.ll @@ -0,0 +1,19 @@ +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %s -o %t.o +; RUN: lld -flavor wasm -e entry -o %t.wasm %t.o +; RUN: obj2yaml %t.wasm | FileCheck %s +; RUN: lld -flavor wasm --entry=entry -o %t.wasm %t.o +; RUN: obj2yaml %t.wasm | FileCheck %s + +define void @entry() local_unnamed_addr #0 { +entry: + ret void +} + +; CHECK: - Type: EXPORT +; CHECK: Exports: +; CHECK: - Name: memory +; CHECK: Kind: MEMORY +; CHECK: Index: 0 +; CHECK: - Name: entry +; CHECK: Kind: FUNCTION +; CHECK: Index: 0 diff --git a/test/wasm/function-imports-first.ll b/test/wasm/function-imports-first.ll new file mode 100644 index 000000000000..085345ad7ffc --- /dev/null +++ b/test/wasm/function-imports-first.ll @@ -0,0 +1,42 @@ +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %p/Inputs/ret32.ll -o %t.ret32.o +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %s -o %t.o +; RUN: lld -flavor wasm -o %t.wasm %t.o %t.ret32.o +; RUN: obj2yaml %t.wasm | FileCheck %s + +; Function Attrs: nounwind +define hidden void @_start() local_unnamed_addr #0 { +entry: + %call = tail call i32 @ret32(float 0.000000e+00) #2 + ret void +} + +declare i32 @ret32(float) local_unnamed_addr #1 + +; CHECK: - Type: TYPE +; CHECK: Signatures: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: ReturnType: NORESULT +; CHECK-NEXT: ParamTypes: +; CHECK-NEXT: - Index: 1 +; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ParamTypes: +; CHECK-NEXT: - F32 +; CHECK: - Type: FUNCTION +; CHECK-NEXT: FunctionTypes: [ 0, 1 ] +; CHECK: - Type: CODE +; CHECK-NEXT: Functions: +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 43000000001081808080001A0B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 41000B +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: linking +; CHECK-NEXT: DataSize: 0 +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: name +; CHECK-NEXT: FunctionNames: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: Name: _start +; CHECK-NEXT: - Index: 1 +; CHECK-NEXT: Name: ret32 +; CHECK-NEXT: ... diff --git a/test/wasm/function-imports.ll b/test/wasm/function-imports.ll new file mode 100644 index 000000000000..e0988ff95f96 --- /dev/null +++ b/test/wasm/function-imports.ll @@ -0,0 +1,37 @@ +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %p/Inputs/ret32.ll -o %t.ret32.o +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %s -o %t.o +; RUN: lld -flavor wasm -o %t.wasm %t.ret32.o %t.o +; RUN: obj2yaml %t.wasm | FileCheck %s + +; Function Attrs: nounwind +define hidden void @_start() local_unnamed_addr #0 { +entry: + %call = tail call i32 @ret32(float 0.000000e+00) #2 + ret void +} + +declare i32 @ret32(float) local_unnamed_addr #1 + +; CHECK: Sections: +; CHECK: - Type: TYPE +; CHECK-NEXT: Signatures: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ParamTypes: +; CHECK-NEXT: - F32 +; CHECK-NEXT: - Index: 1 +; CHECK-NEXT: ReturnType: NORESULT +; CHECK-NEXT: ParamTypes: +; CHECK-NEXT: - Type: FUNCTION +; CHECK-NEXT: FunctionTypes: [ 0, 1 ] +; CHECK: - Type: CODE +; CHECK-NEXT: Functions: +; CHECK: - Locals: +; CHECK: - Locals: +; CHECK: Name: name +; CHECK-NEXT: FunctionNames: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: Name: ret32 +; CHECK-NEXT: - Index: 1 +; CHECK-NEXT: Name: _start +; CHECK-NEXT: ... diff --git a/test/wasm/function-index.test b/test/wasm/function-index.test new file mode 100644 index 000000000000..03bd879b5176 --- /dev/null +++ b/test/wasm/function-index.test @@ -0,0 +1,18 @@ +# RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %p/Inputs/ret32.ll -o %t.ret32.o +# RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %p/Inputs/ret64.ll -o %t.ret64.o +# RUN: lld -flavor wasm -r -o %t.wasm %t.ret32.o %t.ret64.o +# RUN: obj2yaml %t.wasm | FileCheck %s + +CHECK: Sections: +CHECK: - Type: TYPE +CHECK: Signatures: +CHECK: - Index: 0 +CHECK: ReturnType: I32 +CHECK: ParamTypes: +CHECK: - F32 +CHECK: - Index: 1 +CHECK: ReturnType: I64 +CHECK: ParamTypes: +CHECK: - F64 +CHECK: - Type: FUNCTION +CHECK: FunctionTypes: [ 0, 1 ] diff --git a/test/wasm/import-memory.test b/test/wasm/import-memory.test new file mode 100644 index 000000000000..af0ff910449c --- /dev/null +++ b/test/wasm/import-memory.test @@ -0,0 +1,13 @@ +# RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %p/Inputs/ret32.ll -o %t.ret32.o +# RUN: lld -flavor wasm -entry ret32 --import-memory -o %t.wasm %t.ret32.o +# RUN: obj2yaml %t.wasm | FileCheck %s + +# Verify the --import-memory flag creates a memory import + +# CHECK: - Type: IMPORT +# CHECK-NEXT: Imports: +# CHECK-NEXT: - Module: env +# CHECK-NEXT: Field: memory +# CHECK-NEXT: Kind: MEMORY +# CHECK-NEXT: Memory: +# CHECK-NEXT: Initial: 0x00000002 diff --git a/test/wasm/invalid-stack-size.test b/test/wasm/invalid-stack-size.test new file mode 100644 index 000000000000..6597c548499a --- /dev/null +++ b/test/wasm/invalid-stack-size.test @@ -0,0 +1,9 @@ +; RUN: llc -mtriple wasm32-unknown-unknown-wasm -filetype=obj %s -o %t.o +; RUN: not lld -flavor wasm -o %t.wasm -z stack-size=1 %t.o 2>&1 | FileCheck %s + +define i32 @_start() local_unnamed_addr #1 { +entry: + ret i32 0 +} + +; CHECK: error: stack size must be 16-byte aligned diff --git a/test/wasm/lit.local.cfg b/test/wasm/lit.local.cfg new file mode 100644 index 000000000000..bc76e57c8e87 --- /dev/null +++ b/test/wasm/lit.local.cfg @@ -0,0 +1,4 @@ +if 'wasm' not in config.available_features: + config.unsupported = True + +config.suffixes = ['.test', '.yaml', '.ll'] diff --git a/test/wasm/load-undefined.ll b/test/wasm/load-undefined.ll new file mode 100644 index 000000000000..f979c9acb517 --- /dev/null +++ b/test/wasm/load-undefined.ll @@ -0,0 +1,38 @@ +; Verify that the -u / --undefined option is able to pull in symbols from +; an archive, and doesn't error when uses to pull in a symbol already loaded. +; +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-unknown-wasm %S/Inputs/ret64.ll -o %t.o +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-unknown-wasm %S/Inputs/ret32.ll -o %t2.o +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-unknown-wasm %s -o %t3.o +; RUN: llvm-ar rcs %t2.a %t2.o +; RUN: lld -flavor wasm %t3.o %t2.a %t.o -o %t.wasm -u ret32 --undefined ret64 +; RUN: obj2yaml %t.wasm | FileCheck %s + +define i32 @_start() local_unnamed_addr { +entry: + ret i32 1 +} + +; CHECK: - Type: EXPORT +; CHECK-NEXT: Exports: +; CHECK-NEXT: - Name: memory +; CHECK-NEXT: Kind: MEMORY +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: - Name: _start +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: - Name: ret32 +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 1 +; CHECK-NEXT: - Name: ret64 +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 2 +; CHECK-NEXT: - Type: + + +; Verify that referencing a symbol that doesn't exist won't work +; RUN: not lld -flavor wasm %t3.o -o %t.wasm -u symboldoesnotexist 2>&1 | FileCheck -check-prefix=CHECK-UNDEFINED1 %s +; CHECK-UNDEFINED1: error: undefined symbol: symboldoesnotexist + +; RUN: not lld -flavor wasm %t3.o -o %t.wasm --undefined symboldoesnotexist --allow-undefined 2>&1 | FileCheck -check-prefix=CHECK-UNDEFINED2 %s +; CHECK-UNDEFINED2: function forced with --undefined not found: symboldoesnotexist diff --git a/test/wasm/local-symbols.ll b/test/wasm/local-symbols.ll new file mode 100644 index 000000000000..3e6722b124ec --- /dev/null +++ b/test/wasm/local-symbols.ll @@ -0,0 +1,78 @@ +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %s -o %t.o +; RUN: lld -flavor wasm -o %t.wasm %t.o +; RUN: obj2yaml %t.wasm | FileCheck %s + +@foo = default global i32 1, align 4 +@bar = internal default global i32 3, align 4 + +define internal i32 @baz() local_unnamed_addr { +entry: + ret i32 2 +} + +define i32 @_start() local_unnamed_addr { +entry: + ret i32 1 +} + +; CHECK: --- !WASM +; CHECK-NEXT: FileHeader: +; CHECK-NEXT: Version: 0x00000001 +; CHECK-NEXT: Sections: +; CHECK-NEXT: - Type: TYPE +; CHECK-NEXT: Signatures: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ParamTypes: +; CHECK-NEXT: - Type: FUNCTION +; CHECK-NEXT: FunctionTypes: [ 0, 0 ] +; CHECK-NEXT: - Type: TABLE +; CHECK-NEXT: Tables: +; CHECK-NEXT: - ElemType: ANYFUNC +; CHECK-NEXT: Limits: +; CHECK-NEXT: Flags: [ HAS_MAX ] +; CHECK-NEXT: Initial: 0x00000001 +; CHECK-NEXT: Maximum: 0x00000001 +; CHECK-NEXT: - Type: MEMORY +; CHECK-NEXT: Memories: +; CHECK-NEXT: - Initial: 0x00000002 +; CHECK-NEXT: - Type: GLOBAL +; CHECK-NEXT: Globals: +; CHECK-NEXT: - Type: I32 +; CHECK-NEXT: Mutable: true +; CHECK-NEXT: InitExpr: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 66576 +; CHECK-NEXT: - Type: EXPORT +; CHECK-NEXT: Exports: +; CHECK-NEXT: - Name: memory +; CHECK-NEXT: Kind: MEMORY +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: - Name: _start +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 1 +; CHECK-NEXT: - Type: CODE +; CHECK-NEXT: Functions: +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 41020B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 41010B +; CHECK-NEXT: - Type: DATA +; CHECK-NEXT: Segments: +; CHECK-NEXT: - SectionOffset: 7 +; CHECK-NEXT: MemoryIndex: 0 +; CHECK-NEXT: Offset: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 1024 +; CHECK-NEXT: Content: '0100000003000000' +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: linking +; CHECK-NEXT: DataSize: 8 +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: name +; CHECK-NEXT: FunctionNames: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: Name: baz +; CHECK-NEXT: - Index: 1 +; CHECK-NEXT: Name: _start +; CHECK-NEXT: ... diff --git a/test/wasm/many-functions.ll b/test/wasm/many-functions.ll new file mode 100644 index 000000000000..77326d739a8b --- /dev/null +++ b/test/wasm/many-functions.ll @@ -0,0 +1,695 @@ +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %p/Inputs/many-funcs.ll -o %t.many.o +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %s -o %t.o +; RUN: lld -flavor wasm -r -o %t.wasm %t.many.o %t.o +; RUN: obj2yaml %t.wasm | FileCheck %s + +; Test that relocations within the CODE section correctly handle +; linking object with different header sizes. many-funcs.ll has +; 128 function and so the final output requires a 2-byte LEB in +; the CODE section header to store the function count. + +define i32 @func() { +entry: + %call = tail call i32 @func() + ret i32 %call +} + +; CHECK: - Type: CODE +; CHECK-NEXT: Relocations: +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000008 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000014 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000020 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000002C +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000038 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000044 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000050 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000005C +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000068 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000074 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000080 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000008C +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000098 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000000A4 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000000B0 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000000BC +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000000C8 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000000D4 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000000E0 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000000EC +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000000F8 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000104 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000110 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000011C +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000128 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000134 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000140 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000014C +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000158 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000164 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000170 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000017C +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000188 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000194 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000001A0 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000001AC +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000001B8 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000001C4 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000001D0 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000001DC +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000001E8 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000001F4 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000200 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000020C +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000218 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000224 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000230 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000023C +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000248 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000254 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000260 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000026C +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000278 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000284 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000290 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000029C +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000002A8 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000002B4 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000002C0 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000002CC +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000002D8 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000002E4 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000002F0 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000002FC +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000308 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000314 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000320 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000032C +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000338 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000344 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000350 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000035C +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000368 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000374 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000380 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000038C +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000398 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000003A4 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000003B0 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000003BC +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000003C8 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000003D4 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000003E0 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000003EC +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000003F8 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000404 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000410 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000041C +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000428 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000434 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000440 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000044C +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000458 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000464 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000470 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000047C +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000488 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000494 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000004A0 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000004AC +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000004B8 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000004C4 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000004D0 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000004DC +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000004E8 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000004F4 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000500 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000050C +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000518 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000524 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000530 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000053C +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000548 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000554 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000560 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000056C +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000578 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000584 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000590 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000059C +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000005A8 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000005B4 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000005C0 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000005CC +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000005D8 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000005E4 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x000005F0 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Offset: 0x000005FC +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_LEB +; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Offset: 0x00000608 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB +; CHECK-NEXT: Index: 129 +; CHECK-NEXT: Offset: 0x00000611 +; CHECK-NEXT: Functions: +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280284808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280280808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4100280280808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 1081818080000B +; CHECK-NEXT: - Type: DATA +; CHECK-NEXT: Segments: +; CHECK-NEXT: - SectionOffset: 6 +; CHECK-NEXT: MemoryIndex: 0 +; CHECK-NEXT: Offset: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 0 +; CHECK-NEXT: Content: '01000000' +; CHECK-NEXT: - SectionOffset: 15 +; CHECK-NEXT: MemoryIndex: 0 +; CHECK-NEXT: Offset: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 4 +; CHECK-NEXT: Content: '01000000' +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: linking +; CHECK-NEXT: DataSize: 8 +; CHECK-NEXT: SegmentInfo: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: Name: .data.g0 +; CHECK-NEXT: Alignment: 4 +; CHECK-NEXT: Flags: [ ] +; CHECK-NEXT: - Index: 1 +; CHECK-NEXT: Name: .data.foo +; CHECK-NEXT: Alignment: 4 +; CHECK-NEXT: Flags: [ ] diff --git a/test/wasm/relocatable.ll b/test/wasm/relocatable.ll new file mode 100644 index 000000000000..cb86aa20cab2 --- /dev/null +++ b/test/wasm/relocatable.ll @@ -0,0 +1,194 @@ +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %p/Inputs/hello.ll -o %t.hello.o +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %s -o %t.o +; RUN: lld -flavor wasm -r -o %t.wasm %t.hello.o %t.o +; RUN: obj2yaml %t.wasm | FileCheck %s + +; Function Attrs: nounwind +define hidden i32 @my_func() local_unnamed_addr { +entry: + %call = tail call i32 @foo_import() + ret i32 1 +} + +declare i32 @foo_import() local_unnamed_addr +@data_import = external global i64 + +@func_addr1 = hidden global i32()* @my_func, align 4 +@func_addr2 = hidden global i32()* @foo_import, align 4 +@data_addr1 = hidden global i64* @data_import, align 8 + +; CHECK: --- !WASM +; CHECK-NEXT: FileHeader: +; CHECK-NEXT: Version: 0x00000001 +; CHECK-NEXT: Sections: +; CHECK-NEXT: - Type: TYPE +; CHECK-NEXT: Signatures: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: ReturnType: NORESULT +; CHECK-NEXT: ParamTypes: +; CHECK-NEXT: - Index: 1 +; CHECK-NEXT: ReturnType: NORESULT +; CHECK-NEXT: ParamTypes: +; CHECK-NEXT: - I32 +; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ParamTypes: +; CHECK-NEXT: - Type: IMPORT +; CHECK-NEXT: Imports: +; CHECK-NEXT: - Module: env +; CHECK-NEXT: Field: puts +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: SigIndex: 1 +; CHECK-NEXT: - Module: env +; CHECK-NEXT: Field: foo_import +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: SigIndex: 2 +; CHECK-NEXT: - Module: env +; CHECK-NEXT: Field: data_import +; CHECK-NEXT: Kind: GLOBAL +; CHECK-NEXT: GlobalType: I32 +; CHECK-NEXT: GlobalMutable: false +; CHECK-NEXT: - Type: FUNCTION +; CHECK-NEXT: FunctionTypes: [ 0, 2 ] +; CHECK-NEXT: - Type: TABLE +; CHECK-NEXT: Tables: +; CHECK-NEXT: - ElemType: ANYFUNC +; CHECK-NEXT: Limits: +; CHECK-NEXT: Flags: [ HAS_MAX ] +; CHECK-NEXT: Initial: 0x00000002 +; CHECK-NEXT: Maximum: 0x00000002 +; CHECK-NEXT: - Type: MEMORY +; CHECK-NEXT: Memories: +; CHECK-NEXT: - Initial: 0x00000001 +; CHECK-NEXT: - Type: GLOBAL +; CHECK-NEXT: Globals: +; CHECK-NEXT: - Type: I32 +; CHECK-NEXT: Mutable: false +; CHECK-NEXT: InitExpr: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 0 +; CHECK-NEXT: - Type: I32 +; CHECK-NEXT: Mutable: false +; CHECK-NEXT: InitExpr: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 8 +; CHECK-NEXT: - Type: I32 +; CHECK-NEXT: Mutable: false +; CHECK-NEXT: InitExpr: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 12 +; CHECK-NEXT: - Type: I32 +; CHECK-NEXT: Mutable: false +; CHECK-NEXT: InitExpr: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 16 +; CHECK-NEXT: - Type: EXPORT +; CHECK-NEXT: Exports: +; CHECK-NEXT: - Name: hello +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 2 +; CHECK-NEXT: - Name: my_func +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 3 +; CHECK-NEXT: - Name: hello_str +; CHECK-NEXT: Kind: GLOBAL +; CHECK-NEXT: Index: 1 +; CHECK-NEXT: - Name: func_addr1 +; CHECK-NEXT: Kind: GLOBAL +; CHECK-NEXT: Index: 2 +; CHECK-NEXT: - Name: func_addr2 +; CHECK-NEXT: Kind: GLOBAL +; CHECK-NEXT: Index: 3 +; CHECK-NEXT: - Name: data_addr1 +; CHECK-NEXT: Kind: GLOBAL +; CHECK-NEXT: Index: 4 +; CHECK-NEXT: - Type: ELEM +; CHECK-NEXT: Segments: +; CHECK-NEXT: - Offset: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 0 +; CHECK-NEXT: Functions: [ 3, 1 ] +; CHECK-NEXT: - Type: CODE +; CHECK-NEXT: Relocations: +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_SLEB +; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Offset: 0x00000004 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x0000000A +; CHECK-NEXT: - Type: R_WEBASSEMBLY_FUNCTION_INDEX_LEB +; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Offset: 0x00000013 +; CHECK-NEXT: Functions: +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4180808080001080808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 1081808080001A41010B +; CHECK-NEXT: - Type: DATA +; CHECK-NEXT: Relocations: +; CHECK-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_I32 +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000012 +; CHECK-NEXT: - Type: R_WEBASSEMBLY_TABLE_INDEX_I32 +; CHECK-NEXT: Index: 1 +; CHECK-NEXT: Offset: 0x0000001B +; CHECK-NEXT: - Type: R_WEBASSEMBLY_MEMORY_ADDR_I32 +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000024 +; CHECK-NEXT: Segments: +; CHECK-NEXT: - SectionOffset: 6 +; CHECK-NEXT: MemoryIndex: 0 +; CHECK-NEXT: Offset: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 0 +; CHECK-NEXT: Content: 68656C6C6F0A00 +; CHECK-NEXT: - SectionOffset: 18 +; CHECK-NEXT: MemoryIndex: 0 +; CHECK-NEXT: Offset: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 8 +; CHECK-NEXT: Content: '00000000' +; CHECK-NEXT: - SectionOffset: 27 +; CHECK-NEXT: MemoryIndex: 0 +; CHECK-NEXT: Offset: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 12 +; CHECK-NEXT: Content: '01000000' +; CHECK-NEXT: - SectionOffset: 36 +; CHECK-NEXT: MemoryIndex: 0 +; CHECK-NEXT: Offset: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 16 +; CHECK-NEXT: Content: FFFFFFFF +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: linking +; CHECK-NEXT: DataSize: 20 +; CHECK-NEXT: SegmentInfo: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: Name: .rodata.hello_str +; CHECK-NEXT: Alignment: 1 +; CHECK-NEXT: Flags: [ ] +; CHECK-NEXT: - Index: 1 +; CHECK-NEXT: Name: .data.func_addr1 +; CHECK-NEXT: Alignment: 4 +; CHECK-NEXT: Flags: [ ] +; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: Name: .data.func_addr2 +; CHECK-NEXT: Alignment: 4 +; CHECK-NEXT: Flags: [ ] +; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: Name: .data.data_addr1 +; CHECK-NEXT: Alignment: 8 +; CHECK-NEXT: Flags: [ ] +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: name +; CHECK-NEXT: FunctionNames: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: Name: puts +; CHECK-NEXT: - Index: 1 +; CHECK-NEXT: Name: foo_import +; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: Name: hello +; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: Name: my_func +; CHECK-NEXT: ... diff --git a/test/wasm/signature-mismatch.ll b/test/wasm/signature-mismatch.ll new file mode 100644 index 000000000000..88f70fea5123 --- /dev/null +++ b/test/wasm/signature-mismatch.ll @@ -0,0 +1,16 @@ +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %p/Inputs/ret32.ll -o %t.ret32.o +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %s -o %t.main.o +; RUN: not lld -flavor wasm --check-signatures -o %t.wasm %t.main.o %t.ret32.o 2>&1 | FileCheck %s + +; Function Attrs: nounwind +define hidden void @_start() local_unnamed_addr #0 { +entry: + %call = tail call i32 @ret32(i32 1, i64 2, i32 3) #2 + ret void +} + +declare i32 @ret32(i32, i64, i32) local_unnamed_addr #1 + +; CHECK: error: function signature mismatch: ret32 +; CHECK-NEXT: >>> defined as (I32, I64, I32) -> I32 in {{.*}}.main.o +; CHECK-NEXT: >>> defined as (F32) -> I32 in {{.*}}.ret32.o diff --git a/test/wasm/stack-pointer.ll b/test/wasm/stack-pointer.ll new file mode 100644 index 000000000000..738f0dce8e81 --- /dev/null +++ b/test/wasm/stack-pointer.ll @@ -0,0 +1,64 @@ +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %s -o %t.o +; RUN: lld -flavor wasm --emit-relocs -o %t.wasm %t.o +; RUN: obj2yaml %t.wasm | FileCheck %s + +; Function Attrs: nounwind +define hidden i32 @_start() local_unnamed_addr { +entry: + %retval = alloca i32, align 4 + ret i32 0 +} + +; CHECK: --- !WASM +; CHECK-NEXT: FileHeader: +; CHECK-NEXT: Version: 0x00000001 +; CHECK-NEXT: Sections: +; CHECK-NEXT: - Type: TYPE +; CHECK-NEXT: Signatures: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ParamTypes: +; CHECK-NEXT: - Type: FUNCTION +; CHECK-NEXT: FunctionTypes: [ 0 ] +; CHECK-NEXT: - Type: TABLE +; CHECK-NEXT: Tables: +; CHECK-NEXT: - ElemType: ANYFUNC +; CHECK-NEXT: Limits: +; CHECK-NEXT: Flags: [ HAS_MAX ] +; CHECK-NEXT: Initial: 0x00000001 +; CHECK-NEXT: Maximum: 0x00000001 +; CHECK-NEXT: - Type: MEMORY +; CHECK-NEXT: Memories: +; CHECK-NEXT: - Initial: 0x00000002 +; CHECK-NEXT: - Type: GLOBAL +; CHECK-NEXT: Globals: +; CHECK-NEXT: - Type: I32 +; CHECK-NEXT: Mutable: true +; CHECK-NEXT: InitExpr: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 66560 +; CHECK-NEXT: - Type: EXPORT +; CHECK-NEXT: Exports: +; CHECK-NEXT: - Name: memory +; CHECK-NEXT: Kind: MEMORY +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: - Name: _start +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: - Type: CODE +; CHECK-NEXT: Relocations: +; CHECK-NEXT: - Type: R_WEBASSEMBLY_GLOBAL_INDEX_LEB +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: Offset: 0x00000004 +; CHECK-NEXT: Functions: +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 23808080800041106B1A41000B +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: linking +; CHECK-NEXT: DataSize: 0 +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: name +; CHECK-NEXT: FunctionNames: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: Name: _start +; CHECK-NEXT: ... diff --git a/test/wasm/strip-debug.test b/test/wasm/strip-debug.test new file mode 100644 index 000000000000..57667a9f4406 --- /dev/null +++ b/test/wasm/strip-debug.test @@ -0,0 +1,6 @@ +RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %p/Inputs/ret32.ll -o %t.ret32.o +RUN: lld -flavor wasm --strip-debug --entry=ret32 -o %t.wasm %t.ret32.o +RUN: obj2yaml %t.wasm | FileCheck %s + +# Check that there is no name section +CHECK-NOT: Name: name diff --git a/test/wasm/symbol-type-mismatch.ll b/test/wasm/symbol-type-mismatch.ll new file mode 100644 index 000000000000..706a361dd767 --- /dev/null +++ b/test/wasm/symbol-type-mismatch.ll @@ -0,0 +1,9 @@ +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %s -o %t.o +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %p/Inputs/ret32.ll -o %t.ret32.o +; RUN: not lld -flavor wasm -o %t.wasm %t.o %t.ret32.o 2>&1 | FileCheck %s + +@ret32 = extern_weak global i32, align 4 + +; CHECK: error: symbol type mismatch: ret32 +; CHECK: >>> defined as Global in {{.*}}symbol-type-mismatch.ll.tmp.o +; CHECK: >>> defined as Function in {{.*}}.ret32.o diff --git a/test/wasm/undefined-entry.test b/test/wasm/undefined-entry.test new file mode 100644 index 000000000000..00a0761f4b6c --- /dev/null +++ b/test/wasm/undefined-entry.test @@ -0,0 +1,4 @@ +RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %p/Inputs/ret32.ll -o %t.ret32.o +RUN: not lld -flavor wasm -o %t.wasm %t.ret32.o 2>&1 | FileCheck %s + +CHECK: error: undefined symbol: _start diff --git a/test/wasm/undefined.ll b/test/wasm/undefined.ll new file mode 100644 index 000000000000..c5f266431702 --- /dev/null +++ b/test/wasm/undefined.ll @@ -0,0 +1,20 @@ +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %s -o %t.o +; RUN: lld -flavor wasm --allow-undefined -o %t.wasm %t.o + +; Fails due to undefined 'foo' +; RUN: not lld -flavor wasm -o %t.wasm %t.o 2>&1 | FileCheck %s +; CHECK: error: {{.*}}.o: undefined symbol: foo + +; But succeeds if we pass a file containing 'foo' as --allow-undefined-file. +; RUN: echo 'foo' > %t.txt +; RUN: lld -flavor wasm --allow-undefined-file=%t.txt -o %t.wasm %t.o + +; Takes the address of the external foo() resulting in undefined external +@bar = hidden local_unnamed_addr global i8* bitcast (i32 ()* @foo to i8*), align 4 + +declare i32 @foo() #0 + +define hidden void @_start() local_unnamed_addr #0 { +entry: + ret void +} diff --git a/test/wasm/version.ll b/test/wasm/version.ll new file mode 100644 index 000000000000..aed7b39ff3b9 --- /dev/null +++ b/test/wasm/version.ll @@ -0,0 +1,13 @@ +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %s -o %t.o +; RUN: lld -flavor wasm -o %t.wasm %t.o +; RUN: llvm-readobj -file-headers %t.wasm | FileCheck %s + +define hidden void @_start() local_unnamed_addr #0 { +entry: + ret void +} + +; CHECK: Format: WASM +; CHECK: Arch: wasm32 +; CHECK: AddressSize: 32bit +; CHECK: Version: 0x1 diff --git a/test/wasm/visibility-hidden.ll b/test/wasm/visibility-hidden.ll new file mode 100644 index 000000000000..9960b952492b --- /dev/null +++ b/test/wasm/visibility-hidden.ll @@ -0,0 +1,46 @@ +; RUN: llc -mtriple=wasm32-unknown-unknown-wasm -filetype=obj -o %t.o %s +; RUN: llc -mtriple=wasm32-unknown-unknown-wasm -filetype=obj %S/Inputs/hidden.ll -o %t2.o +; RUN: llvm-ar rcs %t2.a %t2.o +; RUN: lld -flavor wasm %t.o %t2.a -o %t.wasm +; RUN: obj2yaml %t.wasm | FileCheck %s + +; Test that hidden symbols are not exported, whether pulled in from an archive +; or directly. + +define hidden i32 @objectHidden() { +entry: + ret i32 0 +} + +define i32 @objectDefault() { +entry: + ret i32 0 +} + +declare i32 @archiveHidden() +declare i32 @archiveDefault() + +define i32 @_start() { +entry: + %call1 = call i32 @objectHidden() + %call2 = call i32 @objectDefault() + %call3 = call i32 @archiveHidden() + %call4 = call i32 @archiveDefault() + ret i32 0 +} + +; CHECK: - Type: EXPORT +; CHECK-NEXT: Exports: +; CHECK-NEXT: - Name: memory +; CHECK-NEXT: Kind: MEMORY +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: - Name: _start +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 2 +; CHECK-NEXT: - Name: archiveDefault +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 4 +; CHECK-NEXT: - Name: objectDefault +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 1 +; CHECK-NEXT: - Type: diff --git a/test/wasm/weak-alias-overide.ll b/test/wasm/weak-alias-overide.ll new file mode 100644 index 000000000000..5f4021e18b0f --- /dev/null +++ b/test/wasm/weak-alias-overide.ll @@ -0,0 +1,92 @@ +; RUN: llc -mtriple wasm32-unknown-unknown-wasm -filetype=obj -o %t.o %s +; RUN: llc -mtriple=wasm32-unknown-unknown-wasm -filetype=obj %S/Inputs/weak-alias.ll -o %t2.o +; RUN: lld -flavor wasm %t.o %t2.o -o %t.wasm +; RUN: obj2yaml %t.wasm | FileCheck %s + +; Test that the strongly defined bar is used correctly despite the existence +; of the weak alias + +define i32 @bar() local_unnamed_addr #1 { + ret i32 1 +} + +; Function Attrs: nounwind uwtable +define void @_start() local_unnamed_addr #1 { +entry: + %call = tail call i32 @bar() #2 + ret void +} + +; CHECK: --- !WASM +; CHECK-NEXT: FileHeader: +; CHECK-NEXT: Version: 0x00000001 +; CHECK-NEXT: Sections: +; CHECK-NEXT: - Type: TYPE +; CHECK-NEXT: Signatures: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ParamTypes: +; CHECK-NEXT: - Index: 1 +; CHECK-NEXT: ReturnType: NORESULT +; CHECK-NEXT: ParamTypes: +; CHECK-NEXT: - Type: FUNCTION +; CHECK-NEXT: FunctionTypes: [ 0, 1, 0, 0 ] +; CHECK-NEXT: - Type: TABLE +; CHECK-NEXT: Tables: +; CHECK-NEXT: - ElemType: ANYFUNC +; CHECK-NEXT: Limits: +; CHECK-NEXT: Flags: [ HAS_MAX ] +; CHECK-NEXT: Initial: 0x00000001 +; CHECK-NEXT: Maximum: 0x00000001 +; CHECK-NEXT: - Type: MEMORY +; CHECK-NEXT: Memories: +; CHECK-NEXT: - Initial: 0x00000002 +; CHECK-NEXT: - Type: GLOBAL +; CHECK-NEXT: Globals: +; CHECK-NEXT: - Type: I32 +; CHECK-NEXT: Mutable: true +; CHECK-NEXT: InitExpr: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 66560 +; CHECK-NEXT: - Type: EXPORT +; CHECK-NEXT: Exports: +; CHECK-NEXT: - Name: memory +; CHECK-NEXT: Kind: MEMORY +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: - Name: _start +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 1 +; CHECK-NEXT: - Name: bar +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: - Name: foo +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 2 +; CHECK-NEXT: - Name: call_bar +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 3 +; CHECK-NEXT: - Type: CODE +; CHECK-NEXT: Functions: +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 41010B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 1080808080001A0B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 41000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 1080808080000B +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: linking +; CHECK-NEXT: DataSize: 0 +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: name +; CHECK-NEXT: FunctionNames: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: Name: bar +; CHECK-NEXT: - Index: 1 +; CHECK-NEXT: Name: _start +; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: Name: foo +; CHECK-NEXT: - Index: 3 +; CHECK-NEXT: Name: call_bar +; CHECK-NEXT: ... diff --git a/test/wasm/weak-alias.ll b/test/wasm/weak-alias.ll new file mode 100644 index 000000000000..6f96d4d17643 --- /dev/null +++ b/test/wasm/weak-alias.ll @@ -0,0 +1,82 @@ +; RUN: llc -mtriple wasm32-unknown-unknown-wasm -filetype=obj -o %t.o %s +; RUN: llc -mtriple=wasm32-unknown-unknown-wasm -filetype=obj %S/Inputs/weak-alias.ll -o %t2.o +; RUN: lld -flavor wasm %t.o %t2.o -o %t.wasm +; RUN: obj2yaml %t.wasm | FileCheck %s + +; Test that weak aliases (bar is a weak alias of foo) are linked correctly + +declare i32 @bar() local_unnamed_addr #1 + +; Function Attrs: nounwind uwtable +define i32 @_start() local_unnamed_addr #1 { +entry: + %call = tail call i32 @bar() #2 + ret i32 %call +} + +; CHECK: --- !WASM +; CHECK-NEXT: FileHeader: +; CHECK-NEXT: Version: 0x00000001 +; CHECK-NEXT: Sections: +; CHECK-NEXT: - Type: TYPE +; CHECK-NEXT: Signatures: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ParamTypes: +; CHECK-NEXT: - Type: FUNCTION +; CHECK-NEXT: FunctionTypes: [ 0, 0, 0 ] +; CHECK-NEXT: - Type: TABLE +; CHECK-NEXT: Tables: +; CHECK-NEXT: - ElemType: ANYFUNC +; CHECK-NEXT: Limits: +; CHECK-NEXT: Flags: [ HAS_MAX ] +; CHECK-NEXT: Initial: 0x00000001 +; CHECK-NEXT: Maximum: 0x00000001 +; CHECK-NEXT: - Type: MEMORY +; CHECK-NEXT: Memories: +; CHECK-NEXT: - Initial: 0x00000002 +; CHECK-NEXT: - Type: GLOBAL +; CHECK-NEXT: Globals: +; CHECK-NEXT: - Type: I32 +; CHECK-NEXT: Mutable: true +; CHECK-NEXT: InitExpr: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 66560 +; CHECK-NEXT: - Type: EXPORT +; CHECK-NEXT: Exports: +; CHECK-NEXT: - Name: memory +; CHECK-NEXT: Kind: MEMORY +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: - Name: _start +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: - Name: bar +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 1 +; CHECK-NEXT: - Name: foo +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 1 +; CHECK-NEXT: - Name: call_bar +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 2 +; CHECK-NEXT: - Type: CODE +; CHECK-NEXT: Functions: +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 1081808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 41000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 1081808080000B +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: linking +; CHECK-NEXT: DataSize: 0 +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: name +; CHECK-NEXT: FunctionNames: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: Name: _start +; CHECK-NEXT: - Index: 1 +; CHECK-NEXT: Name: foo +; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: Name: call_bar +; CHECK-NEXT: ... diff --git a/test/wasm/weak-external.ll b/test/wasm/weak-external.ll new file mode 100644 index 000000000000..891f7666ec76 --- /dev/null +++ b/test/wasm/weak-external.ll @@ -0,0 +1,86 @@ +; RUN: llc -mtriple wasm32-unknown-unknown-wasm -filetype=obj -o %t.o %s +; RUN: lld -flavor wasm -strip-debug %t.o -o %t.wasm +; RUN: obj2yaml %t.wasm | FileCheck %s + +; Test that undefined weak externals (global_var) and (foo) don't cause +; link failures and resolve to zero. + +@global_var = extern_weak global i32, align 4 + +declare extern_weak i32 @foo() + +define i8* @get_address_of_foo() #0 { +entry: + ret i8* bitcast (i32 ()* @foo to i8*) +} + +define i32* @get_address_of_global_var() #0 { + ret i32* @global_var +} + +define i32 @_start() #0 { +entry: + %0 = load i32, i32* @global_var, align 4 + ret i32 %0 +} + +; CHECK: --- !WASM +; CHECK-NEXT: FileHeader: +; CHECK-NEXT: Version: 0x00000001 +; CHECK-NEXT: Sections: +; CHECK-NEXT: - Type: TYPE +; CHECK-NEXT: Signatures: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ParamTypes: +; CHECK-NEXT: - Type: FUNCTION +; CHECK-NEXT: FunctionTypes: [ 0, 0, 0 ] +; CHECK-NEXT: - Type: TABLE +; CHECK-NEXT: Tables: +; CHECK-NEXT: - ElemType: ANYFUNC +; CHECK-NEXT: Limits: +; CHECK-NEXT: Flags: [ HAS_MAX ] +; CHECK-NEXT: Initial: 0x00000002 +; CHECK-NEXT: Maximum: 0x00000002 +; CHECK-NEXT: - Type: MEMORY +; CHECK-NEXT: Memories: +; CHECK-NEXT: - Initial: 0x00000002 +; CHECK-NEXT: - Type: GLOBAL +; CHECK-NEXT: Globals: +; CHECK-NEXT: - Type: I32 +; CHECK-NEXT: Mutable: true +; CHECK-NEXT: InitExpr: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 66560 +; CHECK-NEXT: - Type: EXPORT +; CHECK-NEXT: Exports: +; CHECK-NEXT: - Name: memory +; CHECK-NEXT: Kind: MEMORY +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: - Name: _start +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 2 +; CHECK-NEXT: - Name: get_address_of_foo +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: - Name: get_address_of_global_var +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 1 +; CHECK-NEXT: - Type: ELEM +; CHECK-NEXT: Segments: +; CHECK-NEXT: - Offset: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 1 +; CHECK-NEXT: Functions: [ 0 ] +; CHECK-NEXT: - Type: CODE +; CHECK-NEXT: Functions: +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4181808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 41FFFFFFFF7F0B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 41002802FFFFFFFF0F0B +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: linking +; CHECK-NEXT: DataSize: 0 +; CHECK-NEXT: ... diff --git a/test/wasm/weak-symbols.ll b/test/wasm/weak-symbols.ll new file mode 100644 index 000000000000..c282d005623f --- /dev/null +++ b/test/wasm/weak-symbols.ll @@ -0,0 +1,93 @@ +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %p/Inputs/weak-symbol1.ll -o %t1.o +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %p/Inputs/weak-symbol2.ll -o %t2.o +; RUN: llc -filetype=obj -mtriple=wasm32-unknown-uknown-wasm %s -o %t.o +; RUN: lld -flavor wasm -o %t.wasm %t.o %t1.o %t2.o +; RUN: obj2yaml %t.wasm | FileCheck %s + +declare i32 @weakFn() local_unnamed_addr + +define void @_start() local_unnamed_addr { +entry: + %call = call i32 @weakFn() + ret void +} + +; CHECK: --- !WASM +; CHECK-NEXT: FileHeader: +; CHECK-NEXT: Version: 0x00000001 +; CHECK-NEXT: Sections: +; CHECK-NEXT: - Type: TYPE +; CHECK-NEXT: Signatures: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: ReturnType: NORESULT +; CHECK-NEXT: ParamTypes: +; CHECK-NEXT: - Index: 1 +; CHECK-NEXT: ReturnType: I32 +; CHECK-NEXT: ParamTypes: +; CHECK-NEXT: - Type: FUNCTION +; CHECK-NEXT: FunctionTypes: [ 0, 1, 1, 1, 1 ] +; CHECK-NEXT: - Type: TABLE +; CHECK-NEXT: Tables: +; CHECK-NEXT: - ElemType: ANYFUNC +; CHECK-NEXT: Limits: +; CHECK-NEXT: Flags: [ HAS_MAX ] +; CHECK-NEXT: Initial: 0x00000002 +; CHECK-NEXT: Maximum: 0x00000002 +; CHECK-NEXT: - Type: MEMORY +; CHECK-NEXT: Memories: +; CHECK-NEXT: - Initial: 0x00000002 +; CHECK-NEXT: - Type: GLOBAL +; CHECK-NEXT: Globals: +; CHECK-NEXT: - Type: I32 +; CHECK-NEXT: Mutable: true +; CHECK-NEXT: InitExpr: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 66560 +; CHECK-NEXT: - Type: EXPORT +; CHECK-NEXT: Exports: +; CHECK-NEXT: - Name: memory +; CHECK-NEXT: Kind: MEMORY +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: - Name: _start +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 0 +; CHECK-NEXT: - Name: weakFn +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 1 +; CHECK-NEXT: - Name: exportWeak1 +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 2 +; CHECK-NEXT: - Name: exportWeak2 +; CHECK-NEXT: Kind: FUNCTION +; CHECK-NEXT: Index: 4 +; CHECK-NEXT: - Type: ELEM +; CHECK-NEXT: Segments: +; CHECK-NEXT: - Offset: +; CHECK-NEXT: Opcode: I32_CONST +; CHECK-NEXT: Value: 1 +; CHECK-NEXT: Functions: [ 1 ] +; CHECK-NEXT: - Type: CODE +; CHECK-NEXT: Functions: +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 1081808080001A0B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 41010B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4181808080000B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 41020B +; CHECK-NEXT: - Locals: +; CHECK-NEXT: Body: 4181808080000B +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: linking +; CHECK-NEXT: DataSize: 0 +; CHECK-NEXT: - Type: CUSTOM +; CHECK-NEXT: Name: name +; CHECK-NEXT: FunctionNames: +; CHECK-NEXT: - Index: 0 +; CHECK-NEXT: Name: _start +; CHECK-NEXT: - Index: 2 +; CHECK-NEXT: Name: exportWeak1 +; CHECK-NEXT: - Index: 4 +; CHECK-NEXT: Name: exportWeak2 +; CHECK-NEXT: ... |