diff --git a/lld/test/ELF/arm-icf-exidx.s b/lld/test/ELF/arm-icf-exidx.s --- a/lld/test/ELF/arm-icf-exidx.s +++ b/lld/test/ELF/arm-icf-exidx.s @@ -22,6 +22,9 @@ nop bx lr +// CHECK: Contents of section .ARM.exidx: +// CHECK-NEXT: 100d4 18100000 b0b0b080 14100000 01000000 + // CHECK: Disassembly of section .text: // CHECK-EMPTY: // CHECK-NEXT: g: @@ -29,6 +32,3 @@ // CHECK: __aeabi_unwind_cpp_pr0: // CHECK-NEXT: 110f0: 00 f0 20 e3 nop // CHECK-NEXT: 110f4: 1e ff 2f e1 bx lr - -// CHECK: Contents of section .ARM.exidx: -// CHECK-NEXT: 100d4 18100000 b0b0b080 14100000 01000000 diff --git a/lld/test/ELF/arm-target1.s b/lld/test/ELF/arm-target1.s --- a/lld/test/ELF/arm-target1.s +++ b/lld/test/ELF/arm-target1.s @@ -25,12 +25,12 @@ .word 32 // Force generation of $d.0 as section is not all data nop +// RELATIVE: SYMBOL TABLE: +// RELATIVE: 00001154 .text 00000000 patatino // RELATIVE: Disassembly of section .text: // RELATIVE-EMPTY: // RELATIVE: $d.0: // RELATIVE: 1150: 04 00 00 00 .word 0x00000004 -// RELATIVE: SYMBOL TABLE: -// RELATIVE: 00001154 .text 00000000 patatino // ABS: can't create dynamic relocation R_ARM_TARGET1 against symbol: patatino in readonly segment; recompile object files with -fPIC or pass '-Wl,-z,notext' to allow text relocations in the output // ABS: >>> defined in {{.*}}.o diff --git a/lld/test/ELF/eh-frame-hdr-abs-fde.s b/lld/test/ELF/eh-frame-hdr-abs-fde.s --- a/lld/test/ELF/eh-frame-hdr-abs-fde.s +++ b/lld/test/ELF/eh-frame-hdr-abs-fde.s @@ -7,6 +7,10 @@ # RUN: ld.lld --eh-frame-hdr %t.o -o %t # RUN: llvm-objdump -s -dwarf=frames %t | FileCheck %s +# CHECK: Augmentation: "zLR" +# CHECK: Augmentation data: 00 1B +# ^-- DW_EH_PE_pcrel | DW_EH_PE_udata4 | DW_EH_PE_signed + # CHECK: Contents of section .eh_frame_hdr: # CHECK-NEXT: 200190 011b033b 14000000 01000000 54100000 # ^-- 0x201000 - 0x200190 @@ -15,10 +19,6 @@ # CHECK: Contents of section .text: # CHECK-NEXT: 2011e4 90 -# CHECK: Augmentation: "zLR" -# CHECK: Augmentation data: 00 1B -# ^-- DW_EH_PE_pcrel | DW_EH_PE_udata4 | DW_EH_PE_signed - .text .globl __start __start: diff --git a/lld/test/ELF/got32-i386.s b/lld/test/ELF/got32-i386.s --- a/lld/test/ELF/got32-i386.s +++ b/lld/test/ELF/got32-i386.s @@ -13,11 +13,11 @@ movl foo@GOT, %ebx ## 73728 == 0x12000 == ADDR(.got) -# CHECK: _start: -# CHECK-NEXT: 4010f5: 8b 1d {{.*}} movl 4202748, %ebx # CHECK: Sections: # CHECK: Name Size VMA # CHECK: .got 00000004 00000000004020fc +# CHECK: _start: +# CHECK-NEXT: 4010f5: 8b 1d {{.*}} movl 4202748, %ebx # RUN: not ld.lld %t.o -o %t -pie 2>&1 | FileCheck %s --check-prefix=ERR # ERR: error: symbol 'foo' cannot be preempted; recompile with -fPIE diff --git a/lld/test/ELF/got32x-i386.s b/lld/test/ELF/got32x-i386.s --- a/lld/test/ELF/got32x-i386.s +++ b/lld/test/ELF/got32x-i386.s @@ -32,14 +32,14 @@ # RUN: llvm-objdump -section-headers -d %t1 | FileCheck %s ## 73728 == 0x12000 == ADDR(.got) +# CHECK: Sections: +# CHECK: Name Size VMA +# CHECK: .got.plt 0000000c 0000000000403134 # CHECK: _start: # CHECK-NEXT: 401115: 8b 05 {{.*}} movl 4202800, %eax # CHECK-NEXT: 40111b: 8b 1d {{.*}} movl 4202800, %ebx # CHECK-NEXT: 401121: 8b 80 {{.*}} movl -4100(%eax), %eax # CHECK-NEXT: 401127: 8b 83 {{.*}} movl -4100(%ebx), %eax -# CHECK: Sections: -# CHECK: Name Size VMA -# CHECK: .got.plt 0000000c 0000000000403134 # RUN: not ld.lld %S/Inputs/i386-got32x-baseless.elf -o %t1 -pie 2>&1 | \ # RUN: FileCheck %s --check-prefix=ERR diff --git a/lld/test/ELF/i386-pc8-pc16-addend.s b/lld/test/ELF/i386-pc8-pc16-addend.s --- a/lld/test/ELF/i386-pc8-pc16-addend.s +++ b/lld/test/ELF/i386-pc8-pc16-addend.s @@ -3,12 +3,12 @@ # RUN: ld.lld %t1.o -o %t.out # RUN: llvm-objdump -s -t %t.out | FileCheck %s +# CHECK: SYMBOL TABLE: +# CHECK: 004010b7 .und # CHECK: Contents of section .text: # CHECK-NEXT: 4010b4 020000 ## 0x4010b7 - 0x4010b4 + addend(-1) = 0x02 ## 0x4010b7 - 0x4010b5 + addend(-2) = 0x0000 -# CHECK: SYMBOL TABLE: -# CHECK: 004010b7 .und .byte und-.-1 .short und-.-2 diff --git a/lld/test/ELF/i386-reloc8-reloc16-addend.s b/lld/test/ELF/i386-reloc8-reloc16-addend.s --- a/lld/test/ELF/i386-reloc8-reloc16-addend.s +++ b/lld/test/ELF/i386-reloc8-reloc16-addend.s @@ -3,12 +3,12 @@ # RUN: ld.lld -Ttext=0x0 %t1.o -o %t.out # RUN: llvm-objdump -s -t %t.out | FileCheck %s -# CHECK: Contents of section .text: -# CHECK-NEXT: 0000 020100 ## 0x3 + addend(-1) = 0x02 ## 0x3 + addend(-2) = 0x0100 # CHECK: SYMBOL TABLE: # CHECK: 00000003 .und +# CHECK: Contents of section .text: +# CHECK-NEXT: 0000 020100 .byte und-1 .short und-2 diff --git a/lld/test/ELF/i386-retpoline-nopic.s b/lld/test/ELF/i386-retpoline-nopic.s --- a/lld/test/ELF/i386-retpoline-nopic.s +++ b/lld/test/ELF/i386-retpoline-nopic.s @@ -6,6 +6,10 @@ // RUN: ld.lld %t1.o %t2.so -o %t.exe -z retpolineplt // RUN: llvm-objdump -d -s --no-show-raw-insn %t.exe | FileCheck %s +// CHECK: Contents of section .got.plt: +// CHECK-NEXT: 40224000 00000000 00000000 10124000 +// CHECK-NEXT: 30124000 + // CHECK: Disassembly of section .plt: // CHECK-EMPTY: // CHECK-NEXT: .plt: @@ -56,10 +60,6 @@ // CHECK-NEXT: 40123e: int3 // CHECK-NEXT: 40123f: int3 -// CHECK: Contents of section .got.plt: -// CHECK-NEXT: 40224000 00000000 00000000 10124000 -// CHECK-NEXT: 30124000 - .global _start _start: jmp bar@PLT diff --git a/lld/test/ELF/i386-retpoline-pic.s b/lld/test/ELF/i386-retpoline-pic.s --- a/lld/test/ELF/i386-retpoline-pic.s +++ b/lld/test/ELF/i386-retpoline-pic.s @@ -6,6 +6,10 @@ // RUN: ld.lld %t1.o %t2.so -o %t.exe -z retpolineplt -pie // RUN: llvm-objdump -d -s --no-show-raw-insn %t.exe | FileCheck %s +// CHECK: Contents of section .got.plt: +// CHECK-NEXT: 32a8 40220000 00000000 00000000 11120000 +// CHECK-NEXT: 32b8 31120000 + // CHECK: Disassembly of section .plt: // CHECK-EMPTY: // CHECK-NEXT: .plt: @@ -53,10 +57,6 @@ // CHECK-NEXT: 123e: int3 // CHECK-NEXT: 123f: int3 -// CHECK: Contents of section .got.plt: -// CHECK-NEXT: 32a8 40220000 00000000 00000000 11120000 -// CHECK-NEXT: 32b8 31120000 - .global _start _start: jmp bar@PLT diff --git a/lld/test/ELF/mips-32.s b/lld/test/ELF/mips-32.s --- a/lld/test/ELF/mips-32.s +++ b/lld/test/ELF/mips-32.s @@ -24,6 +24,10 @@ v2: .word v1 # R_MIPS_32 target v1 addend 0 +# SYM: SYMBOL TABLE: +# SYM: 00011000 .data 00000000 v1 + + # BE: Contents of section .data: # BE-NEXT: {{.*}} 00000004 00011000 # ^-- v2+4 ^-- v1 @@ -31,10 +35,6 @@ # EL: Contents of section .data: # EL-NEXT: {{.*}} 04000000 00100100 # ^-- v2+4 ^-- v1 - -# SYM: SYMBOL TABLE: -# SYM: 00011000 .data 00000000 v1 - # REL: Relocation section # REL: {{.*}} R_MIPS_REL32 # REL-NEXT: {{.*}} R_MIPS_REL32 [[V2:[0-9a-f]+]] diff --git a/lld/test/ELF/mips-64-got.s b/lld/test/ELF/mips-64-got.s --- a/lld/test/ELF/mips-64-got.s +++ b/lld/test/ELF/mips-64-got.s @@ -10,6 +10,8 @@ # RUN: llvm-objdump -d -t --no-show-raw-insn %t.exe | FileCheck %s # RUN: llvm-readelf -r -s --mips-plt-got %t.exe | FileCheck -check-prefix=GOT %s +# CHECK: {{[0-9a-f]+}}1c8 .text 00000000 foo + # CHECK: __start: # CHECK-NEXT: {{.*}} ld $2, -32736($gp) # CHECK-NEXT: {{.*}} daddiu $2, $2, 456 @@ -17,8 +19,6 @@ # CHECK-NEXT: {{.*}} addiu $2, $2, -32720 # CHECK-NEXT: {{.*}} addiu $2, $2, -32712 -# CHECK: {{[0-9a-f]+}}1c8 .text 00000000 foo - # GOT: There are no relocations in this file. # GOT: Symbol table '.symtab' diff --git a/lld/test/ELF/mips-64-rels.s b/lld/test/ELF/mips-64-rels.s --- a/lld/test/ELF/mips-64-rels.s +++ b/lld/test/ELF/mips-64-rels.s @@ -11,6 +11,12 @@ # RUN: llvm-objdump -d -s -t --print-imm-hex --no-show-raw-insn %t.exe | FileCheck %s # RUN: llvm-readobj -r %t.exe | FileCheck -check-prefix=REL %s +# CHECK: 0000000000037ff0 .got 00000000 .hidden _gp + +# CHECK: Contents of section .rodata: +# CHECK-NEXT: {{[0-9a-f]+}} ffffffff fffe9014 +# ^-- 0x21004 - 0x37ff0 = 0xfffffffffffe9014 + # CHECK: __start: # CHECK-NEXT: 21000: lui $gp, 0x1 # ^-- 0x21000 - 0x37ff0 @@ -22,12 +28,6 @@ # ^-- 0 - 0xfffffffffffe9010 # ^-- %lo(0x16ff0) -# CHECK: Contents of section .rodata: -# CHECK-NEXT: {{[0-9a-f]+}} ffffffff fffe9014 -# ^-- 0x21004 - 0x37ff0 = 0xfffffffffffe9014 - -# CHECK: 0000000000037ff0 .got 00000000 .hidden _gp - # REL: Relocations [ # REL-NEXT: ] diff --git a/lld/test/ELF/mips-64.s b/lld/test/ELF/mips-64.s --- a/lld/test/ELF/mips-64.s +++ b/lld/test/ELF/mips-64.s @@ -13,11 +13,11 @@ v2: .quad v1 # R_MIPS_64 target v1 addend 0 -# SYM: Contents of section .data: -# SYM-NEXT: {{.*}} 00000000 00000008 00000000 [[V1:[0-9a-f]+]] - # SYM: SYMBOL TABLE: -# SYM: 00000000[[V1]] .data 00000000 v1 +# SYM: 00000000[[V1:[0-9a-f]+]] .data 00000000 v1 + +# SYM: Contents of section .data: +# SYM-NEXT: {{.*}} 00000000 00000008 00000000 [[V1]] # CHECK: Relocation section # CHECK: [[V2:[0-9a-f]+]] {{.*}} R_MIPS_REL32/R_MIPS_64/R_MIPS_NONE diff --git a/lld/test/ELF/mips-got16-relocatable.s b/lld/test/ELF/mips-got16-relocatable.s --- a/lld/test/ELF/mips-got16-relocatable.s +++ b/lld/test/ELF/mips-got16-relocatable.s @@ -21,17 +21,17 @@ # OBJ-NEXT: addiu $4, $25, 16 # OBJ-NEXT: 00000014: R_MIPS_LO16 .data +# SO: SYMBOL TABLE +# SO: 00020{{0*}}[[D1:[0-9a-f]+]] .data {{0+}} data +# SO: 00020{{0*}}[[D2:[0-9a-f]+]] .data {{0+}} data + # SO: Disassembly of section .text: # SO-EMPTY: # SO-NEXT: .text: # SO-NEXT: lw $25, -0x7fe8($gp) -# SO-NEXT: addiu $4, $25, 0x[[D1:[0-9a-f]+]] +# SO-NEXT: addiu $4, $25, 0x[[D1]] # SO: lw $25, -0x7fe8($gp) -# SO-NEXT: addiu $4, $25, 0x[[D2:[0-9a-f]+]] - -# SO: SYMBOL TABLE -# SO: [[D1]] -# SO: [[D2]] +# SO-NEXT: addiu $4, $25, 0x[[D2]] .text lw $t9, %got(.data)($gp) diff --git a/lld/test/ELF/mips-got16.s b/lld/test/ELF/mips-got16.s --- a/lld/test/ELF/mips-got16.s +++ b/lld/test/ELF/mips-got16.s @@ -9,6 +9,10 @@ # RUN: ld.lld %t.o -shared --script %t.script -o %t.so # RUN: llvm-objdump -d -t --no-show-raw-insn %t.so | FileCheck %s # RUN: llvm-readelf -r --mips-plt-got %t.so | FileCheck -check-prefix=GOT %s +# +# CHECK: SYMBOL TABLE: +# CHECK: 00024008 .data 00000000 .hidden bar +# CHECK: 00000000 *UND* 00000000 foo # CHECK: __start: # CHECK-NEXT: lw $8, -32744($gp) @@ -22,10 +26,6 @@ # CHECK-NEXT: lw $8, -32720($gp) # CHECK-NEXT: addi $8, $8, 16392 # CHECK-NEXT: lw $8, -32716($gp) -# -# CHECK: SYMBOL TABLE: -# CHECK: 00024008 .data 00000000 .hidden bar -# CHECK: 00000000 *UND* 00000000 foo # GOT: There are no relocations in this file. diff --git a/lld/test/ELF/mips-gp-disp.s b/lld/test/ELF/mips-gp-disp.s --- a/lld/test/ELF/mips-gp-disp.s +++ b/lld/test/ELF/mips-gp-disp.s @@ -17,14 +17,14 @@ # INT-SO: 00000000 0 NOTYPE LOCAL HIDDEN ABS _gp_disp # EXT-SO: 00020000 0 NOTYPE GLOBAL DEFAULT 9 _gp_disp +# DIS: 00037ff0 .got 00000000 .hidden _gp +# DIS: 00002000 .text 00000000 __start # DIS: Disassembly of section .text: # DIS-EMPTY: # DIS-NEXT: __start: # DIS-NEXT: lui $8, 3 # DIS-NEXT: addi $8, $8, 24560 # ^-- (_gp - __start) & 0xffff -# DIS: 00037ff0 .got 00000000 .hidden _gp -# DIS: 00002000 .text 00000000 __start # REL: There are no relocations in this file diff --git a/lld/test/ELF/mips-gp-ext.s b/lld/test/ELF/mips-gp-ext.s --- a/lld/test/ELF/mips-gp-ext.s +++ b/lld/test/ELF/mips-gp-ext.s @@ -25,6 +25,10 @@ # RUN: ld.lld -shared -o %t.abs.so --script %t.abs.script %t.o # RUN: llvm-objdump -s -t %t.abs.so | FileCheck --check-prefix=ABS %s +# REL: 000000e0 .text 00000000 foo +# REL: 00000000 *ABS* 00000000 .hidden _gp_disp +# REL: 000001ec *ABS* 00000000 .hidden _gp + # REL: Contents of section .reginfo: # REL-NEXT: 0018 10000104 00000000 00000000 00000000 # REL-NEXT: 0028 00000000 000001ec @@ -42,9 +46,9 @@ # ^-- 0x30-0x1ec # foo - GP -# REL: 000000e0 .text 00000000 foo -# REL: 00000000 *ABS* 00000000 .hidden _gp_disp -# REL: 000001ec *ABS* 00000000 .hidden _gp +# ABS: 000000e0 .text 00000000 foo +# ABS: 00000000 *ABS* 00000000 .hidden _gp_disp +# ABS: 00000200 *ABS* 00000000 .hidden _gp # ABS: Contents of section .reginfo: # ABS-NEXT: 0018 10000104 00000000 00000000 00000000 @@ -63,10 +67,6 @@ # ^-- 0xe0-0x200 # foo - GP -# ABS: 000000e0 .text 00000000 foo -# ABS: 00000000 *ABS* 00000000 .hidden _gp_disp -# ABS: 00000200 *ABS* 00000000 .hidden _gp - .text foo: lui $t0, %hi(_gp_disp) diff --git a/lld/test/ELF/mips-gp-local.s b/lld/test/ELF/mips-gp-local.s --- a/lld/test/ELF/mips-gp-local.s +++ b/lld/test/ELF/mips-gp-local.s @@ -9,13 +9,13 @@ # RUN: ld.lld --script %t.script -o %t.exe %t.o # RUN: llvm-objdump -d -t --no-show-raw-insn %t.exe | FileCheck %s +# CHECK: 00037ff0 .got 00000000 .hidden _gp +# CHECK: 00011000 .text 00000000 __start + # CHECK: __start: # CHECK-NEXT: lui $8, 3 # CHECK-NEXT: addi $8, $8, 32752 -# CHECK: 00037ff0 .got 00000000 .hidden _gp -# CHECK: 00011000 .text 00000000 __start - .text .globl __start __start: diff --git a/lld/test/ELF/mips-gprel32-relocs-gp0.s b/lld/test/ELF/mips-gprel32-relocs-gp0.s --- a/lld/test/ELF/mips-gprel32-relocs-gp0.s +++ b/lld/test/ELF/mips-gprel32-relocs-gp0.s @@ -14,16 +14,16 @@ # REL: GP: 0x0 -# DUMP: Contents of section .rodata: -# DUMP: 1000 fffffff4 fffffff8 -# ^ 0x20004 + 0x7ff0 - 0x28000 -# ^ 0x20008 + 0x7ff0 - 0x28000 - # DUMP: SYMBOL TABLE: # DUMP: 00020008 .text 00000000 bar # DUMP: 00020004 .text 00000000 foo # DUMP: 00028000 .got 00000000 .hidden _gp +# DUMP: Contents of section .rodata: +# DUMP: 1000 fffffff4 fffffff8 +# ^ 0x20004 + 0x7ff0 - 0x28000 +# ^ 0x20008 + 0x7ff0 - 0x28000 + .text .global __start __start: diff --git a/lld/test/ELF/mips-gprel32-relocs.s b/lld/test/ELF/mips-gprel32-relocs.s --- a/lld/test/ELF/mips-gprel32-relocs.s +++ b/lld/test/ELF/mips-gprel32-relocs.s @@ -23,12 +23,12 @@ .gpword foo .gpword bar -# CHECK: Contents of section .rodata: -# CHECK: 1000 ffff8004 ffff8008 -# ^ 0x20004 - 0x28000 -# ^ 0x20008 - 0x28000 - # CHECK: SYMBOL TABLE: # CHECK: 00020008 .text 00000000 bar # CHECK: 00020004 .text 00000000 foo # CHECK: 00028000 .got 00000000 .hidden _gp + +# CHECK: Contents of section .rodata: +# CHECK: 1000 ffff8004 ffff8008 +# ^ 0x20004 - 0x28000 +# ^ 0x20008 - 0x28000 diff --git a/lld/test/ELF/mips-hilo-gp-disp.s b/lld/test/ELF/mips-hilo-gp-disp.s --- a/lld/test/ELF/mips-hilo-gp-disp.s +++ b/lld/test/ELF/mips-hilo-gp-disp.s @@ -23,6 +23,11 @@ lui $t0,%hi(_gp_disp) addi $t0,$t0,%lo(_gp_disp) +# CHECK: SYMBOL TABLE: +# CHECK: 0001100c .text 00000000 bar +# CHECK: 00037ff0 .got 00000000 .hidden _gp +# CHECK: 00011000 .text 00000000 __start + # CHECK: Disassembly of section .text: # CHECK-EMPTY: # CHECK-NEXT: __start: @@ -35,8 +40,3 @@ # ^-- %hi(0x37ff0-0x1100c) # CHECK-NEXT: 11010: addi $8, $8, 28644 # ^-- %lo(0x37ff0-0x11010+4) - -# CHECK: SYMBOL TABLE: -# CHECK: 0001100c .text 00000000 bar -# CHECK: 00037ff0 .got 00000000 .hidden _gp -# CHECK: 00011000 .text 00000000 __start diff --git a/lld/test/ELF/mips-hilo-hi-only.s b/lld/test/ELF/mips-hilo-hi-only.s --- a/lld/test/ELF/mips-hilo-hi-only.s +++ b/lld/test/ELF/mips-hilo-hi-only.s @@ -15,12 +15,12 @@ # WARN: can't find matching R_MIPS_LO16 relocation for R_MIPS_HI16 +# CHECK: SYMBOL TABLE: +# CHECK: 00020{{0*}}[[VAL:[0-9a-f]+]] .text 00000000 _label +# CHECK: 00020{{.*}} .text 00000000 __start + # CHECK: __start: # CHECK-NEXT: lui $8, 0x3 # ^-- %hi(__start) w/o addend -# CHECK-NEXT: addi $8, $8, 0x[[VAL:[0-9a-f]+]] +# CHECK-NEXT: addi $8, $8, 0x[[VAL]] # ^-- %lo(_label) - -# CHECK: SYMBOL TABLE: -# CHECK: 00020{{0*}}[[VAL]] .text 00000000 _label -# CHECK: 00020{{.*}} .text 00000000 __start diff --git a/lld/test/ELF/mips-hilo.s b/lld/test/ELF/mips-hilo.s --- a/lld/test/ELF/mips-hilo.s +++ b/lld/test/ELF/mips-hilo.s @@ -30,6 +30,11 @@ g1: .word 0 +# CHECK: SYMBOL TABLE: +# CHECK: 0021020 l O .data 00000004 l1 +# CHECK: 0021000 .text 00000000 __start +# CHECK: 0021024 g O .data 00000004 g1 + # CHECK: __start: # CHECK-NEXT: 21000: lui $8, 2 # ^-- %hi(__start+4) @@ -45,8 +50,3 @@ # ^-- %hi(l1+0x20000-4) # CHECK-NEXT: 21018: addi $8, $8, 4124 # ^-- %lo(l1-4) - -# CHECK: SYMBOL TABLE: -# CHECK: 0021020 l O .data 00000004 l1 -# CHECK: 0021000 .text 00000000 __start -# CHECK: 0021024 g O .data 00000004 g1 diff --git a/lld/test/ELF/mips-mgot.s b/lld/test/ELF/mips-mgot.s --- a/lld/test/ELF/mips-mgot.s +++ b/lld/test/ELF/mips-mgot.s @@ -14,20 +14,20 @@ # RUN: llvm-objdump -s -section=.got -t %t.so | FileCheck %s # RUN: llvm-readobj -r --dyn-syms --mips-plt-got %t.so | FileCheck -check-prefix=GOT %s +# CHECK: SYMBOL TABLE: +# CHECK: 00000000 l O .tdata 00000000 loc0 +# CHECK: [[FOO0:[0-9a-f]+]] .text 00000000 foo0 +# CHECK: 00000000 g O .tdata 00000000 tls0 +# CHECK: 00000004 g O .tdata 00000000 tls1 +# CHECK: [[FOO2:[0-9a-f]+]] .text 00000000 foo2 + # CHECK: Contents of section .got: -# CHECK-NEXT: 70000 00000000 80000000 [[FOO0:[0-9a-f]+]] [[FOO2:[0-9a-f]+]] +# CHECK-NEXT: 70000 00000000 80000000 [[FOO0]] [[FOO2]] # CHECK-NEXT: 70010 00000000 00000004 00010000 00020000 # CHECK-NEXT: 70020 00030000 00040000 00050000 00060000 # CHECK-NEXT: 70030 00000000 00000000 00000000 00000000 # CHECK-NEXT: 70040 00000000 00000000 00000000 -# CHECK: SYMBOL TABLE: -# CHECK: 00000000 l O .tdata 00000000 loc0 -# CHECK: [[FOO0]] .text 00000000 foo0 -# CHECK: 00000000 g O .tdata 00000000 tls0 -# CHECK: 00000004 g O .tdata 00000000 tls1 -# CHECK: [[FOO2]] .text 00000000 foo2 - # GOT: Relocations [ # GOT-NEXT: Section (7) .rel.dyn { # GOT-NEXT: 0x70018 R_MIPS_REL32 - 0x0 diff --git a/lld/test/ELF/mips-micro-cross-calls.s b/lld/test/ELF/mips-micro-cross-calls.s --- a/lld/test/ELF/mips-micro-cross-calls.s +++ b/lld/test/ELF/mips-micro-cross-calls.s @@ -14,31 +14,31 @@ # RUN: --no-show-raw-insn --print-imm-hex %t-eb.exe \ # RUN: | FileCheck --check-prefixes=SYM,MICRO %s +# REG: {{0*}}[[FOOT:[0-9a-f]+]] l F .text 0000000e 0x80 __microLA25Thunk_foo +# REG: {{0*}}[[BAR:[0-9a-f]+]] g F .text 00000000 bar +# REG: {{0*}}[[MIC:[0-9a-f]+]] .text 00000000 0x80 micro + # REG: __start: -# REG-NEXT: jalx 0x[[MIC:[0-9a-f]+]] +# REG-NEXT: jalx 0x[[MIC]] # REG-NEXT: nop -# REG-NEXT: jalx 0x[[FOOT:[0-9a-f]+]] <__microLA25Thunk_foo> +# REG-NEXT: jalx 0x[[FOOT]] <__microLA25Thunk_foo> # REG: __LA25Thunk_bar: # REG-NEXT: lui $25, 0x2 -# REG-NEXT: j 0x[[BAR:[0-9a-f]+]] +# REG-NEXT: j 0x[[BAR]] + +# MICRO: {{0*}}[[BART:[0-9a-f]+]] l F .text 00000010 __LA25Thunk_bar +# MICRO: {{0*}}[[START:[0-9a-f]+]] .text 00000000 __start +# MICRO: {{0*}}[[FOO:[0-9a-f]+]] g F .text 00000000 0x80 foo # MICRO: micro: -# MICRO-NEXT: jalx 0x[[START:[0-9a-f]+]] +# MICRO-NEXT: jalx 0x[[START]] # MICRO-NEXT: nop -# MICRO-NEXT: jalx 0x[[BART:[0-9a-f]+]] +# MICRO-NEXT: jalx 0x[[BART]] # MICRO: __microLA25Thunk_foo: # MICRO-NEXT: lui $25, 0x2 -# MICRO-NEXT: j 0x[[FOO:[0-9a-f]+]] - -# REG: [[FOOT]] l F .text 0000000e 0x80 __microLA25Thunk_foo -# REG: [[BAR]] g F .text 00000000 bar -# REG: [[MIC]] .text 00000000 0x80 micro - -# MICRO: [[BART]] l F .text 00000010 __LA25Thunk_bar -# MICRO: [[START]] .text 00000000 __start -# MICRO: [[FOO]] g F .text 00000000 0x80 foo +# MICRO-NEXT: j 0x[[FOO]] .text .set nomicromips diff --git a/lld/test/ELF/mips-micro-relocs.s b/lld/test/ELF/mips-micro-relocs.s --- a/lld/test/ELF/mips-micro-relocs.s +++ b/lld/test/ELF/mips-micro-relocs.s @@ -25,16 +25,9 @@ # RUN: | FileCheck --check-prefixes=ASM,EL %s # RUN: llvm-readelf -h %tel.exe | FileCheck --check-prefix=ELF %s -# ASM: __start: -# ASM-NEXT: 20110: lui $3, 1 -# ASM-NEXT: addiu $3, $3, 32495 -# ASM-NEXT: lw $3, -32744($gp) -# ASM-NEXT: lw $3, -32744($3) -# ASM-NEXT: beqz16 $6, -32 -# ASM-NEXT: sll $3, $fp, 0 -# ASM-NEXT: b16 -40 -# ASM-NEXT: nop -# ASM-NEXT: b -44 +# ASM: 00038000 .got 00000000 .hidden _gp +# ASM: 00020100 g F .text 00000000 0x80 foo +# ASM: 00020110 .text 00000000 0x80 __start # EB: Contents of section .data: # EB-NEXT: 30000 fffe8111 @@ -48,9 +41,16 @@ # EL: Contents of section .debug_info # EL-NEXT: 0000 11010200 -# ASM: 00038000 .got 00000000 .hidden _gp -# ASM: 00020100 g F .text 00000000 0x80 foo -# ASM: 00020110 .text 00000000 0x80 __start +# ASM: __start: +# ASM-NEXT: 20110: lui $3, 1 +# ASM-NEXT: addiu $3, $3, 32495 +# ASM-NEXT: lw $3, -32744($gp) +# ASM-NEXT: lw $3, -32744($3) +# ASM-NEXT: beqz16 $6, -32 +# ASM-NEXT: sll $3, $fp, 0 +# ASM-NEXT: b16 -40 +# ASM-NEXT: nop +# ASM-NEXT: b -44 # ELF: Entry point address: 0x20111 diff --git a/lld/test/ELF/mips-micror6-relocs.s b/lld/test/ELF/mips-micror6-relocs.s --- a/lld/test/ELF/mips-micror6-relocs.s +++ b/lld/test/ELF/mips-micror6-relocs.s @@ -20,14 +20,14 @@ # RUN: llvm-objdump -d -t -mattr=micromips --no-show-raw-insn %tel.exe \ # RUN: | FileCheck %s +# CHECK: 00020100 g F .text 00000000 0x80 foo +# CHECK: 00020110 .text 00000000 0x80 __start + # CHECK: __start: # CHECK-NEXT: 20110: lapc $2, -12 # CHECK-NEXT: beqzc $3, -36 # CHECK-NEXT: balc -24 -# CHECK: 00020100 g F .text 00000000 0x80 foo -# CHECK: 00020110 .text 00000000 0x80 __start - .text .set micromips .global __start diff --git a/lld/test/ELF/mips-n32-rels.s b/lld/test/ELF/mips-n32-rels.s --- a/lld/test/ELF/mips-n32-rels.s +++ b/lld/test/ELF/mips-n32-rels.s @@ -26,6 +26,14 @@ .section .rodata,"a",@progbits .gpword(loc) # R_MIPS_GPREL32 +# CHECK: 00020104 .text 00000000 loc +# CHECK: 00028100 .got 00000000 .hidden _gp +# CHECK: 00020100 g F .text 00000000 __start + +# CHECK: Contents of section .rodata: +# CHECK-NEXT: {{[0-9a-f]+}} ffff8004 +# ^-- loc - _gp + # CHECK: Disassembly of section .text: # CHECK-EMPTY: # CHECK-NEXT: __start: @@ -39,14 +47,6 @@ # ^-- 0 - 0xffff8000 # ^-- %lo(0x8000) -# CHECK: Contents of section .rodata: -# CHECK-NEXT: {{[0-9a-f]+}} ffff8004 -# ^-- loc - _gp - -# CHECK: 00020104 .text 00000000 loc -# CHECK: 00028100 .got 00000000 .hidden _gp -# CHECK: 00020100 g F .text 00000000 __start - # ELF: Class: ELF32 # ELF: Data: 2's complement, big endian # ELF: Version: 1 (current) diff --git a/lld/test/ELF/mips-nonalloc.s b/lld/test/ELF/mips-nonalloc.s --- a/lld/test/ELF/mips-nonalloc.s +++ b/lld/test/ELF/mips-nonalloc.s @@ -7,11 +7,12 @@ # RUN: ld.lld %t1.o %t2.o -o %t.exe # RUN: llvm-objdump -t -s %t.exe | FileCheck %s +# CHECK: [[SYM:[0-9a-f]+]] .text 00000000 __start + # CHECK: Contents of section .debug_info: -# CHECK-NEXT: 0000 ffffffff [[SYM:[0-9a-f]+]] [[SYM]] -# ^------------------^-- __start +# CHECK-NEXT: 0000 ffffffff [[SYM]] [[SYM]] +# ^-------^-- __start -# CHECK: [[SYM]] .text 00000000 __start .global __start __start: diff --git a/lld/test/ELF/mips-pc-relocs.s b/lld/test/ELF/mips-pc-relocs.s --- a/lld/test/ELF/mips-pc-relocs.s +++ b/lld/test/ELF/mips-pc-relocs.s @@ -26,6 +26,13 @@ .data .word _foo+8-. # R_MIPS_PC32 +# CHECK: 00020000 .text 00000000 __start +# CHECK: 00020020 .text 00000000 _foo + +# CHECK: Contents of section .data: +# CHECK-NEXT: 30000 ffff0028 00000000 00000000 00000000 +# ^-- 0x20020 + 8 - 0x30000 + # CHECK: Disassembly of section .text: # CHECK-EMPTY: # CHECK-NEXT: __start: @@ -41,10 +48,3 @@ # ^-- %hi(0x20020-0x20010) # CHECK-NEXT: 20014: addiu $2, $2, 12 # ^-- %lo(0x20020-0x20014) - -# CHECK: Contents of section .data: -# CHECK-NEXT: 30000 ffff0028 00000000 00000000 00000000 -# ^-- 0x20020 + 8 - 0x30000 - -# CHECK: 00020000 .text 00000000 __start -# CHECK: 00020020 .text 00000000 _foo diff --git a/lld/test/ELF/mips-tls-64.s b/lld/test/ELF/mips-tls-64.s --- a/lld/test/ELF/mips-tls-64.s +++ b/lld/test/ELF/mips-tls-64.s @@ -19,12 +19,9 @@ # RUN: llvm-objdump -d -s -t --no-show-raw-insn %t-out.so | FileCheck -check-prefix=DIS-SO %s # RUN: llvm-readobj -r --mips-plt-got %t-out.so | FileCheck -check-prefix=SO %s -# DIS: __start: -# DIS-NEXT: addiu $2, $3, -32720 -# DIS-NEXT: addiu $2, $3, -32736 -# DIS-NEXT: addiu $2, $3, -32704 -# DIS-NEXT: addiu $2, $3, -32688 -# DIS-NEXT: addiu $2, $3, -32728 +# DIS: 0000000000000000 l O .tdata 00000000 loc +# DIS: 0000000000000004 g O .tdata 00000000 bar +# DIS: 0000000000000000 g O *UND* 00000000 foo # DIS: Contents of section .got: # DIS-NEXT: 30000 00000000 00000000 80000000 00000000 @@ -33,9 +30,12 @@ # DIS-NEXT: 30030 00000000 00000001 00000000 00000000 # DIS-NEXT: 30040 00000000 00000001 ffffffff ffff8004 -# DIS: 0000000000000000 l O .tdata 00000000 loc -# DIS: 0000000000000004 g O .tdata 00000000 bar -# DIS: 0000000000000000 g O *UND* 00000000 foo +# DIS: __start: +# DIS-NEXT: addiu $2, $3, -32720 +# DIS-NEXT: addiu $2, $3, -32736 +# DIS-NEXT: addiu $2, $3, -32704 +# DIS-NEXT: addiu $2, $3, -32688 +# DIS-NEXT: addiu $2, $3, -32728 # CHECK: Relocations [ # CHECK-NEXT: Section (7) .rel.dyn { diff --git a/lld/test/ELF/mips-tls-hilo.s b/lld/test/ELF/mips-tls-hilo.s --- a/lld/test/ELF/mips-tls-hilo.s +++ b/lld/test/ELF/mips-tls-hilo.s @@ -10,6 +10,8 @@ # RUN: ld.lld %t.o -shared -o %t.so # RUN: llvm-readobj -r --mips-plt-got %t.so | FileCheck -check-prefix=SO %s +# DIS: 00000000 l O .tdata 00000000 loc0 + # DIS: __start: # DIS-NEXT: addiu $2, $3, 0 # ^-- %hi(loc0 - .tdata - 0x8000) @@ -20,8 +22,6 @@ # DIS-NEXT: addiu $2, $3, -28672 # ^-- %lo(loc0 - .tdata - 0x7000) -# DIS: 00000000 l O .tdata 00000000 loc0 - # CHECK: Relocations [ # CHECK-NEXT: ] # CHECK-NOT: Primary GOT diff --git a/lld/test/ELF/mips-tls-static-64.s b/lld/test/ELF/mips-tls-static-64.s --- a/lld/test/ELF/mips-tls-static-64.s +++ b/lld/test/ELF/mips-tls-static-64.s @@ -6,13 +6,13 @@ # RUN: ld.lld -static %t -o %t.exe # RUN: llvm-objdump -s -t %t.exe | FileCheck %s +# CHECK: SYMBOL TABLE: +# CHECK: [[TGA:[0-9a-f]{8}]] .text 00000000 __tls_get_addr +# CHECK: 0000000000000000 g O .tdata 00000000 tls1 +# # CHECK: Contents of section .data: -# CHECK-NEXT: {{.*}} [[TGA:[0-9a-f]+]] ffffffff ffff8004 ffffffff +# CHECK-NEXT: {{.*}} [[TGA]] ffffffff ffff8004 ffffffff # CHECK-NEXT: {{.*}} ffff9004 -# -# CHECK: SYMBOL TABLE: -# CHECK: [[TGA]] .text 00000000 __tls_get_addr -# CHECK: 0000000000000000 g O .tdata 00000000 tls1 .text .global __start diff --git a/lld/test/ELF/mips-tls-static.s b/lld/test/ELF/mips-tls-static.s --- a/lld/test/ELF/mips-tls-static.s +++ b/lld/test/ELF/mips-tls-static.s @@ -6,15 +6,15 @@ # RUN: ld.lld -static %t -o %t.exe # RUN: llvm-objdump -s -t %t.exe | FileCheck %s +# CHECK: SYMBOL TABLE: +# CHECK: [[TGA:[0-9a-f]+]] .text 00000000 __tls_get_addr +# CHECK: 00000000 g O .tdata 00000000 tls1 +# # CHECK: Contents of section .data: -# CHECK-NEXT: {{.*}} [[TGA:[0-9a-f]+]] ffff8004 ffff9004 +# CHECK-NEXT: {{.*}} [[TGA]] ffff8004 ffff9004 # CHECK: Contents of section .got: # CHECK-NEXT: {{.*}} 00000000 80000000 ffff9000 00000001 # CHECK-NEXT: {{.*}} ffff8000 00000001 00000000 -# -# CHECK: SYMBOL TABLE: -# CHECK: [[TGA]] .text 00000000 __tls_get_addr -# CHECK: 00000000 g O .tdata 00000000 tls1 .text .global __start diff --git a/lld/test/ELF/mips-tls.s b/lld/test/ELF/mips-tls.s --- a/lld/test/ELF/mips-tls.s +++ b/lld/test/ELF/mips-tls.s @@ -19,21 +19,21 @@ # RUN: llvm-objdump -d -s -t --no-show-raw-insn %t-out.so | FileCheck -check-prefix=DIS-SO %s # RUN: llvm-readobj -r --mips-plt-got %t-out.so | FileCheck -check-prefix=SO %s -# DIS: __start: -# DIS-NEXT: addiu $2, $3, -32736 -# DIS-NEXT: addiu $2, $3, -32744 -# DIS-NEXT: addiu $2, $3, -32728 -# DIS-NEXT: addiu $2, $3, -32720 -# DIS-NEXT: addiu $2, $3, -32740 +# DIS: 00000000 l O .tdata 00000000 loc +# DIS: 00000004 g O .tdata 00000000 bar +# DIS: 00000000 g O *UND* 00000000 foo # DIS: Contents of section .got: # DIS-NEXT: 30000 00000000 80000000 00000000 ffff9004 # DIS-NEXT: 30010 00000000 00000000 00000001 00000000 # DIS-NEXT: 30020 00000001 ffff8004 -# DIS: 00000000 l O .tdata 00000000 loc -# DIS: 00000004 g O .tdata 00000000 bar -# DIS: 00000000 g O *UND* 00000000 foo +# DIS: __start: +# DIS-NEXT: addiu $2, $3, -32736 +# DIS-NEXT: addiu $2, $3, -32744 +# DIS-NEXT: addiu $2, $3, -32728 +# DIS-NEXT: addiu $2, $3, -32720 +# DIS-NEXT: addiu $2, $3, -32740 # CHECK: Relocations [ # CHECK-NEXT: Section (7) .rel.dyn { diff --git a/lld/test/ELF/msp430.s b/lld/test/ELF/msp430.s --- a/lld/test/ELF/msp430.s +++ b/lld/test/ELF/msp430.s @@ -6,6 +6,17 @@ ;; Check handling of basic msp430 relocation types. + .data +;; R_MSP430_8 + .byte _byte +;; R_MSP430_16 + .word _start +;; R_MSP430_32 + .long _start + +; CHECK: Contents of section .data: +; CHECK-NEXT: 2000 21008000 800000 + .text .global foo foo: @@ -29,16 +40,5 @@ ; CHECK: 800a: {{.*}} mov #-1, -12 - .data -;; R_MSP430_8 - .byte _byte -;; R_MSP430_16 - .word _start -;; R_MSP430_32 - .long _start - -; CHECK: Contents of section .data: -; CHECK-NEXT: 2000 21008000 800000 - ; RUN: od -x %t.exe | FileCheck -check-prefix=TRAP %s ; TRAP: 4343 4343 4343 4343 4343 4343 4343 4343 diff --git a/lld/test/ELF/non-alloc-link-order-gc.s b/lld/test/ELF/non-alloc-link-order-gc.s --- a/lld/test/ELF/non-alloc-link-order-gc.s +++ b/lld/test/ELF/non-alloc-link-order-gc.s @@ -5,14 +5,14 @@ ## Check that we are able to GC non-allocatable metadata sections without crash. +# CHECK: Name Size +# CHECK: .stack_sizes 00000001 + # CHECK: Disassembly of section .stack_sizes: # CHECK-EMPTY: # CHECK-NEXT: .stack_sizes: # CHECK-NEXT: 01 -# CHECK: Name Size -# CHECK: .stack_sizes 00000001 - .section .text.live,"ax",@progbits .globl live live: diff --git a/lld/test/ELF/relocation-common.s b/lld/test/ELF/relocation-common.s --- a/lld/test/ELF/relocation-common.s +++ b/lld/test/ELF/relocation-common.s @@ -10,5 +10,5 @@ .global sym1 .comm sym1,4,4 -# CHECK: 201158: {{.*}} movl $1, 4098(%rip) # CHECK: 0000000000202164 g O .bss 00000004 sym1 +# CHECK: 201158: {{.*}} movl $1, 4098(%rip) diff --git a/lld/test/ELF/relocation.s b/lld/test/ELF/relocation.s --- a/lld/test/ELF/relocation.s +++ b/lld/test/ELF/relocation.s @@ -46,6 +46,39 @@ // SEC-NEXT: EntrySize: 0 // SEC-NEXT: } +.section .R_X86_64_64,"a",@progbits +.global R_X86_64_64 +R_X86_64_64: + .quad R_X86_64_64 + +// CHECK: Contents of section .R_X86_64_64: +// CHECK-NEXT: 2002f8 f8022000 00000000 + +.section .R_X86_64_GOTPCREL,"a",@progbits +.global R_X86_64_GOTPCREL +R_X86_64_GOTPCREL: + .long zed@gotpcrel + +// 0x202460(.got) - 0x200300(.R_X86_64_GOTPCREL) = 0x2160 +// CHECK: Contents of section .R_X86_64_GOTPCREL +// CHECK-NEXT: 200300 60210000 + +.section .R_X86_64_GOT32,"a",@progbits +.global R_X86_64_GOT32 +R_X86_64_GOT32: + .long zed@got + +// CHECK: Contents of section .R_X86_64_GOT32: +// CHECK-NEXT: f8efffff + + +// CHECK: Contents of section .R_X86_64_GOT64: +// CHECK-NEXT: f8efffff ffffffff +.section .R_X86_64_GOT64,"a",@progbits +.global R_X86_64_GOT64 +R_X86_64_GOT64: + .quad zed@got + .section .text,"ax",@progbits,unique,1 .global _start _start: @@ -111,36 +144,3 @@ // CHECK-EMPTY: // CHECK-NEXT: R_X86_64_32S_2: // CHECK-NEXT: 201331: {{.*}} movl 2102112, %eax - -.section .R_X86_64_64,"a",@progbits -.global R_X86_64_64 -R_X86_64_64: - .quad R_X86_64_64 - -// CHECK: Contents of section .R_X86_64_64: -// CHECK-NEXT: 2002f8 f8022000 00000000 - -.section .R_X86_64_GOTPCREL,"a",@progbits -.global R_X86_64_GOTPCREL -R_X86_64_GOTPCREL: - .long zed@gotpcrel - -// 0x202460(.got) - 0x200300(.R_X86_64_GOTPCREL) = 0x2160 -// CHECK: Contents of section .R_X86_64_GOTPCREL -// CHECK-NEXT: 200300 60210000 - -.section .R_X86_64_GOT32,"a",@progbits -.global R_X86_64_GOT32 -R_X86_64_GOT32: - .long zed@got - -// CHECK: Contents of section .R_X86_64_GOT32: -// CHECK-NEXT: f8efffff - - -// CHECK: Contents of section .R_X86_64_GOT64: -// CHECK-NEXT: f8efffff ffffffff -.section .R_X86_64_GOT64,"a",@progbits -.global R_X86_64_GOT64 -R_X86_64_GOT64: - .quad zed@got diff --git a/lld/test/ELF/x86-64-retpoline-znow.s b/lld/test/ELF/x86-64-retpoline-znow.s --- a/lld/test/ELF/x86-64-retpoline-znow.s +++ b/lld/test/ELF/x86-64-retpoline-znow.s @@ -6,6 +6,11 @@ // RUN: ld.lld -shared %t1.o %t2.so -o %t.exe -z retpolineplt -z now // RUN: llvm-objdump -d -s --no-show-raw-insn %t.exe | FileCheck %s +// CHECK: Contents of section .got.plt: +// CHECK-NEXT: 23f0 10230000 00000000 00000000 00000000 +// CHECK-NEXT: 2400 00000000 00000000 00000000 00000000 +// CHECK-NEXT: 2410 00000000 00000000 + // CHECK: Disassembly of section .plt: // CHECK-EMPTY: // CHECK-NEXT: .plt: @@ -43,11 +48,6 @@ // CHECK-NEXT: int3 // CHECK-NEXT: int3 -// CHECK: Contents of section .got.plt: -// CHECK-NEXT: 23f0 10230000 00000000 00000000 00000000 -// CHECK-NEXT: 2400 00000000 00000000 00000000 00000000 -// CHECK-NEXT: 2410 00000000 00000000 - .global _start _start: jmp bar@PLT diff --git a/lld/test/ELF/x86-64-retpoline.s b/lld/test/ELF/x86-64-retpoline.s --- a/lld/test/ELF/x86-64-retpoline.s +++ b/lld/test/ELF/x86-64-retpoline.s @@ -6,6 +6,11 @@ // RUN: ld.lld -shared %t1.o %t2.so -o %t.exe -z retpolineplt // RUN: llvm-objdump -d -s --no-show-raw-insn %t.exe | FileCheck %s +// CHECK: Contents of section .got.plt: +// CHECK-NEXT: 3430 70230000 00000000 00000000 00000000 +// CHECK-NEXT: 3440 00000000 00000000 41130000 00000000 +// CHECK-NEXT: 3450 61130000 00000000 + // CHECK: Disassembly of section .plt: // CHECK-EMPTY: // CHECK-NEXT: .plt: @@ -56,11 +61,6 @@ // CHECK-NEXT: int3 // CHECK-NEXT: int3 -// CHECK: Contents of section .got.plt: -// CHECK-NEXT: 3430 70230000 00000000 00000000 00000000 -// CHECK-NEXT: 3440 00000000 00000000 41130000 00000000 -// CHECK-NEXT: 3450 61130000 00000000 - .global _start _start: jmp bar@PLT diff --git a/llvm/test/MC/COFF/symidx.s b/llvm/test/MC/COFF/symidx.s --- a/llvm/test/MC/COFF/symidx.s +++ b/llvm/test/MC/COFF/symidx.s @@ -8,8 +8,8 @@ .symidx bar .symidx foo -// CHECK: Contents of section .data: -// CHECK-NEXT: 0000 0[[BAR:[1-9]]]000000 0[[FOO:[1-9]]]000000 // CHECK: SYMBOL TABLE: -// CHECK: [ [[FOO]]](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 foo -// CHECK-NEXT: [ [[BAR]]](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000001 bar +// CHECK: [ [[FOO:[1-9]]]](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000000 foo +// CHECK-NEXT: [ [[BAR:[1-9]]]](sec 1)(fl 0x00)(ty 0)(scl 3) (nx 0) 0x00000001 bar +// CHECK: Contents of section .data: +// CHECK-NEXT: 0000 0[[BAR]]000000 0[[FOO]]000000 diff --git a/llvm/test/tools/llvm-objdump/X86/adjust-vma.test b/llvm/test/tools/llvm-objdump/X86/adjust-vma.test --- a/llvm/test/tools/llvm-objdump/X86/adjust-vma.test +++ b/llvm/test/tools/llvm-objdump/X86/adjust-vma.test @@ -3,6 +3,35 @@ # RUN: llvm-objdump --all-headers -D -z --adjust-vma=0x0 %t | FileCheck %s --check-prefixes=COMMON,NOADJUST # RUN: llvm-objdump --all-headers -D -z --adjust-vma=0x123000 %t | FileCheck %s --check-prefixes=COMMON,ADJUST +# NOADJUST: Sections: +# NOADJUST-NEXT: Idx Name Size VMA Type +# NOADJUST-NEXT: 0 00000000 0000000000000000 +# NOADJUST-NEXT: 1 .text 00000002 0000000000000000 TEXT +# NOADJUST-NEXT: 2 .debug_str 00000004 0000000000000000 +# NOADJUST-NEXT: 3 .rela.debug_str 00000018 0000000000000000 +# NOADJUST-NEXT: 4 .data 00000004 0000000000000000 DATA +# NOADJUST-NEXT: 5 .rela.data 00000018 0000000000000000 +# NOADJUST-NEXT: 6 .symtab 00000060 0000000000000000 +# NOADJUST-NEXT: 7 .strtab 00000010 0000000000000000 +# NOADJUST-NEXT: 8 .shstrtab 0000003c 0000000000000000 + +# ADJUST: Sections: +# ADJUST-NEXT: Idx Name Size VMA Type +# ADJUST-NEXT: 0 00000000 0000000000000000 +# ADJUST-NEXT: 1 .text 00000002 0000000000123000 TEXT +# ADJUST-NEXT: 2 .debug_str 00000004 0000000000000000 +# ADJUST-NEXT: 3 .rela.debug_str 00000018 0000000000000000 +# ADJUST-NEXT: 4 .data 00000004 0000000000123000 DATA +# ADJUST-NEXT: 5 .rela.data 00000018 0000000000000000 +# ADJUST-NEXT: 6 .symtab 00000060 0000000000000000 +# ADJUST-NEXT: 7 .strtab 00000010 0000000000000000 +# ADJUST-NEXT: 8 .shstrtab 0000003c 0000000000000000 + +# COMMON: SYMBOL TABLE: +# COMMON-NEXT: 0000000000000001 l F .text 00000000 func +# COMMON-NEXT: 0000000000000000 .text 00000000 sym +# COMMON-NEXT: 0000000000000000 l d .text 00000000 .text + # NOADJUST: 0000000000000000 sym: # NOADJUST-NEXT: 0: {{.*}} nop # NOADJUST: 0000000000000001 func: @@ -41,35 +70,6 @@ # COMMON-NEXT: 0: {{.*}} addb %al, (%rax) ## ... There are more lines here. We do not care. -# NOADJUST: Sections: -# NOADJUST-NEXT: Idx Name Size VMA Type -# NOADJUST-NEXT: 0 00000000 0000000000000000 -# NOADJUST-NEXT: 1 .text 00000002 0000000000000000 TEXT -# NOADJUST-NEXT: 2 .debug_str 00000004 0000000000000000 -# NOADJUST-NEXT: 3 .rela.debug_str 00000018 0000000000000000 -# NOADJUST-NEXT: 4 .data 00000004 0000000000000000 DATA -# NOADJUST-NEXT: 5 .rela.data 00000018 0000000000000000 -# NOADJUST-NEXT: 6 .symtab 00000060 0000000000000000 -# NOADJUST-NEXT: 7 .strtab 00000010 0000000000000000 -# NOADJUST-NEXT: 8 .shstrtab 0000003c 0000000000000000 - -# ADJUST: Sections: -# ADJUST-NEXT: Idx Name Size VMA Type -# ADJUST-NEXT: 0 00000000 0000000000000000 -# ADJUST-NEXT: 1 .text 00000002 0000000000123000 TEXT -# ADJUST-NEXT: 2 .debug_str 00000004 0000000000000000 -# ADJUST-NEXT: 3 .rela.debug_str 00000018 0000000000000000 -# ADJUST-NEXT: 4 .data 00000004 0000000000123000 DATA -# ADJUST-NEXT: 5 .rela.data 00000018 0000000000000000 -# ADJUST-NEXT: 6 .symtab 00000060 0000000000000000 -# ADJUST-NEXT: 7 .strtab 00000010 0000000000000000 -# ADJUST-NEXT: 8 .shstrtab 0000003c 0000000000000000 - -# COMMON: SYMBOL TABLE: -# COMMON-NEXT: 0000000000000001 l F .text 00000000 func -# COMMON-NEXT: 0000000000000000 .text 00000000 sym -# COMMON-NEXT: 0000000000000000 l d .text 00000000 .text - --- !ELF FileHeader: Class: ELFCLASS64 diff --git a/llvm/test/tools/llvm-objdump/X86/demangle.s b/llvm/test/tools/llvm-objdump/X86/demangle.s --- a/llvm/test/tools/llvm-objdump/X86/demangle.s +++ b/llvm/test/tools/llvm-objdump/X86/demangle.s @@ -1,13 +1,13 @@ # RUN: llvm-mc %s -filetype=obj -triple=x86_64-pc-linux -o %t # RUN: llvm-objdump -t -r --demangle %t | FileCheck %s -## Check we demangle symbols when printing relocations. -# CHECK: 000000000000001 R_X86_64_PLT32 foo()-4 - ## Check we demangle symbols when printing symbol table. # CHECK: SYMBOL TABLE: # CHECK-NEXT: 0000000000000000 g F .text 00000000 foo() +## Check we demangle symbols when printing relocations. +# CHECK: 000000000000001 R_X86_64_PLT32 foo()-4 + ## Check the case when relocations are inlined into disassembly. # RUN: llvm-objdump -d -r --demangle %t | FileCheck %s --check-prefix=INLINE # INLINE: foo(): diff --git a/llvm/test/tools/llvm-objdump/X86/elf-disassemble-dynamic-relocs.test b/llvm/test/tools/llvm-objdump/X86/elf-disassemble-dynamic-relocs.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-objdump/X86/elf-disassemble-dynamic-relocs.test @@ -0,0 +1,117 @@ +## Show that --disassemble + --dynamic-reloc prints relocations inline and +## does not dump the relocation sections. + +# RUN: yaml2obj %s -o %t.o +# RUN: llvm-objdump %t.o --dynamic-reloc | \ +# RUN: FileCheck %s --check-prefix=DYN-RELOC --implicit-check-not=Disassembly +# RUN: llvm-objdump %t.o --disassemble --dynamic-reloc | \ +# RUN: FileCheck %s --implicit-check-not="DYNAMIC RELOCATION RECORDS" + +# DYN-RELOC: DYNAMIC RELOCATION RECORDS + +# CHECK: Disassembly of section .text: + +--- !ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_DYN + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [SHF_ALLOC, SHF_EXECINSTR] + Content: 'e800000000e800000000' + - Name: .foo + Type: SHT_PROGBITS + Size: 16 + Flags: [SHF_ALLOC] + Address: 0x100000 + AddressAlign: 0x100 + - Name: .got.plt + Type: SHT_PROGBITS + Flags: [SHF_WRITE, SHF_ALLOC] + Address: 0x100100 + AddressAlign: 0x1000 + - Name: .rela.dyn + Type: SHT_RELA + Address: 0x100200 + AddressAlign: 0x100 + Info: .foo + Link: .dynsym + Flags: [SHF_ALLOC] + Relocations: + - Offset: 0 + Type: R_X86_64_RELATIVE + Addend: 0 + - Name: .rela.plt + Type: SHT_RELA + Address: 0x100300 + AddressAlign: 0x100 + Info: .got.plt + Link: .dynsym + Flags: [SHF_ALLOC] + Relocations: + - Offset: 0 + Symbol: 2 # bar + Type: R_X86_64_JUMP_SLOT + - Name: .rel.dyn + Type: SHT_REL + Address: 0x100400 + AddressAlign: 0x100 + Info: .foo + Link: .dynsym + Flags: [SHF_ALLOC] + Relocations: + - Offset: 8 + Symbol: 1 # foo + Type: R_X86_64_NONE + - Name: .dynamic + Type: SHT_DYNAMIC + Address: 0x100500 + AddressAlign: 0x100 + Link: .dynstr + Flags: [SHF_ALLOC] + Entries: + - Tag: DT_RELA + Value: 0x100200 + - Tag: DT_RELASZ + Value: 24 + - Tag: DT_RELAENT + Value: 24 + - Tag: DT_JMPREL + Value: 0x100300 + - Tag: DT_PLTREL + Value: 7 + - Tag: DT_PLTRELSZ + Value: 24 + - Tag: DT_REL + Value: 0x100400 + - Tag: DT_RELSZ + Value: 16 + - Tag: DT_RELENT + Value: 16 + - Tag: DT_NULL + Value: 0 +ProgramHeaders: + - Type: PT_LOAD + VAddr: 0x100000 + Align: 0x100 + Sections: + - Section: .foo + - Section: .rela.dyn + - Section: .rela.plt + - Section: .rel.dyn + - Section: .dynamic + - Type: PT_DYNAMIC + VAddr: 0x100500 + Align: 0x100 + Sections: + - Section: .dynamic +DynamicSymbols: + - Name: foo + Section: .foo + Binding: STB_GLOBAL + - Name: bar + Type: STT_FUNC + Binding: STB_GLOBAL diff --git a/llvm/test/tools/llvm-objdump/X86/out-of-section-sym.test b/llvm/test/tools/llvm-objdump/X86/out-of-section-sym.test --- a/llvm/test/tools/llvm-objdump/X86/out-of-section-sym.test +++ b/llvm/test/tools/llvm-objdump/X86/out-of-section-sym.test @@ -5,12 +5,13 @@ // RUN: cmp %t0 %t1 // RUN: FileCheck --input-file %t0 %s -CHECK: Disassembly of section .text: -CHECK-EMPTY: -CHECK-NEXT: _start: -CHECK-NEXT: 10: c3 retl -CHECK-NEXT: SYMBOL TABLE: +CHECK: SYMBOL TABLE: CHECK-NEXT: 00000010 l d .text 00000000 .text CHECK-NEXT: 00000010 .text 00000000 _start CHECK-NEXT: 00000020 .text 00000000 _fdata CHECK-NEXT: 00000010 .text 00000000 _ftext +CHECK-EMPTY: +CHECK-NEXT: Disassembly of section .text: +CHECK-EMPTY: +CHECK-NEXT: _start: +CHECK-NEXT: 10: c3 retl diff --git a/llvm/test/tools/llvm-objdump/all-headers.test b/llvm/test/tools/llvm-objdump/all-headers.test --- a/llvm/test/tools/llvm-objdump/all-headers.test +++ b/llvm/test/tools/llvm-objdump/all-headers.test @@ -1,8 +1,9 @@ # RUN: yaml2obj %s > %t # RUN: llvm-objdump --all-headers %t | FileCheck %s -## Check we print file format, architecture and start address followed by the -## other data when using --all-headers. +## Note: --all-headers (-x) is an alias for --archive-headers --file-headers +## --section-headers --private-headers --reloc --syms (-afhprt). Test for them +## in the following order which provides GNU objdump compatability. # CHECK: file format ELF64-x86-64 # CHECK-EMPTY: @@ -11,8 +12,10 @@ # CHECK-EMPTY: # CHECK-NEXT: Program Header: # CHECK: Dynamic Section: +# CHECK: INIT 0x00000000000006a0 # CHECK: Sections: # CHECK: SYMBOL TABLE: +# CHECK: RELOCATION RECORDS FOR [.text]: ## Check how we dump the archives. ## Check we dump the appropriate headers for each file in the archive. @@ -23,26 +26,51 @@ # RUN: llvm-objdump --all-headers %t.a | FileCheck %s --check-prefix=ARCHIVE # ARCHIVE: {{.*}}.a({{.*}}): file format ELF64-x86-64 +# ARCHIVE: rw-r--r-- # ARCHIVE: architecture: x86_64 # ARCHIVE: start address: 0x0000000000000000 -# ARCHIVE: rw-r--r-- # ARCHIVE: Program Header: # ARCHIVE: Dynamic Section: +# ARCHIVE: INIT 0x00000000000006a0 # ARCHIVE: Sections: # ARCHIVE: SYMBOL TABLE: +# ARCHIVE: RELOCATION RECORDS FOR [.text]: # ARCHIVE: {{.*}}.a({{.*}}2): file format ELF64-x86-64 +# ARCHIVE: rw-r--r-- # ARCHIVE: architecture: x86_64 # ARCHIVE: start address: 0x0000000000000000 -# ARCHIVE: rw-r--r-- # ARCHIVE: Program Header: # ARCHIVE: Dynamic Section: +# ARCHIVE: INIT 0x00000000000006a0 # ARCHIVE: Sections: # ARCHIVE: SYMBOL TABLE: +# ARCHIVE: RELOCATION RECORDS FOR [.text]: !ELF FileHeader: Class: ELFCLASS64 Data: ELFDATA2LSB - Type: ET_EXEC + Type: ET_REL Machine: EM_X86_64 Sections: + - Name: .text + Type: SHT_PROGBITS + - Name: .rel.text + Type: SHT_REL + Info: .text + Relocations: + - Offset: 0x1 + Symbol: foo + Type: R_X86_64_32 + - Name: .dynamic + Type: SHT_DYNAMIC + Flags: [ SHF_WRITE, SHF_ALLOC ] + EntSize: 0x0000000000000010 + Entries: + - Tag: DT_INIT + Value: 0x00000000000006A0 + - Tag: DT_NULL + Value: 0x0000000000000000 +Symbols: + - Name: foo + Section: .text diff --git a/llvm/test/tools/llvm-objdump/headers-ordering.test b/llvm/test/tools/llvm-objdump/headers-ordering.test new file mode 100644 --- /dev/null +++ b/llvm/test/tools/llvm-objdump/headers-ordering.test @@ -0,0 +1,69 @@ +# RUN: yaml2obj %s > %t.o +# RUN: llvm-objdump --all-headers --full-contents --dwarf=frames \ +# RUN: --reloc %t.o | FileCheck %s --check-prefixes=CHECK,RELOC +# RUN: llvm-objdump --all-headers --full-contents --dwarf=frames \ +# RUN: --disassemble %t.o | FileCheck %s --check-prefixes=CHECK,DISASM + +## Test the ordering of most of the headers. Note that --disassemble suppresses +## --reloc, so we test them independently. + +## File headers (-f) +# CHECK: file format ELF64-x86-64 +# CHECK: architecture: x86_64 +# CHECK: start address: 0x0000000000000000 +## Private headers (-p) +# CHECK: Program Header: +# CHECK: Dynamic Section: +# CHECK: INIT 0x00000000000006a0 +## Section headers (h) +# CHECK: Sections: +## Symbol table (-t) +# CHECK: SYMBOL TABLE: +## DWARF contents: +# CHECK: .eh_frame contents: +## Relocations (-r) +# RELOC: RELOCATION RECORDS FOR [.text]: +## Section contents (-s) +# CHECK: Contents of section .rel.text: +# CHECK: Contents of section .dynamic: +# CHECK: Contents of section .symtab: +# CHECK: Contents of section .strtab: +# CHECK: Contents of section .shstrtab: +## Disassembly +# DISASM: Disassembly of section .text: + +!ELF +FileHeader: + Class: ELFCLASS64 + Data: ELFDATA2LSB + Type: ET_REL + Machine: EM_X86_64 +Sections: + - Name: .text + Type: SHT_PROGBITS + Flags: [ SHF_ALLOC, SHF_EXECINSTR ] + Content: e800000000e800000000 + - Name: .rel.text + Type: SHT_REL + Info: .text + Relocations: + - Offset: 0x1 + Symbol: foo + Type: R_X86_64_32 + - Name: .dynamic + Type: SHT_DYNAMIC + Flags: [ SHF_WRITE, SHF_ALLOC ] + EntSize: 0x0000000000000010 + Entries: + - Tag: DT_INIT + Value: 0x00000000000006A0 + - Tag: DT_NULL + Value: 0x0000000000000000 + - Name: .eh_frame + Type: SHT_X86_64_UNWIND + Flags: [ SHF_ALLOC ] + AddressAlign: 0x0000000000000001 + Content: 00000000 +Symbols: + - Name: foo + Section: .text diff --git a/llvm/tools/llvm-objdump/llvm-objdump.cpp b/llvm/tools/llvm-objdump/llvm-objdump.cpp --- a/llvm/tools/llvm-objdump/llvm-objdump.cpp +++ b/llvm/tools/llvm-objdump/llvm-objdump.cpp @@ -2076,27 +2076,37 @@ if (StartAddress.getNumOccurrences() || StopAddress.getNumOccurrences()) checkForInvalidStartStopAddress(O, StartAddress, StopAddress); + // Note: the order here matches GNU objdump for compatability. StringRef ArchiveName = A ? A->getFileName() : ""; - if (FileHeaders) - printFileHeaders(O); if (ArchiveHeaders && !MachOOpt && C) printArchiveChild(ArchiveName, *C); - if (Disassemble) - disassembleObject(O, Relocations); - if (Relocations && !Disassemble) - printRelocations(O); - if (DynamicRelocations) - printDynamicRelocations(O); + if (FileHeaders) + printFileHeaders(O); if (PrivateHeaders || FirstPrivateHeader) printPrivateFileHeaders(O, FirstPrivateHeader); if (SectionHeaders) printSectionHeaders(O); - if (SectionContents) - printSectionContents(O); if (SymbolTable) printSymbolTable(O, ArchiveName); + if (DwarfDumpType != DIDT_Null) { + std::unique_ptr DICtx = DWARFContext::create(*O); + // Dump the complete DWARF structure. + DIDumpOptions DumpOpts; + DumpOpts.DumpType = DwarfDumpType; + DICtx->dump(outs(), DumpOpts); + } + if (Relocations && !Disassemble) + printRelocations(O); + if (DynamicRelocations && !Disassemble) + printDynamicRelocations(O); + if (SectionContents) + printSectionContents(O); + if (Disassemble) + disassembleObject(O, Relocations); if (UnwindInfo) printUnwindInfo(O); + + // Mach-O specific options: if (ExportsTrie) printExportsTrie(O); if (Rebase) @@ -2107,17 +2117,12 @@ printLazyBindTable(O); if (WeakBind) printWeakBindTable(O); + + // Other special sections: if (RawClangAST) printRawClangAST(O); if (FaultMapSection) printFaultMaps(O); - if (DwarfDumpType != DIDT_Null) { - std::unique_ptr DICtx = DWARFContext::create(*O); - // Dump the complete DWARF structure. - DIDumpOptions DumpOpts; - DumpOpts.DumpType = DwarfDumpType; - DICtx->dump(outs(), DumpOpts); - } } static void dumpObject(const COFFImportFile *I, const Archive *A,