diff options
Diffstat (limited to 'lld/test')
78 files changed, 1141 insertions, 277 deletions
diff --git a/lld/test/COFF/Inputs/manifest-uac.test b/lld/test/COFF/Inputs/manifest-uac.test new file mode 100644 index 0000000..5269339 --- /dev/null +++ b/lld/test/COFF/Inputs/manifest-uac.test @@ -0,0 +1,11 @@ +<?xml version='1.0' encoding='UTF-8' standalone='yes'?> +<assembly xmlns='urn:schemas-microsoft-com:asm.v1' manifestVersion='1.0'> + <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> + <security> + <requestedPrivileges> + <requestedExecutionLevel level='asInvoker' + uiAccess='false'/> + </requestedPrivileges> + </security> + </trustInfo> +</assembly> diff --git a/lld/test/COFF/arm64ec-codemap.test b/lld/test/COFF/arm64ec-codemap.test index 0502611..bbc682d 100644 --- a/lld/test/COFF/arm64ec-codemap.test +++ b/lld/test/COFF/arm64ec-codemap.test @@ -7,6 +7,7 @@ RUN: llvm-mc -filetype=obj -triple=arm64ec-windows arm64ec-func-sym2.s -o arm64e RUN: llvm-mc -filetype=obj -triple=arm64ec-windows data-sec.s -o data-sec.obj RUN: llvm-mc -filetype=obj -triple=arm64ec-windows data-sec2.s -o data-sec2.obj RUN: llvm-mc -filetype=obj -triple=arm64ec-windows empty-sec.s -o arm64ec-empty-sec.obj +RUN: llvm-mc -filetype=obj -triple=arm64ec-windows entry-thunk.s -o entry-thunk.obj RUN: llvm-mc -filetype=obj -triple=x86_64-windows x86_64-func-sym.s -o x86_64-func-sym.obj RUN: llvm-mc -filetype=obj -triple=x86_64-windows empty-sec.s -o x86_64-empty-sec.obj RUN: llvm-mc -filetype=obj -triple=aarch64-windows %S/Inputs/loadconfig-arm64.s -o loadconfig-arm64.obj @@ -162,15 +163,17 @@ RUN: loadconfig-arm64ec.obj -dll -noentry -merge:test=.testdata -merge: RUN: llvm-readobj --coff-load-config testcm.dll | FileCheck -check-prefix=CODEMAPCM %s CODEMAPCM: CodeMap [ -CODEMAPCM-NEXT: 0x4008 - 0x4016 X64 +CODEMAPCM-NEXT: 0x4000 - 0x4016 X64 CODEMAPCM-NEXT: ] RUN: llvm-objdump -d testcm.dll | FileCheck -check-prefix=DISASMCM %s DISASMCM: Disassembly of section .testdat: DISASMCM-EMPTY: DISASMCM-NEXT: 0000000180004000 <.testdat>: -DISASMCM-NEXT: 180004000: 00000001 udf #0x1 -DISASMCM-NEXT: 180004004: 00000000 udf #0x0 +DISASMCM-NEXT: 180004000: 01 00 addl %eax, (%rax) +DISASMCM-NEXT: 180004002: 00 00 addb %al, (%rax) +DISASMCM-NEXT: 180004004: 00 00 addb %al, (%rax) +DISASMCM-NEXT: 180004006: 00 00 addb %al, (%rax) DISASMCM-NEXT: 180004008: b8 03 00 00 00 movl $0x3, %eax DISASMCM-NEXT: 18000400d: c3 retq DISASMCM-NEXT: 18000400e: 00 00 addb %al, (%rax) @@ -207,6 +210,14 @@ DISASMMS-NEXT: 0000000180006000 <test2>: DISASMMS-NEXT: 180006000: 528000a0 mov w0, #0x5 // =5 DISASMMS-NEXT: 180006004: d65f03c0 ret +Test the code map that includes an ARM64EC function padded by its entry-thunk offset. + +RUN: lld-link -out:testpad.dll -machine:arm64ec entry-thunk.obj loadconfig-arm64ec.obj -dll -noentry -include:func +RUN: llvm-readobj --coff-load-config testpad.dll | FileCheck -check-prefix=CODEMAPPAD %s +CODEMAPPAD: CodeMap [ +CODEMAPPAD: 0x1000 - 0x1010 ARM64EC +CODEMAPPAD-NEXT: ] + #--- arm64-func-sym.s .text @@ -266,3 +277,22 @@ x86_64_func_sym2: .section .empty1, "xr" .section .empty2, "xr" .section .empty3, "xr" + +#--- entry-thunk.s + .section .text,"xr",discard,func + .globl func + .p2align 2, 0x0 +func: + mov w0, #1 + ret + + .section .wowthk$aa,"xr",discard,thunk + .globl thunk + .p2align 2 +thunk: + ret + + .section .hybmp$x,"yi" + .symidx func + .symidx thunk + .word 1 // entry thunk diff --git a/lld/test/COFF/driver.test b/lld/test/COFF/driver.test index 8f58ff4..1c265bf 100644 --- a/lld/test/COFF/driver.test +++ b/lld/test/COFF/driver.test @@ -17,6 +17,9 @@ LIBHELP: OVERVIEW: LLVM Lib # RUN: env LLD_IN_TEST=1 not lld-link /WX /lib 2>&1 | FileCheck -check-prefix=LIBBAD %s LIBBAD: ignoring /lib since it's not the first argument +# RUN: env LLD_IN_TEST=1 not lld-link /link 2>&1 | FileCheck -check-prefix=LINKBAD %s +LINKBAD: ignoring /link, did you pass it multiple times? + # RUN: yaml2obj %p/Inputs/hello32.yaml -o %t.obj # RUN: not lld-link /out:/ %t.obj 2>&1 | FileCheck -check-prefix=DIR %s DIR: cannot open output file diff --git a/lld/test/COFF/manifest-uac.test b/lld/test/COFF/manifest-uac.test new file mode 100644 index 0000000..d3a17c7 --- /dev/null +++ b/lld/test/COFF/manifest-uac.test @@ -0,0 +1,33 @@ +# REQUIRES: libxml2 + +# RUN: yaml2obj %p/Inputs/ret42.yaml -o %t.obj +# RUN: lld-link /out:%t.exe /entry:main \ +# RUN: /manifest:embed \ +# RUN: /manifestinput:%p/Inputs/manifest-uac.test %t.obj +# RUN: llvm-readobj --coff-resources %t.exe | FileCheck %s + +CHECK: Data ( +CHECK-NEXT: 0000: 3C3F786D 6C207665 7273696F 6E3D2231 |<?xml version="1| +CHECK-NEXT: 0010: 2E302220 656E636F 64696E67 3D225554 |.0" encoding="UT| +CHECK-NEXT: 0020: 462D3822 3F3E0A3C 61737365 6D626C79 |F-8"?>.<assembly| +CHECK-NEXT: 0030: 20786D6C 6E733D22 75726E3A 73636865 | xmlns="urn:sche| +CHECK-NEXT: 0040: 6D61732D 6D696372 6F736F66 742D636F |mas-microsoft-co| +CHECK-NEXT: 0050: 6D3A6173 6D2E7631 22206D61 6E696665 |m:asm.v1" manife| +CHECK-NEXT: 0060: 73745665 7273696F 6E3D2231 2E30223E |stVersion="1.0">| +CHECK-NEXT: 0070: 0A20203C 74727573 74496E66 6F20786D |. <trustInfo xm| +CHECK-NEXT: 0080: 6C6E733D 2275726E 3A736368 656D6173 |lns="urn:schemas| +CHECK-NEXT: 0090: 2D6D6963 726F736F 66742D63 6F6D3A61 |-microsoft-com:a| +CHECK-NEXT: 00A0: 736D2E76 33223E0A 20202020 3C736563 |sm.v3">. <sec| +CHECK-NEXT: 00B0: 75726974 793E0A20 20202020 203C7265 |urity>. <re| +CHECK-NEXT: 00C0: 71756573 74656450 72697669 6C656765 |questedPrivilege| +CHECK-NEXT: 00D0: 733E0A20 20202020 2020203C 72657175 |s>. <requ| +CHECK-NEXT: 00E0: 65737465 64457865 63757469 6F6E4C65 |estedExecutionLe| +CHECK-NEXT: 00F0: 76656C20 6C657665 6C3D2261 73496E76 |vel level="asInv| +CHECK-NEXT: 0100: 6F6B6572 22207569 41636365 73733D22 |oker" uiAccess="| +CHECK-NEXT: 0110: 66616C73 65222F3E 0A202020 2020203C |false"/>. <| +CHECK-NEXT: 0120: 2F726571 75657374 65645072 6976696C |/requestedPrivil| +CHECK-NEXT: 0130: 65676573 3E0A2020 20203C2F 73656375 |eges>. </secu| +CHECK-NEXT: 0140: 72697479 3E0A2020 3C2F7472 75737449 |rity>. </trustI| +CHECK-NEXT: 0150: 6E666F3E 0A3C2F61 7373656D 626C793E |nfo>.</assembly>| +CHECK-NEXT: 0160: 0A |.| +CHECK-NEXT: ) diff --git a/lld/test/COFF/manifest.test b/lld/test/COFF/manifest.test index 4910600..09de96e 100644 --- a/lld/test/COFF/manifest.test +++ b/lld/test/COFF/manifest.test @@ -10,7 +10,7 @@ MANIFEST: <?xml version="1.0" standalone="yes"?> MANIFEST: <assembly xmlns="urn:schemas-microsoft-com:asm.v1" MANIFEST: manifestVersion="1.0"> -MANIFEST: <trustInfo> +MANIFEST: <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> MANIFEST: <security> MANIFEST: <requestedPrivileges> MANIFEST: <requestedExecutionLevel level='asInvoker' uiAccess='false'/> @@ -26,7 +26,7 @@ MANIFEST: </assembly> UAC: <?xml version="1.0" standalone="yes"?> UAC: <assembly xmlns="urn:schemas-microsoft-com:asm.v1" UAC: manifestVersion="1.0"> -UAC: <trustInfo> +UAC: <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> UAC: <security> UAC: <requestedPrivileges> UAC: <requestedExecutionLevel level='requireAdministrator' uiAccess='true'/> @@ -43,7 +43,7 @@ UAC: </assembly> DEPENDENCY: <?xml version="1.0" standalone="yes"?> DEPENDENCY: <assembly xmlns="urn:schemas-microsoft-com:asm.v1" DEPENDENCY: manifestVersion="1.0"> -DEPENDENCY: <trustInfo> +DEPENDENCY: <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> DEPENDENCY: <security> DEPENDENCY: <requestedPrivileges> DEPENDENCY: <requestedExecutionLevel level='asInvoker' uiAccess='false'/> @@ -90,7 +90,7 @@ NOUACNODEP: </assembly> SEVERALDEPS: <?xml version="1.0" standalone="yes"?> SEVERALDEPS: <assembly xmlns="urn:schemas-microsoft-com:asm.v1" SEVERALDEPS: manifestVersion="1.0"> -SEVERALDEPS: <trustInfo> +SEVERALDEPS: <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> SEVERALDEPS: <security> SEVERALDEPS: <requestedPrivileges> SEVERALDEPS: <requestedExecutionLevel level='asInvoker' uiAccess='false'/> @@ -139,31 +139,34 @@ EMBED: 0040: 6D61732D 6D696372 6F736F66 742D636F |mas-microsoft-co| EMBED: 0050: 6D3A6173 6D2E7631 220A2020 20202020 |m:asm.v1". | EMBED: 0060: 20202020 6D616E69 66657374 56657273 | manifestVers| EMBED: 0070: 696F6E3D 22312E30 223E0A20 203C7472 |ion="1.0">. <tr| -EMBED: 0080: 75737449 6E666F3E 0A202020 203C7365 |ustInfo>. <se| -EMBED: 0090: 63757269 74793E0A 20202020 20203C72 |curity>. <r| -EMBED: 00A0: 65717565 73746564 50726976 696C6567 |equestedPrivileg| -EMBED: 00B0: 65733E0A 20202020 20202020 203C7265 |es>. <re| -EMBED: 00C0: 71756573 74656445 78656375 74696F6E |questedExecution| -EMBED: 00D0: 4C657665 6C206C65 76656C3D 27617349 |Level level='asI| -EMBED: 00E0: 6E766F6B 65722720 75694163 63657373 |nvoker' uiAccess| -EMBED: 00F0: 3D276661 6C736527 2F3E0A20 20202020 |='false'/>. | -EMBED: 0100: 203C2F72 65717565 73746564 50726976 | </requestedPriv| -EMBED: 0110: 696C6567 65733E0A 20202020 3C2F7365 |ileges>. </se| -EMBED: 0120: 63757269 74793E0A 20203C2F 74727573 |curity>. </trus| -EMBED: 0130: 74496E66 6F3E0A20 203C6465 70656E64 |tInfo>. <depend| -EMBED: 0140: 656E6379 3E0A2020 20203C64 6570656E |ency>. <depen| -EMBED: 0150: 64656E74 41737365 6D626C79 3E0A2020 |dentAssembly>. | -EMBED: 0160: 20202020 3C617373 656D626C 79496465 | <assemblyIde| -EMBED: 0170: 6E746974 7920666F 6F3D2762 61722720 |ntity foo='bar' | -EMBED: 0180: 2F3E0A20 2020203C 2F646570 656E6465 |/>. </depende| -EMBED: 0190: 6E744173 73656D62 6C793E0A 20203C2F |ntAssembly>. </| -EMBED: 01A0: 64657065 6E64656E 63793E0A 20203C64 |dependency>. <d| -EMBED: 01B0: 6570656E 64656E63 793E0A20 2020203C |ependency>. <| -EMBED: 01C0: 64657065 6E64656E 74417373 656D626C |dependentAssembl| -EMBED: 01D0: 793E0A20 20202020 203C6173 73656D62 |y>. <assemb| -EMBED: 01E0: 6C794964 656E7469 74792062 617A3D27 |lyIdentity baz='| -EMBED: 01F0: 71757578 27202F3E 0A202020 203C2F64 |quux' />. </d| -EMBED: 0200: 6570656E 64656E74 41737365 6D626C79 |ependentAssembly| -EMBED: 0210: 3E0A2020 3C2F6465 70656E64 656E6379 |>. </dependency| -EMBED: 0220: 3E0A3C2F 61737365 6D626C79 3E0A |>.</assembly>.| +EMBED: 0080: 75737449 6E666F20 786D6C6E 733D2275 |ustInfo xmlns="u| +EMBED: 0090: 726E3A73 6368656D 61732D6D 6963726F |rn:schemas-micro| +EMBED: 00A0: 736F6674 2D636F6D 3A61736D 2E763322 |soft-com:asm.v3"| +EMBED: 00B0: 3E0A2020 20203C73 65637572 6974793E |>. <security>| +EMBED: 00C0: 0A202020 2020203C 72657175 65737465 |. <requeste| +EMBED: 00D0: 64507269 76696C65 6765733E 0A202020 |dPrivileges>. | +EMBED: 00E0: 20202020 20203C72 65717565 73746564 | <requested| +EMBED: 00F0: 45786563 7574696F 6E4C6576 656C206C |ExecutionLevel l| +EMBED: 0100: 6576656C 3D276173 496E766F 6B657227 |evel='asInvoker'| +EMBED: 0110: 20756941 63636573 733D2766 616C7365 | uiAccess='false| +EMBED: 0120: 272F3E0A 20202020 20203C2F 72657175 |'/>. </requ| +EMBED: 0130: 65737465 64507269 76696C65 6765733E |estedPrivileges>| +EMBED: 0140: 0A202020 203C2F73 65637572 6974793E |. </security>| +EMBED: 0150: 0A20203C 2F747275 7374496E 666F3E0A |. </trustInfo>.| +EMBED: 0160: 20203C64 6570656E 64656E63 793E0A20 | <dependency>. | +EMBED: 0170: 2020203C 64657065 6E64656E 74417373 | <dependentAss| +EMBED: 0180: 656D626C 793E0A20 20202020 203C6173 |embly>. <as| +EMBED: 0190: 73656D62 6C794964 656E7469 74792066 |semblyIdentity f| +EMBED: 01A0: 6F6F3D27 62617227 202F3E0A 20202020 |oo='bar' />. | +EMBED: 01B0: 3C2F6465 70656E64 656E7441 7373656D |</dependentAssem| +EMBED: 01C0: 626C793E 0A20203C 2F646570 656E6465 |bly>. </depende| +EMBED: 01D0: 6E63793E 0A20203C 64657065 6E64656E |ncy>. <dependen| +EMBED: 01E0: 63793E0A 20202020 3C646570 656E6465 |cy>. <depende| +EMBED: 01F0: 6E744173 73656D62 6C793E0A 20202020 |ntAssembly>. | +EMBED: 0200: 20203C61 7373656D 626C7949 64656E74 | <assemblyIdent| +EMBED: 0210: 69747920 62617A3D 27717575 7827202F |ity baz='quux' /| +EMBED: 0220: 3E0A2020 20203C2F 64657065 6E64656E |>. </dependen| +EMBED: 0230: 74417373 656D626C 793E0A20 203C2F64 |tAssembly>. </d| +EMBED: 0240: 6570656E 64656E63 793E0A3C 2F617373 |ependency>.</ass| +EMBED: 0250: 656D626C 793E0A |embly>.| EMBED: ) diff --git a/lld/test/COFF/manifestinput.test b/lld/test/COFF/manifestinput.test index 04af80a..cbf27b1 100644 --- a/lld/test/COFF/manifestinput.test +++ b/lld/test/COFF/manifestinput.test @@ -5,22 +5,21 @@ # RUN: /manifest:embed \ # RUN: /manifestuac:"level='requireAdministrator'" \ # RUN: /manifestinput:%p/Inputs/manifestinput.test %t.obj -# RUN: llvm-readobj --coff-resources --file-headers %t.exe | FileCheck %s \ -# RUN: -check-prefix TEST_EMBED +# RUN: llvm-readobj --coff-resources --file-headers %t.exe | FileCheck %s -TEST_EMBED: ResourceTableRVA: 0x2000 -TEST_EMBED-NEXT: ResourceTableSize: 0x2A0 -TEST_EMBED-DAG: Resources [ -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: MANIFEST (ID 24) [ -TEST_EMBED-NEXT: Table Offset: 0x18 -TEST_EMBED-NEXT: Number of String Entries: 0 -TEST_EMBED-NEXT: Number of ID Entries: 1 -TEST_EMBED-NEXT: Name: (ID 1) [ -TEST_EMBED-NEXT: Table Offset: 0x30 -TEST_EMBED-NEXT: Number of String Entries: 0 -TEST_EMBED-NEXT: Number of ID Entries: 1 -TEST_EMBED-NEXT: Language: (ID 1033) [ -TEST_EMBED-NEXT: Entry Offset: 0x48 +CHECK: ResourceTableRVA: 0x2000 +CHECK-NEXT: ResourceTableSize: 0x2C8 +CHECK-DAG: Resources [ +CHECK-NEXT: Total Number of Resources: 1 +CHECK-DAG: Number of String Entries: 0 +CHECK-NEXT: Number of ID Entries: 1 +CHECK-NEXT: Type: MANIFEST (ID 24) [ +CHECK-NEXT: Table Offset: 0x18 +CHECK-NEXT: Number of String Entries: 0 +CHECK-NEXT: Number of ID Entries: 1 +CHECK-NEXT: Name: (ID 1) [ +CHECK-NEXT: Table Offset: 0x30 +CHECK-NEXT: Number of String Entries: 0 +CHECK-NEXT: Number of ID Entries: 1 +CHECK-NEXT: Language: (ID 1033) [ +CHECK-NEXT: Entry Offset: 0x48 diff --git a/lld/test/ELF/aarch64-build-attributes.s b/lld/test/ELF/aarch64-build-attributes.s index f2d5421..3d333bf 100644 --- a/lld/test/ELF/aarch64-build-attributes.s +++ b/lld/test/ELF/aarch64-build-attributes.s @@ -1,11 +1,11 @@ // REQUIRES: aarch64 // RUN: rm -rf %t && split-file %s %t && cd %t -// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o %t1.o -// RUN: llvm-mc -triple=aarch64 -filetype=obj pauth-bti-gcs.s -o %t2.o -// RUN: llvm-mc -triple=aarch64 -filetype=obj pauth-bti-pac.s -o %t3.o -// RUN: ld.lld -r %t1.o %t2.o %t3.o -o %t.merged.o -// RUN: llvm-readelf -n %t.merged.o | FileCheck %s --check-prefix=NOTE +// RUN: llvm-mc -triple=aarch64 -filetype=obj %s -o 1.o +// RUN: llvm-mc -triple=aarch64 -filetype=obj pauth-bti-gcs.s -o 2.o +// RUN: llvm-mc -triple=aarch64 -filetype=obj pauth-bti-pac.s -o 3.o +// RUN: ld.lld -r 1.o 2.o 3.o -o merged.o +// RUN: llvm-readelf -n merged.o | FileCheck %s --check-prefix=NOTE /// This test merges three object files with AArch64 build attributes. /// All contain identical PAuth ABI info (platform/version), which must be preserved. diff --git a/lld/test/ELF/aarch64-funcinit64-invalid.s b/lld/test/ELF/aarch64-funcinit64-invalid.s new file mode 100644 index 0000000..4577db7 --- /dev/null +++ b/lld/test/ELF/aarch64-funcinit64-invalid.s @@ -0,0 +1,18 @@ +# REQUIRES: aarch64 + +# RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t.o +# RUN: not ld.lld %t.o -o %t 2>&1 | FileCheck --check-prefix=ERR %s + +.rodata +# ERR: error: relocation R_AARCH64_FUNCINIT64 cannot be used against local symbol +.8byte func@FUNCINIT + +.data +# ERR: error: relocation R_AARCH64_FUNCINIT64 cannot be used against ifunc symbol 'ifunc' +.8byte ifunc@FUNCINIT + +.text +func: +.type ifunc, @gnu_indirect_function +ifunc: +ret diff --git a/lld/test/ELF/aarch64-funcinit64.s b/lld/test/ELF/aarch64-funcinit64.s new file mode 100644 index 0000000..5f2b863 --- /dev/null +++ b/lld/test/ELF/aarch64-funcinit64.s @@ -0,0 +1,19 @@ +# REQUIRES: aarch64 + +# RUN: llvm-mc -filetype=obj -triple=aarch64 %s -o %t.o +# RUN: ld.lld %t.o -o %t +# RUN: llvm-readelf -s -r %t | FileCheck %s +# RUN: ld.lld %t.o -o %t -pie +# RUN: llvm-readelf -s -r %t | FileCheck %s +# RUN: not ld.lld %t.o -o %t -shared 2>&1 | FileCheck --check-prefix=ERR %s + +.data +# CHECK: R_AARCH64_IRELATIVE [[FOO:[0-9a-f]*]] +# ERR: relocation R_AARCH64_FUNCINIT64 cannot be used against preemptible symbol 'foo' +.8byte foo@FUNCINIT + +.text +# CHECK: {{0*}}[[FOO]] {{.*}} foo +.globl foo +foo: +ret diff --git a/lld/test/ELF/arm-wraparound-veneer.s b/lld/test/ELF/arm-wraparound-veneer.s new file mode 100644 index 0000000..74dd6f2 --- /dev/null +++ b/lld/test/ELF/arm-wraparound-veneer.s @@ -0,0 +1,102 @@ +// REQUIRES: arm +// RUN: rm -rf %t && split-file %s %t && cd %t +// RUN: llvm-mc -filetype=obj -triple=armv7-none-eabi code.s -o code.o +// RUN: ld.lld -T unsigned1.ld code.o -o unsigned1.elf +// RUN: llvm-objdump --triple=armv7 --no-show-raw-insn -d unsigned1.elf | FileCheck %s --check-prefix=UNSIGNED1 +// RUN: ld.lld -T unsigned2.ld code.o -o unsigned2.elf +// RUN: llvm-objdump --triple=armv7 --no-show-raw-insn -d unsigned2.elf | FileCheck %s --check-prefix=UNSIGNED2 +// RUN: ld.lld -T signed1.ld code.o -o signed1.elf +// RUN: llvm-objdump --triple=armv7 --no-show-raw-insn -d signed1.elf | FileCheck %s --check-prefix=SIGNED1 +// RUN: ld.lld -T signed2.ld code.o -o signed2.elf +// RUN: llvm-objdump --triple=armv7 --no-show-raw-insn -d signed2.elf | FileCheck %s --check-prefix=SIGNED2 + +/// The aim of this test is to ensure that a BL instruction near one end of the +/// address space can reach a function at the extreme other end, directly, +/// using a branch offset that makes the address wrap round. We check this at +/// both the unsigned wraparound point (one address near 0 and the other near +/// 0xFFFFFFFF) and the signed wraparound point (addresses either side of +/// 0x80000000), crossing the boundary in both directions. In all four cases we +/// expect a direct branch with no veneer. + +// UNSIGNED1: Disassembly of section .text.lowaddr: +// UNSIGNED1: <func>: +// UNSIGNED1: 10000: bx lr +// +// UNSIGNED1: Disassembly of section .text.highaddr: +// UNSIGNED1: <_start>: +// UNSIGNED1: ffff0000: bl 0x10000 +// UNSIGNED1-NEXT: bx lr + +// UNSIGNED2: Disassembly of section .text.lowaddr: +// UNSIGNED2: <_start>: +// UNSIGNED2: 10000: bl 0xffff0000 +// UNSIGNED2-NEXT: bx lr +// +// UNSIGNED2: Disassembly of section .text.highaddr: +// UNSIGNED2: <func>: +// UNSIGNED2: ffff0000: bx lr + +// SIGNED1: Disassembly of section .text.posaddr: +// SIGNED1: <_start>: +// SIGNED1: 7fff0000: bl 0x80010000 +// SIGNED1-NEXT: bx lr +// +// SIGNED1: Disassembly of section .text.negaddr: +// SIGNED1: <func>: +// SIGNED1: 80010000: bx lr + +// SIGNED2: Disassembly of section .text.posaddr: +// SIGNED2: <func>: +// SIGNED2: 7fff0000: bx lr +// +// SIGNED2: Disassembly of section .text.negaddr: +// SIGNED2: <_start>: +// SIGNED2: 80010000: bl 0x7fff0000 +// SIGNED2-NEXT: bx lr + +//--- code.s + + .section .text.callee, "ax", %progbits + .global func + .type func, %function +func: + bx lr + + .section .text.caller, "ax", %progbits + .global _start + .type _start, %function +_start: + bl func + bx lr + +//--- unsigned1.ld + +ENTRY(_start) +SECTIONS { + .text.lowaddr 0x00010000 : AT(0x00010000) { *(.text.callee) } + .text.highaddr 0xffff0000 : AT(0xffff0000) { *(.text.caller) } +} + +//--- unsigned2.ld + +ENTRY(_start) +SECTIONS { + .text.lowaddr 0x00010000 : AT(0x00010000) { *(.text.caller) } + .text.highaddr 0xffff0000 : AT(0xffff0000) { *(.text.callee) } +} + +//--- signed1.ld + +ENTRY(_start) +SECTIONS { + .text.posaddr 0x7fff0000 : AT(0x7fff0000) { *(.text.caller) } + .text.negaddr 0x80010000 : AT(0x80010000) { *(.text.callee) } +} + +//--- signed2.ld + +ENTRY(_start) +SECTIONS { + .text.posaddr 0x7fff0000 : AT(0x7fff0000) { *(.text.callee) } + .text.negaddr 0x80010000 : AT(0x80010000) { *(.text.caller) } +} diff --git a/lld/test/ELF/dso-undef-extract-lazy.s b/lld/test/ELF/dso-undef-extract-lazy.s index 40b0758..5d92545 100644 --- a/lld/test/ELF/dso-undef-extract-lazy.s +++ b/lld/test/ELF/dso-undef-extract-lazy.s @@ -25,6 +25,11 @@ # CHECK-FETCH: GLOBAL DEFAULT {{[0-9]+}} foo +## Unversioned undefined symbols also extract the archive definitions. +# RUN: yaml2obj %t/ver.yaml -o %t4.so +# RUN: ld.lld %t1.o %t4.so %t2.a -o %t.exe +# RUN: llvm-readelf --dyn-symbols %t.exe | FileCheck %s --check-prefix=CHECK-FETCH + #--- main.s .text .globl _start @@ -38,3 +43,39 @@ foo: #--- shlib.s .global foo + +#--- ver.yaml +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 +Sections: + - Name: .gnu.version + Type: SHT_GNU_versym + Flags: [ SHF_ALLOC ] + Address: 0x0000000000200210 + AddressAlign: 0x0000000000000002 + EntSize: 0x0000000000000002 +## Test both index 0 and 1 for unversioned undefined symbols. +## https://sourceware.org/PR33577 + Entries: [ 0, 0, 1 ] + - Name: .gnu.version_r + Type: SHT_GNU_verneed + Flags: [ SHF_ALLOC ] + Address: 0x0000000000200250 + AddressAlign: 0x0000000000000004 + Dependencies: + - Version: 1 + File: dso.so.0 + Entries: + - Name: v1 + Hash: 1937 + Flags: 0 + Other: 3 +DynamicSymbols: + - Name: _start + Binding: STB_GLOBAL + - Name: foo + Binding: STB_GLOBAL diff --git a/lld/test/ELF/linkerscript/version-script.s b/lld/test/ELF/linkerscript/version-script.s index 52382ee..6b97fed 100644 --- a/lld/test/ELF/linkerscript/version-script.s +++ b/lld/test/ELF/linkerscript/version-script.s @@ -17,7 +17,7 @@ # CHECK-NEXT: Name: # CHECK-NEXT: } # CHECK-NEXT: Symbol { -# CHECK-NEXT: Version: 1 +# CHECK-NEXT: Version: 0 # CHECK-NEXT: Name: und # CHECK-NEXT: } # CHECK-NEXT: Symbol { diff --git a/lld/test/ELF/riscv-vendor-relocations.s b/lld/test/ELF/riscv-vendor-relocations.s index b0f3c4a..f121ade 100644 --- a/lld/test/ELF/riscv-vendor-relocations.s +++ b/lld/test/ELF/riscv-vendor-relocations.s @@ -8,12 +8,19 @@ TARGET: nop -.global INVALID_VENDOR +.local INVALID_VENDOR +.local QUALCOMM +.local ANDES .reloc 1f, R_RISCV_VENDOR, INVALID_VENDOR+0 .reloc 1f, R_RISCV_VENDOR, INVALID_VENDOR+0 .reloc 1f, R_RISCV_CUSTOM255, TARGET -1: - nop - # CHECK: error: {{.*}}:(.text+0x4): malformed consecutive R_RISCV_VENDOR relocations # CHECK: error: {{.*}}:(.text+0x4): unknown vendor-specific relocation (255) in namespace 'INVALID_VENDOR' against symbol 'TARGET' +.reloc 1f, R_RISCV_VENDOR, QUALCOMM+0 +.reloc 1f, R_RISCV_CUSTOM192, TARGET +# CHECK: error: {{.*}}:(.text+0x4): unsupported vendor-specific relocation R_RISCV_QC_ABS20_U against symbol TARGET +.reloc 1f, R_RISCV_VENDOR, ANDES+0 +.reloc 1f, R_RISCV_CUSTOM241, TARGET +# CHECK: error: {{.*}}:(.text+0x4): unsupported vendor-specific relocation R_RISCV_NDS_BRANCH_10 against symbol TARGET +1: + nop diff --git a/lld/test/ELF/version-script-extern-undefined.s b/lld/test/ELF/version-script-extern-undefined.s index 3811422..010b4d5 100644 --- a/lld/test/ELF/version-script-extern-undefined.s +++ b/lld/test/ELF/version-script-extern-undefined.s @@ -11,7 +11,7 @@ # CHECK-NEXT: Name: # CHECK-NEXT: } # CHECK-NEXT: Symbol { -# CHECK-NEXT: Version: 1 +# CHECK-NEXT: Version: 0 # CHECK-NEXT: Name: _Z3abbi # CHECK-NEXT: } # CHECK-NEXT: ] diff --git a/lld/test/MachO/bp-section-orderer.s b/lld/test/MachO/bp-section-orderer.s index 90924e5..d7de90d 100644 --- a/lld/test/MachO/bp-section-orderer.s +++ b/lld/test/MachO/bp-section-orderer.s @@ -106,6 +106,11 @@ r3: r4: .quad s2 +# cstrings are ignored by runBalancedPartitioning() +.cstring +cstr: + .asciz "this is cstr" + .bss bss0: .zero 10 diff --git a/lld/test/MachO/handle-invalid-section-reference-too-big.test b/lld/test/MachO/handle-invalid-section-reference-too-big.test new file mode 100644 index 0000000..1642d63 --- /dev/null +++ b/lld/test/MachO/handle-invalid-section-reference-too-big.test @@ -0,0 +1,128 @@ +# REQUIRES: aarch64 + +## This is a regression test which makes sure that when there is an invalid section index +## associated with a section symbol, the linker does not segfault. + +## Test YAML content was created using the following steps +## 1. Create an object file from the following assembly +## `llvm-mc -filetype=obj -triple=arm64-apple-darwin symbol.s -o symbol.o` +## +## .text +## .section __TEST,__mystuff +## .globl _mysec +## _mysec: +## .byte 0xC3 +## +## 2. Use obj2yaml to convert object file to yaml +## `obj2yaml symbol.o -o symbol.yaml` +## +## 3. Manually set n_sect value of ltmp1 symbol to 10 which is greater than the number of sections 2. +## + +# RUN: yaml2obj %s -o %t +# RUN: not %lld -platform_version macos 10.14 11.0 -arch arm64 %t 2>&1 | FileCheck %s --check-prefix=FATAL + +# FATAL: error: section symbol ltmp0 in {{.*}} has an invalid section index [10] greater than the total number of sections [2] + +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x100000C + cpusubtype: 0x0 + filetype: 0x1 + ncmds: 3 + sizeofcmds: 336 + flags: 0x0 + reserved: 0x0 +LoadCommands: + - cmd: LC_SEGMENT_64 + cmdsize: 232 + segname: '' + vmaddr: 0 + vmsize: 1 + fileoff: 368 + filesize: 1 + maxprot: 7 + initprot: 7 + nsects: 2 + flags: 0 + Sections: + - sectname: __text + segname: __TEXT + addr: 0x0 + size: 0 + offset: 0x170 + align: 0 + reloff: 0x0 + nreloc: 0 + flags: 0x80000000 + reserved1: 0x0 + reserved2: 0x0 + reserved3: 0x0 + content: '' + - sectname: __mystuff + segname: __TEST + addr: 0x0 + size: 1 + offset: 0x170 + align: 0 + reloff: 0x0 + nreloc: 0 + flags: 0x0 + reserved1: 0x0 + reserved2: 0x0 + reserved3: 0x0 + content: C3 + - cmd: LC_SYMTAB + cmdsize: 24 + symoff: 376 + nsyms: 3 + stroff: 424 + strsize: 24 + - cmd: LC_DYSYMTAB + cmdsize: 80 + ilocalsym: 0 + nlocalsym: 2 + iextdefsym: 2 + nextdefsym: 1 + iundefsym: 3 + nundefsym: 0 + tocoff: 0 + ntoc: 0 + modtaboff: 0 + nmodtab: 0 + extrefsymoff: 0 + nextrefsyms: 0 + indirectsymoff: 0 + nindirectsyms: 0 + extreloff: 0 + nextrel: 0 + locreloff: 0 + nlocrel: 0 +LinkEditData: + NameList: + - n_strx: 14 + n_type: 0xE + n_sect: 10 + n_desc: 0 + n_value: 0 + - n_strx: 8 + n_type: 0xE + n_sect: 2 + n_desc: 0 + n_value: 0 + - n_strx: 1 + n_type: 0xF + n_sect: 2 + n_desc: 0 + n_value: 0 + StringTable: + - '' + - _mysec + - ltmp1 + - ltmp0 + - '' + - '' + - '' + - '' +... diff --git a/lld/test/MachO/handle-invalid-section-reference-zero.test b/lld/test/MachO/handle-invalid-section-reference-zero.test new file mode 100644 index 0000000..ab63670 --- /dev/null +++ b/lld/test/MachO/handle-invalid-section-reference-zero.test @@ -0,0 +1,128 @@ +# REQUIRES: aarch64 + +## This is a regression test which makes sure that when there is an invalid section index +## associated with a section symbol, the linker does not segfault. + +## Test YAML content was created using the following steps +## 1. Create an object file from the following assembly +## `llvm-mc -filetype=obj -triple=arm64-apple-darwin symbol.s -o symbol.o` +## +## .text +## .section __TEST,__mystuff +## .globl _mysec +## _mysec: +## .byte 0xC3 +## +## 2. Use obj2yaml to convert object file to yaml +## `obj2yaml symbol.o -o symbol.yaml` +## +## 3. Manually set n_sect value of ltmp1 symbol to 0 instead of 1. +## + +# RUN: yaml2obj %s -o %t +# RUN: not %lld -platform_version macos 10.14 11.0 -arch arm64 %t 2>&1 | FileCheck %s --check-prefix=FATAL + +# FATAL: error: section symbol ltmp0 in {{.*}} has an invalid section index [0] + +--- !mach-o +FileHeader: + magic: 0xFEEDFACF + cputype: 0x100000C + cpusubtype: 0x0 + filetype: 0x1 + ncmds: 3 + sizeofcmds: 336 + flags: 0x0 + reserved: 0x0 +LoadCommands: + - cmd: LC_SEGMENT_64 + cmdsize: 232 + segname: '' + vmaddr: 0 + vmsize: 1 + fileoff: 368 + filesize: 1 + maxprot: 7 + initprot: 7 + nsects: 2 + flags: 0 + Sections: + - sectname: __text + segname: __TEXT + addr: 0x0 + size: 0 + offset: 0x170 + align: 0 + reloff: 0x0 + nreloc: 0 + flags: 0x80000000 + reserved1: 0x0 + reserved2: 0x0 + reserved3: 0x0 + content: '' + - sectname: __mystuff + segname: __TEST + addr: 0x0 + size: 1 + offset: 0x170 + align: 0 + reloff: 0x0 + nreloc: 0 + flags: 0x0 + reserved1: 0x0 + reserved2: 0x0 + reserved3: 0x0 + content: C3 + - cmd: LC_SYMTAB + cmdsize: 24 + symoff: 376 + nsyms: 3 + stroff: 424 + strsize: 24 + - cmd: LC_DYSYMTAB + cmdsize: 80 + ilocalsym: 0 + nlocalsym: 2 + iextdefsym: 2 + nextdefsym: 1 + iundefsym: 3 + nundefsym: 0 + tocoff: 0 + ntoc: 0 + modtaboff: 0 + nmodtab: 0 + extrefsymoff: 0 + nextrefsyms: 0 + indirectsymoff: 0 + nindirectsyms: 0 + extreloff: 0 + nextrel: 0 + locreloff: 0 + nlocrel: 0 +LinkEditData: + NameList: + - n_strx: 14 + n_type: 0xE + n_sect: 0 + n_desc: 0 + n_value: 0 + - n_strx: 8 + n_type: 0xE + n_sect: 2 + n_desc: 0 + n_value: 0 + - n_strx: 1 + n_type: 0xF + n_sect: 2 + n_desc: 0 + n_value: 0 + StringTable: + - '' + - _mysec + - ltmp1 + - ltmp0 + - '' + - '' + - '' + - '' +... diff --git a/lld/test/MachO/invalid/bad-offsets.s b/lld/test/MachO/invalid/bad-offsets.s new file mode 100644 index 0000000..e1244ee --- /dev/null +++ b/lld/test/MachO/invalid/bad-offsets.s @@ -0,0 +1,45 @@ +## Test that we properly detect and report out-of-bounds offsets in literal sections. +## We're intentionally testing fatal errors (for malformed input files), and +## fatal errors aren't supported for testing when main is run twice. +# XFAIL: main-run-twice + +# REQUIRES: x86 +# RUN: rm -rf %t; split-file %s %t + +## Test WordLiteralInputSection bounds checking +# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/word-literal.s -o %t/word-literal.o +# RUN: not %lld -dylib %t/word-literal.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=WORD + +## Test CStringInputSection bounds checking +# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/cstring.s -o %t/cstring.o +# RUN: not %lld -dylib %t/cstring.o -o /dev/null 2>&1 | FileCheck %s --check-prefix=CSTRING + +# WORD: error: {{.*}}word-literal.o:(__literal4): offset is outside the section +# CSTRING: error: {{.*}}cstring.o:(__cstring): offset is outside the section + +#--- word-literal.s +.section __TEXT,__literal4,4byte_literals +L_literal: + .long 0x01020304 + +.text +.globl _main +_main: + # We use a subtractor expression to force a section relocation. Symbol relocations + # don't trigger the error. + .long L_literal - _main + 4 + +.subsections_via_symbols + +#--- cstring.s +## Create a cstring section with a reference that points past the end +.cstring +L_str: + .asciz "foo" + +.text +.globl _main +_main: + .long L_str - _main + 4 + +.subsections_via_symbols
\ No newline at end of file diff --git a/lld/test/MachO/invalid/invalid-relocation-length.yaml b/lld/test/MachO/invalid/invalid-relocation-length.yaml index ff8759b..2661e4e 100644 --- a/lld/test/MachO/invalid/invalid-relocation-length.yaml +++ b/lld/test/MachO/invalid/invalid-relocation-length.yaml @@ -2,7 +2,7 @@ # RUN: yaml2obj %s -o %t.o # RUN: not %lld -o %t %t.o 2>&1 | FileCheck %s -DFILE=%t.o # -# CHECK: error: UNSIGNED relocation has width 2 bytes, but must be 4 or 8 bytes at offset 1 of __TEXT,__text in [[FILE]] +# CHECK: error: UNSIGNED relocation has invalid width of 2 bytes at offset 1 of __TEXT,__text in [[FILE]] !mach-o FileHeader: diff --git a/lld/test/MachO/order-file-cstring.s b/lld/test/MachO/order-file-cstring.s index 3c6d2a3..d673430 100644 --- a/lld/test/MachO/order-file-cstring.s +++ b/lld/test/MachO/order-file-cstring.s @@ -4,32 +4,34 @@ # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/test.s -o %t/test.o # RUN: llvm-mc -filetype=obj -triple=arm64-apple-darwin %t/more-cstrings.s -o %t/more-cstrings.o -# RUN: %lld --deduplicate-strings -arch arm64 -lSystem -e _main -o %t/test-0 %t/test.o %t/more-cstrings.o +# RUN: %lld -arch arm64 -lSystem -e _main -o %t/test-0 %t/test.o %t/more-cstrings.o # RUN: llvm-nm --numeric-sort --format=just-symbols %t/test-0 | FileCheck %s --check-prefix=ORIGIN_SYM # RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/test-0 | FileCheck %s --check-prefix=ORIGIN_SEC -# RUN: %lld --deduplicate-strings -arch arm64 -lSystem -e _main -o %t/test-1 %t/test.o %t/more-cstrings.o -order_file %t/ord-1 +# RUN: %lld -arch arm64 -lSystem -e _main -o %t/test-1 %t/test.o %t/more-cstrings.o -order_file %t/ord-1 # RUN: llvm-nm --numeric-sort --format=just-symbols %t/test-1 | FileCheck %s --check-prefix=ONE_SYM # RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/test-1 | FileCheck %s --check-prefix=ONE_SEC +# RUN: %lld --no-deduplicate-strings -arch arm64 -lSystem -e _main -o %t/test-1-dup %t/test.o %t/more-cstrings.o -order_file %t/ord-1 +# RUN: llvm-nm --numeric-sort --format=just-symbols %t/test-1-dup | FileCheck %s --check-prefix=ONE_SYM +# RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/test-1-dup | FileCheck %s --check-prefix=ONE_SEC -# RUN: %lld --deduplicate-strings -arch arm64 -lSystem -e _main -o %t/test-2 %t/test.o %t/more-cstrings.o -order_file %t/ord-2 +# RUN: %lld -arch arm64 -lSystem -e _main -o %t/test-2 %t/test.o %t/more-cstrings.o -order_file %t/ord-2 # RUN: llvm-nm --numeric-sort --format=just-symbols %t/test-2 | FileCheck %s --check-prefix=TWO_SYM # RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/test-2 | FileCheck %s --check-prefix=TWO_SEC -# RUN: %lld --deduplicate-strings -arch arm64 -lSystem -e _main -o %t/test-3 %t/test.o %t/more-cstrings.o -order_file %t/ord-3 +# RUN: %lld -arch arm64 -lSystem -e _main -o %t/test-3 %t/test.o %t/more-cstrings.o -order_file %t/ord-3 # RUN: llvm-nm --numeric-sort --format=just-symbols %t/test-3 | FileCheck %s --check-prefix=THREE_SYM # RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/test-3 | FileCheck %s --check-prefix=THREE_SEC -# RUN: %lld --deduplicate-strings -arch arm64 -lSystem -e _main -o %t/test-4 %t/test.o %t/more-cstrings.o -order_file %t/ord-4 +# RUN: %lld -arch arm64 -lSystem -e _main -o %t/test-4 %t/test.o %t/more-cstrings.o -order_file %t/ord-4 # RUN: llvm-nm --numeric-sort --format=just-symbols %t/test-4 | FileCheck %s --check-prefix=FOUR_SYM # RUN: llvm-objdump --macho --section="__TEXT,__cstring" %t/test-4 | FileCheck %s --check-prefix=FOUR_SEC # RUN: llvm-readobj --string-dump=__cstring %t/test-4 | FileCheck %s --check-prefix=FOUR_SEC_ESCAPE - # We expect: -# 1) Covered cstring symbols are reordered -# 2) the rest of the cstring symbols remain original relative order within the cstring section +# 1) Covered cstring symbols to be reordered +# 2) the rest of the cstring symbols remain in the original relative order within the cstring section # ORIGIN_SYM: _local_foo1 # ORIGIN_SYM: _globl_foo2 @@ -58,8 +60,8 @@ CSTR;1496286555 #foo3 CSTR;1343999025 -# ONE_SYM: _globl_foo2 -# ONE_SYM: _local_foo2 +# ONE_SYM-DAG: _globl_foo2 +# ONE_SYM-DAG: _local_foo2 # ONE_SYM: _bar # ONE_SYM: _bar2 # ONE_SYM: _globl_foo3 diff --git a/lld/test/MachO/read-workers.s b/lld/test/MachO/read-workers.s index 294106b..4d2f88c 100644 --- a/lld/test/MachO/read-workers.s +++ b/lld/test/MachO/read-workers.s @@ -1,7 +1,4 @@ # REQUIRES: x86 && thread_support -## Sometimes fails, particularly in an ASAN build, do not run until -## https://github.com/llvm/llvm-project/pull/157917 addresses the cause. -# UNSUPPORTED: target={{.*}} # RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t.o ## A non-negative integer is allowed. diff --git a/lld/test/MachO/set-slop-scale.s b/lld/test/MachO/set-slop-scale.s new file mode 100644 index 0000000..a18acce --- /dev/null +++ b/lld/test/MachO/set-slop-scale.s @@ -0,0 +1,11 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-darwin %s -o %t.o +# RUN: %lld -o /dev/null %t.o --slop_scale=1 +# RUN: not %lld -o /dev/null %t.o --slop_scale=-1 2>&1 | FileCheck %s +# CHECK: error: --slop_scale=: expected a non-negative integer, but got '-1' + +.text +.global _main +_main: + mov $0, %rax + ret diff --git a/lld/test/MachO/weak-alias-override.s b/lld/test/MachO/weak-alias-override.s new file mode 100644 index 0000000..224ddc4 --- /dev/null +++ b/lld/test/MachO/weak-alias-override.s @@ -0,0 +1,97 @@ +# REQUIRES: x86 +# RUN: rm -rf %t; split-file %s %t +# RUN: mkdir -p %t/bin + +# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/weak.o %t/weak.s +# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/strong_a.o %t/strong_a.s +# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/strong_b.o %t/strong_b.s + +# --- Test Case 1: No overrides +# RUN: %lld %t/weak.o -o %t/bin/alone -e _s +# RUN: llvm-nm -am %t/bin/alone | FileCheck --check-prefix=NM_ALONE %s + +# NM_ALONE: [[#%x, P_ADDR:]] (__TEXT,__const) weak external _placeholder_int +# NM_ALONE: [[#P_ADDR]] (__TEXT,__const) weak external _weak_a +# NM_ALONE: [[#P_ADDR]] (__TEXT,__const) weak external _weak_b + +# --- Test Case 2: Override weak_a +# RUN: %lld %t/weak.o %t/strong_a.o -o %t/bin/with_a -e _s +# RUN: llvm-nm -am %t/bin/with_a | FileCheck --check-prefix=NM_WITH_A %s +# RUN: llvm-nm -am %t/bin/with_a | FileCheck --check-prefix=NM_WITH_A_BAD %s + +# NM_WITH_A: [[#%x, P_ADDR:]] (__TEXT,__const) weak external _placeholder_int +# NM_WITH_A: [[#%x, A_ADDR:]] (__TEXT,__const) external _strong_a +# NM_WITH_A: [[#A_ADDR]] (__TEXT,__const) external _weak_a +# NM_WITH_A: [[#P_ADDR]] (__TEXT,__const) weak external _weak_b + +# --- Addresses of _placeholder_int and _strong_a must not match. +# NM_WITH_A_BAD: [[#%x, P_ADDR:]] (__TEXT,__const) weak external _placeholder_int +# NM_WITH_A_BAD-NOT: [[#P_ADDR]] (__TEXT,__const) external _strong_a + +# --- Test Case 3: Override weak_b +# RUN: %lld %t/weak.o %t/strong_b.o -o %t/bin/with_b -e _s +# RUN: llvm-nm -am %t/bin/with_b | FileCheck --check-prefix=NM_WITH_B %s +# RUN: llvm-nm -am %t/bin/with_b | FileCheck --check-prefix=NM_WITH_B_BAD %s + +# NM_WITH_B: [[#%x, P_ADDR:]] (__TEXT,__const) weak external _placeholder_int +# NM_WITH_B: [[#%x, B_ADDR:]] (__TEXT,__const) external _strong_b +# NM_WITH_B: [[#P_ADDR]] (__TEXT,__const) weak external _weak_a +# NM_WITH_B: [[#B_ADDR]] (__TEXT,__const) external _weak_b + +# --- Addresses of _placeholder_int and _strong_a must not match. +# NM_WITH_B_BAD: [[#%x, P_ADDR:]] (__TEXT,__const) weak external _placeholder_int +# NM_WITH_B_BAD-NOT: [[#P_ADDR]] (__TEXT,__const) external _strong_b + +# --- Test Case 4: Override weak_a and weak_b +# RUN: %lld %t/weak.o %t/strong_a.o %t/strong_b.o -o %t/bin/with_ab -e _s +# RUN: llvm-nm -am %t/bin/with_ab | FileCheck --check-prefix=NM_WITH_AB %s +# RUN: llvm-nm -am %t/bin/with_ab | FileCheck --check-prefix=NM_WITH_AB_BAD %s + +# NM_WITH_AB: [[#%x, P_ADDR:]] (__TEXT,__const) weak external _placeholder_int +# NM_WITH_AB: [[#%x, A_ADDR:]] (__TEXT,__const) external _strong_a +# NM_WITH_AB: [[#%x, B_ADDR:]] (__TEXT,__const) external _strong_b +# NM_WITH_AB: [[#A_ADDR]] (__TEXT,__const) external _weak_a +# NM_WITH_AB: [[#B_ADDR]] (__TEXT,__const) external _weak_b + +# --- Addresses of _placeholder_int, _strong_a, and _strong_b must all be distinct +# NM_WITH_AB_BAD: [[#%x, P_ADDR:]] (__TEXT,__const) weak external _placeholder_int +# NM_WITH_AB_BAD-NOT: [[#P_ADDR]] (__TEXT,__const) external _strong_a +# NM_WITH_AB_BAD-NOT: [[#P_ADDR]] (__TEXT,__const) external _strong_b + +#--- weak.s +.section __TEXT,__const +.globl _placeholder_int +.weak_definition _placeholder_int +_placeholder_int: + .long 0 + +.globl _weak_a +.set _weak_a, _placeholder_int +.weak_definition _weak_a + +.globl _weak_b +.set _weak_b, _placeholder_int +.weak_definition _weak_b + +.globl _s +_s: + .quad _weak_a + .quad _weak_b + +#--- strong_a.s +.section __TEXT,__const +.globl _strong_a +_strong_a: + .long 1 + +.globl _weak_a +_weak_a = _strong_a + +#--- strong_b.s +.section __TEXT,__const +.globl _strong_b +_strong_b: + .long 2 + +.globl _weak_b +_weak_b = _strong_b diff --git a/lld/test/MachO/x86-64-relocs.s b/lld/test/MachO/x86-64-relocs.s index cdeee96c..d29f689 100644 --- a/lld/test/MachO/x86-64-relocs.s +++ b/lld/test/MachO/x86-64-relocs.s @@ -4,14 +4,27 @@ # RUN: llvm-objdump --no-print-imm-hex --section-headers --syms -d %t | FileCheck %s # CHECK-LABEL: Sections: +# CHECK: __branch_target {{[0-9a-z]+}} [[#%x, BRANCH_SECT:]] # CHECK: __data {{[0-9a-z]+}} [[#%x, DATA_ADDR:]] # CHECK-LABEL: SYMBOL TABLE: -# CHECK: [[#%x, F_ADDR:]] {{.*}} _f +# CHECK-DAG: [[#%x, F_ADDR:]] {{.*}} _f +# CHECK-DAG: [[#%x, G_ADDR:]] {{.*}} _g # CHECK-LABEL: <_main>: ## Test X86_64_RELOC_BRANCH +## Test symbol (extern) relocations first (most common case) # CHECK: callq 0x[[#%x, F_ADDR]] <_f> +# CHECK: jrcxz 0x[[#%x, F_ADDR]] <_f> +# CHECK: callq 0x[[#%x, G_ADDR]] <_g> +# CHECK: jrcxz 0x[[#%x, G_ADDR]] <_g> +## Test section (local) BRANCH relocations +# CHECK: callq 0x[[#%x, BRANCH_SECT]] +## NOTE: ld64 rejects 1-byte local branch relocations as unsupported, but it +## doesn't take any extra code for us to support it +# CHECK: jrcxz 0x[[#%x, BRANCH_SECT]] + +# CHECK-LABEL: <_f>: ## Test extern (symbol) X86_64_RELOC_SIGNED # CHECK: leaq [[#%u, LOCAL_OFF:]](%rip), %rsi # CHECK-NEXT: [[#%x, DATA_ADDR - LOCAL_OFF]] @@ -24,18 +37,33 @@ # NONPCREL-NEXT: 100001000 08200000 01000000 08200000 01000000 .section __TEXT,__text -.globl _main, _f +.globl _main, _f, _g + _main: - callq _f # X86_64_RELOC_BRANCH + callq _f # X86_64_RELOC_BRANCH with r_length=2 + jrcxz _f # X86_64_RELOC_BRANCH with r_length=0 + # Test negative addends + callq _f - 1 + jrcxz _f - 1 + # Test section relocations + callq L_.branch_target + jrcxz L_.branch_target mov $0, %rax ret +_g: + .byte 0x0 + _f: leaq _local(%rip), %rsi # Generates a X86_64_RELOC_SIGNED pcrel symbol relocation leaq L_.private(%rip), %rsi # Generates a X86_64_RELOC_SIGNED pcrel section relocation movq L_.ptr_1(%rip), %rsi ret +.section __TEXT,__branch_target +L_.branch_target: + ret + .data ## References to this generate a symbol relocation _local: diff --git a/lld/test/MinGW/driver.test b/lld/test/MinGW/driver.test index 47809d8..ef03c01 100644 --- a/lld/test/MinGW/driver.test +++ b/lld/test/MinGW/driver.test @@ -37,6 +37,12 @@ ARM64X-SAME: -machine:arm64x ARM64X-SAME: -alternatename:__image_base__=__ImageBase ARM64X-SAME: foo.o +RUN: ld.lld -### foo.o -m mipspe 2>&1 | FileCheck -check-prefix=MIPS %s +MIPS: -out:a.exe +MIPS-SAME: -machine:mips +MIPS-SAME: -alternatename:__image_base__=__ImageBase +MIPS-SAME: foo.o + RUN: ld.lld -### foo.o -m i386pep -shared 2>&1 | FileCheck -check-prefix=SHARED %s RUN: ld.lld -### foo.o -m i386pep --shared 2>&1 | FileCheck -check-prefix=SHARED %s RUN: ld.lld -### foo.o -m i386pep --dll 2>&1 | FileCheck -check-prefix=SHARED %s diff --git a/lld/test/wasm/alias.s b/lld/test/wasm/alias.s index 0bb035b..83f40a8 100644 --- a/lld/test/wasm/alias.s +++ b/lld/test/wasm/alias.s @@ -24,7 +24,7 @@ _start: # CHECK-NEXT: FunctionTypes: [ 0 ] # CHECK-NEXT: - Type: MEMORY # CHECK-NEXT: Memories: -# CHECK-NEXT: - Minimum: 0x2 +# CHECK-NEXT: - Minimum: 0x1 # CHECK-NEXT: - Type: GLOBAL # CHECK-NEXT: Globals: # CHECK-NEXT: - Index: 0 @@ -32,7 +32,7 @@ _start: # CHECK-NEXT: Mutable: true # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 66560 +# CHECK-NEXT: Value: 65536 # CHECK-NEXT: - Type: EXPORT # CHECK-NEXT: Exports: # CHECK-NEXT: - Name: memory diff --git a/lld/test/wasm/bss-only.s b/lld/test/wasm/bss-only.s index 1c0500f..bec7592 100644 --- a/lld/test/wasm/bss-only.s +++ b/lld/test/wasm/bss-only.s @@ -26,13 +26,13 @@ b: # CHECK-NEXT: Mutable: true # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 67568 +# CHECK-NEXT: Value: 65536 # CHECK-NEXT: - Index: 1 # CHECK-NEXT: Type: I32 # CHECK-NEXT: Mutable: false # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 2028 +# CHECK-NEXT: Value: 66540 # CHECK-NEXT: - Type: EXPORT # CHECK-NEXT: Exports: # CHECK-NEXT: - Name: memory diff --git a/lld/test/wasm/build-id.test b/lld/test/wasm/build-id.test index dd6e223710..5fafd21 100644 --- a/lld/test/wasm/build-id.test +++ b/lld/test/wasm/build-id.test @@ -43,12 +43,12 @@ foo: # DEFAULT: Contents of section build_id: -# DEFAULT-NEXT: 0079 10299168 1e3c845a 3c8f80ae 2f16cc22 .).h.<.Z<.../.." -# DEFAULT-NEXT: 0089 2d +# DEFAULT-NEXT: 0079 103f86e6 3bb81959 2e99ffa9 acfed331 .?..;..Y.......1 +# DEFAULT-NEXT: 0089 3a # SHA1: Contents of section build_id: -# SHA1-NEXT: 0079 145abdda 387a9bc4 e3aed3c3 3319cd37 .Z..8z......3..7 -# SHA1-NEXT: 0089 0212237c e4 ..#|. +# SHA1-NEXT: 0079 1410ade4 e75d1c9d 71023465 03b7572f .....]..q.4e..W/ +# SHA1-NEXT: 0089 c06c5ae0 74 .lZ.t # UUID: Contents of section build_id: # UUID-NEXT: 0079 10 diff --git a/lld/test/wasm/call-indirect.s b/lld/test/wasm/call-indirect.s index 7bf39a9..64eaa59 100644 --- a/lld/test/wasm/call-indirect.s +++ b/lld/test/wasm/call-indirect.s @@ -82,13 +82,13 @@ indirect_func: # CHECK-NEXT: Mutable: true # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 66576 +# CHECK-NEXT: Value: 65536 # CHECK-NEXT: - Index: 1 # CHECK-NEXT: Type: I32 # CHECK-NEXT: Mutable: false # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 1032 +# CHECK-NEXT: Value: 65544 # CHECK-NEXT: - Type: EXPORT # CHECK-NEXT: Exports: # CHECK-NEXT: - Name: memory @@ -125,23 +125,23 @@ indirect_func: # CHECK-NEXT: Body: 42010B # CHECK-NEXT: - Index: 1 # CHECK-NEXT: Locals: -# CHECK-NEXT: Body: 410028028088808000118080808000001A410028028488808000118180808000001A0B +# CHECK-NEXT: Body: 410028028080848000118080808000001A410028028480848000118180808000001A0B # CHECK-NEXT: - Index: 2 # CHECK-NEXT: Locals: # CHECK-NEXT: Body: 41020B # CHECK-NEXT: - Index: 3 # CHECK-NEXT: Locals: -# CHECK-NEXT: Body: 410028028888808000118180808000001A0B +# CHECK-NEXT: Body: 410028028880848000118180808000001A0B # CHECK-NEXT: - Index: 4 # CHECK-NEXT: Locals: # CHECK-NEXT: Body: 42012000118280808000001A0B # CHECK-NEXT: - Type: DATA # CHECK-NEXT: Segments: -# CHECK-NEXT: - SectionOffset: 7 +# CHECK-NEXT: - SectionOffset: 8 # CHECK-NEXT: InitFlags: 0 # CHECK-NEXT: Offset: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 1024 +# CHECK-NEXT: Value: 65536 # CHECK-NEXT: Content: '010000000200000002000000' # CHECK-NEXT: - Type: CUSTOM # CHECK-NEXT: Name: name diff --git a/lld/test/wasm/comdats.ll b/lld/test/wasm/comdats.ll index 2dd687f..1662a98 100644 --- a/lld/test/wasm/comdats.ll +++ b/lld/test/wasm/comdats.ll @@ -23,13 +23,13 @@ entry: ; CHECK-NEXT: Mutable: true ; CHECK-NEXT: InitExpr: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 66576 +; CHECK-NEXT: Value: 65536 ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Type: I32 ; CHECK-NEXT: Mutable: false ; CHECK-NEXT: InitExpr: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 1024 +; CHECK-NEXT: Value: 65536 ; CHECK-NEXT: - Type: EXPORT ; CHECK-NEXT: Exports: ; CHECK-NEXT: - Name: memory @@ -69,7 +69,7 @@ entry: ; CHECK-NEXT: Body: 1080808080001082808080001A0B ; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4180888080000B +; CHECK-NEXT: Body: 4180808480000B ; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 0B @@ -81,9 +81,9 @@ entry: ; CHECK-NEXT: Body: 4181808080000B ; CHECK-NEXT: - Type: DATA ; CHECK-NEXT: Segments: -; CHECK-NEXT: - SectionOffset: 7 +; CHECK-NEXT: - SectionOffset: 8 ; CHECK-NEXT: InitFlags: 0 ; CHECK-NEXT: Offset: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 1024 +; CHECK-NEXT: Value: 65536 ; CHECK-NEXT: Content: '616263' diff --git a/lld/test/wasm/compress-relocs.s b/lld/test/wasm/compress-relocs.s index 41d4ff5..37f1b3b 100644 --- a/lld/test/wasm/compress-relocs.s +++ b/lld/test/wasm/compress-relocs.s @@ -47,16 +47,16 @@ test_memory_and_indirect_call_relocs: end_function # CHECK: test_memory_and_indirect_call_relocs -# CHECK: 41 90 88 80 80 00 i32.const 1040 +# CHECK: 41 90 80 84 80 00 i32.const 65552 # CHECK: 11 80 80 80 80 00 80 80 80 80 00 call_indirect 0 -# CHECK: 28 02 94 88 80 80 00 i32.load 1044 +# CHECK: 28 02 94 80 84 80 00 i32.load 65556 # CHECK: 11 81 80 80 80 00 80 80 80 80 00 call_indirect 1 # CHECK: 41 81 80 80 80 00 i32.const 1 # CHECK: 11 80 80 80 80 00 80 80 80 80 00 call_indirect 0 # COMPRESS: test_memory_and_indirect_call_relocs -# COMPRESS: 41 90 08 i32.const 1040 +# COMPRESS: 41 90 80 04 i32.const 65552 # COMPRESS: 11 00 00 call_indirect 0 -# COMPRESS: 28 02 94 08 i32.load 1044 +# COMPRESS: 28 02 94 80 04 i32.load 65556 # COMPRESS: 11 01 00 call_indirect 1 # COMPRESS: 41 01 i32.const 1 # COMPRESS: 11 00 00 call_indirect 0 @@ -91,11 +91,11 @@ test_relative_relocs: end_function # CHECK: test_relative_relocs -# CHECK: 41 90 88 80 80 00 i32.const 1040 +# CHECK: 41 90 80 84 80 00 i32.const 65552 # CHECK: 41 81 80 80 80 00 i32.const 1 # CHECK: 41 83 80 80 80 00 i32.const 3 # COMPRESS: test_relative_relocs -# COMPRESS: 41 90 08 i32.const 1040 +# COMPRESS: 41 90 80 04 i32.const 65552 # COMPRESS: 41 01 i32.const 1 # COMPRESS: 41 03 i32.const 3 diff --git a/lld/test/wasm/compress-relocs64.s b/lld/test/wasm/compress-relocs64.s index 44e7a08..f3ff646 100644 --- a/lld/test/wasm/compress-relocs64.s +++ b/lld/test/wasm/compress-relocs64.s @@ -36,12 +36,12 @@ test_memory_and_indirect_call_relocs: end_function # CHECK: test_memory_and_indirect_call_relocs -# CHECK: 42 90 88 80 80 80 80 80 80 80 00 i64.const 1040 -# CHECK: 29 03 98 88 80 80 80 80 80 80 80 00 i64.load 1048 +# CHECK: 42 90 80 84 80 80 80 80 80 80 00 i64.const 65552 +# CHECK: 29 03 98 80 84 80 80 80 80 80 80 00 i64.load 65560 # CHECK: 42 81 80 80 80 80 80 80 80 80 00 i64.const 1 # COMPRESS: test_memory_and_indirect_call_relocs -# COMPRESS: 42 90 08 i64.const 1040 -# COMPRESS: 29 03 98 08 i64.load 1048 +# COMPRESS: 42 90 80 04 i64.const 65552 +# COMPRESS: 29 03 98 80 04 i64.load 65560 # COMPRESS: 42 01 i64.const 1 .globl test_relative_relocs @@ -56,11 +56,11 @@ test_relative_relocs: end_function # CHECK: test_relative_relocs -# CHECK: 42 90 88 80 80 80 80 80 80 80 00 i64.const 1040 +# CHECK: 42 90 80 84 80 80 80 80 80 80 00 i64.const 65552 # CHECK: 42 81 80 80 80 80 80 80 80 80 00 i64.const 1 # CHECK: 42 83 80 80 80 80 80 80 80 80 00 i64.const 3 # COMPRESS: test_relative_relocs -# COMPRESS: 42 90 08 i64.const 1040 +# COMPRESS: 42 90 80 04 i64.const 65552 # COMPRESS: 42 01 i64.const 1 # COMPRESS: 42 03 i64.const 3 diff --git a/lld/test/wasm/custom-section-name.ll b/lld/test/wasm/custom-section-name.ll index 8799fbf..89cb72f 100644 --- a/lld/test/wasm/custom-section-name.ll +++ b/lld/test/wasm/custom-section-name.ll @@ -16,29 +16,29 @@ target triple = "wasm32-unknown-unknown" ; CHECK-LABEL: - Type: DATA ; CHECK-NEXT: Segments: -; CHECK-NEXT: - SectionOffset: 7 +; CHECK-NEXT: - SectionOffset: 8 ; CHECK-NEXT: InitFlags: 0 ; CHECK-NEXT: Offset: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 1024 +; CHECK-NEXT: Value: 65536 ; CHECK-NEXT: Content: '00000000' -; CHECK-NEXT: - SectionOffset: 17 +; CHECK-NEXT: - SectionOffset: 19 ; CHECK-NEXT: InitFlags: 0 ; CHECK-NEXT: Offset: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 1028 +; CHECK-NEXT: Value: 65540 ; CHECK-NEXT: Content: 2A000000 -; CHECK-NEXT: - SectionOffset: 27 +; CHECK-NEXT: - SectionOffset: 30 ; CHECK-NEXT: InitFlags: 0 ; CHECK-NEXT: Offset: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 1032 +; CHECK-NEXT: Value: 65544 ; CHECK-NEXT: Content: '07000000' -; BSS-NEXT: - SectionOffset: 37 +; BSS-NEXT: - SectionOffset: 41 ; BSS-NEXT: InitFlags: 0 ; BSS-NEXT: Offset: ; BSS-NEXT: Opcode: I32_CONST -; BSS-NEXT: Value: 1036 +; BSS-NEXT: Value: 65548 ; BSS-NEXT: Content: '00000000' ; NO-BSS-NOT: - SectionOffset: diff --git a/lld/test/wasm/data-layout.s b/lld/test/wasm/data-layout.s index a68bc03..8df834d 100644 --- a/lld/test/wasm/data-layout.s +++ b/lld/test/wasm/data-layout.s @@ -63,33 +63,33 @@ local_struct_internal_ptr: # CHECK-NEXT: Mutable: true # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: [[PTR]]_CONST -# CHECK-NEXT: Value: 66624 +# CHECK-NEXT: Value: 65536 # CHECK-NEXT: - Index: 1 # CHECK-NEXT: Type: [[PTR]] # CHECK-NEXT: Mutable: false # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: [[PTR]]_CONST -# CHECK-NEXT: Value: 1080 +# CHECK-NEXT: Value: 65592 # CHECK-NEXT: - Index: 2 # CHECK-NEXT: Type: [[PTR]] # CHECK-NEXT: Mutable: false # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: [[PTR]]_CONST -# CHECK-NEXT: Value: 66624 +# CHECK-NEXT: Value: 65600 # CHECK: - Type: DATA # CHECK-NEXT: Segments: -# CHECK-NEXT: - SectionOffset: 7 +# CHECK-NEXT: - SectionOffset: 8 # CHECK-NEXT: InitFlags: 0 # CHECK-NEXT: Offset: # CHECK-NEXT: Opcode: [[PTR]]_CONST -# CHECK-NEXT: Value: 1024 +# CHECK-NEXT: Value: 65536 # CHECK-NEXT: Content: 68656C6C6F0A00 -# CHECK-NEXT: - SectionOffset: 20 +# CHECK-NEXT: - SectionOffset: 22 # CHECK-NEXT: InitFlags: 0 # CHECK-NEXT: Offset: # CHECK-NEXT: Opcode: [[PTR]]_CONST -# CHECK-NEXT: Value: 1040 +# CHECK-NEXT: Value: 65552 # RUN: wasm-ld -no-gc-sections --allow-undefined --no-entry \ diff --git a/lld/test/wasm/data-segment-merging.ll b/lld/test/wasm/data-segment-merging.ll index e6f3c5e..34c49e8 100644 --- a/lld/test/wasm/data-segment-merging.ll +++ b/lld/test/wasm/data-segment-merging.ll @@ -15,11 +15,11 @@ ; MERGE-LABEL: - Type: DATA ; MERGE-NEXT: Segments: -; MERGE-NEXT: - SectionOffset: 7 +; MERGE-NEXT: - SectionOffset: 8 ; MERGE-NEXT: InitFlags: 0 ; MERGE-NEXT: Offset: ; MERGE: Content: 636F6E7374616E74000000002B -; MERGE-NEXT: - SectionOffset: 26 +; MERGE-NEXT: - SectionOffset: 28 ; MERGE-NEXT: InitFlags: 0 ; MERGE-NEXT: Offset: ; MERGE: Content: 68656C6C6F00676F6F6462796500776861746576657200002A000000 @@ -41,27 +41,27 @@ ; SEPARATE-NOT: DATACOUNT ; SEPARATE-LABEL: - Type: DATA ; SEPARATE-NEXT: Segments: -; SEPARATE-NEXT: - SectionOffset: 7 +; SEPARATE-NEXT: - SectionOffset: 8 ; SEPARATE-NEXT: InitFlags: 0 ; SEPARATE-NEXT: Offset: ; SEPARATE: Content: 636F6E7374616E7400 -; SEPARATE-NEXT: - SectionOffset: 22 +; SEPARATE-NEXT: - SectionOffset: 24 ; SEPARATE-NEXT: InitFlags: 0 ; SEPARATE-NEXT: Offset: ; SEPARATE: Content: 2B -; SEPARATE-NEXT: - SectionOffset: 29 +; SEPARATE-NEXT: - SectionOffset: 32 ; SEPARATE-NEXT: InitFlags: 0 ; SEPARATE-NEXT: Offset: ; SEPARATE: Content: 68656C6C6F00 -; SEPARATE-NEXT: - SectionOffset: 41 +; SEPARATE-NEXT: - SectionOffset: 45 ; SEPARATE-NEXT: InitFlags: 0 ; SEPARATE-NEXT: Offset: ; SEPARATE: Content: 676F6F6462796500 -; SEPARATE-NEXT: - SectionOffset: 55 +; SEPARATE-NEXT: - SectionOffset: 60 ; SEPARATE-NEXT: InitFlags: 0 ; SEPARATE-NEXT: Offset: ; SEPARATE: Content: '776861746576657200' -; SEPARATE-NEXT: - SectionOffset: 70 +; SEPARATE-NEXT: - SectionOffset: 76 ; SEPARATE-NEXT: InitFlags: 0 ; SEPARATE-NEXT: Offset: ; SEPARATE: Content: 2A000000 diff --git a/lld/test/wasm/data-segments.ll b/lld/test/wasm/data-segments.ll index 6c401c4..237f428 100644 --- a/lld/test/wasm/data-segments.ll +++ b/lld/test/wasm/data-segments.ll @@ -61,20 +61,20 @@ ; ACTIVE-NEXT: Body: 0B ; ACTIVE-NEXT: - Type: DATA ; ACTIVE-NEXT: Segments: -; ACTIVE-NEXT: - SectionOffset: 7 +; ACTIVE-NEXT: - SectionOffset: 8 ; ACTIVE-NEXT: InitFlags: 0 ; ACTIVE-NEXT: Offset: ; ACTIVE32-NEXT: Opcode: I32_CONST ; ACTIVE64-NEXT: Opcode: I64_CONST -; ACTIVE-NEXT: Value: 1024 +; ACTIVE-NEXT: Value: 65536 ; ACTIVE-NEXT: Content: 636F6E7374616E74000000002B -; ACTIVE-NEXT: - SectionOffset: 26 +; ACTIVE-NEXT: - SectionOffset: 28 ; ACTIVE-NEXT: InitFlags: 0 ; ACTIVE-NEXT: Offset: ; ACTIVE32-NEXT: Opcode: I32_CONST ; ACTIVE64-NEXT: Opcode: I64_CONST -; ACTIVE-NEXT: Value: 1040 -; ACTIVE-NEXT: Content: 68656C6C6F00676F6F646279650000002A000000 +; ACTIVE-NEXT: Value: 65552 +; ACTIVE-NEXT: Content: 68656C6C6F00676F6F646279650000002A00000063000000 ; ACTIVE-NEXT: - Type: CUSTOM ; ACTIVE-NEXT: Name: name ; ACTIVE-NEXT: FunctionNames: @@ -201,7 +201,7 @@ ; DIS-NEXT: block ; DIS-NEXT: block -; NOPIC-DIS-NEXT: [[PTR]].const 11064 +; NOPIC-DIS-NEXT: [[PTR]].const 75576 ; PIC-DIS-NEXT: local.get 0 ; DIS-NEXT: i32.const 0 @@ -211,8 +211,8 @@ ; DIS-NEXT: # 2: down to label0 ; DIS-NEXT: end -; NOPIC-DIS-NEXT: [[PTR]].const 1024 -; NOPIC-DIS-NEXT: [[PTR]].const 1024 +; NOPIC-DIS-NEXT: [[PTR]].const 65536 +; NOPIC-DIS-NEXT: [[PTR]].const 65536 ; NOPIC-DIS-NEXT: global.set 1 ; PIC-DIS-NEXT: [[PTR]].const 0 ; PIC-DIS-NEXT: global.get 1 @@ -224,7 +224,7 @@ ; DIS-NEXT: i32.const 4 ; DIS-NEXT: memory.init 0, 0 -; NOPIC-DIS-NEXT: [[PTR]].const 1028 +; NOPIC-DIS-NEXT: [[PTR]].const 65540 ; PIC-DIS-NEXT: [[PTR]].const 4 ; PIC-DIS-NEXT: global.get 1 ; PIC-DIS-NEXT: [[PTR]].add @@ -233,7 +233,7 @@ ; DIS-NEXT: i32.const 13 ; DIS-NEXT: memory.init 1, 0 -; NOPIC-DIS-NEXT: [[PTR]].const 1044 +; NOPIC-DIS-NEXT: [[PTR]].const 65556 ; PIC-DIS-NEXT: [[PTR]].const 20 ; PIC-DIS-NEXT: global.get 1 ; PIC-DIS-NEXT: [[PTR]].add @@ -241,7 +241,7 @@ ; DIS-NEXT: i32.const 0 ; DIS-NEXT: i32.const 20 ; DIS-NEXT: memory.init 2, 0 -; NOPIC-DIS-NEXT: [[PTR]].const 1064 +; NOPIC-DIS-NEXT: [[PTR]].const 65576 ; PIC-DIS-NEXT: [[PTR]].const 40 ; PIC-DIS-NEXT: global.get 1 ; PIC-DIS-NEXT: [[PTR]].add @@ -249,13 +249,13 @@ ; DIS-NEXT: [[PTR]].const 10000 ; DIS-NEXT: memory.fill 0 -; NOPIC-DIS-NEXT: [[PTR]].const 11064 +; NOPIC-DIS-NEXT: [[PTR]].const 75576 ; PIC-DIS-NEXT: local.get 0 ; DIS-NEXT: i32.const 2 ; DIS-NEXT: i32.atomic.store 0 -; NOPIC-DIS-NEXT: [[PTR]].const 11064 +; NOPIC-DIS-NEXT: [[PTR]].const 75576 ; PIC-DIS-NEXT: local.get 0 ; DIS-NEXT: i32.const -1 @@ -264,7 +264,7 @@ ; DIS-NEXT: br 1 # 1: down to label1 ; DIS-NEXT: end -; NOPIC-DIS-NEXT: [[PTR]].const 11064 +; NOPIC-DIS-NEXT: [[PTR]].const 75576 ; PIC-DIS-NEXT: local.get 0 ; DIS-NEXT: i32.const 1 diff --git a/lld/test/wasm/debuginfo.test b/lld/test/wasm/debuginfo.test index 9cb1cc3..7e6bd51 100644 --- a/lld/test/wasm/debuginfo.test +++ b/lld/test/wasm/debuginfo.test @@ -50,7 +50,7 @@ CHECK-NEXT: DW_AT_type (0x000000ac "int[2]") CHECK-NEXT: DW_AT_external (true) CHECK-NEXT: DW_AT_decl_file ("{{.*}}hi_foo.c") CHECK-NEXT: DW_AT_decl_line (1) -CHECK: DW_AT_location (DW_OP_addr 0x400) +CHECK: DW_AT_location (DW_OP_addr 0x10000) CHECK: DW_TAG_array_type diff --git a/lld/test/wasm/dylink-non-pie.s b/lld/test/wasm/dylink-non-pie.s index 3157b8c..fddfddb 100755 --- a/lld/test/wasm/dylink-non-pie.s +++ b/lld/test/wasm/dylink-non-pie.s @@ -32,7 +32,7 @@ f_p: # DIS: <__wasm_apply_data_relocs>: # DIS-EMPTY: -# DIS-NEXT: i32.const 1024 +# DIS-NEXT: i32.const 65536 # DIS-NEXT: global.get 0 # DIS-NEXT: i32.store 0 # DIS-NEXT: end diff --git a/lld/test/wasm/emit-relocs.s b/lld/test/wasm/emit-relocs.s index 385344c..3df345c 100644 --- a/lld/test/wasm/emit-relocs.s +++ b/lld/test/wasm/emit-relocs.s @@ -41,11 +41,11 @@ foo: # CHECK: - Type: DATA # CHECK-NEXT: Segments: -# CHECK-NEXT: - SectionOffset: 7 +# CHECK-NEXT: - SectionOffset: 8 # CHECK-NEXT: InitFlags: 0 # CHECK-NEXT: Offset: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 1024 +# CHECK-NEXT: Value: 65536 # CHECK-NEXT: Content: '00000000' # There should be a single relocation in this section (just the live symbol) @@ -75,5 +75,5 @@ foo: # CHECK-NEXT: Kind: DATA # CHECK-NEXT: Name: __stack_low # CHECK-NEXT: Flags: [ VISIBILITY_HIDDEN, ABSOLUTE ] -# CHECK-NEXT: Offset: 1040 # CHECK-NEXT: Size: 0 +# CHECK-NEXT: - Index: 3 diff --git a/lld/test/wasm/externref.s b/lld/test/wasm/externref.s index ffc63a6..1443e5f 100644 --- a/lld/test/wasm/externref.s +++ b/lld/test/wasm/externref.s @@ -35,7 +35,7 @@ _start: # CHECK-NEXT: Mutable: true # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 66560 +# CHECK-NEXT: Value: 65536 # CHECK-NEXT: - Index: 1 # CHECK-NEXT: Type: EXTERNREF # CHECK-NEXT: Mutable: true diff --git a/lld/test/wasm/gc-sections.ll b/lld/test/wasm/gc-sections.ll index e709ab7..69d7ed2 100644 --- a/lld/test/wasm/gc-sections.ll +++ b/lld/test/wasm/gc-sections.ll @@ -57,7 +57,7 @@ entry: ; CHECK-NEXT: Mutable: true ; CHECK-NEXT: InitExpr: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 66576 +; CHECK-NEXT: Value: 65536 ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Type: I64 ; CHECK-NEXT: Mutable: true @@ -67,11 +67,11 @@ entry: ; CHECK: - Type: DATA ; CHECK-NEXT: Segments: -; CHECK-NEXT: - SectionOffset: 7 +; CHECK-NEXT: - SectionOffset: 8 ; CHECK-NEXT: InitFlags: 0 ; CHECK-NEXT: Offset: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 1024 +; CHECK-NEXT: Value: 65536 ; CHECK-NEXT: Content: '02000000' ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name @@ -123,7 +123,7 @@ entry: ; NO-GC-NEXT: Mutable: true ; NO-GC-NEXT: InitExpr: ; NO-GC-NEXT: Opcode: I32_CONST -; NO-GC-NEXT: Value: 66576 +; NO-GC-NEXT: Value: 65536 ; NO-GC-NEXT: - Index: 1 ; NO-GC-NEXT: Type: I64 ; NO-GC-NEXT: Mutable: true @@ -139,11 +139,11 @@ entry: ; NO-GC: - Type: DATA ; NO-GC-NEXT: Segments: -; NO-GC-NEXT: - SectionOffset: 7 +; NO-GC-NEXT: - SectionOffset: 8 ; NO-GC-NEXT: InitFlags: 0 ; NO-GC-NEXT: Offset: ; NO-GC-NEXT: Opcode: I32_CONST -; NO-GC-NEXT: Value: 1024 +; NO-GC-NEXT: Value: 65536 ; NO-GC-NEXT: Content: '010000000000000002000000' ; NO-GC-NEXT: - Type: CUSTOM ; NO-GC-NEXT: Name: name diff --git a/lld/test/wasm/global-base.test b/lld/test/wasm/global-base.test index 0e65f0c..e84b8ec 100644 --- a/lld/test/wasm/global-base.test +++ b/lld/test/wasm/global-base.test @@ -19,19 +19,19 @@ CHECK-1024-NEXT: Type: I32 CHECK-1024-NEXT: Mutable: true CHECK-1024-NEXT: InitExpr: CHECK-1024-NEXT: Opcode: I32_CONST -CHECK-1024-NEXT: Value: 66560 +CHECK-1024-NEXT: Value: 65536 CHECK-1024-NEXT: - Index: 1 CHECK-1024-NEXT: Type: I32 CHECK-1024-NEXT: Mutable: false CHECK-1024-NEXT: InitExpr: CHECK-1024-NEXT: Opcode: I32_CONST -CHECK-1024-NEXT: Value: 1024 +CHECK-1024-NEXT: Value: 65536 CHECK-1024-NEXT: - Index: 2 CHECK-1024-NEXT: Type: I32 CHECK-1024-NEXT: Mutable: false CHECK-1024-NEXT: InitExpr: CHECK-1024-NEXT: Opcode: I32_CONST -CHECK-1024-NEXT: Value: 1024 +CHECK-1024-NEXT: Value: 65536 CHECK-1024: - Type: EXPORT CHECK-1024: - Name: __data_end @@ -50,7 +50,7 @@ CHECK-16777216-NEXT: Type: I32 CHECK-16777216-NEXT: Mutable: true CHECK-16777216-NEXT: InitExpr: CHECK-16777216-NEXT: Opcode: I32_CONST -CHECK-16777216-NEXT: Value: 16842752 +CHECK-16777216-NEXT: Value: 65536 CHECK-16777216-NEXT: - Index: 1 CHECK-16777216-NEXT: Type: I32 CHECK-16777216-NEXT: Mutable: false diff --git a/lld/test/wasm/globals.s b/lld/test/wasm/globals.s index 6e049e1..47d9ba8 100644 --- a/lld/test/wasm/globals.s +++ b/lld/test/wasm/globals.s @@ -42,7 +42,7 @@ immutable_global: # CHECK-NEXT: Mutable: true # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 66560 +# CHECK-NEXT: Value: 65536 # CHECK-NEXT: - Index: 1 # CHECK-NEXT: Type: I32 # CHECK-NEXT: Mutable: false diff --git a/lld/test/wasm/import-memory.test b/lld/test/wasm/import-memory.test index dd7066d..9b8148e 100644 --- a/lld/test/wasm/import-memory.test +++ b/lld/test/wasm/import-memory.test @@ -10,7 +10,7 @@ # CHECK-NEXT: Field: memory # CHECK-NEXT: Kind: MEMORY # CHECK-NEXT: Memory: -# CHECK-NEXT: Minimum: 0x2 +# CHECK-NEXT: Minimum: 0x1 # CHECK-NEXT: - Type: diff --git a/lld/test/wasm/init-fini.ll b/lld/test/wasm/init-fini.ll index ef2f41f..7471ebb 100644 --- a/lld/test/wasm/init-fini.ll +++ b/lld/test/wasm/init-fini.ll @@ -78,7 +78,7 @@ entry: ; CHECK-NEXT: Body: 10041005100A100F1012100F10141004100C100F10161002100E0B ; CHECK: - Index: 22 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 02404186808080004100418088808000108080808000450D00000B0B +; CHECK-NEXT: Body: 02404186808080004100418080848000108080808000450D00000B0B ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name ; CHECK-NEXT: FunctionNames: diff --git a/lld/test/wasm/large-memory.test b/lld/test/wasm/large-memory.test index 5b737e4..a2888c6 100644 --- a/lld/test/wasm/large-memory.test +++ b/lld/test/wasm/large-memory.test @@ -12,7 +12,7 @@ RUN: obj2yaml %t2.wasm | FileCheck %s --check-prefixes=CHECK,CHECK-4G CHECK: - Type: MEMORY CHECK-NEXT: Memories: CHECK-NEXT: - Flags: [ HAS_MAX ] -CHECK-NEXT: Minimum: 0x2 +CHECK-NEXT: Minimum: 0x1 CHECK-2G-NEXT: Maximum: 0x8000 CHECK-4G-NEXT: Maximum: 0x10000 diff --git a/lld/test/wasm/local-symbols.ll b/lld/test/wasm/local-symbols.ll index 8faee64..6c639a8 100644 --- a/lld/test/wasm/local-symbols.ll +++ b/lld/test/wasm/local-symbols.ll @@ -45,13 +45,13 @@ entry: ; CHECK-NEXT: Mutable: true ; CHECK-NEXT: InitExpr: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 66576 +; CHECK-NEXT: Value: 65536 ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Type: I32 ; CHECK-NEXT: Mutable: false ; CHECK-NEXT: InitExpr: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 1024 +; CHECK-NEXT: Value: 65536 ; CHECK-NEXT: - Type: EXPORT ; CHECK-NEXT: Exports: ; CHECK-NEXT: - Name: memory @@ -67,17 +67,17 @@ entry: ; CHECK-NEXT: Functions: ; CHECK-NEXT: - Index: 0 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4100280284888080000B +; CHECK-NEXT: Body: 4100280284808480000B ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 1080808080001A0B ; CHECK-NEXT: - Type: DATA ; CHECK-NEXT: Segments: -; CHECK-NEXT: - SectionOffset: 7 +; CHECK-NEXT: - SectionOffset: 8 ; CHECK-NEXT: InitFlags: 0 ; CHECK-NEXT: Offset: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 1024 +; CHECK-NEXT: Value: 65536 ; CHECK-NEXT: Content: '0100000003000000' ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name diff --git a/lld/test/wasm/locals-duplicate.test b/lld/test/wasm/locals-duplicate.test index 5c3135a..88819b2 100644 --- a/lld/test/wasm/locals-duplicate.test +++ b/lld/test/wasm/locals-duplicate.test @@ -26,7 +26,7 @@ ; CHECK-NEXT: Maximum: 0x7 ; CHECK-NEXT: - Type: MEMORY ; CHECK-NEXT: Memories: -; CHECK-NEXT: - Minimum: 0x2 +; CHECK-NEXT: - Minimum: 0x2 ; CHECK-NEXT: - Type: GLOBAL ; CHECK-NEXT: Globals: ; CHECK-NEXT: - Index: 0 @@ -34,19 +34,19 @@ ; CHECK-NEXT: Mutable: true ; CHECK-NEXT: InitExpr: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 66592 +; CHECK-NEXT: Value: 65536 ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Type: I32 ; CHECK-NEXT: Mutable: false ; CHECK-NEXT: InitExpr: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 1028 +; CHECK-NEXT: Value: 65540 ; CHECK-NEXT: - Index: 2 ; CHECK-NEXT: Type: I32 ; CHECK-NEXT: Mutable: false ; CHECK-NEXT: InitExpr: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 1036 +; CHECK-NEXT: Value: 65548 ; CHECK-NEXT: - Type: EXPORT ; CHECK-NEXT: Exports: ; CHECK-NEXT: - Name: memory @@ -119,13 +119,13 @@ ; CHECK-NEXT: Body: 41020B ; CHECK-NEXT: - Index: 3 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4180888080000B +; CHECK-NEXT: Body: 4180808480000B ; CHECK-NEXT: - Index: 4 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4184888080000B +; CHECK-NEXT: Body: 4184808480000B ; CHECK-NEXT: - Index: 5 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4188888080000B +; CHECK-NEXT: Body: 4188808480000B ; CHECK-NEXT: - Index: 6 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 4181808080000B @@ -146,13 +146,13 @@ ; CHECK-NEXT: Body: 41020B ; CHECK-NEXT: - Index: 12 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 418C888080000B +; CHECK-NEXT: Body: 418C808480000B ; CHECK-NEXT: - Index: 13 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4190888080000B +; CHECK-NEXT: Body: 4190808480000B ; CHECK-NEXT: - Index: 14 ; CHECK-NEXT: Locals: -; CHECK-NEXT: Body: 4194888080000B +; CHECK-NEXT: Body: 4194808480000B ; CHECK-NEXT: - Index: 15 ; CHECK-NEXT: Locals: ; CHECK-NEXT: Body: 4184808080000B @@ -164,11 +164,11 @@ ; CHECK-NEXT: Body: 4186808080000B ; CHECK-NEXT: - Type: DATA ; CHECK-NEXT: Segments: -; CHECK-NEXT: - SectionOffset: 7 +; CHECK-NEXT: - SectionOffset: 8 ; CHECK-NEXT: InitFlags: 0 ; CHECK-NEXT: Offset: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 1024 +; CHECK-NEXT: Value: 65536 ; CHECK-NEXT: Content: '010000000100000001000000010000000100000001000000' ; CHECK-NEXT: - Type: CUSTOM ; CHECK-NEXT: Name: name diff --git a/lld/test/wasm/lto/cpu-string.ll b/lld/test/wasm/lto/cpu-string.ll new file mode 100644 index 0000000..7b5a88f --- /dev/null +++ b/lld/test/wasm/lto/cpu-string.ll @@ -0,0 +1,27 @@ +; RUN: llvm-as %s -o %t.o + +; RUN: wasm-ld %t.o -o %t.wasm +; RUN: obj2yaml %t.wasm | FileCheck %s + +; CHECK: bulk-memory +; CHECK-NOT: multimemory + +; RUN: wasm-ld -mllvm -mcpu=mvp %t.o -o %t.mvp.wasm +; RUN: obj2yaml %t.mvp.wasm | FileCheck --check-prefix=CHECK-MVP %s + +; CHECK-MVP-NOT: bulk-memory +; CHECK-MVP-NOT: multimemory + +; RUN: wasm-ld -mllvm -mcpu=bleeding-edge %t.o -o %t.mvp.wasm +; RUN: obj2yaml %t.mvp.wasm | FileCheck --check-prefix=CHECK-BLEEDING-EDGE %s + +; CHECK-BLEEDING-EDGE: bulk-memory +; CHECK-BLEEDING-EDGE: multimemory + +target datalayout = "e-m:e-p:32:32-p10:8:8-p20:8:8-i64:64-n32:64-S128-ni:1:10:20" +target triple = "wasm32-unknown-unknown" + +define void @_start() #0 { +entry: + ret void +} diff --git a/lld/test/wasm/lto/relocation-model.ll b/lld/test/wasm/lto/relocation-model.ll index 8fe198d..a042615 100644 --- a/lld/test/wasm/lto/relocation-model.ll +++ b/lld/test/wasm/lto/relocation-model.ll @@ -8,6 +8,11 @@ ; RUN: wasm-ld %t.o -o %t_static.wasm -save-temps -r -mllvm -relocation-model=static ; RUN: llvm-readobj -r %t_static.wasm.lto.o | FileCheck %s --check-prefix=STATIC +;; Linking with --unresolved-symbols=import-dynamic should also generate PIC +;; code for external references. +; RUN: wasm-ld %t.o -o %t_import.wasm -save-temps --experimental-pic --unresolved-symbols=import-dynamic +; RUN: llvm-readobj -r %t_import.wasm.lto.o | FileCheck %s --check-prefix=PIC + ; PIC: R_WASM_GLOBAL_INDEX_LEB foo ; STATIC: R_WASM_MEMORY_ADDR_LEB foo diff --git a/lld/test/wasm/lto/tls.ll b/lld/test/wasm/lto/tls.ll index b61edfb..9c1642e 100644 --- a/lld/test/wasm/lto/tls.ll +++ b/lld/test/wasm/lto/tls.ll @@ -30,13 +30,13 @@ attributes #0 = { noinline nounwind optnone "target-features"="+atomics,+bulk-me ; CHECK-NEXT: Mutable: true ; CHECK-NEXT: InitExpr: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 66576 +; CHECK-NEXT: Value: 65536 ; CHECK-NEXT: - Index: 1 ; CHECK-NEXT: Type: I32 ; CHECK-NEXT: Mutable: false ; CHECK-NEXT: InitExpr: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 1024 +; CHECK-NEXT: Value: 65536 ; CHECK: GlobalNames: ; CHECK-NEXT: - Index: 0 diff --git a/lld/test/wasm/lto/used.ll b/lld/test/wasm/lto/used.ll index a185103..dd36259 100644 --- a/lld/test/wasm/lto/used.ll +++ b/lld/test/wasm/lto/used.ll @@ -26,11 +26,11 @@ return: ; CHECK: - Type: DATA ; CHECK-NEXT: Segments: -; CHECK-NEXT: - SectionOffset: 7 +; CHECK-NEXT: - SectionOffset: 8 ; CHECK-NEXT: InitFlags: 0 ; CHECK-NEXT: Offset: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 1024 +; CHECK-NEXT: Value: 65536 ; CHECK-NEXT: Content: '01000000' ; CHECK: - Type: CUSTOM diff --git a/lld/test/wasm/map-file.s b/lld/test/wasm/map-file.s index 2757f50..380ab57 100644 --- a/lld/test/wasm/map-file.s +++ b/lld/test/wasm/map-file.s @@ -59,15 +59,15 @@ somezeroes: # CHECK-NEXT: - 66 b write_global # CHECK-NEXT: - 71 f {{.*}}{{/|\\}}map-file.s.tmp1.o:(_start) # CHECK-NEXT: - 71 f _start -# CHECK-NEXT: - 82 11 DATA -# CHECK-NEXT: 400 83 8 .data -# CHECK-NEXT: 400 89 8 {{.*}}{{/|\\}}map-file.s.tmp1.o:(.data.somedata) -# CHECK-NEXT: 400 89 8 somedata -# CHECK-NEXT: 408 82 4 .bss -# CHECK-NEXT: 408 0 4 {{.*}}{{/|\\}}map-file.s.tmp1.o:(.bss.somezeroes) -# CHECK-NEXT: 408 0 4 somezeroes -# CHECK-NEXT: - 93 12 CUSTOM(.debug_info) -# CHECK-NEXT: - a5 61 CUSTOM(name) +# CHECK-NEXT: - 82 12 DATA +# CHECK-NEXT: 10000 83 8 .data +# CHECK-NEXT: 10000 8a 8 {{.*}}{{/|\\}}map-file.s.tmp1.o:(.data.somedata) +# CHECK-NEXT: 10000 8a 8 somedata +# CHECK-NEXT: 10008 82 4 .bss +# CHECK-NEXT: 10008 0 4 {{.*}}{{/|\\}}map-file.s.tmp1.o:(.bss.somezeroes) +# CHECK-NEXT: 10008 0 4 somezeroes +# CHECK-NEXT: - 94 12 CUSTOM(.debug_info) +# CHECK-NEXT: - a6 61 CUSTOM(name) # RUN: not wasm-ld %t1.o -o /dev/null -Map=/ 2>&1 \ # RUN: | FileCheck -check-prefix=FAIL %s diff --git a/lld/test/wasm/memory-naming.test b/lld/test/wasm/memory-naming.test index 766d9cd5..66143c3 100644 --- a/lld/test/wasm/memory-naming.test +++ b/lld/test/wasm/memory-naming.test @@ -57,7 +57,7 @@ # CHECK-IMPORT-NEXT: Field: bar # CHECK-IMPORT-NEXT: Kind: MEMORY # CHECK-IMPORT-NEXT: Memory: -# CHECK-IMPORT-NEXT: Minimum: 0x2 +# CHECK-IMPORT-NEXT: Minimum: 0x1 # CHECK-IMPORT: - Type: EXPORT # CHECK-IMPORT-NEXT: Exports: # CHECK-IMPORT-NEXT: - Name: _start @@ -77,7 +77,7 @@ # CHECK-IMPORT-DEFAULT-NEXT: Field: foo # CHECK-IMPORT-DEFAULT-NEXT: Kind: MEMORY # CHECK-IMPORT-DEFAULT-NEXT: Memory: -# CHECK-IMPORT-DEFAULT-NEXT: Minimum: 0x2 +# CHECK-IMPORT-DEFAULT-NEXT: Minimum: 0x1 # CHECK-IMPORT-DEFAULT-NEXT: - Type: # RUN:wasm-ld --import-memory=foo,bar --export-memory=qux -o %t.both.wasm %t.start.o @@ -91,7 +91,7 @@ # CHECK-BOTH-NEXT: Field: bar # CHECK-BOTH-NEXT: Kind: MEMORY # CHECK-BOTH-NEXT: Memory: -# CHECK-BOTH-NEXT: Minimum: 0x2 +# CHECK-BOTH-NEXT: Minimum: 0x1 # CHECK-BOTH: - Type: EXPORT # CHECK-BOTH-NEXT: Exports: # CHECK-BOTH-NEXT: - Name: qux diff --git a/lld/test/wasm/merge-string.s b/lld/test/wasm/merge-string.s index a4b89abf..229f393 100644 --- a/lld/test/wasm/merge-string.s +++ b/lld/test/wasm/merge-string.s @@ -41,21 +41,21 @@ negative_addend: // COMMON-NEXT: Mutable: true // COMMON-NEXT: InitExpr: // COMMON-NEXT: Opcode: I32_CONST -// COMMON-NEXT: Value: 66576 +// COMMON-NEXT: Value: 65536 // COMMON-NEXT: - Index: 1 // COMMON-NEXT: Type: I32 // COMMON-NEXT: Mutable: false // COMMON-NEXT: InitExpr: // COMMON-NEXT: Opcode: I32_CONST -// MERGE-NEXT: Value: 1024 -// NOMERGE-NEXT: Value: 1028 +// MERGE-NEXT: Value: 65536 +// NOMERGE-NEXT: Value: 65540 // COMMON-NEXT: - Index: 2 // COMMON-NEXT: Type: I32 // COMMON-NEXT: Mutable: false // COMMON-NEXT: InitExpr: // COMMON-NEXT: Opcode: I32_CONST -// MERGE-NEXT: Value: 1025 -// NOMERGE-NEXT: Value: 1029 +// MERGE-NEXT: Value: 65537 +// NOMERGE-NEXT: Value: 65541 // COMMON-NEXT: - Type: EXPORT // COMMON-NEXT: Exports: // COMMON-NEXT: - Name: memory @@ -71,11 +71,11 @@ negative_addend: // // COMMON: - Type: DATA // COMMON-NEXT: Segments: -// COMMON-NEXT: - SectionOffset: 7 +// COMMON-NEXT: - SectionOffset: 8 // COMMON-NEXT: InitFlags: 0 // COMMON-NEXT: Offset: // COMMON-NEXT: Opcode: I32_CONST -// COMMON-NEXT: Value: 1024 +// COMMON-NEXT: Value: 65536 // MERGE-NEXT: Content: '61626300' // NOMERGE-NEXT: Content: '6162630061626300626300' diff --git a/lld/test/wasm/multi-table.s b/lld/test/wasm/multi-table.s index afe8dda..31cba9f 100644 --- a/lld/test/wasm/multi-table.s +++ b/lld/test/wasm/multi-table.s @@ -87,7 +87,7 @@ call_indirect_explicit_tables: # CHECK-NEXT: Mutable: true # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 66576 +# CHECK-NEXT: Value: 65536 # CHECK-NEXT: - Type: EXPORT # CHECK-NEXT: Exports: # CHECK-NEXT: - Name: memory @@ -127,14 +127,14 @@ call_indirect_explicit_tables: # CHECK-NEXT: Body: 42010B # CHECK-NEXT: - Index: 3 # CHECK-NEXT: Locals: [] -# CHECK-NEXT: Body: 41002802808880800011818080800083808080001A41002802848880800011828080800083808080001A0B +# CHECK-NEXT: Body: 41002802808084800011818080800083808080001A41002802848084800011828080800083808080001A0B # CHECK-NEXT: - Type: DATA # CHECK-NEXT: Segments: -# CHECK-NEXT: - SectionOffset: 7 +# CHECK-NEXT: - SectionOffset: 8 # CHECK-NEXT: InitFlags: 0 # CHECK-NEXT: Offset: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 1024 +# CHECK-NEXT: Value: 65536 # CHECK-NEXT: Content: '0100000002000000' # CHECK-NEXT: - Type: CUSTOM # CHECK-NEXT: Name: name diff --git a/lld/test/wasm/no-strip-segment.s b/lld/test/wasm/no-strip-segment.s index e70acae..2b79ed6 100644 --- a/lld/test/wasm/no-strip-segment.s +++ b/lld/test/wasm/no-strip-segment.s @@ -47,16 +47,16 @@ grab_liba: # "greetings" section # CHECK: - Type: DATA # CHECK: Segments: -# CHECK: - SectionOffset: 7 +# CHECK: - SectionOffset: 8 # CHECK: InitFlags: 0 # CHECK: Offset: # CHECK: Opcode: I32_CONST -# CHECK: Value: 1024 +# CHECK: Value: 65536 # CHECK: Content: 68656C6C6F00776F726C6400 # "weahters" section. -# CHECK: - SectionOffset: 25 +# CHECK: - SectionOffset: 27 # CHECK: InitFlags: 0 # CHECK: Offset: # CHECK: Opcode: I32_CONST -# CHECK: Value: 1036 +# CHECK: Value: 65548 # CHECK: Content: 636C6F75647900 diff --git a/lld/test/wasm/no-tls.s b/lld/test/wasm/no-tls.s index c0786c8..c082c1e 100644 --- a/lld/test/wasm/no-tls.s +++ b/lld/test/wasm/no-tls.s @@ -28,7 +28,7 @@ _start: # CHECK-NEXT: Mutable: true # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 66560 +# CHECK-NEXT: Value: 65536 # __tls_base # CHECK-NEXT: - Index: 1 diff --git a/lld/test/wasm/page-size.s b/lld/test/wasm/page-size.s index a2bf694..17850b5 100644 --- a/lld/test/wasm/page-size.s +++ b/lld/test/wasm/page-size.s @@ -19,7 +19,7 @@ foo: # CHECK-CUSTOM: - Type: MEMORY # CHECK-CUSTOM-NEXT: Memories: # CHECK-CUSTOM-NEXT: - Flags: [ HAS_PAGE_SIZE ] -# CHECK-CUSTOM-NEXT: Minimum: 0x10410 +# CHECK-CUSTOM-NEXT: Minimum: 0x10004 # CHECK-CUSTOM-NEXT: PageSize: 0x1 # RUN: llvm-objdump --disassemble-symbols=_start %t.custom.wasm | FileCheck %s --check-prefix=CHECK-CUSTOM-DIS @@ -51,7 +51,7 @@ foo: # CHECK-CUSTOM-IMPORT-NEXT: Kind: MEMORY # CHECK-CUSTOM-IMPORT-NEXT: Memory: # CHECK-CUSTOM-IMPORT-NEXT: Flags: [ HAS_PAGE_SIZE ] -# CHECK-CUSTOM-IMPORT-NEXT: Minimum: 0x10410 +# CHECK-CUSTOM-IMPORT-NEXT: Minimum: 0x10004 # CHECK-CUSTOM-IMPORT-NEXT: PageSize: 0x1 # RUN: llvm-objdump --disassemble-symbols=_start %t.custom-import.wasm | FileCheck %s --check-prefix=CHECK-CUSTOM-IMPORT-DIS diff --git a/lld/test/wasm/pic-static.ll b/lld/test/wasm/pic-static.ll index 794b721..12ac4c3 100644 --- a/lld/test/wasm/pic-static.ll +++ b/lld/test/wasm/pic-static.ll @@ -62,7 +62,7 @@ entry: ; CHECK-NEXT: Mutable: true ; CHECK-NEXT: InitExpr: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 66576 +; CHECK-NEXT: Value: 65536 ; GOT.func.ret32 ; CHECK-NEXT: - Index: 1 @@ -70,7 +70,7 @@ entry: ; CHECK-NEXT: Mutable: false ; CHECK-NEXT: InitExpr: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 1 +; CHECK-NEXT: Value: 1 ; GOT.func.missing_function ; CHECK-NEXT: - Index: 2 @@ -102,7 +102,7 @@ entry: ; CHECK-NEXT: Mutable: false ; CHECK-NEXT: InitExpr: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 1024 +; CHECK-NEXT: Value: 65536 ; GOT.mem.ret32_ptr ; CHECK-NEXT: - Index: 6 @@ -110,7 +110,7 @@ entry: ; CHECK-NEXT: Mutable: false ; CHECK-NEXT: InitExpr: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 1032 +; CHECK-NEXT: Value: 65544 ; __memory_base ; CHECK-NEXT: - Index: 7 diff --git a/lld/test/wasm/reloc-relative.s b/lld/test/wasm/reloc-relative.s index fde1d1d..5aab061 100644 --- a/lld/test/wasm/reloc-relative.s +++ b/lld/test/wasm/reloc-relative.s @@ -50,40 +50,40 @@ far: # CHECK: - Type: DATA # CHECK-NEXT: Segments: -# CHECK-NEXT: - SectionOffset: 7 +# CHECK-NEXT: - SectionOffset: 8 # CHECK-NEXT: InitFlags: 0 # CHECK-NEXT: Offset: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 1024 +# CHECK-NEXT: Value: 65536 # CHECK-NEXT: Content: 68656C6C6F0A00 -# CHECK-NEXT: - SectionOffset: 20 +# CHECK-NEXT: - SectionOffset: 22 # CHECK-NEXT: InitFlags: 0 # CHECK-NEXT: Offset: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 1031 +# CHECK-NEXT: Value: 65543 # CHECK-NEXT: Content: 000000002A000000 -# CHECK-NEXT: - SectionOffset: 34 +# CHECK-NEXT: - SectionOffset: 37 # CHECK-NEXT: InitFlags: 0 # CHECK-NEXT: Offset: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 1039 +# CHECK-NEXT: Value: 65551 # CHECK-NEXT: Content: FCFFFFFFFCFFFFFF -# CHECK-NEXT: - SectionOffset: 48 +# CHECK-NEXT: - SectionOffset: 52 # CHECK-NEXT: InitFlags: 0 # CHECK-NEXT: Offset: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 1047 +# CHECK-NEXT: Value: 65559 # CHECK-NEXT: Content: E9FFFFFFE9FFFFFF -# CHECK-NEXT: - SectionOffset: 62 +# CHECK-NEXT: - SectionOffset: 67 # CHECK-NEXT: InitFlags: 0 # CHECK-NEXT: Offset: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 1055 +# CHECK-NEXT: Value: 65567 # CHECK-NEXT: Content: '0800000008000000' -# CHECK-NEXT: - SectionOffset: 76 +# CHECK-NEXT: - SectionOffset: 82 # CHECK-NEXT: InitFlags: 0 # CHECK-NEXT: Offset: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 1063 +# CHECK-NEXT: Value: 65575 # CHECK-NEXT: Content: '15000000' diff --git a/lld/test/wasm/runtime-relocations-himem.s b/lld/test/wasm/runtime-relocations-himem.s new file mode 100644 index 0000000..a12a93a --- /dev/null +++ b/lld/test/wasm/runtime-relocations-himem.s @@ -0,0 +1,60 @@ +## Verifies runtime relocation code for addresses over 2gb works correctly. +## We have had issues with LEB encoding of address over 2gb in i32.const +## instruction leading to invalid binaries. + +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown -o %t.o %s +# RUN: wasm-ld --global-base=2147483648 --experimental-pic --unresolved-symbols=import-dynamic -no-gc-sections --shared-memory --no-entry -o %t.wasm %t.o +# XUN: obj2yaml %t.wasm | FileCheck %s +# RUN: llvm-objdump -d --no-show-raw-insn --no-leading-addr %t.wasm | FileCheck %s -- + +.globl tls_sym +.globl data_sym +.globl _start +.globaltype __tls_base, i32 + +_start: + .functype _start () -> () + global.get __tls_base + i32.const tls_sym@TLSREL + i32.add + drop + i32.const data_sym + drop + end_function + +.section tls_sec,"T",@ +.p2align 2 +tls_sym: + .int32 0 + .int32 extern_sym + .size tls_sym, 8 + +.section data_sec,"",@ +.p2align 2 +data_sym: + .int32 0 + .int32 extern_sym + .size data_sym, 8 + +.section .custom_section.target_features,"",@ + .int8 2 + .int8 43 + .int8 7 + .ascii "atomics" + .int8 43 + .int8 11 + .ascii "bulk-memory" + +# CHECK: <__wasm_apply_data_relocs>: +# CHECK-EMPTY: +# CHECK-NEXT: i32.const -2147483636 +# CHECK-NEXT: global.get 0 +# CHECK-NEXT: i32.store 0 +# CHECK-NEXT: end + +# CHECK: <__wasm_apply_tls_relocs>: +# CHECK-EMPTY: +# CHECK-NEXT: i32.const -2147483644 +# CHECK-NEXT: global.get 0 +# CHECK-NEXT: i32.store 0 +# CHECK-NEXT: end diff --git a/lld/test/wasm/shared-memory-no-atomics.yaml b/lld/test/wasm/shared-memory-no-atomics.yaml index 942c690..62f4ac9 100644 --- a/lld/test/wasm/shared-memory-no-atomics.yaml +++ b/lld/test/wasm/shared-memory-no-atomics.yaml @@ -55,7 +55,7 @@ Sections: # NO-SHARED: - Type: MEMORY # NO-SHARED-NEXT: Memories: -# NO-SHARED-NEXT: - Minimum: 0x2 +# NO-SHARED-NEXT: - Minimum: 0x1 # NO-SHARED-NOT: Maximum: # SHARED: --shared-memory is disallowed by {{.*}}shared-memory-no-atomics.yaml.tmp1.o because it was not compiled with 'atomics' or 'bulk-memory' features. diff --git a/lld/test/wasm/shared-memory.yaml b/lld/test/wasm/shared-memory.yaml index 4cdbb95..b3490c8 100644 --- a/lld/test/wasm/shared-memory.yaml +++ b/lld/test/wasm/shared-memory.yaml @@ -1,16 +1,16 @@ # RUN: yaml2obj %s -o %t1.o -# RUN: wasm-ld --no-entry --shared-memory --features=atomics,bulk-memory %t1.o -o - | obj2yaml | FileCheck %s --check-prefix SHARED +# RUN: wasm-ld --no-entry --no-gc-sections --shared-memory --features=atomics,bulk-memory %t1.o -o - | obj2yaml | FileCheck %s --check-prefix SHARED -# RUN: not wasm-ld --no-entry --shared-memory --max-memory=100000 %t1.o -o - 2>&1 | FileCheck %s --check-prefix SHARED-UNALIGNED +# RUN: not wasm-ld --no-entry --no-gc-sections --shared-memory --max-memory=100000 %t1.o -o - 2>&1 | FileCheck %s --check-prefix SHARED-UNALIGNED -# RUN: not wasm-ld --no-entry --shared-memory --max-memory=131072 --features=bulk-memory %t1.o -o - 2>&1 | FileCheck %s --check-prefix SHARED-NO-ATOMICS +# RUN: not wasm-ld --no-entry --no-gc-sections --shared-memory --max-memory=131072 --features=bulk-memory %t1.o -o - 2>&1 | FileCheck %s --check-prefix SHARED-NO-ATOMICS -# RUN: not wasm-ld --no-entry --shared-memory --max-memory=131072 --features=atomics %t1.o -o - 2>&1 | FileCheck %s --check-prefix SHARED-NO-BULK-MEM +# RUN: not wasm-ld --no-entry --no-gc-sections --shared-memory --max-memory=131072 --features=atomics %t1.o -o - 2>&1 | FileCheck %s --check-prefix SHARED-NO-BULK-MEM # RUN: wasm-ld --relocatable --features=atomics %t1.o -o - | obj2yaml | FileCheck %s --check-prefix ATOMICS-RELOCATABLE -# RUN: wasm-ld --no-entry --shared-memory --max-memory=131072 --features=atomics,bulk-memory %t1.o -o - | obj2yaml | FileCheck %s --check-prefix SHARED +# XUN: wasm-ld --no-entry --no-gc-sections --shared-memory --max-memory=131072 --features=atomics,bulk-memory %t1.o -o - | obj2yaml | FileCheck %s --check-prefix SHARED --- !WASM FileHeader: @@ -22,7 +22,7 @@ Sections: Field: __linear_memory Kind: MEMORY Memory: - Minimum: 0x00000001 + Minimum: 0x00000009 - Module: env Field: __indirect_function_table Kind: TABLE diff --git a/lld/test/wasm/stack-first.test b/lld/test/wasm/stack-first.test index 72e1a00..91f06a4 100644 --- a/lld/test/wasm/stack-first.test +++ b/lld/test/wasm/stack-first.test @@ -5,9 +5,20 @@ ; Also test that __heap_base is still aligned with the --stack-first option. RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %p/Inputs/stack-first.s -o %t.o -RUN: wasm-ld -z stack-size=512 --stack-first --export=__data_end --export=__heap_base --export=someByte -o %t.wasm %t.o + +; Check that the default is `--stack-first` +RUN: wasm-ld -z stack-size=512 --export=__data_end --export=__heap_base --export=someByte -o %t.wasm %t.o +RUN: obj2yaml %t.wasm | FileCheck %s + +; Check `--no-stack-first` +RUN: wasm-ld -z stack-size=512 --no-stack-first --export=__data_end --export=__heap_base --export=someByte -o %t.wasm %t.o +RUN: obj2yaml %t.wasm | FileCheck %s --check-prefix=NOT-FIRST + +; Check `--stack-first` +RUN: wasm-ld -z stack-size=512 --no-stack-first --stack-first --export=__data_end --export=__heap_base --export=someByte -o %t.wasm %t.o RUN: obj2yaml %t.wasm | FileCheck %s + CHECK: - Type: GLOBAL CHECK-NEXT: Globals: CHECK-NEXT: - Index: 0 @@ -51,3 +62,19 @@ CHECK-NEXT: Index: 2 CHECK-NEXT: - Name: __heap_base CHECK-NEXT: Kind: GLOBAL CHECK-NEXT: Index: 3 + +NOT-FIRST: - Type: GLOBAL +NOT-FIRST-NEXT: Globals: +NOT-FIRST-NEXT: - Index: 0 +NOT-FIRST-NEXT: Type: I32 +NOT-FIRST-NEXT: Mutable: true +NOT-FIRST-NEXT: InitExpr: +NOT-FIRST-NEXT: Opcode: I32_CONST +NOT-FIRST-NEXT: Value: 1552 +NOT-FIRST-NEXT: - Index: 1 +NOT-FIRST-NEXT: Type: I32 +NOT-FIRST-NEXT: Mutable: false +NOT-FIRST-NEXT: InitExpr: +NOT-FIRST-NEXT: Opcode: I32_CONST +NOT-FIRST-NEXT: Value: 1024 + diff --git a/lld/test/wasm/startstop.ll b/lld/test/wasm/startstop.ll index e7a5c80..c22956f 100644 --- a/lld/test/wasm/startstop.ll +++ b/lld/test/wasm/startstop.ll @@ -27,19 +27,19 @@ entry: ; CHECK: - Type: DATA ; CHECK-NEXT: Segments: -; CHECK-NEXT: - SectionOffset: 7 +; CHECK-NEXT: - SectionOffset: 8 ; CHECK-NEXT: InitFlags: 0 ; CHECK-NEXT: Offset: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 1024 +; CHECK-NEXT: Value: 65536 ; CHECK-NEXT: Content: 03000000040000002A0000002B000000 -; ASM: 0000006e <get_start>: +; ASM: 00000070 <get_start>: ; ASM-EMPTY: -; ASM-NEXT: 70: i32.const 1024 -; ASM-NEXT: 76: end +; ASM-NEXT: 72: i32.const 65536 +; ASM-NEXT: 78: end -; ASM: 00000077 <get_end>: +; ASM: 00000079 <get_end>: ; ASM-EMPTY: -; ASM-NEXT: 79: i32.const 1040 -; ASM-NEXT: 7f: end +; ASM-NEXT: 7b: i32.const 65552 +; ASM-NEXT: 81: end diff --git a/lld/test/wasm/table-base.s b/lld/test/wasm/table-base.s index 56fff41..92156c4 100644 --- a/lld/test/wasm/table-base.s +++ b/lld/test/wasm/table-base.s @@ -29,7 +29,7 @@ _start: # CHECK-DEFAULT-NEXT: Mutable: true # CHECK-DEFAULT-NEXT: InitExpr: # CHECK-DEFAULT-NEXT: Opcode: I32_CONST -# CHECK-DEFAULT-NEXT: Value: 66560 +# CHECK-DEFAULT-NEXT: Value: 65536 # CHECK-DEFAULT-NEXT: - Index: 1 # CHECK-DEFAULT-NEXT: Type: I32 # CHECK-DEFAULT-NEXT: Mutable: false @@ -58,7 +58,7 @@ _start: # CHECK-100-NEXT: Mutable: true # CHECK-100-NEXT: InitExpr: # CHECK-100-NEXT: Opcode: I32_CONST -# CHECK-100-NEXT: Value: 66560 +# CHECK-100-NEXT: Value: 65536 # CHECK-100-NEXT: - Index: 1 # CHECK-100-NEXT: Type: I32 # CHECK-100-NEXT: Mutable: false diff --git a/lld/test/wasm/tls-align.s b/lld/test/wasm/tls-align.s index 4fd296e..3b51165 100644 --- a/lld/test/wasm/tls-align.s +++ b/lld/test/wasm/tls-align.s @@ -65,7 +65,7 @@ tls2: # CHECK-NEXT: Mutable: true # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 66592 +# CHECK-NEXT: Value: 65536 # __tls_base # CHECK-NEXT: - Index: 1 diff --git a/lld/test/wasm/tls-non-shared-memory-basic.s b/lld/test/wasm/tls-non-shared-memory-basic.s index 8ef0173..66ccf8f 100644 --- a/lld/test/wasm/tls-non-shared-memory-basic.s +++ b/lld/test/wasm/tls-non-shared-memory-basic.s @@ -27,11 +27,11 @@ tls1: # CHECK: - Type: DATA # CHECK-NEXT: Segments: -# CHECK-NEXT: - SectionOffset: 7 +# CHECK-NEXT: - SectionOffset: 8 # CHECK-NEXT: InitFlags: 0 # CHECK-NEXT: Offset: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 1024 +# CHECK-NEXT: Value: 65536 # CHECK-NEXT: Content: 2B000000 # CHECK-NEXT: - Type: CUSTOM # CHECK-NOT: - Type: IMPORT diff --git a/lld/test/wasm/tls-non-shared-memory.s b/lld/test/wasm/tls-non-shared-memory.s index 04fbb62..0d73acb 100644 --- a/lld/test/wasm/tls-non-shared-memory.s +++ b/lld/test/wasm/tls-non-shared-memory.s @@ -63,38 +63,38 @@ tls1: # CHECK-NEXT: Mutable: true # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 66576 +# CHECK-NEXT: Value: 65536 # __tls_base # CHECK-NEXT: - Index: 1 # CHECK-NEXT: Type: I32 # CHECK-NEXT: Mutable: false # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 1024 +# CHECK-NEXT: Value: 65536 # GOT.data.internal.tls1 # CHECK-NEXT: - Index: 2 # CHECK-NEXT: Type: I32 # CHECK-NEXT: Mutable: false # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 1024 +# CHECK-NEXT: Value: 65536 # CHECK-NEXT: - Type: EXPORT # CHECK: - Type: DATA # .data # CHECK-NEXT: Segments: -# CHECK-NEXT: - SectionOffset: 7 +# CHECK-NEXT: - SectionOffset: 8 # CHECK-NEXT: InitFlags: 0 # CHECK-NEXT: Offset: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 1024 +# CHECK-NEXT: Value: 65536 # CHECK-NEXT: Content: 2B000000 # .tdata -# CHECK-NEXT: - SectionOffset: 17 +# CHECK-NEXT: - SectionOffset: 19 # CHECK-NEXT: InitFlags: 0 # CHECK-NEXT: Offset: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 1028 +# CHECK-NEXT: Value: 65540 # CHECK-NEXT: Content: 2A000000 # CHECK-NEXT: - Type: CUSTOM diff --git a/lld/test/wasm/tls.s b/lld/test/wasm/tls.s index b1f47f6..21f25f5 100644 --- a/lld/test/wasm/tls.s +++ b/lld/test/wasm/tls.s @@ -98,7 +98,7 @@ tls3: # CHECK-NEXT: Mutable: true # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 66592 +# CHECK-NEXT: Value: 65536 # __tls_base # CHECK-NEXT: - Index: 1 diff --git a/lld/test/wasm/undefined-weak-call.s b/lld/test/wasm/undefined-weak-call.s index 7490104..47775c8 100644 --- a/lld/test/wasm/undefined-weak-call.s +++ b/lld/test/wasm/undefined-weak-call.s @@ -61,7 +61,7 @@ callWeakFuncs: # CHECK-NEXT: Maximum: 0x1 # CHECK-NEXT: - Type: MEMORY # CHECK-NEXT: Memories: -# CHECK-NEXT: - Minimum: 0x2 +# CHECK-NEXT: - Minimum: 0x1 # CHECK-NEXT: - Type: GLOBAL # CHECK-NEXT: Globals: # CHECK-NEXT: - Index: 0 @@ -69,7 +69,7 @@ callWeakFuncs: # CHECK-NEXT: Mutable: true # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 66560 +# CHECK-NEXT: Value: 65536 # CHECK-NEXT: - Type: EXPORT # CHECK-NEXT: Exports: # CHECK-NEXT: - Name: memory diff --git a/lld/test/wasm/weak-alias-overide.ll b/lld/test/wasm/weak-alias-overide.ll index ca6f4bf..30bf7cf 100644 --- a/lld/test/wasm/weak-alias-overide.ll +++ b/lld/test/wasm/weak-alias-overide.ll @@ -44,7 +44,7 @@ entry: ; CHECK-NEXT: Maximum: 0x3 ; CHECK-NEXT: - Type: MEMORY ; CHECK-NEXT: Memories: -; CHECK-NEXT: - Minimum: 0x2 +; CHECK-NEXT: - Minimum: 0x1 ; CHECK-NEXT: - Type: GLOBAL ; CHECK-NEXT: Globals: ; CHECK-NEXT: - Index: 0 @@ -52,7 +52,7 @@ entry: ; CHECK-NEXT: Mutable: true ; CHECK-NEXT: InitExpr: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 66560 +; CHECK-NEXT: Value: 65536 ; CHECK-NEXT: - Type: EXPORT ; CHECK-NEXT: Exports: ; CHECK-NEXT: - Name: memory diff --git a/lld/test/wasm/weak-alias.ll b/lld/test/wasm/weak-alias.ll index 1768b8f..86e42a7 100644 --- a/lld/test/wasm/weak-alias.ll +++ b/lld/test/wasm/weak-alias.ll @@ -41,7 +41,7 @@ entry: ; CHECK-NEXT: Maximum: 0x2 ; CHECK-NEXT: - Type: MEMORY ; CHECK-NEXT: Memories: -; CHECK-NEXT: - Minimum: 0x2 +; CHECK-NEXT: - Minimum: 0x1 ; CHECK-NEXT: - Type: GLOBAL ; CHECK-NEXT: Globals: ; CHECK-NEXT: - Index: 0 @@ -49,7 +49,7 @@ entry: ; CHECK-NEXT: Mutable: true ; CHECK-NEXT: InitExpr: ; CHECK-NEXT: Opcode: I32_CONST -; CHECK-NEXT: Value: 66560 +; CHECK-NEXT: Value: 65536 ; CHECK-NEXT: - Type: EXPORT ; CHECK-NEXT: Exports: ; CHECK-NEXT: - Name: memory diff --git a/lld/test/wasm/weak-symbols.s b/lld/test/wasm/weak-symbols.s index 165ec17..ed85851 100644 --- a/lld/test/wasm/weak-symbols.s +++ b/lld/test/wasm/weak-symbols.s @@ -48,13 +48,13 @@ _start: # CHECK-NEXT: Mutable: true # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 66576 +# CHECK-NEXT: Value: 65536 # CHECK-NEXT: - Index: 1 # CHECK-NEXT: Type: I32 # CHECK-NEXT: Mutable: false # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 1024 +# CHECK-NEXT: Value: 65536 # CHECK-NEXT: - Type: EXPORT # CHECK-NEXT: Exports: # CHECK-NEXT: - Name: memory @@ -97,11 +97,11 @@ _start: # CHECK-NEXT: Body: 4181808080000B # CHECK-NEXT: - Type: DATA # CHECK-NEXT: Segments: -# CHECK-NEXT: - SectionOffset: 7 +# CHECK-NEXT: - SectionOffset: 8 # CHECK-NEXT: InitFlags: 0 # CHECK-NEXT: Offset: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 1024 +# CHECK-NEXT: Value: 65536 # CHECK-NEXT: Content: '01000000' # CHECK-NEXT: - Type: CUSTOM # CHECK-NEXT: Name: name diff --git a/lld/test/wasm/weak-undefined-pic.s b/lld/test/wasm/weak-undefined-pic.s index 5937380..1a3a171 100644 --- a/lld/test/wasm/weak-undefined-pic.s +++ b/lld/test/wasm/weak-undefined-pic.s @@ -45,7 +45,7 @@ _start: # CHECK-NEXT: Mutable: true # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 66560 +# CHECK-NEXT: Value: 65536 # Global 'undefined_weak:foo' representing the GOT entry for foo # Unlike other internal GOT entries that need to be mutable this one # is immutable and not updated by `__wasm_apply_global_relocs` diff --git a/lld/test/wasm/weak-undefined.s b/lld/test/wasm/weak-undefined.s index e1f551d..558cac5 100644 --- a/lld/test/wasm/weak-undefined.s +++ b/lld/test/wasm/weak-undefined.s @@ -67,7 +67,7 @@ _start: # CHECK-NEXT: Maximum: 0x1 # CHECK-NEXT: - Type: MEMORY # CHECK-NEXT: Memories: -# CHECK-NEXT: - Minimum: 0x2 +# CHECK-NEXT: - Minimum: 0x1 # CHECK-NEXT: - Type: GLOBAL # CHECK-NEXT: Globals: # CHECK-NEXT: - Index: 0 @@ -75,7 +75,7 @@ _start: # CHECK-NEXT: Mutable: true # CHECK-NEXT: InitExpr: # CHECK-NEXT: Opcode: I32_CONST -# CHECK-NEXT: Value: 66560 +# CHECK-NEXT: Value: 65536 # CHECK-NEXT: - Type: EXPORT # CHECK-NEXT: Exports: # CHECK-NEXT: - Name: memory diff --git a/lld/test/wasm/wrap_import.s b/lld/test/wasm/wrap_import.s new file mode 100644 index 0000000..ce3b6f5 --- /dev/null +++ b/lld/test/wasm/wrap_import.s @@ -0,0 +1,32 @@ +# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o +# RUN: wasm-ld -wrap nosuchsym -wrap foo -allow-undefined -o %t.wasm %t.o +# RUN: obj2yaml %t.wasm | FileCheck %s + +.globl foo +.globl _start + +foo: + .functype foo () -> () + end_function + +_start: + .functype _start () -> () + call foo + end_function + +# CHECK: - Type: IMPORT +# CHECK-NEXT: Imports: +# CHECK-NEXT: - Module: env +# CHECK-NEXT: Field: __wrap_foo +# CHECK-NEXT: Kind: FUNCTION +# CHECK-NEXT SigIndex: 0 + +# CHECK: - Type: CODE +# CHECK-NEXT: Functions: +# CHECK-NEXT: Index: 1 + +# CHECK: FunctionNames: +# CHECK-NEXT: - Index: 0 +# CHECK-NEXT: Name: __wrap_foo +# CHECK-NEXT: - Index: 1 +# CHECK-NEXT: Name: _start |
