llvm-project/lld/test/elf/consecutive-weak-sym-defs.test

82 lines
2.2 KiB
Plaintext

#Tests that multiple consecutive weak symbol definitions do not confuse the
#ELF reader. For example:
#
# my_weak_func1:
# my_weak_func2:
# my_weak_func3:
# code
#
#If my_weak_func2 is merged to other definition, this should not disturb the
#definition my_weak_func1 to "code".
#
#
#RUN: yaml2obj -format=elf %p/Inputs/consecutive-weak-defs.o.yaml -o=%t1.o
#RUN: yaml2obj -format=elf %p/Inputs/main-with-global-def.o.yaml -o=%t2.o
#RUN: lld -flavor gnu -target x86_64 %t1.o %t2.o -e=main -o %t1
#RUN: obj2yaml %t1 | FileCheck -check-prefix CHECKLAYOUT %s
#
# Check that the layout has not been changed:
#
#CHECKLAYOUT: Name: .text
#CHECKLAYOUT-NEXT: Type:
#CHECKLAYOUT-NEXT: Flags:
#CHECKLAYOUT-NEXT: Address:
#CHECKLAYOUT-NEXT: AddressAlign:
#CHECKLAYOUT-NEXT: Content: 554889E5E8020000005DC3554889E5B8640000005DC3
# ^~~> my_func ^~~> my_weak_func
#
#
#
#Our two input files were produced by the following code:
#
#Inputs/consecutive-weak-defs.o.yaml (this one is in assembly to allow us to
# easily define multiple labels)
#
# .text
# .globl my_func
# .type my_func,@function
# my_func:
# pushq %rbp
# movq %rsp, %rbp
# callq my_weak_func
# popq %rbp
# retq
# .Ltmp0:
# .size my_func, .Ltmp0-my_func
#
# .text
# .weak my_weak_func
# .type my_weak_func,@function
# .weak my_weak_func2
# .type my_weak_func2,@function
# .weak my_weak_func3
# .type my_weak_func3,@function
# my_weak_func:
# my_weak_func2:
# my_weak_func3:
# pushq %rbp
# movq %rsp, %rbp
# movl $100, %eax
# popq %rbp
# retq
# .Ltmp1:
# .size my_weak_func, .Ltmp1-my_weak_func
# .size my_weak_func2, .Ltmp1-my_weak_func2
# .size my_weak_func3, .Ltmp1-my_weak_func3
#
#Inputs/main-with-global-def.o.yaml:
#
# int my_func();
#
# int my_weak_func2() {
# return 200;
# }
#
# int main() {
# return my_func();
# }
#
#-------------------------------------------------------------------------------
# The net effect is that this program should return 100.