brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.0 KiB · c9841a6 Raw
71 lines · plain
1# REQUIRES: x862## Test that --emit-relocs keeps local symbols which are used in relocations3## even when --discard-{locals,all} is given.4 5## There are two separate code paths that mark used local symbols when6## --gc-sections is specified and when is not. The test checks both.7 8# RUN: llvm-mc -filetype=obj -triple=x86_64 -save-temp-labels %s -o %t.o9 10# RUN: ld.lld --emit-relocs --discard-locals %t.o -o %tlocal11# RUN: llvm-readelf -s %tlocal | FileCheck --check-prefixes=DISCARD-LOCALS,DISCARD-LOCALS-NOGC %s12# RUN: llvm-readobj -r %tlocal | FileCheck --check-prefix=REL %s13 14## --gc-sections can discard symbols relative to GCed sections (including STT_SECTION).15# RUN: ld.lld --emit-relocs --discard-locals --gc-sections %t.o -o %tlocal.gc16# RUN: llvm-readelf -s %tlocal.gc | FileCheck --check-prefix=DISCARD-LOCALS %s17# RUN: llvm-readobj -r %tlocal | FileCheck --check-prefix=REL %s18 19# RUN: ld.lld --emit-relocs --discard-all %t.o -o %tall20# RUN: llvm-readelf -s %tall | FileCheck --check-prefixes=DISCARD-ALL,DISCARD-ALL-NOGC %s21# RUN: llvm-readobj -r %tall | FileCheck --check-prefix=REL %s22 23# RUN: ld.lld --emit-relocs --discard-all --gc-sections %t.o -o %tall.gc24# RUN: llvm-readelf -s %tall.gc | FileCheck --check-prefix=DISCARD-ALL %s25# RUN: llvm-readobj -r %tall.gc | FileCheck --check-prefix=REL %s26 27## --discard-locals removes unused local symbols which start with ".L"28# DISCARD-LOCALS:    0: {{0+}} 0 NOTYPE  LOCAL  DEFAULT UND29# DISCARD-LOCALS-NEXT:           NOTYPE  LOCAL  DEFAULT {{.*}} .Lused30# DISCARD-LOCALS-NEXT:           NOTYPE  LOCAL  DEFAULT {{.*}} used31# DISCARD-LOCALS-NEXT:           NOTYPE  LOCAL  DEFAULT {{.*}} unused32# DISCARD-LOCALS-NOGC-NEXT:      NOTYPE  LOCAL  DEFAULT {{.*}} unused_gc33# DISCARD-LOCALS-NEXT:           SECTION LOCAL  DEFAULT {{.*}} .text34# DISCARD-LOCALS-NEXT:           SECTION LOCAL  DEFAULT {{.*}} text35# DISCARD-LOCALS-NOGC-NEXT:      SECTION LOCAL  DEFAULT {{.*}} gc36# DISCARD-LOCALS-NEXT:           SECTION LOCAL  DEFAULT {{.*}} .comment37# DISCARD-LOCALS-NEXT:           NOTYPE  GLOBAL DEFAULT {{.*}} _start38 39## --discard-all removes all unused regular local symbols.40# DISCARD-ALL:       0: {{0+}} 0 NOTYPE  LOCAL  DEFAULT UND41# DISCARD-ALL-NEXT:              NOTYPE  LOCAL  DEFAULT {{.*}} .Lused42# DISCARD-ALL-NEXT:              NOTYPE  LOCAL  DEFAULT {{.*}} used43# DISCARD-ALL-NEXT:              SECTION LOCAL  DEFAULT {{.*}} .text44# DISCARD-ALL-NEXT:              SECTION LOCAL  DEFAULT {{.*}} text45# DISCARD-ALL-NOGC-NEXT:         SECTION LOCAL  DEFAULT {{.*}} gc46# DISCARD-ALL-NEXT:              SECTION LOCAL  DEFAULT {{.*}} .comment47# DISCARD-ALL-NEXT:              NOTYPE  GLOBAL DEFAULT {{.*}} _start48 49# REL:      .rela.text {50# REL-NEXT:   R_X86_64_PLT32 text 0xFFFFFFFFFFFFFFFC51# REL-NEXT:   R_X86_64_PLT32 .Lused 0xFFFFFFFFFFFFFFFC52# REL-NEXT:   R_X86_64_PLT32 used 0xFFFFFFFFFFFFFFFC53# REL-NEXT: }54 55.globl _start56_start:57  call text@plt58  jmp .Lused@plt59  call used@plt60 61.section text,"ax"62.Lunused:63.Lused:64unused:65used:66 67.section gc,"ax"68.Lunused_gc:69unused_gc:70  ret71