rand/rand-x86ish.S: Establish GOT pointer before making an i386 PLT call.
authorMark Wooding <mdw@distorted.org.uk>
Mon, 25 May 2020 16:36:13 +0000 (17:36 +0100)
committerMark Wooding <mdw@distorted.org.uk>
Mon, 25 May 2020 16:41:52 +0000 (17:41 +0100)
Otherwise you just get a segfault.

rand/rand-x86ish.S

index b91a937..399ccb1 100644 (file)
@@ -54,7 +54,8 @@ FUNC(rand_quick_x86ish_rdrand)
 
 #if CPUFAM_X86
        mov     edx, [SP + 4]
-       stalloc 28
+       push    ebx
+       stalloc 24
 #endif
 #if CPUFAM_AMD64 && ABI_SYSV
        stalloc 8
@@ -82,7 +83,8 @@ FUNC(rand_quick_x86ish_rdseed)
 
 #if CPUFAM_X86
        mov     edx, [SP + 4]
-       stalloc 28
+       push    ebx
+       stalloc 24
 #endif
 #if CPUFAM_AMD64 && ABI_SYSV
        stalloc 8
@@ -106,6 +108,7 @@ FUNC(rand_quick_x86ish_rdseed)
        // Success.
 1:
 #if CPUFAM_X86
+       ldgot   ebx
        mov     [SP + 16], AX
        lea     ecx, [SP + 16]
        mov     dword ptr [SP + 12], 32
@@ -131,7 +134,8 @@ FUNC(rand_quick_x86ish_rdseed)
        // Done.
 9:
 #if CPUFAM_X86
-       stfree  28
+       stfree  24
+       pop     ebx
 #endif
 #if CPUFAM_AMD64 && ABI_SYSV
        stfree  8