-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[X86-64] Only treat PC-relative globals as memory content if they are…
… dynamically relocated This makes sure that both of the following work as expected: 1. mov eax, [rip + myglob@GOTPCREL] used for shared libraries compiled to position independent code (-fPIC) Here myglob is dynamically relocated through the GOT 2. mov eax, [rip + myglob] used for non-PIC code to access a global directly without any indirection through the GOT [Test] Added one test to verify RIP-relative globals work as expected
- Loading branch information
1 parent
b09192e
commit 7a6f9c2
Showing
4 changed files
with
82 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
// REQUIRES: x86_64-linux | ||
// RUN: clang -O0 -o %t %s | ||
// RUN: llvm-mctoll -d -I /usr/include/stdio.h %t | ||
// RUN: clang -o %t-dis %t-dis.ll | ||
// RUN: %t-dis 2>&1 | FileCheck %s | ||
// CHECK: i = 0 | ||
// CHECK: i = 10 | ||
// CHECK-EMPTY | ||
|
||
.text | ||
.intel_syntax noprefix | ||
.file "raise-call64r-float.s" | ||
|
||
.globl main # -- Begin function main | ||
.p2align 4, 0x90 | ||
.type main,@function | ||
main: # @main | ||
movabs rdi, offset .L.str | ||
mov esi, [rip + i] | ||
mov al, 0 | ||
call printf | ||
|
||
mov dword ptr [rip + i], 10 | ||
|
||
movabs rdi, offset .L.str | ||
mov esi, [rip + i] | ||
mov al, 0 | ||
call printf | ||
|
||
xor rax, rax | ||
ret | ||
|
||
|
||
.type .L.str,@object # @.str | ||
.section .rodata.str1.1,"aMS",@progbits,1 | ||
.L.str: | ||
.asciz "i = %d\n" | ||
.size .L.str, 8 | ||
|
||
.bss | ||
.type i,@object | ||
.globl i | ||
.p2align 2 | ||
i: | ||
.long 0 | ||
.size i, 4 |