brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.4 KiB · f1d7da4 Raw
110 lines · plain
1# REQUIRES: x862# RUN: rm -rf %t; split-file %s %t3 4# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/common.s -o %t/common.o5# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/weak-common.s -o %t/weak-common.o6# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/defined.s -o %t/defined.o7# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/weak-defined.s -o %t/weak-defined.o8# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/libfoo.s -o %t/libfoo.o9# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/test.s -o %t/test.o10# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %t/calls-foo.s -o %t/calls-foo.o11 12# RUN: %lld -lSystem -order_file %t/order -dylib %t/libfoo.o -o %t/libfoo.dylib13 14# RUN: llvm-ar rcs %t/defined.a %t/defined.o15# RUN: llvm-ar rcs %t/weak-defined-and-common.a %t/weak-defined.o %t/common.o16# RUN: llvm-ar rcs %t/common-and-weak-defined.a %t/common.o %t/weak-defined.o17 18## The weak attribute appears to have no effect on common symbols. Given two19## common symbols of the same name, we always pick the one with the larger size,20## regardless of whether it is weak. Moreover, the resolved symbol in the output21## file will always be non-weak, even if the winning input symbol definition was22## weak.23# RUN: %lld -lSystem -order_file %t/order %t/common.o %t/weak-common.o %t/test.o -o %t/test24# RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=LARGER-COMMON25# RUN: %lld -lSystem -order_file %t/order %t/weak-common.o %t/common.o %t/test.o -o %t/test26# RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=LARGER-COMMON27 28## Defined symbols are the only ones that take precedence over common symbols.29# RUN: %lld -lSystem -order_file %t/order %t/defined.o %t/common.o %t/test.o -o %t/test30# RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=DEFINED31# RUN: %lld -lSystem -order_file %t/order %t/common.o %t/defined.o %t/test.o -o %t/test32# RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=DEFINED33 34# RUN: %lld -lSystem -order_file %t/order %t/weak-defined.o %t/common.o %t/test.o -o %t/test35# RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=WEAK-DEFINED36# RUN: %lld -lSystem -order_file %t/order %t/common.o %t/weak-defined.o %t/test.o -o %t/test37# RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=WEAK-DEFINED38 39## Common symbols take precedence over archive symbols.40# RUN: %lld -lSystem -order_file %t/order %t/defined.a %t/weak-common.o %t/test.o -o %t/test41# RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=LARGER-COMMON42# RUN: %lld -lSystem -order_file %t/order %t/weak-common.o %t/defined.a %t/test.o -o %t/test43# RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=LARGER-COMMON44 45## Defined symbols have the same precedence as common symbols within an archive.46# RUN: %lld -lSystem -order_file %t/order %t/weak-defined-and-common.a %t/calls-foo.o -o %t/calls-foo47# RUN: llvm-objdump --syms %t/calls-foo | FileCheck %s --check-prefix=WEAK-DEFINED48# RUN: %lld -lSystem -order_file %t/order %t/calls-foo.o %t/common-and-weak-defined.a -o %t/calls-foo49# RUN: llvm-objdump --syms %t/calls-foo | FileCheck %s --check-prefix=COMMON50 51## Common symbols take precedence over dylib symbols.52# RUN: %lld -lSystem -order_file %t/order %t/libfoo.dylib %t/weak-common.o %t/test.o -o %t/test53# RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=LARGER-COMMON54# RUN: %lld -lSystem -order_file %t/order %t/weak-common.o %t/libfoo.dylib %t/test.o -o %t/test55# RUN: llvm-objdump --syms %t/test | FileCheck %s --check-prefix=LARGER-COMMON56 57# LARGER-COMMON-DAG:   [[#%x, FOO_ADDR:]] g     O __DATA,__common _foo58# LARGER-COMMON-DAG:   [[#FOO_ADDR + 2]]  g     O __DATA,__common _foo_end59 60# COMMON:              g     O __DATA,__common _foo61# DEFINED:             g     F __TEXT,__text _foo62# WEAK-DEFINED:        w     F __TEXT,__text _foo63 64#--- order65## %t/order is important as we determine the size of a given symbol via the66## address of the next symbol.67_foo68_foo_end69 70#--- common.s71.comm _foo, 172 73.globl _bar74_bar:75 76#--- weak-common.s77.weak_definition _foo78.comm _foo, 279 80#--- defined.s81.globl _foo82_foo:83  .quad 0x123484 85#--- weak-defined.s86.globl _foo87.weak_definition _foo88_foo:89  .quad 0x123490 91#--- libfoo.s92.globl _foo93_foo:94  .quad 0x123495 96#--- test.s97.comm _foo_end, 198 99.globl _main100_main:101  ret102 103#--- calls-foo.s104.comm _foo_end, 1105 106.globl _main107_main:108  callq _foo109  ret110