Browse Source

* PIC fixes in cprt0 for i386-openbsd

git-svn-id: trunk@41686 -
nickysn 6 years ago
parent
commit
5f47b0877a
1 changed files with 35 additions and 15 deletions
  1. 35 15
      rtl/openbsd/i386/cprt0.as

+ 35 - 15
rtl/openbsd/i386/cprt0.as

@@ -68,10 +68,15 @@ ___start:
 	subl $16,%esp
 	pushl %esi
 	pushl %ebx
+	call fpc_geteipasecx
+	addl $_GLOBAL_OFFSET_TABLE_,%ecx
+	movl %ecx,%edi
 	movl 12(%ebp),%esi
 	movl 16(%ebp),%eax
-	movl %eax,environ
-	movl %eax,operatingsystem_parameter_envp
+	movl environ@GOT(%edi),%ecx
+	movl %eax,(%ecx)
+	movl operatingsystem_parameter_envp@GOT(%edi),%ecx
+	movl %eax,(%ecx)
 	movl (%esi),%ebx
 	testl %ebx,%ebx
 	je .L3
@@ -79,48 +84,60 @@ ___start:
 	pushl $47
 	pushl %ebx
 	call _strrchr
-	movl %eax,__progname
+	movl __progname@GOT(%edi),%ecx
+	movl %eax,(%ecx)
 	addl $16,%esp
 	testl %eax,%eax
 	jne .L4
-	movl %ebx,__progname
+	movl %ebx,(%ecx)
 	jmp .L5
 	.p2align 4,,7
 .L4:
 	incl %eax
-	movl %eax,__progname
+	movl %eax,(%ecx)
 .L5:
-	movl $__progname_storage,%edx
+	movl __progname_storage@GOT(%edi),%edx
 	jmp .L12
 	.p2align 4,,7
 .L9:
 	movb (%eax),%al
 	movb %al,(%edx)
-	incl __progname
+	movl __progname@GOT(%edi),%ecx
+	incl (%ecx)
 	incl %edx
 .L12:
-	movl __progname,%eax
+	movl __progname@GOT(%edi),%ecx
+	movl (%ecx),%eax
 	cmpb $0,(%eax)
 	je .L7
-	cmpl $__progname_storage+255,%edx
+	movl __progname_storage@GOT(%edi),%ecx
+	addl $255,%ecx
+	cmpl %ecx,%edx
 	jb .L9
 .L7:
 	movb $0,(%edx)
-	movl $__progname_storage,__progname
+	pushl %eax
+	movl __progname_storage@GOT(%edi),%eax
+	movl __progname@GOT(%edi),%ecx
+	movl %eax,(%ecx)
+	popl %eax
 .L3:
 #	call __init
 	subl $16,%esp
 	pushl %eax
 	movl 8(%ebp),%eax
-	movl %eax,operatingsystem_parameter_argc
-	movl %esi,operatingsystem_parameter_argv
+	movl operatingsystem_parameter_argc@GOT(%edi),%ecx
+	movl %eax,(%ecx)
+	movl operatingsystem_parameter_argv@GOT(%edi),%ecx
+	movl %esi,(%ecx)
 	popl %eax
 #	pushl environ
 #	pushl %esi
 #	pushl 8(%ebp)
+	movl ___fpucw@GOT(%edi),%ecx
 	finit
 	fwait
-	fldcw ___fpucw
+	fldcw (%ecx)
 	xorl  %ebp,%ebp
 	call main
 	pushl %eax
@@ -131,9 +148,12 @@ ___start:
 .type _haltproc,@function
 
 _haltproc:
-           mov $1,%eax
-           movzwl operatingsystem_result,%ebx
+           call fpc_geteipasebx
+           addl $_GLOBAL_OFFSET_TABLE_,%ebx
+           movl operatingsystem_result@GOT(%ebx),%ebx
+           movzwl (%ebx),%ebx
            pushl %ebx
+           mov $1,%eax
            call .Lactualsyscall
            addl  $4,%esp
            jmp   _haltproc