2018-06-27 06:20:04 +08:00
|
|
|
// REQUIRES: x86
|
2015-10-10 03:25:07 +08:00
|
|
|
// 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/comdat.s -o %t2.o
|
2015-11-18 14:11:01 +08:00
|
|
|
// RUN: ld.lld -shared %t.o %t.o %t2.o -o %t
|
2015-10-10 03:25:07 +08:00
|
|
|
// RUN: llvm-objdump -d %t | FileCheck %s
|
|
|
|
// RUN: llvm-readobj -s -t %t | FileCheck --check-prefix=READ %s
|
|
|
|
|
2016-09-23 05:08:51 +08:00
|
|
|
// Check that we don't crash with --gc-section and that we print a list of
|
|
|
|
// reclaimed sections on stderr.
|
|
|
|
// RUN: ld.lld --gc-sections --print-gc-sections -shared %t.o %t.o %t2.o -o %t \
|
|
|
|
// RUN: 2>&1 | FileCheck --check-prefix=GC %s
|
2018-02-17 08:09:49 +08:00
|
|
|
// GC: removing unused section {{.*}}.o:(.text)
|
|
|
|
// GC: removing unused section {{.*}}.o:(.text3)
|
|
|
|
// GC: removing unused section {{.*}}.o:(.text)
|
|
|
|
// GC: removing unused section {{.*}}.o:(.text)
|
2016-09-23 05:08:51 +08:00
|
|
|
|
2015-10-10 03:25:07 +08:00
|
|
|
.section .text2,"axG",@progbits,foo,comdat,unique,0
|
|
|
|
foo:
|
|
|
|
nop
|
|
|
|
|
|
|
|
// CHECK: Disassembly of section .text2:
|
|
|
|
// CHECK-NEXT: foo:
|
2015-10-11 07:25:39 +08:00
|
|
|
// CHECK-NEXT: 1000: {{.*}} nop
|
2015-10-10 03:25:07 +08:00
|
|
|
// CHECK-NOT: nop
|
|
|
|
|
|
|
|
.section bar, "ax"
|
|
|
|
call foo
|
|
|
|
|
|
|
|
// CHECK: Disassembly of section bar:
|
|
|
|
// CHECK-NEXT: bar:
|
2015-10-11 07:25:39 +08:00
|
|
|
// 0x1000 - 0x1001 - 5 = -6
|
2015-10-20 03:24:03 +08:00
|
|
|
// 0 - 0x1006 - 5 = -4107
|
2015-10-11 07:25:39 +08:00
|
|
|
// CHECK-NEXT: 1001: {{.*}} callq -6
|
|
|
|
// CHECK-NEXT: 1006: {{.*}} callq -4107
|
2015-10-10 03:25:07 +08:00
|
|
|
|
|
|
|
.section .text3,"axG",@progbits,zed,comdat,unique,0
|
|
|
|
|
|
|
|
|
|
|
|
// READ: Name: .text2
|
|
|
|
// READ-NEXT: Type: SHT_PROGBITS
|
|
|
|
// READ-NEXT: Flags [
|
|
|
|
// READ-NEXT: SHF_ALLOC
|
|
|
|
// READ-NEXT: SHF_EXECINSTR
|
|
|
|
// READ-NEXT: ]
|
|
|
|
|
|
|
|
// READ: Name: .text3
|
|
|
|
// READ-NEXT: Type: SHT_PROGBITS
|
|
|
|
// READ-NEXT: Flags [
|
|
|
|
// READ-NEXT: SHF_ALLOC
|
|
|
|
// READ-NEXT: SHF_EXECINSTR
|
|
|
|
// READ-NEXT: ]
|
|
|
|
|
|
|
|
// READ: Symbols [
|
|
|
|
// READ-NEXT: Symbol {
|
|
|
|
// READ-NEXT: Name: (0)
|
|
|
|
// READ-NEXT: Value: 0x0
|
|
|
|
// READ-NEXT: Size: 0
|
|
|
|
// READ-NEXT: Binding: Local
|
|
|
|
// READ-NEXT: Type: None
|
|
|
|
// READ-NEXT: Other: 0
|
|
|
|
// READ-NEXT: Section: Undefined
|
|
|
|
// READ-NEXT: }
|
|
|
|
// READ-NEXT: Symbol {
|
|
|
|
// READ-NEXT: Name: foo
|
|
|
|
// READ-NEXT: Value
|
|
|
|
// READ-NEXT: Size: 0
|
|
|
|
// READ-NEXT: Binding: Local
|
|
|
|
// READ-NEXT: Type: None
|
|
|
|
// READ-NEXT: Other: 0
|
|
|
|
// READ-NEXT: Section: .text
|
|
|
|
// READ-NEXT: }
|
|
|
|
// READ-NEXT: Symbol {
|
2016-03-02 00:23:13 +08:00
|
|
|
// READ-NEXT: Name: _DYNAMIC
|
|
|
|
// READ-NEXT: Value: 0x2000
|
|
|
|
// READ-NEXT: Size: 0
|
|
|
|
// READ-NEXT: Binding: Local
|
|
|
|
// READ-NEXT: Type: None
|
2016-03-25 00:30:20 +08:00
|
|
|
// READ-NEXT: Other [ (0x2)
|
|
|
|
// READ-NEXT: STV_HIDDEN
|
|
|
|
// READ-NEXT: ]
|
2016-03-02 00:23:13 +08:00
|
|
|
// READ-NEXT: Section: .dynamic
|
|
|
|
// READ-NEXT: }
|
|
|
|
// READ-NEXT: Symbol {
|
2015-10-10 03:25:07 +08:00
|
|
|
// READ-NEXT: Name: abc
|
|
|
|
// READ-NEXT: Value: 0x0
|
|
|
|
// READ-NEXT: Size: 0
|
|
|
|
// READ-NEXT: Binding: Global
|
|
|
|
// READ-NEXT: Type: None
|
|
|
|
// READ-NEXT: Other: 0
|
|
|
|
// READ-NEXT: Section: Undefined
|
|
|
|
// READ-NEXT: }
|
|
|
|
// READ-NEXT: ]
|