xref: /llvm-project/lld/test/ELF/lto/section-name.ll (revision f01fdd17b4d202727023da23bdd120eb0bd94f9f)
1; REQUIRES: x86
2; RUN: llvm-as %s -o %t.o
3; RUN: ld.lld %t.o -o %t.so -shared
4; RUN: llvm-readelf -S %t.so | FileCheck %s
5; RUN: ld.lld %t.o -o %t.so -shared --gc-sections -z nostart-stop-gc
6; RUN: llvm-readelf -S %t.so | FileCheck --check-prefix=GC %s
7
8target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
9target triple = "x86_64-unknown-linux-gnu"
10
11@foo = hidden global i32 42, section "foo_section"
12@bar = hidden global i32 42, section "bar_section"
13@zed = hidden global i32 42, section "zed_section"
14
15@__start_foo_section = external global i32
16@__stop_bar_section = external global i32
17
18define hidden ptr @use1() {
19  ret ptr @__start_foo_section
20}
21
22define ptr @use2() {
23  ret ptr @__stop_bar_section
24}
25
26; CHECK-NOT: zed_section
27; CHECK:     foo_section PROGBITS
28; CHECK-NEXT:     bar_section PROGBITS
29; CHECK-NOT: zed_section
30
31; GC-NOT: zed_section
32; GC-NOT: foo_section
33; GC:     bar_section PROGBITS
34; GC-NOT: zed_section
35; GC-NOT: foo_section
36