diff options
author | David Majnemer <david.majnemer@gmail.com> | 2014-11-11 08:43:57 +0000 |
---|---|---|
committer | David Majnemer <david.majnemer@gmail.com> | 2014-11-11 08:43:57 +0000 |
commit | 2cc4bc77bf11d465faf03b0ae0f5a623f0f73e70 (patch) | |
tree | 1b2f8b1e1f81b4c282266de81b55135ce022e2dc /llvm/test/MC | |
parent | d158db0f63cece2520e0d70b8bd712001cd78322 (diff) | |
download | bcm5719-llvm-2cc4bc77bf11d465faf03b0ae0f5a623f0f73e70.tar.gz bcm5719-llvm-2cc4bc77bf11d465faf03b0ae0f5a623f0f73e70.zip |
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.
llvm-svn: 221678
Diffstat (limited to 'llvm/test/MC')
-rw-r--r-- | llvm/test/MC/COFF/simple-fixups.s | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/llvm/test/MC/COFF/simple-fixups.s b/llvm/test/MC/COFF/simple-fixups.s index 2a74f21f12d..cb5d7642ee6 100644 --- a/llvm/test/MC/COFF/simple-fixups.s +++ b/llvm/test/MC/COFF/simple-fixups.s @@ -1,5 +1,6 @@ -// The purpose of this test is to verify that we do not produce unneeded -// relocations when symbols are in the same section and we know their offset. +// 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 @@ -46,4 +47,4 @@ Ltmp0: ret // CHECK: Sections [ -// CHECK-NOT: RelocationCount: {{[^0]}} +// CHECK: RelocationCount: 1 |