buggy NASM doesn’t relocate symbols properly. I don’t really know why
SDL works with the current code — it must be pure luck — because when
I run it in a slightly different context I get a segfault in _Hermes_X86_CPU.
And when looking at the NASM-generated code it’s quite obvious what’s going
on: NASM generates relocation records for the cpu_flags variable all right,
but they are relative the .text section, not .data, so the runtime linker
does the wrong thing
In this case that variable isn’t needed (patch follows), but in general
I would like to get rid of NASM and Hermes (not necessarily in that order)
Index: x86_main.asm===================================================================
RCS file: /home/slouken/libsdl.org/cvs/SDL12/src/hermes/x86_main.asm,v
retrieving revision 1.1.1.1
diff -u -r1.1.1.1 x86_main.asm
— x86_main.asm 2001/04/26 16:45:45 1.1.1.1
+++ x86_main.asm 2001/10/04 09:20:02
@@ -17,11 +17,6 @@
GLOBAL _Hermes_X86_CPU
-SECTION .data
-cpu_flags dd 0
SECTION .text
;; _ConvertX86:
@@ -109,17 +104,12 @@
pop eax
xor eax,ecx
je .L1
- pusha
- push ebx ; ebx is callee-saves
mov eax,1
cpuid
- mov [cpu_flags],edx
- popa
- mov eax,[cpu_flags]
- pop ebx
- mov eax,edx
.L1:
ret