xref: /llvm-project/lld/test/ELF/comdat.s (revision 4d9020ca0b125a936d5e26b48f07fcfa4bd78004)
1// REQUIRES: x86
2// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
3// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %p/Inputs/comdat.s -o %t2.o
4// RUN: ld.lld -shared %t.o %t2.o -o %t
5// RUN: llvm-objdump -d %t | FileCheck %s
6// RUN: llvm-readelf -S -s %t | FileCheck --check-prefix=READ %s
7// RUN: ld.lld -shared --force-group-allocation %t.o %t2.o -o - | cmp - %t
8
9// Check that we don't crash with --gc-section and that we print a list of
10// reclaimed sections on stderr.
11// RUN: ld.lld --gc-sections --print-gc-sections -shared %t.o %t.o %t2.o -o %t \
12// RUN:   2>&1 | FileCheck --check-prefix=GC %s
13// GC: removing unused section {{.*}}.o:(.text)
14// GC: removing unused section {{.*}}.o:(.text3)
15// GC: removing unused section {{.*}}.o:(.text)
16// GC: removing unused section {{.*}}.o:(.text)
17
18.globl foo
19        .section	.text2,"axG",@progbits,foo,comdat,unique,0
20foo:
21        nop
22
23// CHECK: Disassembly of section .text2:
24// CHECK-EMPTY:
25// CHECK-NEXT: <foo>:
26// CHECK-NEXT:   nop
27// CHECK-NOT: nop
28
29        .section bar, "ax"
30        call foo
31
32// CHECK: Disassembly of section bar:
33// CHECK-EMPTY:
34// CHECK-NEXT: <bar>:
35// CHECK-NEXT:   callq  {{.*}} <foo@plt>
36
37.weak zed
38zed:
39        .section .text3,"axG",@progbits,zed,comdat,unique,0
40
41# READ: .text2 PROGBITS {{.*}} AX
42# READ: .text3 PROGBITS {{.*}} AX
43
44# SYM:  NOTYPE LOCAL  DEFAULT UND
45# SYM:  NOTYPE LOCAL  HIDDEN  [[#]] _DYNAMIC
46# SYM:  NOTYPE GLOBAL DEFAULT [[#]] foo
47# SYM:  NOTYPE GLOBAL DEFAULT [[#]] zed
48# SYM:  NOTYPE GLOBAL DEFAULT UND   abc
49