[ELF][test] Improve relocatable link & /DISCARD/ test

Check that #69295 will fix symbols referenced by relocations that are
defined in discarded sections.
This commit is contained in:
Fangrui Song 2023-10-17 12:49:17 -07:00
parent 389958a9f6
commit 0996ceece6

View File

@ -6,7 +6,27 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64 b.s -o b.o
# RUN: ld.lld -T a.lds a.o b.o -z undefs -o /dev/null 2>&1 | count 0
# RUN: ld.lld -T a.lds a.o b.o -o /dev/null 2>&1 | count 0
# RUN: ld.lld -r -T a.lds a.o b.o -o /dev/null 2>&1 | count 0
# RUN: ld.lld -r -T a.lds a.o b.o -o a.ro 2>&1 | count 0
# RUN: llvm-readelf -r -s a.ro | FileCheck %s --check-prefix=RELOC
# RELOC: Relocation section '.rela.bbb' at offset {{.*}} contains 1 entries:
# RELOC-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
# RELOC-NEXT: 0000000000000000 0000000000000000 R_X86_64_NONE 0
# RELOC-EMPTY:
# RELOC-NEXT: Relocation section '.rela.data' at offset {{.*}} contains 4 entries:
# RELOC-NEXT: Offset Info Type Symbol's Value Symbol's Name + Addend
# RELOC-NEXT: 0000000000000000 0000000000000001 R_X86_64_64 0
# RELOC-NEXT: 0000000000000008 0000000000000001 R_X86_64_64 0
# RELOC-NEXT: 0000000000000010 0000000000000001 R_X86_64_64 0
# RELOC-NEXT: 0000000000000018 0000000000000001 R_X86_64_64 0
# RELOC: Num: Value Size Type Bind Vis Ndx Name
# RELOC-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
# RELOC-NEXT: 1: 0000000000000000 0 SECTION LOCAL DEFAULT 1 .text
# RELOC-NEXT: 2: 0000000000000000 0 SECTION LOCAL DEFAULT 2 .bbb
# RELOC-NEXT: 3: 0000000000000000 0 SECTION LOCAL DEFAULT 4 .data
# RELOC-NEXT: 4: 0000000000000000 0 NOTYPE GLOBAL DEFAULT 1 _start
# RELOC-EMPTY:
#--- a.s
.globl _start