1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-23 03:02:36 +01:00
llvm-mirror/test/MC/COFF/weak.s
Martin Storsjö 87135ac747 [COFF] Assign unique names to autogenerated .weak.<name>.default symbols
These symbols need to be external (MSVC tools error out if a weak
external points at a symbol that isn't external; this was tried before
but had to be reverted in bc5b7217dceecd3eec69593026a9e38dfbfd6908,
and this was originally explicitly fixed in
732eeaf2a930ad2755cb4eb5d99a3deae0de4a72).

If multiple object files have weak symbols with defaults, their
defaults could cause linker errors due to duplicate definitions,
unless the names of the defaults are unique.

GNU binutils handles this by appending the name of another symbol
from the same object file to the name of the default symbol. Try
to implement something similar; before writing the object file,
locate a symbol that should have a unique name and use the name of
that one for making the weak defaults unique.

Differential Revision: https://reviews.llvm.org/D75989
2020-03-13 22:44:55 +02:00

94 lines
2.8 KiB
ArmAsm

// This tests that default-null weak symbols (a GNU extension) are created
// properly via the .weak directive.
// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s | llvm-readobj --symbols | FileCheck %s
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s | llvm-readobj --symbols | FileCheck %s
.def _main;
.scl 2;
.type 32;
.endef
.text
.globl _main
.align 16, 0x90
_main: # @main
# %bb.0: # %entry
subl $4, %esp
movl $_test_weak, %eax
testl %eax, %eax
je LBB0_2
# %bb.1: # %if.then
call _test_weak
movl $1, %eax
addl $4, %esp
ret
LBB0_2: # %return
xorl %eax, %eax
addl $4, %esp
ret
.weak _test_weak
.weak _test_weak_alias
_test_weak_alias=_main
// CHECK: Symbols [
// CHECK: Symbol {
// CHECK: Name: _main
// CHECK-NEXT: Value: 0
// CHECK-NEXT: Section: .text
// CHECK-NEXT: BaseType: Null
// CHECK-NEXT: ComplexType: Function
// CHECK-NEXT: StorageClass: External
// CHECK-NEXT: AuxSymbolCount: 0
// CHECK-NEXT: }
// CHECK: Symbol {
// CHECK: Name: _test_weak
// CHECK-NEXT: Value: 0
// CHECK-NEXT: Section: IMAGE_SYM_UNDEFINED (0)
// CHECK-NEXT: BaseType: Null
// CHECK-NEXT: ComplexType: Null
// CHECK-NEXT: StorageClass: WeakExternal
// CHECK-NEXT: AuxSymbolCount: 1
// CHECK-NEXT: AuxWeakExternal {
// CHECK-NEXT: Linked: .weak._test_weak.default
// CHECK-NEXT: Search: Alias
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK: Symbol {
// CHECK: Name: .weak._test_weak.default._main
// CHECK-NEXT: Value: 0
// CHECK-NEXT: Section: IMAGE_SYM_ABSOLUTE (-1)
// CHECK-NEXT: BaseType: Null
// CHECK-NEXT: ComplexType: Null
// CHECK-NEXT: StorageClass: External
// CHECK-NEXT: AuxSymbolCount: 0
// CHECK-NEXT: }
// CHECK: Symbol {
// CHECK: Name: _test_weak_alias
// CHECK-NEXT: Value: 0
// CHECK-NEXT: Section: IMAGE_SYM_UNDEFINED (0)
// CHECK-NEXT: BaseType: Null
// CHECK-NEXT: ComplexType: Null
// CHECK-NEXT: StorageClass: WeakExternal
// CHECK-NEXT: AuxSymbolCount: 1
// CHECK-NEXT: AuxWeakExternal {
// CHECK-NEXT: Linked: .weak._test_weak_alias.default
// CHECK-NEXT: Search: Alias
// CHECK-NEXT: }
// CHECK-NEXT: }
// CHECK: Symbol {
// CHECK: Name: .weak._test_weak_alias.default._main
// CHECK-NEXT: Value: 0
// CHECK-NEXT: Section: .text
// CHECK-NEXT: BaseType: Null
// CHECK-NEXT: ComplexType: Null
// CHECK-NEXT: StorageClass: External
// CHECK-NEXT: AuxSymbolCount: 0
// CHECK-NEXT: }