2015-10-20 05:00:02 +08:00
|
|
|
// REQUIRES: x86
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
|
|
|
|
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/merge.s -o %t2.o
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld %t.o %t2.o -o %t
|
2019-05-01 13:49:01 +08:00
|
|
|
// RUN: llvm-readobj -S --section-data --symbols %t | FileCheck %s
|
2015-10-20 05:00:02 +08:00
|
|
|
// RUN: llvm-objdump -d %t | FileCheck --check-prefix=DISASM %s
|
|
|
|
|
|
|
|
.section .mysec,"aM",@progbits,4
|
|
|
|
.align 4
|
|
|
|
.global foo
|
|
|
|
.hidden foo
|
|
|
|
.long 0x10
|
|
|
|
foo:
|
|
|
|
.long 0x42
|
|
|
|
bar:
|
|
|
|
.long 0x42
|
|
|
|
zed:
|
|
|
|
.long 0x42
|
|
|
|
|
|
|
|
// CHECK: Name: .mysec
|
|
|
|
// CHECK-NEXT: Type: SHT_PROGBITS
|
|
|
|
// CHECK-NEXT: Flags [
|
|
|
|
// CHECK-NEXT: SHF_ALLOC
|
|
|
|
// CHECK-NEXT: SHF_MERGE
|
|
|
|
// CHECK-NEXT: ]
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: Address: 0x200120
|
2015-11-25 02:48:16 +08:00
|
|
|
// CHECK-NEXT: Offset: 0x120
|
2015-10-20 05:00:02 +08:00
|
|
|
// CHECK-NEXT: Size: 8
|
|
|
|
// CHECK-NEXT: Link: 0
|
|
|
|
// CHECK-NEXT: Info: 0
|
|
|
|
// CHECK-NEXT: AddressAlignment: 4
|
2017-11-16 00:56:20 +08:00
|
|
|
// CHECK-NEXT: EntrySize: 4
|
2015-10-20 05:00:02 +08:00
|
|
|
// CHECK-NEXT: SectionData (
|
|
|
|
// CHECK-NEXT: 0000: 10000000 42000000
|
|
|
|
// CHECK-NEXT: )
|
|
|
|
|
|
|
|
|
2016-11-24 01:44:02 +08:00
|
|
|
// Address of the constant 0x10 = 0x200120 = 2097440
|
|
|
|
// Address of the constant 0x42 = 0x200124 = 2097444
|
2015-10-20 05:00:02 +08:00
|
|
|
|
|
|
|
// CHECK: Symbols [
|
|
|
|
|
|
|
|
// CHECK: Name: bar
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: Value: 0x200124
|
2015-10-20 05:00:02 +08:00
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Loca
|
|
|
|
// CHECK-NEXT: Type: None
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: .mysec
|
|
|
|
|
|
|
|
// CHECK: Name: zed
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: Value: 0x200124
|
2015-10-20 05:00:02 +08:00
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Local
|
|
|
|
// CHECK-NEXT: Type: None
|
|
|
|
// CHECK-NEXT: Other: 0
|
|
|
|
// CHECK-NEXT: Section: .mysec
|
|
|
|
|
|
|
|
// CHECK: Name: foo
|
2016-11-24 01:44:02 +08:00
|
|
|
// CHECK-NEXT: Value: 0x200124
|
2015-10-20 05:00:02 +08:00
|
|
|
// CHECK-NEXT: Size: 0
|
|
|
|
// CHECK-NEXT: Binding: Local
|
|
|
|
// CHECK-NEXT: Type: None
|
2016-03-25 00:30:20 +08:00
|
|
|
// CHECK-NEXT: Other [ (0x2)
|
|
|
|
// CHECK-NEXT: STV_HIDDEN
|
|
|
|
// CHECK-NEXT: ]
|
2015-10-20 05:00:02 +08:00
|
|
|
// CHECK-NEXT: Section: .mysec
|
|
|
|
|
|
|
|
// CHECK: ]
|
|
|
|
|
|
|
|
.text
|
|
|
|
.globl _start
|
|
|
|
_start:
|
|
|
|
// DISASM: Disassembly of section .text:
|
2019-05-01 18:40:48 +08:00
|
|
|
// DISASM-EMPTY:
|
2015-10-20 05:00:02 +08:00
|
|
|
// DISASM-NEXT: _start:
|
|
|
|
|
|
|
|
movl .mysec, %eax
|
2016-11-24 01:44:02 +08:00
|
|
|
// addr(0x10) = 2097440
|
|
|
|
// DISASM-NEXT: movl 2097440, %eax
|
2015-10-20 05:00:02 +08:00
|
|
|
|
|
|
|
movl .mysec+7, %eax
|
2016-11-24 01:44:02 +08:00
|
|
|
// addr(0x42) + 3 = 2097444 + 3 = 2097447
|
|
|
|
// DISASM-NEXT: movl 2097447, %eax
|
2015-10-20 05:00:02 +08:00
|
|
|
|
|
|
|
movl .mysec+8, %eax
|
2016-11-24 01:44:02 +08:00
|
|
|
// addr(0x42) = 2097444
|
|
|
|
// DISASM-NEXT: movl 2097444, %eax
|
2015-10-20 05:00:02 +08:00
|
|
|
|
|
|
|
movl bar+7, %eax
|
2016-11-24 01:44:02 +08:00
|
|
|
// addr(0x42) + 7 = 2097444 + 7 = 2097451
|
|
|
|
// DISASM-NEXT: movl 2097451, %eax
|
2015-10-20 05:00:02 +08:00
|
|
|
|
|
|
|
movl bar+8, %eax
|
2016-11-24 01:44:02 +08:00
|
|
|
// addr(0x42) + 8 = 2097444 + 8 = 2097452
|
|
|
|
// DISASM-NEXT: movl 2097452, %eax
|
2015-10-20 05:00:02 +08:00
|
|
|
|
|
|
|
movl foo, %eax
|
2016-11-24 01:44:02 +08:00
|
|
|
// addr(0x42) = 2097444
|
|
|
|
// DISASM-NEXT: movl 2097444, %eax
|
2015-10-20 05:00:02 +08:00
|
|
|
|
|
|
|
movl foo+7, %eax
|
2016-11-24 01:44:02 +08:00
|
|
|
// addr(0x42) + 7 = = 2097444 + 7 = 2097451
|
|
|
|
// DISASM-NEXT: movl 2097451, %eax
|
2015-10-20 05:00:02 +08:00
|
|
|
|
|
|
|
movl foo+8, %eax
|
2016-11-24 01:44:02 +08:00
|
|
|
// addr(0x42) + 8 = = 2097444 + 8 = 2097452
|
|
|
|
// DISASM-NEXT: movl 2097452, %eax
|
2015-10-20 05:00:02 +08:00
|
|
|
|
|
|
|
// From the other file: movl .mysec, %eax
|
2016-11-24 01:44:02 +08:00
|
|
|
// addr(0x42) = 2097444
|
|
|
|
// DISASM-NEXT: movl 2097444, %eax
|