llvm-6502/test/MC/COFF/simple-fixups.s
David Majnemer 16d8031f94 MC, COFF: Use relocations for function references inside the section
Referencing one symbol from another in the same section does not
generally require a relocation.  However, the MS linker has a feature
called /INCREMENTAL which enables incremental links.  It achieves this
by creating thunks to the actual function and redirecting all
relocations to point to the thunk.

This breaks down with the old scheme if you have a function which
references, say, itself.  On x86_64, we would use %rip relative
addressing to reference the start of the function from out current
position.  This would lead to miscompiles because other references might
reference the thunk instead, breaking function pointer equality.

This fixes PR21520.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@221678 91177308-0d34-0410-b5e6-96231b3b80d8
2014-11-11 08:43:57 +00:00

51 lines
1.3 KiB
ArmAsm

// The purpose of this test is to verify that we produce relocations for
// references to functions. Failing to do so might cause pointer-to-function
// equality to fail if /INCREMENTAL links are used.
// RUN: llvm-mc -filetype=obj -triple i686-pc-win32 %s | llvm-readobj -s | FileCheck %s
// RUN: llvm-mc -filetype=obj -triple x86_64-pc-win32 %s | llvm-readobj -s | FileCheck %s
.def _foo;
.scl 2;
.type 32;
.endef
.text
.globl _foo
.align 16, 0x90
_foo: # @foo
# BB#0: # %e
.align 16, 0x90
LBB0_1: # %i
# =>This Inner Loop Header: Depth=1
jmp LBB0_1
.def _bar;
.scl 2;
.type 32;
.endef
.globl _bar
.align 16, 0x90
_bar: # @bar
# BB#0: # %e
.align 16, 0x90
LBB1_1: # %i
# =>This Inner Loop Header: Depth=1
jmp LBB1_1
.def _baz;
.scl 2;
.type 32;
.endef
.globl _baz
.align 16, 0x90
_baz: # @baz
# BB#0: # %e
subl $4, %esp
Ltmp0:
call _baz
addl $4, %esp
ret
// CHECK: Sections [
// CHECK: RelocationCount: 1