diff options
Diffstat (limited to 'test/ELF')
29 files changed, 814 insertions, 251 deletions
diff --git a/test/ELF/Inputs/relocatable-comdat-multiple.s b/test/ELF/Inputs/relocatable-comdat-multiple.s new file mode 100644 index 000000000000..837a6bb06d09 --- /dev/null +++ b/test/ELF/Inputs/relocatable-comdat-multiple.s @@ -0,0 +1,2 @@ +.section .text.c,"axG",@progbits,bbb,comdat +.section .text.d,"axG",@progbits,bbb,comdat diff --git a/test/ELF/aarch64-undefined-weak.s b/test/ELF/aarch64-undefined-weak.s index 74fef669ed74..e611b6da6607 100644 --- a/test/ELF/aarch64-undefined-weak.s +++ b/test/ELF/aarch64-undefined-weak.s @@ -33,13 +33,13 @@ _start: // CHECK: Disassembly of section .text: // 131076 = 0x20004 -// CHECK: 20000: 01 80 00 14 b #131076 -// CHECK-NEXT: 20004: 02 80 00 94 bl #131080 -// CHECK-NEXT: 20008: 60 00 10 54 b.eq #131084 -// CHECK-NEXT: 2000c: 81 00 10 b4 cbz x1, #131088 -// CHECK-NEXT: 20010: 00 00 00 10 adr x0, #0 -// CHECK-NEXT: 20014: 00 00 00 90 adrp x0, #0 -// CHECK: 20018: 00 00 00 00 .word 0x00000000 -// CHECK-NEXT: 2001c: 00 00 00 00 .word 0x00000000 -// CHECK-NEXT: 20020: 00 00 00 00 .word 0x00000000 -// CHECK-NEXT: 20024: 00 00 .short 0x0000 +// CHECK: 20000: {{.*}} b #131076 +// CHECK-NEXT: 20004: {{.*}} bl #131080 +// CHECK-NEXT: 20008: {{.*}} b.eq #131084 +// CHECK-NEXT: 2000c: {{.*}} cbz x1, #131088 +// CHECK-NEXT: 20010: {{.*}} adr x0, #0 +// CHECK-NEXT: 20014: {{.*}} adrp x0, #0 +// CHECK: 20018: {{.*}} .word 0x00000000 +// CHECK-NEXT: 2001c: {{.*}} .word 0x00000000 +// CHECK-NEXT: 20020: {{.*}} .word 0x00000000 +// CHECK-NEXT: 20024: {{.*}} .short 0x0000 diff --git a/test/ELF/amdgpu-globals.s b/test/ELF/amdgpu-globals.s index 17dfc82ef8f3..e32159b332e7 100644 --- a/test/ELF/amdgpu-globals.s +++ b/test/ELF/amdgpu-globals.s @@ -1,130 +1,56 @@ # RUN: llvm-mc -filetype=obj -triple amdgcn--amdhsa -mcpu=kaveri %s -o %t.o -# RUN: ld.lld %t.o -o %t +# RUN: ld.lld -shared %t.o -o %t # RUN: llvm-readobj -sections -symbols -program-headers %t | FileCheck %s # REQUIRES: amdgpu - .amdgpu_hsa_module_global module_global_program - .size module_global_program, 4 - .hsadata_global_program -module_global_program: - .long 0 ; 0x0 +.type glob0, @object +.data + .globl glob0 +glob0: + .long 1 + .size glob0, 4 - .amdgpu_hsa_program_global program_global_program - .size program_global_program, 4 - .hsadata_global_program -program_global_program: - .long 0 ; 0x0 - - .amdgpu_hsa_module_global module_global_agent - .size module_global_agent, 4 - .hsadata_global_agent -module_global_agent: - .long 0 ; 0x0 - - .amdgpu_hsa_program_global program_global_agent - .size program_global_agent, 4 - .hsadata_global_agent -program_global_agent: - .long 0 ; 0x0 - - .amdgpu_hsa_module_global module_global_readonly - .size module_global_readonly, 4 - .hsatext -module_global_readonly: - .long 0 ; 0x0 - - .amdgpu_hsa_program_global program_global_readonly - .size program_global_readonly, 4 - .hsatext -program_global_readonly: - .long 0 ; 0x0 - -# CHECK: Section { -# CHECK: Name: .hsatext -# CHECK: Type: SHT_PROGBITS -# CHECK: Flags [ (0xC00007) -# CHECK: SHF_ALLOC (0x2) -# CHECK: SHF_AMDGPU_HSA_AGENT (0x800000) -# CHECK: SHF_AMDGPU_HSA_CODE (0x400000) -# CHECK: SHF_EXECINSTR (0x4) -# CHECK: SHF_WRITE (0x1) -# CHECK: ] -# CHECK: Address: [[HSATEXT_ADDR:[0-9xa-f]+]] -# CHECK: } +.type glob1, @object +.section .rodata, #alloc + .globl glob1 +glob1: + .long 2 + .size glob1, 4 # CHECK: Section { -# CHECK: Name: .hsadata_global_program -# CHECK: Type: SHT_PROGBITS (0x1) -# CHECK: Flags [ (0x100003) -# CHECK: SHF_ALLOC (0x2) -# CHECK: SHF_AMDGPU_HSA_GLOBAL (0x100000) -# CHECK: SHF_WRITE (0x1) -# CHECK: ] -# CHECK: Address: [[HSADATA_GLOBAL_PROGRAM_ADDR:[0-9xa-f]+]] +# CHECK: Name: .rodata +# CHECK: Type: SHT_PROGBITS +# CHECK: Flags [ (0x2) +# CHECK: SHF_ALLOC (0x2) +# CHECK: ] +# CHECK: Address: [[RODATA_ADDR:[0-9xa-f]+]] # CHECK: } # CHECK: Section { -# CHECK: Name: .hsadata_global_agent -# CHECK: Type: SHT_PROGBITS (0x1) -# CHECK: Flags [ (0x900003) -# CHECK: SHF_ALLOC (0x2) -# CHECK: SHF_AMDGPU_HSA_AGENT (0x800000) -# CHECK: SHF_AMDGPU_HSA_GLOBAL (0x100000) -# CHECK: SHF_WRITE (0x1) -# CHECK: ] -# CHECK: } - -# CHECK: Symbol { -# CHECK: Name: module_global_agent -# CHECK: Value: -# CHECK: Size: 4 -# CHECK: Binding: Local -# CHECK: Section: .hsadata_global_agent -# CHECK: } - -# CHECK: Symbol { -# CHECK: Name: module_global_program -# CHECK: Value: -# CHECK: Size: 4 -# CHECK: Binding: Local -# CHECK: Section: .hsadata_global_program -# CHECK: } - -# CHECK: Symbol { -# CHECK: Name: module_global_readonly -# CHECK: Value: -# CHECK: Size: 4 -# CHECK: Binding: Local -# CHECK: Type: Object -# CHECK: Section: .hsatext -# CHECK: } - -# CHECK: Symbol { -# CHECK: Name: program_global_agent -# CHECK: Value: -# CHECK: Size: 4 -# CHECK: Binding: Global -# CHECK: Type: Object -# CHECK: Section: .hsadata_global_agent +# CHECK: Name: .data +# CHECK: Type: SHT_PROGBITS +# CHECK: Flags [ (0x3) +# CHECK: SHF_ALLOC (0x2) +# CHECK: SHF_WRITE (0x1) +# CHECK: ] +# CHECK: Address: [[DATA_ADDR:[0-9xa-f]+]] # CHECK: } # CHECK: Symbol { -# CHECK: Name: program_global_program -# CHECK: Value: -# CHECK: Size: 4 -# CHECK: Binding: Global -# CHECK: Type: Object -# CHECK: Section: .hsadata_global_program +# CHECK: Name: glob0 +# CHECK: Value: [[DATA_ADDR]] +# CHECK: Size: 4 +# CHECK: Type: Object +# CHECK: Section: .data # CHECK: } # CHECK: Symbol { -# CHECK: Name: program_global_readonly -# CHECK: Value: -# CHECK: Size: 4 -# CHECK: Binding: Global -# CHECK: Type: Object -# CHECK: Section: .hsatext +# CHECK: Name: glob1 +# CHECK: Value: [[RODATA_ADDR]] +# CHECK: Size: 4 +# CHECK: Type: Object +# CHECK: Section: .rodata # CHECK: } # CHECK: ProgramHeader { diff --git a/test/ELF/amdgpu-kernels.s b/test/ELF/amdgpu-kernels.s index 62a8cb74a541..c76613f1a336 100644 --- a/test/ELF/amdgpu-kernels.s +++ b/test/ELF/amdgpu-kernels.s @@ -1,5 +1,5 @@ # RUN: llvm-mc -filetype=obj -triple amdgcn--amdhsa -mcpu=kaveri %s -o %t.o -# RUN: ld.lld %t.o -o %t +# RUN: ld.lld -shared %t.o -o %t # RUN: llvm-readobj -sections -symbols -program-headers %t | FileCheck %s # REQUIRES: amdgpu @@ -7,7 +7,7 @@ .hsa_code_object_version 1,0 .hsa_code_object_isa 7,0,0,"AMD","AMDGPU" -.hsatext +.text .globl kernel0 .align 256 .amdgpu_hsa_kernel kernel0 @@ -27,16 +27,12 @@ kernel1: # CHECK: Section { -# CHECK: Name: .hsatext +# CHECK: Name: .text # CHECK: Type: SHT_PROGBITS -# CHECK: Flags [ (0xC00007) +# CHECK: Flags [ (0x6) # CHECK: SHF_ALLOC (0x2) -# CHECK: SHF_AMDGPU_HSA_AGENT (0x800000) -# CHECK: SHF_AMDGPU_HSA_CODE (0x400000) # CHECK: SHF_EXECINSTR (0x4) -# CHECK: SHF_WRITE (0x1) # CHECK: ] -# CHECK: Address: [[HSATEXT_ADDR:[0-9xa-f]+]] # CHECK: } # CHECK: Symbol { @@ -45,7 +41,7 @@ kernel1: # CHECK: Size: 4 # CHECK: Binding: Global # CHECK: Type: AMDGPU_HSA_KERNEL -# CHECK: Section: .hsatext +# CHECK: Section: .text # CHECK: } # CHECK: Symbol { @@ -54,7 +50,7 @@ kernel1: # CHECK: Size: 8 # CHECK: Binding: Global # CHECK: Type: AMDGPU_HSA_KERNEL -# CHECK: Section: .hsatext +# CHECK: Section: .text # CHECK: } # CHECK: ProgramHeader { diff --git a/test/ELF/arm-icf-exidx.s b/test/ELF/arm-icf-exidx.s index cb801b7f2420..6af30285db67 100644 --- a/test/ELF/arm-icf-exidx.s +++ b/test/ELF/arm-icf-exidx.s @@ -19,13 +19,15 @@ g: .section .text.h .global __aeabi_unwind_cpp_pr0 __aeabi_unwind_cpp_pr0: + nop bx lr // CHECK: Disassembly of section .text: // CHECK-NEXT: f: // CHECK-NEXT: 11000: 1e ff 2f e1 bx lr // CHECK: __aeabi_unwind_cpp_pr0: -// CHECK-NEXT: 11004: 1e ff 2f e1 bx lr +// CHECK-NEXT: 11004: 00 f0 20 e3 nop +// CHECK-NEXT: 11008: 1e ff 2f e1 bx lr // CHECK: Contents of section .ARM.exidx: // CHECK-NEXT: 100d4 2c0f0000 b0b0b080 280f0000 01000000 diff --git a/test/ELF/arm-thumb-no-undefined-thunk.s b/test/ELF/arm-thumb-no-undefined-thunk.s index f668c8c278de..af2d3eb52044 100644 --- a/test/ELF/arm-thumb-no-undefined-thunk.s +++ b/test/ELF/arm-thumb-no-undefined-thunk.s @@ -19,6 +19,6 @@ _start: // CHECK: Disassembly of section .text: // CHECK-NEXT: _start: // 69636 = 0x11004 = next instruction -// CHECK: 11000: 11 f0 02 f8 bl #69636 -// CHECK-NEXT: 11004: 11 f0 04 b8 b.w #69640 -// CHECK-NEXT: 11008: 11 f0 06 b8 b.w #69644 +// CHECK: 11000: {{.*}} bl #69636 +// CHECK-NEXT: 11004: {{.*}} b.w #69640 +// CHECK-NEXT: 11008: {{.*}} b.w #69644 diff --git a/test/ELF/arm-thumb-thunk-symbols.s b/test/ELF/arm-thumb-thunk-symbols.s new file mode 100644 index 000000000000..42046f802f96 --- /dev/null +++ b/test/ELF/arm-thumb-thunk-symbols.s @@ -0,0 +1,42 @@ +// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t +// RUN: ld.lld %t -o %t2 2>&1 +// RUN: llvm-readobj --symbols %t2 | FileCheck %s +// RUN: ld.lld --shared %t -o %t3 2>&1 +// RUN: llvm-readobj --symbols %t3 | FileCheck -check-prefix=CHECK-PI %s +// REQUIRES: arm + +// Check that the symbols generated for Thunks have the correct symbol type +// of STT_FUNC and the correct value of bit 0 (0 for ARM 1 for Thumb) + .syntax unified + .section .text.thumb, "ax", %progbits + .thumb + .balign 0x1000 + .globl thumb_fn + .type thumb_fn, %function +thumb_fn: + b.w arm_fn + + .section .text.arm, "ax", %progbits + .arm + .balign 0x1000 + .globl arm_fn + .type arm_fn, %function +arm_fn: + b thumb_fn + +// CHECK: Name: __Thumbv7ABSLongThunk_arm_fn +// CHECK-NEXT: Value: 0x11005 +// CHECK-NEXT: Size: 10 +// CHECK-NEXT: Binding: Local (0x0) +// CHECK-NEXT: Type: Function (0x2) +// CHECK: Name: __ARMv7ABSLongThunk_thumb_fn +// CHECK-NEXT: Value: 0x11010 +// CHECK-NEXT: Size: 12 +// CHECK-NEXT: Binding: Local (0x0) +// CHECK-NEXT: Type: Function (0x2) + +// CHECK-PI: Name: __ThumbV7PILongThunk_arm_fn +// CHECK-PI-NEXT: Value: 0x1005 +// CHECK-PI-NEXT: Size: 12 +// CHECK-PI-NEXT: Binding: Local (0x0) +// CHECK-PI-NEXT: Type: Function (0x2) diff --git a/test/ELF/arm-thumb-undefined-weak.s b/test/ELF/arm-thumb-undefined-weak.s index 087f8e71cb21..792b81e3603a 100644 --- a/test/ELF/arm-thumb-undefined-weak.s +++ b/test/ELF/arm-thumb-undefined-weak.s @@ -29,10 +29,10 @@ _start: // CHECK: Disassembly of section .text: // 69636 = 0x11004 -// CHECK: 11000: 11 f0 02 80 beq.w #69636 -// CHECK-NEXT: 11004: 11 f0 04 b8 b.w #69640 -// CHECK-NEXT: 11008: 11 f0 06 f8 bl #69644 +// CHECK: 11000: {{.*}} beq.w #69636 +// CHECK-NEXT: 11004: {{.*}} b.w #69640 +// CHECK-NEXT: 11008: {{.*}} bl #69644 // blx is transformed into bl so we don't change state -// CHECK-NEXT: 1100c: 11 f0 08 f8 bl #69648 -// CHECK-NEXT: 11010: c0 f2 00 00 movt r0, #0 -// CHECK-NEXT: 11014: 40 f2 00 00 movw r0, #0 +// CHECK-NEXT: 1100c: {{.*}} bl #69648 +// CHECK-NEXT: 11010: {{.*}} movt r0, #0 +// CHECK-NEXT: 11014: {{.*}} movw r0, #0 diff --git a/test/ELF/arm-undefined-weak.s b/test/ELF/arm-undefined-weak.s index df67b467e263..5d77b1b4e698 100644 --- a/test/ELF/arm-undefined-weak.s +++ b/test/ELF/arm-undefined-weak.s @@ -29,11 +29,11 @@ _start: // CHECK: Disassembly of section .text: // 69636 = 0x11004 -// CHECK: 11000: 01 44 00 ea b #69636 -// CHECK-NEXT: 11004: 02 44 00 eb bl #69640 +// CHECK: 11000: {{.*}} b #69636 +// CHECK-NEXT: 11004: {{.*}} bl #69640 // blx is transformed into bl so we don't change state -// CHECK-NEXT: 11008: 03 44 00 eb bl #69644 -// CHECK-NEXT: 1100c: 00 00 40 e3 movt r0, #0 -// CHECK-NEXT: 11010: 00 00 00 e3 movw r0, #0 -// CHECK: 11014: 00 00 00 00 .word 0x00000000 +// CHECK-NEXT: 11008: {{.*}} bl #69644 +// CHECK-NEXT: 1100c: {{.*}} movt r0, #0 +// CHECK-NEXT: 11010: {{.*}} movw r0, #0 +// CHECK: 11014: {{.*}} .word 0x00000000 diff --git a/test/ELF/dso_handle.s b/test/ELF/dso_handle.s new file mode 100644 index 000000000000..99e2594ef814 --- /dev/null +++ b/test/ELF/dso_handle.s @@ -0,0 +1,19 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: ld.lld -shared %t.o -o %t +# RUN: llvm-readobj -symbols %t | FileCheck %s +# CHECK: Name: __dso_handle +# CHECK-NEXT: Value: 0x0 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Local +# CHECK-NEXT: Type: None +# CHECK-NEXT: Other [ +# CHECK-NEXT: STV_HIDDEN +# CHECK-NEXT: ] +# CHECK-NEXT: Section: .dynsym + +.text +.global foo, __dso_handle +foo: + lea __dso_handle(%rip),%rax diff --git a/test/ELF/ehdr_start.s b/test/ELF/ehdr_start.s index 32bcf4b84751..94e0fedcfc52 100644 --- a/test/ELF/ehdr_start.s +++ b/test/ELF/ehdr_start.s @@ -13,10 +13,21 @@ # CHECK-NEXT: ] # CHECK-NEXT: Section: .text (0x1) +# CHECK: Name: __executable_start +# CHECK-NEXT: Value: 0x200000 +# CHECK-NEXT: Size: 0 +# CHECK-NEXT: Binding: Local +# CHECK-NEXT: Type: None +# CHECK-NEXT: Other [ +# CHECK-NEXT: STV_HIDDEN +# CHECK-NEXT: ] +# CHECK-NEXT: Section: .text + .text .global _start, __ehdr_start _start: .quad __ehdr_start + .quad __executable_start # RUN: ld.lld -r %t.o -o %t.r # RUN: llvm-readobj -symbols %t.r | FileCheck %s --check-prefix=RELOCATABLE diff --git a/test/ELF/emit-relocs-merge.s b/test/ELF/emit-relocs-merge.s index 3fecca23b735..c700c337e334 100644 --- a/test/ELF/emit-relocs-merge.s +++ b/test/ELF/emit-relocs-merge.s @@ -8,7 +8,7 @@ # CHECK-NEXT: 0x1000 R_X86_64_64 zed 0x0 # CHECK-NEXT: 0x1008 R_X86_64_64 zed 0x0 # CHECK-NEXT: } -# CHECK-NEXT: Section ({{.*}}) .rela.data { +# CHECK-NEXT: Section ({{.*}}) .rela.data.foo { # CHECK-NEXT: 0x1000 R_X86_64_64 zed 0x0 # CHECK-NEXT: 0x1008 R_X86_64_64 zed 0x0 # CHECK-NEXT: } diff --git a/test/ELF/gdb-index-empty.s b/test/ELF/gdb-index-empty.s index 933afed33e2f..24f20803a008 100644 --- a/test/ELF/gdb-index-empty.s +++ b/test/ELF/gdb-index-empty.s @@ -8,109 +8,73 @@ # echo "void _start() { __builtin_unreachable(); }" | \ # clang -Os -g -S -o gdb-index-empty.s -x c - -Xclang -fdebug-compilation-dir -Xclang . - .text - .file "-" - .globl _start - .type _start,@function -_start: # @_start +.text +.globl _start +.type _start,@function +_start: .Lfunc_begin0: - .cfi_startproc -# BB#0: # %entry .Lfunc_end0: - .size _start, .Lfunc_end0-_start - .cfi_endproc - .file 1 "<stdin>" - .section .debug_str,"MS",@progbits,1 -.Linfo_string0: - .asciz "clang version 5.0.0 " # string offset=0 -.Linfo_string1: - .asciz "-" # string offset=21 -.Linfo_string2: - .asciz "." # string offset=23 -.Linfo_string3: - .asciz "_start" # string offset=25 - .section .debug_loc,"",@progbits - .section .debug_abbrev,"",@progbits - .byte 1 # Abbreviation Code - .byte 17 # DW_TAG_compile_unit - .byte 1 # DW_CHILDREN_yes - .byte 37 # DW_AT_producer - .byte 14 # DW_FORM_strp - .byte 19 # DW_AT_language - .byte 5 # DW_FORM_data2 - .byte 3 # DW_AT_name - .byte 14 # DW_FORM_strp - .byte 16 # DW_AT_stmt_list - .byte 23 # DW_FORM_sec_offset - .byte 27 # DW_AT_comp_dir - .byte 14 # DW_FORM_strp - .byte 17 # DW_AT_low_pc - .byte 1 # DW_FORM_addr - .byte 18 # DW_AT_high_pc - .byte 6 # DW_FORM_data4 - .byte 0 # EOM(1) - .byte 0 # EOM(2) - .byte 2 # Abbreviation Code - .byte 46 # DW_TAG_subprogram - .byte 0 # DW_CHILDREN_no - .byte 17 # DW_AT_low_pc - .byte 1 # DW_FORM_addr - .byte 18 # DW_AT_high_pc - .byte 6 # DW_FORM_data4 - .byte 64 # DW_AT_frame_base - .byte 24 # DW_FORM_exprloc - .byte 3 # DW_AT_name - .byte 14 # DW_FORM_strp - .byte 58 # DW_AT_decl_file - .byte 11 # DW_FORM_data1 - .byte 59 # DW_AT_decl_line - .byte 11 # DW_FORM_data1 - .byte 63 # DW_AT_external - .byte 25 # DW_FORM_flag_present - .byte 0 # EOM(1) - .byte 0 # EOM(2) - .byte 0 # EOM(3) - .section .debug_info,"",@progbits -.Lcu_begin0: - .long 60 # Length of Unit - .short 4 # DWARF version number - .long .debug_abbrev # Offset Into Abbrev. Section - .byte 8 # Address Size (in bytes) - .byte 1 # Abbrev [1] 0xb:0x35 DW_TAG_compile_unit - .long .Linfo_string0 # DW_AT_producer - .short 12 # DW_AT_language - .long .Linfo_string1 # DW_AT_name - .long .Lline_table_start0 # DW_AT_stmt_list - .long .Linfo_string2 # DW_AT_comp_dir - .quad .Lfunc_begin0 # DW_AT_low_pc - .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc - .byte 2 # Abbrev [2] 0x2a:0x15 DW_TAG_subprogram - .quad .Lfunc_begin0 # DW_AT_low_pc - .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc - .byte 1 # DW_AT_frame_base - .byte 87 - .long .Linfo_string3 # DW_AT_name - .byte 1 # DW_AT_decl_file - .byte 1 # DW_AT_decl_line - # DW_AT_external - .byte 0 # End Of Children Mark - .section .debug_ranges,"",@progbits - .section .debug_macinfo,"",@progbits -.Lcu_macro_begin0: - .byte 0 # End Of Macro List Mark - .section .debug_pubnames,"",@progbits - .long .LpubNames_end0-.LpubNames_begin0 # Length of Public Names Info -.LpubNames_begin0: - .short 2 # DWARF Version - .long .Lcu_begin0 # Offset of Compilation Unit Info - .long 64 # Compilation Unit Length - .long 42 # DIE offset - .asciz "_start" # External Name - .long 0 # End Mark -.LpubNames_end0: +.section .debug_abbrev,"",@progbits + .byte 1 # Abbreviation Code + .byte 17 # DW_TAG_compile_unit + .byte 1 # DW_CHILDREN_yes + .byte 37 # DW_AT_producer + .byte 14 # DW_FORM_strp + .byte 19 # DW_AT_language + .byte 5 # DW_FORM_data2 + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 16 # DW_AT_stmt_list + .byte 23 # DW_FORM_sec_offset + .byte 27 # DW_AT_comp_dir + .byte 14 # DW_FORM_strp + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 2 # Abbreviation Code + .byte 46 # DW_TAG_subprogram + .byte 0 # DW_CHILDREN_no + .byte 17 # DW_AT_low_pc + .byte 1 # DW_FORM_addr + .byte 18 # DW_AT_high_pc + .byte 6 # DW_FORM_data4 + .byte 64 # DW_AT_frame_base + .byte 24 # DW_FORM_exprloc + .byte 3 # DW_AT_name + .byte 14 # DW_FORM_strp + .byte 58 # DW_AT_decl_file + .byte 11 # DW_FORM_data1 + .byte 59 # DW_AT_decl_line + .byte 11 # DW_FORM_data1 + .byte 63 # DW_AT_external + .byte 25 # DW_FORM_flag_present + .byte 0 # EOM(1) + .byte 0 # EOM(2) + .byte 0 # EOM(3) - .ident "clang version 5.0.0 " - .section ".note.GNU-stack","",@progbits - .section .debug_line,"",@progbits -.Lline_table_start0: +.section .debug_info,"",@progbits + .long 60 # Length of Unit + .short 4 # DWARF version number + .long .debug_abbrev # Offset Into Abbrev. Section + .byte 8 # Address Size (in bytes) + .byte 1 # Abbrev [1] 0xb:0x35 DW_TAG_compile_unit + .long 0 # DW_AT_producer + .short 12 # DW_AT_language + .long 0 # DW_AT_name + .long 0 # DW_AT_stmt_list + .long 0 # DW_AT_comp_dir + .quad .Lfunc_begin0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .byte 2 # Abbrev [2] 0x2a:0x15 DW_TAG_subprogram + .quad .Lfunc_begin0 # DW_AT_low_pc + .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc + .byte 1 # DW_AT_frame_base + .byte 87 + .long 0 # DW_AT_name + .byte 1 # DW_AT_decl_file + .byte 1 # DW_AT_decl_line + .byte 0 # End Of Children Mark diff --git a/test/ELF/i386-reloc-large-addend.s b/test/ELF/i386-reloc-large-addend.s new file mode 100644 index 000000000000..b644640404e2 --- /dev/null +++ b/test/ELF/i386-reloc-large-addend.s @@ -0,0 +1,15 @@ +// RUN: llvm-mc %s -o %t.o -triple i386-pc-linux-code16 -filetype=obj + +// RUN: echo ".global foo; foo = 0x1" > %t1.s +// RUN: llvm-mc %t1.s -o %t1.o -triple i386-pc-linux -filetype=obj + +// RUN: ld.lld -Ttext 0x7000 %t.o %t1.o -o %t +// RUN: llvm-objdump -d -triple=i386-pc-linux-code16 %t | FileCheck %s + +// CHECK: Disassembly of section .text: +// CHECK-NEXT: _start: +// CHECK-NEXT: 7000: e9 fe 1f jmp 8190 +// 0x1 + 0x9000 - 0x7003 == 8190 + .global _start +_start: +jmp foo + 0x9000 diff --git a/test/ELF/i386-reloc-range.s b/test/ELF/i386-reloc-range.s new file mode 100644 index 000000000000..47447d0efa32 --- /dev/null +++ b/test/ELF/i386-reloc-range.s @@ -0,0 +1,22 @@ +// RUN: llvm-mc %s -o %t.o -triple i386-pc-linux-code16 -filetype=obj + +// RUN: echo ".global foo; foo = 0x10202" > %t1.s +// RUN: llvm-mc %t1.s -o %t1.o -triple i386-pc-linux -filetype=obj +// RUN: echo ".global foo; foo = 0x10203" > %t2.s +// RUN: llvm-mc %t2.s -o %t2.o -triple i386-pc-linux -filetype=obj + +// RUN: ld.lld -Ttext 0x200 %t.o %t1.o -o %t1 +// RUN: llvm-objdump -d -triple=i386-pc-linux-code16 %t1 | FileCheck %s + +// CHECK: Disassembly of section .text: +// CHECK-NEXT: _start: +// CHECK-NEXT: 200: {{.*}} jmp -1 +// 0x10202 - 0x203 == 0xffff + +// RUN: not ld.lld -Ttext 0x200 %t.o %t2.o -o %t2 2>&1 | FileCheck --check-prefix=ERR %s + +// ERR: {{.*}}:(.text+0x1): relocation R_386_PC16 out of range + + .global _start +_start: + jmp foo diff --git a/test/ELF/icf-comdat.s b/test/ELF/icf-comdat.s new file mode 100644 index 000000000000..28c0a586bf03 --- /dev/null +++ b/test/ELF/icf-comdat.s @@ -0,0 +1,23 @@ +# REQUIRES: x86 + +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t +# RUN: ld.lld %t -o %t2 --icf=all --verbose | FileCheck %s + +# CHECK: selected .text.f1 +# CHECK: removed .text.f2 + +.globl _start, f1, f2 +_start: + ret + +.section .text.f1,"ax" +f1: + mov $60, %rax + mov $42, %rdi + syscall + +.section .text.f2,"axG",@progbits,foo,comdat +f2: + mov $60, %rax + mov $42, %rdi + syscall diff --git a/test/ELF/linkerscript/early-assign-symbol.s b/test/ELF/linkerscript/early-assign-symbol.s index 21940c088393..0626e66e6fb6 100644 --- a/test/ELF/linkerscript/early-assign-symbol.s +++ b/test/ELF/linkerscript/early-assign-symbol.s @@ -7,7 +7,7 @@ # RUN: echo "SECTIONS { aaa = ABSOLUTE(foo - 1) + 1; .text : { *(.text*) } }" > %t2.script # RUN: not ld.lld -o %t --script %t2.script %t.o 2>&1 | FileCheck %s -# CHECK: error: unable to evaluate expression: input section .text has no output section assigned +# CHECK: error: {{.*}}.script:1: unable to evaluate expression: input section .text has no output section assigned .section .text .globl foo diff --git a/test/ELF/linkerscript/emit-relocs-multiple.s b/test/ELF/linkerscript/emit-relocs-multiple.s new file mode 100644 index 000000000000..b04ca1be7a15 --- /dev/null +++ b/test/ELF/linkerscript/emit-relocs-multiple.s @@ -0,0 +1,20 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: echo "SECTIONS { .zed : { *(.foo) *(.bar) } }" > %t.script +# RUN: ld.lld --emit-relocs --script %t.script %t.o -o %t1 +# RUN: llvm-readobj -r %t1 | FileCheck %s + +# CHECK: Relocations [ +# CHECK-NEXT: Section {{.*}} .rela.foo { +# CHECK-NEXT: 0x1 R_X86_64_32 .zed 0x0 +# CHECK-NEXT: 0x6 R_X86_64_32 .zed 0x5 +# CHECK-NEXT: } +# CHECK-NEXT: ] + +.section .foo,"ax",@progbits +aaa: + movl $aaa, %edx + +.section .bar,"ax",@progbits +bbb: + movl $bbb, %edx diff --git a/test/ELF/linkerscript/expr-invalid-sec.s b/test/ELF/linkerscript/expr-invalid-sec.s index 9476be3c3b14..5687751b6806 100644 --- a/test/ELF/linkerscript/expr-invalid-sec.s +++ b/test/ELF/linkerscript/expr-invalid-sec.s @@ -3,4 +3,4 @@ # RUN: echo "SECTIONS { foo = ADDR(.text) + ADDR(.text); };" > %t.script # RUN: not ld.lld -o %t.so --script %t.script %t.o -shared 2>&1 | FileCheck %s -# CHECK: At least one side of the expression must be absolute +# CHECK: error: {{.*}}.script:1: at least one side of the expression must be absolute diff --git a/test/ELF/linkerscript/noload.s b/test/ELF/linkerscript/noload.s new file mode 100644 index 000000000000..9d0e085a0504 --- /dev/null +++ b/test/ELF/linkerscript/noload.s @@ -0,0 +1,46 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o +# RUN: echo "SECTIONS { \ +# RUN: .data_noload_a (NOLOAD) : { *(.data_noload_a) } \ +# RUN: .data_noload_b (0x10000) (NOLOAD) : { *(.data_noload_b) } };" > %t.script +# RUN: ld.lld -o %t --script %t.script %t.o +# RUN: llvm-readobj --symbols -sections %t + +# CHECK: Section { +# CHECK-NEXT: Index: 2 +# CHECK-NEXT: Name: .data_noload_a +# CHECK-NEXT: Type: SHT_NOBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_ALLOC +# CHECK-NEXT: SHF_WRITE +# CHECK-NEXT: ] +# CHECK-NEXT: Address: 0x0 +# CHECK-NEXT: Offset: 0x1000 +# CHECK-NEXT: Size: 4096 +# CHECK-NEXT: Link: 0 +# CHECK-NEXT: Info: 0 +# CHECK-NEXT: AddressAlignment: 1 +# CHECK-NEXT: EntrySize: 0 +# CHECK-NEXT: } +# CHECK-NEXT: Section { +# CHECK-NEXT: Index: 3 +# CHECK-NEXT: Name: .data_noload_b +# CHECK-NEXT: Type: SHT_NOBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_ALLOC +# CHECK-NEXT: SHF_WRITE +# CHECK-NEXT: ] +# CHECK-NEXT: Address: 0x10000 +# CHECK-NEXT: Offset: 0x1000 +# CHECK-NEXT: Size: 4096 +# CHECK-NEXT: Link: 0 +# CHECK-NEXT: Info: 0 +# CHECK-NEXT: AddressAlignment: 1 +# CHECK-NEXT: EntrySize: 0 +# CHECK-NEXT: } + +.section .data_noload_a,"aw",@progbits +.zero 4096 + +.section .data_noload_b,"aw",@progbits +.zero 4096 diff --git a/test/ELF/lto/Inputs/defsym-bar.ll b/test/ELF/lto/Inputs/defsym-bar.ll new file mode 100644 index 000000000000..748c7b23f6a8 --- /dev/null +++ b/test/ELF/lto/Inputs/defsym-bar.ll @@ -0,0 +1,21 @@ +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +declare void @this_is_bar1() +declare void @this_is_bar2() +declare void @this_is_bar3() + +define hidden void @bar1() { + call void @this_is_bar1() + ret void +} + +define hidden void @bar2() { + call void @this_is_bar2() + ret void +} + +define hidden void @bar3() { + call void @this_is_bar3() + ret void +} diff --git a/test/ELF/lto/Inputs/wrap-bar.ll b/test/ELF/lto/Inputs/wrap-bar.ll new file mode 100644 index 000000000000..407ebfbf6ec3 --- /dev/null +++ b/test/ELF/lto/Inputs/wrap-bar.ll @@ -0,0 +1,14 @@ +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define hidden void @bar() { + ret void +} + +define hidden void @__real_bar() { + ret void +} + +define hidden void @__wrap_bar() { + ret void +} diff --git a/test/ELF/lto/defsym.ll b/test/ELF/lto/defsym.ll new file mode 100644 index 000000000000..4c2fe45b3c53 --- /dev/null +++ b/test/ELF/lto/defsym.ll @@ -0,0 +1,28 @@ +; REQUIRES: x86 +; RUN: llvm-as %s -o %t.o +; RUN: llvm-as %S/Inputs/defsym-bar.ll -o %t1.o +; RUN: ld.lld %t.o %t1.o -shared -o %t.so -defsym=bar2=bar3 +; RUN: llvm-objdump -d %t.so | FileCheck %s + +; Call to bar2() should not be inlined and should be routed to bar3() +; Symbol bar3 should not be eliminated + +; CHECK: foo: +; CHECK-NEXT: pushq %rax +; CHECK-NEXT: callq +; CHECK-NEXT: callq{{.*}}<bar3> +; CHECK-NEXT: callq + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +declare void @bar1() +declare void @bar2() +declare void @bar3() + +define void @foo() { + call void @bar1() + call void @bar2() + call void @bar3() + ret void +} diff --git a/test/ELF/lto/wrap-1.ll b/test/ELF/lto/wrap-1.ll new file mode 100644 index 000000000000..b61dfaeb5903 --- /dev/null +++ b/test/ELF/lto/wrap-1.ll @@ -0,0 +1,35 @@ +; REQUIRES: x86 +; RUN: llvm-as %s -o %t.o +; RUN: ld.lld %t.o -o %t.out -wrap=bar -save-temps +; RUN: llvm-readobj -t %t.out | FileCheck %s +; RUN: cat %t.out.resolution.txt | FileCheck -check-prefix=RESOLS %s + +; CHECK: Name: __wrap_bar +; CHECK-NEXT: Value: +; CHECK-NEXT: Size: +; CHECK-NEXT: Binding: Global +; CHECK-NEXT: Type: Function + +; Make sure that the 'r' (linker redefined) bit is set for bar and __wrap_bar +; in the resolutions file. +; RESOLS: ,bar,r +; RESOLS: ,__wrap_bar,px +; RESOLS: ,__real_bar,pxr + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +declare void @bar() + +define void @_start() { + call void @bar() + ret void +} + +define void @__wrap_bar() { + ret void +} + +define void @__real_bar() { + ret void +} diff --git a/test/ELF/lto/wrap-2.ll b/test/ELF/lto/wrap-2.ll new file mode 100644 index 000000000000..b2e33f83138e --- /dev/null +++ b/test/ELF/lto/wrap-2.ll @@ -0,0 +1,36 @@ +; REQUIRES: x86 +; RUN: llvm-as %s -o %t.o +; RUN: llvm-as %S/Inputs/wrap-bar.ll -o %t1.o +; RUN: ld.lld %t.o %t1.o -shared -o %t.so -wrap=bar +; RUN: llvm-objdump -d %t.so | FileCheck %s +; RUN: llvm-readobj -t %t.so | FileCheck -check-prefix=BIND %s + +; Make sure that calls in foo() are not eliminated and that bar is +; routed to __wrap_bar and __real_bar is routed to bar. + +; CHECK: foo: +; CHECK-NEXT: pushq %rax +; CHECK-NEXT: callq{{.*}}<__wrap_bar> +; CHECK-NEXT: callq{{.*}}<bar> + +; Check that bar and __wrap_bar retain their original binding. +; BIND: Name: bar +; BIND-NEXT: Value: +; BIND-NEXT: Size: +; BIND-NEXT: Binding: Local +; BIND: Name: __wrap_bar +; BIND-NEXT: Value: +; BIND-NEXT: Size: +; BIND-NEXT: Binding: Local + +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +declare void @bar() +declare void @__real_bar() + +define void @foo() { + call void @bar() + call void @__real_bar() + ret void +} diff --git a/test/ELF/mips-npic-call-pic-script.s b/test/ELF/mips-npic-call-pic-script.s new file mode 100644 index 000000000000..6028989ee4cb --- /dev/null +++ b/test/ELF/mips-npic-call-pic-script.s @@ -0,0 +1,255 @@ +# REQUIRES: mips +# Check LA25 stubs creation. This stub code is necessary when +# non-PIC code calls PIC function. +# RUN: echo "SECTIONS { .out 0x20000 : { *(.text.*) . = . + 0x100 ; *(.text) } }" > %t1.script +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ +# RUN: %p/Inputs/mips-fpic.s -o %t-fpic.o +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ +# RUN: %p/Inputs/mips-fnpic.s -o %t-fnpic.o +# RUN: ld.lld -r %t-fpic.o %t-fnpic.o -o %t-sto-pic.o +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux \ +# RUN: %p/Inputs/mips-pic.s -o %t-pic.o +# RUN: llvm-mc -filetype=obj -triple=mips-unknown-linux %s -o %t-npic.o +# RUN: ld.lld --script %t1.script %t-npic.o %t-pic.o %t-sto-pic.o -o %t.exe +# RUN: llvm-objdump -d %t.exe | FileCheck %s + +# CHECK: Disassembly of section .out: +# CHECK-NEXT: __LA25Thunk_foo1a: +# CHECK-NEXT: 20000: 3c 19 00 02 lui $25, 2 +# CHECK-NEXT: 20004: 08 00 80 08 j 131104 <foo1a> +# CHECK-NEXT: 20008: 27 39 00 20 addiu $25, $25, 32 +# CHECK-NEXT: 2000c: 00 00 00 00 nop +# CHECK: __LA25Thunk_foo1b: +# CHECK-NEXT: 20010: 3c 19 00 02 lui $25, 2 +# CHECK-NEXT: 20014: 08 00 80 09 j 131108 <foo1b> +# CHECK-NEXT: 20018: 27 39 00 24 addiu $25, $25, 36 +# CHECK-NEXT: 2001c: 00 00 00 00 nop +# CHECK: foo1a: +# CHECK-NEXT: 20020: 00 00 00 00 nop +# CHECK: foo1b: +# CHECK-NEXT: 20024: 00 00 00 00 nop +# CHECK: __LA25Thunk_foo2: +# CHECK-NEXT: 20028: 3c 19 00 02 lui $25, 2 +# CHECK-NEXT: 2002c: 08 00 80 10 j 131136 <foo2> +# CHECK-NEXT: 20030: 27 39 00 40 addiu $25, $25, 64 +# CHECK-NEXT: 20034: 00 00 00 00 nop +# CHECK-NEXT: 20038: 00 00 00 00 nop +# CHECK-NEXT: 2003c: 00 00 00 00 nop +# CHECK: foo2: +# CHECK-NEXT: 20040: 00 00 00 00 nop +# CHECK-NEXT: 20044: 00 00 00 00 nop +# CHECK-NEXT: 20048: 00 00 00 00 nop +# CHECK-NEXT: 2004c: 00 00 00 00 nop +# CHECK-NEXT: 20050: 00 00 00 00 nop +# CHECK-NEXT: 20054: 00 00 00 00 nop +# CHECK-NEXT: 20058: 00 00 00 00 nop +# CHECK-NEXT: 2005c: 00 00 00 00 nop +# CHECK-NEXT: 20060: 00 00 00 00 nop +# CHECK-NEXT: 20064: 00 00 00 00 nop +# CHECK-NEXT: 20068: 00 00 00 00 nop +# CHECK-NEXT: 2006c: 00 00 00 00 nop +# CHECK-NEXT: 20070: 00 00 00 00 nop +# CHECK-NEXT: 20074: 00 00 00 00 nop +# CHECK-NEXT: 20078: 00 00 00 00 nop +# CHECK-NEXT: 2007c: 00 00 00 00 nop +# CHECK-NEXT: 20080: 00 00 00 00 nop +# CHECK-NEXT: 20084: 00 00 00 00 nop +# CHECK-NEXT: 20088: 00 00 00 00 nop +# CHECK-NEXT: 2008c: 00 00 00 00 nop +# CHECK-NEXT: 20090: 00 00 00 00 nop +# CHECK-NEXT: 20094: 00 00 00 00 nop +# CHECK-NEXT: 20098: 00 00 00 00 nop +# CHECK-NEXT: 2009c: 00 00 00 00 nop +# CHECK-NEXT: 200a0: 00 00 00 00 nop +# CHECK-NEXT: 200a4: 00 00 00 00 nop +# CHECK-NEXT: 200a8: 00 00 00 00 nop +# CHECK-NEXT: 200ac: 00 00 00 00 nop +# CHECK-NEXT: 200b0: 00 00 00 00 nop +# CHECK-NEXT: 200b4: 00 00 00 00 nop +# CHECK-NEXT: 200b8: 00 00 00 00 nop +# CHECK-NEXT: 200bc: 00 00 00 00 nop +# CHECK-NEXT: 200c0: 00 00 00 00 nop +# CHECK-NEXT: 200c4: 00 00 00 00 nop +# CHECK-NEXT: 200c8: 00 00 00 00 nop +# CHECK-NEXT: 200cc: 00 00 00 00 nop +# CHECK-NEXT: 200d0: 00 00 00 00 nop +# CHECK-NEXT: 200d4: 00 00 00 00 nop +# CHECK-NEXT: 200d8: 00 00 00 00 nop +# CHECK-NEXT: 200dc: 00 00 00 00 nop +# CHECK-NEXT: 200e0: 00 00 00 00 nop +# CHECK-NEXT: 200e4: 00 00 00 00 nop +# CHECK-NEXT: 200e8: 00 00 00 00 nop +# CHECK-NEXT: 200ec: 00 00 00 00 nop +# CHECK-NEXT: 200f0: 00 00 00 00 nop +# CHECK-NEXT: 200f4: 00 00 00 00 nop +# CHECK-NEXT: 200f8: 00 00 00 00 nop +# CHECK-NEXT: 200fc: 00 00 00 00 nop +# CHECK-NEXT: 20100: 00 00 00 00 nop +# CHECK-NEXT: 20104: 00 00 00 00 nop +# CHECK-NEXT: 20108: 00 00 00 00 nop +# CHECK-NEXT: 2010c: 00 00 00 00 nop +# CHECK-NEXT: 20110: 00 00 00 00 nop +# CHECK-NEXT: 20114: 00 00 00 00 nop +# CHECK-NEXT: 20118: 00 00 00 00 nop +# CHECK-NEXT: 2011c: 00 00 00 00 nop +# CHECK-NEXT: 20120: 00 00 00 00 nop +# CHECK-NEXT: 20124: 00 00 00 00 nop +# CHECK-NEXT: 20128: 00 00 00 00 nop +# CHECK-NEXT: 2012c: 00 00 00 00 nop +# CHECK-NEXT: 20130: 00 00 00 00 nop +# CHECK-NEXT: 20134: 00 00 00 00 nop +# CHECK-NEXT: 20138: 00 00 00 00 nop +# CHECK-NEXT: 2013c: 00 00 00 00 nop +# CHECK-NEXT: 20140: 00 00 00 00 nop +# CHECK-NEXT: 20144: 00 00 00 00 nop +# CHECK-NEXT: 20148: 00 00 00 00 nop +# CHECK-NEXT: 2014c: 00 00 00 00 nop +# CHECK: __start: +# CHECK-NEXT: 20150: 0c 00 80 00 jal 131072 <__LA25Thunk_foo1a> +# CHECK-NEXT: 20154: 00 00 00 00 nop +# CHECK-NEXT: 20158: 0c 00 80 0a jal 131112 <__LA25Thunk_foo2> +# CHECK-NEXT: 2015c: 00 00 00 00 nop +# CHECK-NEXT: 20160: 0c 00 80 04 jal 131088 <__LA25Thunk_foo1b> +# CHECK-NEXT: 20164: 00 00 00 00 nop +# CHECK-NEXT: 20168: 0c 00 80 0a jal 131112 <__LA25Thunk_foo2> +# CHECK-NEXT: 2016c: 00 00 00 00 nop +# CHECK-NEXT: 20170: 0c 00 80 60 jal 131456 <__LA25Thunk_fpic> +# CHECK-NEXT: 20174: 00 00 00 00 nop +# CHECK-NEXT: 20178: 0c 00 80 68 jal 131488 <fnpic> +# CHECK-NEXT: 2017c: 00 00 00 00 nop +# CHECK: __LA25Thunk_fpic: +# CHECK-NEXT: 20180: 3c 19 00 02 lui $25, 2 +# CHECK-NEXT: 20184: 08 00 80 64 j 131472 <fpic> +# CHECK-NEXT: 20188: 27 39 01 90 addiu $25, $25, 400 +# CHECK-NEXT: 2018c: 00 00 00 00 nop +# CHECK: fpic: +# CHECK-NEXT: 20190: 00 00 00 00 nop +# CHECK-NEXT: 20194: 00 00 00 00 nop +# CHECK-NEXT: 20198: 00 00 00 00 nop +# CHECK-NEXT: 2019c: 00 00 00 00 nop +# CHECK: fnpic: +# CHECK-NEXT: 201a0: 00 00 00 00 nop + + .text + .globl __start +__start: + jal foo1a + jal foo2 + jal foo1b + jal foo2 + jal fpic + jal fnpic + +# Test script with orphans added to existing OutputSection, the .text.1 and +# .text.2 sections will be added to .text +# RUN: echo "SECTIONS { .text 0x20000 : { *(.text) } }" > %t2.script +# RUN: ld.lld --script %t2.script %t-npic.o %t-pic.o %t-sto-pic.o -o %t2.exe +# RUN: llvm-objdump -d %t2.exe | FileCheck -check-prefix=ORPH1 %s +# ORPH1: Disassembly of section .text: +# ORPH1-NEXT: __start: +# ORPH1-NEXT: 20000: 0c 00 80 15 jal 131156 <__LA25Thunk_foo1a> +# ORPH1-NEXT: 20004: 00 00 00 00 nop +# ORPH1-NEXT: 20008: 0c 00 80 22 jal 131208 <__LA25Thunk_foo2> +# ORPH1-NEXT: 2000c: 00 00 00 00 nop +# ORPH1-NEXT: 20010: 0c 00 80 19 jal 131172 <__LA25Thunk_foo1b> +# ORPH1-NEXT: 20014: 00 00 00 00 nop +# ORPH1-NEXT: 20018: 0c 00 80 22 jal 131208 <__LA25Thunk_foo2> +# ORPH1-NEXT: 2001c: 00 00 00 00 nop +# ORPH1-NEXT: 20020: 0c 00 80 0c jal 131120 <__LA25Thunk_fpic> +# ORPH1-NEXT: 20024: 00 00 00 00 nop +# ORPH1-NEXT: 20028: 0c 00 80 14 jal 131152 <fnpic> +# ORPH1-NEXT: 2002c: 00 00 00 00 nop +# ORPH1: __LA25Thunk_fpic: +# ORPH1-NEXT: 20030: 3c 19 00 02 lui $25, 2 +# ORPH1-NEXT: 20034: 08 00 80 10 j 131136 <fpic> +# ORPH1-NEXT: 20038: 27 39 00 40 addiu $25, $25, 64 +# ORPH1-NEXT: 2003c: 00 00 00 00 nop +# ORPH1: fpic: +# ORPH1-NEXT: 20040: 00 00 00 00 nop +# ORPH1-NEXT: 20044: 00 00 00 00 nop +# ORPH1-NEXT: 20048: 00 00 00 00 nop +# ORPH1-NEXT: 2004c: 00 00 00 00 nop +# ORPH1: fnpic: +# ORPH1-NEXT: 20050: 00 00 00 00 nop +# ORPH1: __LA25Thunk_foo1a: +# ORPH1-NEXT: 20054: 3c 19 00 02 lui $25, 2 +# ORPH1-NEXT: 20058: 08 00 80 20 j 131200 <foo1a> +# ORPH1-NEXT: 2005c: 27 39 00 80 addiu $25, $25, 128 +# ORPH1-NEXT: 20060: 00 00 00 00 nop +# ORPH1: __LA25Thunk_foo1b: +# ORPH1-NEXT: 20064: 3c 19 00 02 lui $25, 2 +# ORPH1-NEXT: 20068: 08 00 80 21 j 131204 <foo1b> +# ORPH1-NEXT: 2006c: 27 39 00 84 addiu $25, $25, 132 +# ORPH1-NEXT: 20070: 00 00 00 00 nop +# ORPH1-NEXT: 20074: 00 00 00 00 nop +# ORPH1-NEXT: 20078: 00 00 00 00 nop +# ORPH1-NEXT: 2007c: 00 00 00 00 nop +# ORPH1: foo1a: +# ORPH1-NEXT: 20080: 00 00 00 00 nop +# ORPH1: foo1b: +# ORPH1-NEXT: 20084: 00 00 00 00 nop +# ORPH1: __LA25Thunk_foo2: +# ORPH1-NEXT: 20088: 3c 19 00 02 lui $25, 2 +# ORPH1-NEXT: 2008c: 08 00 80 28 j 131232 <foo2> +# ORPH1-NEXT: 20090: 27 39 00 a0 addiu $25, $25, 160 +# ORPH1-NEXT: 20094: 00 00 00 00 nop +# ORPH1-NEXT: 20098: 00 00 00 00 nop +# ORPH1-NEXT: 2009c: 00 00 00 00 nop +# ORPH1: foo2: +# ORPH1-NEXT: 200a0: 00 00 00 00 nop + +# Test script with orphans added to new OutputSection, the .text.1 and +# .text.2 sections will form a new OutputSection .text +# RUN: echo "SECTIONS { .out 0x20000 : { *(.text) } }" > %t3.script +# RUN: ld.lld --script %t3.script %t-npic.o %t-pic.o %t-sto-pic.o -o %t3.exe +# RUN: llvm-objdump -d %t3.exe | FileCheck -check-prefix=ORPH2 %s +# ORPH2: Disassembly of section .out: +# ORPH2-NEXT: __start: +# ORPH2-NEXT: 20000: 0c 00 80 18 jal 131168 <__LA25Thunk_foo1a> +# ORPH2-NEXT: 20004: 00 00 00 00 nop +# ORPH2-NEXT: 20008: 0c 00 80 22 jal 131208 <__LA25Thunk_foo2> +# ORPH2-NEXT: 2000c: 00 00 00 00 nop +# ORPH2-NEXT: 20010: 0c 00 80 1c jal 131184 <__LA25Thunk_foo1b> +# ORPH2-NEXT: 20014: 00 00 00 00 nop +# ORPH2-NEXT: 20018: 0c 00 80 22 jal 131208 <__LA25Thunk_foo2> +# ORPH2-NEXT: 2001c: 00 00 00 00 nop +# ORPH2-NEXT: 20020: 0c 00 80 0c jal 131120 <__LA25Thunk_fpic> +# ORPH2-NEXT: 20024: 00 00 00 00 nop +# ORPH2-NEXT: 20028: 0c 00 80 14 jal 131152 <fnpic> +# ORPH2-NEXT: 2002c: 00 00 00 00 nop +# ORPH2: __LA25Thunk_fpic: +# ORPH2-NEXT: 20030: 3c 19 00 02 lui $25, 2 +# ORPH2-NEXT: 20034: 08 00 80 10 j 131136 <fpic> +# ORPH2-NEXT: 20038: 27 39 00 40 addiu $25, $25, 64 +# ORPH2-NEXT: 2003c: 00 00 00 00 nop +# ORPH2: fpic: +# ORPH2-NEXT: 20040: 00 00 00 00 nop +# ORPH2-NEXT: 20044: 00 00 00 00 nop +# ORPH2-NEXT: 20048: 00 00 00 00 nop +# ORPH2-NEXT: 2004c: 00 00 00 00 nop +# ORPH2: fnpic: +# ORPH2-NEXT: 20050: 00 00 00 00 nop +# ORPH2-NEXT: Disassembly of section .text: +# ORPH2-NEXT: __LA25Thunk_foo1a: +# ORPH2-NEXT: 20060: 3c 19 00 02 lui $25, 2 +# ORPH2-NEXT: 20064: 08 00 80 20 j 131200 <foo1a> +# ORPH2-NEXT: 20068: 27 39 00 80 addiu $25, $25, 128 +# ORPH2-NEXT: 2006c: 00 00 00 00 nop +# ORPH2: __LA25Thunk_foo1b: +# ORPH2-NEXT: 20070: 3c 19 00 02 lui $25, 2 +# ORPH2-NEXT: 20074: 08 00 80 21 j 131204 <foo1b> +# ORPH2-NEXT: 20078: 27 39 00 84 addiu $25, $25, 132 +# ORPH2-NEXT: 2007c: 00 00 00 00 nop +# ORPH2: foo1a: +# ORPH2-NEXT: 20080: 00 00 00 00 nop +# ORPH2: foo1b: +# ORPH2-NEXT: 20084: 00 00 00 00 nop +# ORPH2: __LA25Thunk_foo2: +# ORPH2-NEXT: 20088: 3c 19 00 02 lui $25, 2 +# ORPH2-NEXT: 2008c: 08 00 80 28 j 131232 <foo2> +# ORPH2-NEXT: 20090: 27 39 00 a0 addiu $25, $25, 160 +# ORPH2-NEXT: 20094: 00 00 00 00 nop +# ORPH2-NEXT: 20098: 00 00 00 00 nop +# ORPH2-NEXT: 2009c: 00 00 00 00 nop +# ORPH2: foo2: +# ORPH2-NEXT: 200a0: 00 00 00 00 nop diff --git a/test/ELF/relocatable-comdat-multiple.s b/test/ELF/relocatable-comdat-multiple.s new file mode 100644 index 000000000000..4c3e7ce7f6d4 --- /dev/null +++ b/test/ELF/relocatable-comdat-multiple.s @@ -0,0 +1,31 @@ +# REQUIRES: x86 +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o +# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %S/Inputs/relocatable-comdat-multiple.s -o %t2.o +# RUN: ld.lld -r %t.o %t2.o -o %t +# RUN: llvm-readobj -elf-section-groups %t | FileCheck %s + +# CHECK: Groups { +# CHECK-NEXT: Group { +# CHECK-NEXT: Name: .group +# CHECK-NEXT: Index: 2 +# CHECK-NEXT: Type: COMDAT +# CHECK-NEXT: Signature: aaa +# CHECK-NEXT: Section(s) in group [ +# CHECK-NEXT: .text.a +# CHECK-NEXT: .text.b +# CHECK-NEXT: ] +# CHECK-NEXT: } +# CHECK-NEXT: Group { +# CHECK-NEXT: Name: .group +# CHECK-NEXT: Index: 5 +# CHECK-NEXT: Type: COMDAT +# CHECK-NEXT: Signature: bbb +# CHECK-NEXT: Section(s) in group [ +# CHECK-NEXT: .text.c +# CHECK-NEXT: .text.d +# CHECK-NEXT: ] +# CHECK-NEXT: } +# CHECK-NEXT: } + +.section .text.a,"axG",@progbits,aaa,comdat +.section .text.b,"axG",@progbits,aaa,comdat diff --git a/test/ELF/relocatable-compressed-input.s b/test/ELF/relocatable-compressed-input.s new file mode 100644 index 000000000000..bdfb2073a1e0 --- /dev/null +++ b/test/ELF/relocatable-compressed-input.s @@ -0,0 +1,45 @@ +# REQUIRES: zlib + +# RUN: llvm-mc -compress-debug-sections=zlib-gnu -filetype=obj -triple=x86_64-unknown-linux %s -o %t1 +# RUN: llvm-readobj -sections %t1 | FileCheck -check-prefix=GNU %s +# GNU: Name: .zdebug_str + +# RUN: ld.lld %t1 -o %t2 -r +# RUN: llvm-readobj -sections -section-data %t2 | FileCheck %s + +## Check we decompress section and remove ".z" prefix specific for zlib-gnu compression. +# CHECK: Section { +# CHECK: Index: +# CHECK: Name: .debug_str +# CHECK-NEXT: Type: SHT_PROGBITS +# CHECK-NEXT: Flags [ +# CHECK-NEXT: SHF_MERGE +# CHECK-NEXT: SHF_STRINGS +# CHECK-NEXT: ] +# CHECK-NEXT: Address: +# CHECK-NEXT: Offset: +# CHECK-NEXT: Size: +# CHECK-NEXT: Link: +# CHECK-NEXT: Info: +# CHECK-NEXT: AddressAlignment: 1 +# CHECK-NEXT: EntrySize: 1 +# CHECK-NEXT: SectionData ( +# CHECK-NEXT: 0000: {{.*}} |short unsigned i| +# CHECK-NEXT: 0010: {{.*}} |nt.unsigned int.| +# CHECK-NEXT: 0020: {{.*}} |long unsigned in| +# CHECK-NEXT: 0030: {{.*}} |t.char.unsigned | +# CHECK-NEXT: 0040: {{.*}} |char.| +# CHECK-NEXT: ) +# CHECK-NEXT: } + +.section .debug_str,"MS",@progbits,1 +.LASF2: + .string "short unsigned int" +.LASF3: + .string "unsigned int" +.LASF0: + .string "long unsigned int" +.LASF8: + .string "char" +.LASF1: + .string "unsigned char" diff --git a/test/ELF/relocatable-empty-archive.s b/test/ELF/relocatable-empty-archive.s new file mode 100644 index 000000000000..545ef7bfc24c --- /dev/null +++ b/test/ELF/relocatable-empty-archive.s @@ -0,0 +1,10 @@ +# REQUIRES: x86 +# RUN: rm -f %t.a +# RUN: llvm-ar rc %t.a +# RUN: ld.lld -m elf_x86_64 %t.a -o %t -r +# RUN: llvm-readobj -file-headers %t | FileCheck %s + +# CHECK: Format: ELF64-x86-64 +# CHECK: Arch: x86_64 +# CHECK: AddressSize: 64bit +# CHECK: Type: Relocatable |