From d2a111105e7fb37af9ed47a8a87215f917be8eb8 Mon Sep 17 00:00:00 2001 From: florian Date: Sun, 23 Oct 2005 13:48:51 +0000 Subject: [PATCH] * made syscall.inc pic safe git-svn-id: trunk@1574 - --- rtl/linux/x86_64/syscall.inc | 79 ++++++++++++++++++++++++++++-------- 1 file changed, 63 insertions(+), 16 deletions(-) diff --git a/rtl/linux/x86_64/syscall.inc b/rtl/linux/x86_64/syscall.inc index 7f9fba0e9c..a089c74e6c 100644 --- a/rtl/linux/x86_64/syscall.inc +++ b/rtl/linux/x86_64/syscall.inc @@ -26,14 +26,21 @@ asm jnae .LSyscOK { Jump to error handler if error. } negq %rax movq %rax,%rdx +{$ifdef FPC_PIC} + movq fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax + movq (%rax),%rax + movq Errno@GOTPCREL(%rip),%rax +{$else FPC_PIC} movq fpc_threadvar_relocate_proc,%rax + leaq Errno,%rbx +{$endif FPC_PIC} testq %rax,%rax jne .LThread - movl %edx,Errno+8 + movl %edx,8(%rbx) jmp .LNoThread .LThread: pushq %rdx - movq Errno,%rdi + movq (%rbx),%rdi call *%rax popq %rdx movl %edx,(%rax) @@ -52,14 +59,21 @@ asm jnae .LSyscOK { Jump to error handler if error. } negq %rax movq %rax,%rdx +{$ifdef FPC_PIC} + movq fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax + movq (%rax),%rax + movq Errno@GOTPCREL(%rip),%rax +{$else FPC_PIC} movq fpc_threadvar_relocate_proc,%rax + leaq Errno,%rbx +{$endif FPC_PIC} testq %rax,%rax jne .LThread - movl %edx,Errno+8 + movl %edx,8(%rbx) jmp .LNoThread .LThread: pushq %rdx - movq Errno,%rdi + movq (%rbx),%rdi call *%rax popq %rdx movl %edx,(%rax) @@ -79,14 +93,21 @@ asm jnae .LSyscOK { Jump to error handler if error. } negq %rax movq %rax,%rdx +{$ifdef FPC_PIC} + movq fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax + movq (%rax),%rax + movq Errno@GOTPCREL(%rip),%rax +{$else FPC_PIC} movq fpc_threadvar_relocate_proc,%rax + leaq Errno,%rbx +{$endif FPC_PIC} testq %rax,%rax jne .LThread - movl %edx,Errno+8 + movl %edx,8(%rbx) jmp .LNoThread .LThread: pushq %rdx - movq Errno,%rdi + movq (%rbx),%rdi call *%rax popq %rdx movl %edx,(%rax) @@ -107,14 +128,21 @@ asm jnae .LSyscOK { Jump to error handler if error. } negq %rax movq %rax,%rdx +{$ifdef FPC_PIC} + movq fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax + movq (%rax),%rax + movq Errno@GOTPCREL(%rip),%rax +{$else FPC_PIC} movq fpc_threadvar_relocate_proc,%rax + leaq Errno,%rbx +{$endif FPC_PIC} testq %rax,%rax jne .LThread - movl %edx,Errno+8 + movl %edx,8(%rbx) jmp .LNoThread .LThread: pushq %rdx - movq Errno,%rdi + movq (%rbx),%rdi call *%rax popq %rdx movl %edx,(%rax) @@ -136,14 +164,21 @@ asm jnae .LSyscOK { Jump to error handler if error. } negq %rax movq %rax,%rdx +{$ifdef FPC_PIC} + movq fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax + movq (%rax),%rax + movq Errno@GOTPCREL(%rip),%rax +{$else FPC_PIC} movq fpc_threadvar_relocate_proc,%rax + leaq Errno,%rbx +{$endif FPC_PIC} testq %rax,%rax jne .LThread - movl %edx,Errno+8 + movl %edx,8(%rbx) jmp .LNoThread .LThread: pushq %rdx - movq Errno,%rdi + movq (%rbx),%rdi call *%rax popq %rdx movl %edx,(%rax) @@ -166,14 +201,21 @@ asm jnae .LSyscOK { Jump to error handler if error. } negq %rax movq %rax,%rdx +{$ifdef FPC_PIC} + movq fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax + movq (%rax),%rax + movq Errno@GOTPCREL(%rip),%rax +{$else FPC_PIC} movq fpc_threadvar_relocate_proc,%rax + leaq Errno,%rbx +{$endif FPC_PIC} testq %rax,%rax jne .LThread - movl %edx,Errno+8 + movl %edx,8(%rbx) jmp .LNoThread .LThread: pushq %rdx - movq Errno,%rdi + movq (%rbx),%rdi call *%rax popq %rdx movl %edx,(%rax) @@ -198,14 +240,21 @@ asm jnae .LSyscOK { Jump to error handler if error. } negq %rax movq %rax,%rdx +{$ifdef FPC_PIC} + movq fpc_threadvar_relocate_proc@GOTPCREL(%rip),%rax + movq (%rax),%rax + movq Errno@GOTPCREL(%rip),%rax +{$else FPC_PIC} movq fpc_threadvar_relocate_proc,%rax + leaq Errno,%rbx +{$endif FPC_PIC} testq %rax,%rax jne .LThread - movl %edx,Errno+8 + movl %edx,8(%rbx) jmp .LNoThread .LThread: pushq %rdx - movq Errno,%rdi + movq (%rbx),%rdi call *%rax popq %rdx movl %edx,(%rax) @@ -219,5 +268,3 @@ end; {$IFDEF SYS_LINUX} {$UNDEF SYSCALL_DEBUG} {$ENDIF SYS_LINUX} - -