瀏覽代碼

* i386-android: Use PIC in the program start-up code.

git-svn-id: trunk@32035 -
yury 9 年之前
父節點
當前提交
ae33685b9d
共有 2 個文件被更改,包括 19 次插入9 次删除
  1. 1 1
      rtl/android/i386/dllprt0.as
  2. 18 8
      rtl/android/i386/prt0.as

+ 1 - 1
rtl/android/i386/dllprt0.as

@@ -66,7 +66,7 @@ _haltproc:
         call    fpc_geteipasebx
         addl    $_GLOBAL_OFFSET_TABLE_,%ebx
         /* Jump to libc exit(). _haltproc has the same declaration as exit. */
-        jmp     exit@GOT
+        jmp     exit@PLT
 
 /* --------------------------------------------------------- */
 .data

+ 18 - 8
rtl/android/i386/prt0.as

@@ -42,23 +42,30 @@
         .globl _fpc_start
         .type _fpc_start,@function
 _fpc_start:
+        /* GOT init */
+        call    fpc_geteipasebx
+        addl    $_GLOBAL_OFFSET_TABLE_,%ebx
         /* Clear the frame pointer since this is the outermost frame.  */
         xorl    %ebp,%ebp
         /* Save initial stackpointer */
-        movl    %esp,__stkptr
+        movl    __stkptr@GOT(%ebx),%eax
+        movl    %esp,(%eax)
         /* First locate the start of the environment variables */
         /* Get argc in ecx */
         movl    (%esp),%ecx
         /* Save argc */
-        movl    %ecx,operatingsystem_parameter_argc
-        /* Get argv pointer in ebx */
-        leal    4(%esp),%ebx
+        movl    operatingsystem_parameter_argc@GOT(%ebx),%eax
+        movl    %ecx,(%eax)
+        /* Get argv pointer in edx */
+        leal    4(%esp),%edx
         /* Save argv */
-        movl    %ebx,operatingsystem_parameter_argv
+        movl    operatingsystem_parameter_argv@GOT(%ebx),%eax
+        movl    %edx,(%eax)
         /* The start of the environment is: esp+ecx*4+12 */
-        leal    12(%esp,%ecx,4),%eax
+        leal    12(%esp,%ecx,4),%edx
         /* Save envp */
-        movl    %eax,operatingsystem_parameter_envp
+        movl    operatingsystem_parameter_envp@GOT(%ebx),%eax
+        movl    %edx,(%eax)
         
         /* Finally go to libc startup code. It will call "PASCALMAIN" via alias "main". */
         /* No need to align stack since it will aligned by libc. */
@@ -68,8 +75,11 @@ _fpc_start:
         .globl  _haltproc
         .type   _haltproc,@function
 _haltproc:
+        /* GOT init */
+        call    fpc_geteipasebx
+        addl    $_GLOBAL_OFFSET_TABLE_,%ebx
         /* Jump to libc exit(). _haltproc has the same declaration as exit. */
-        jmp     exit
+        jmp     exit@PLT
 
 /* --------------------------------------------------------- */
 .data