Interesting behaviour with GCC.

Started by verdraith, January 25, 2023, 10:08:04 PM

Previous topic - Next topic


This is Mostly Useless Info(tm) and probably known, but I figured I'd document it here just in case.

So, on NEXTSTEP and OPENSTEP Intel, GCC will mostly emit i386 Mach-O binaries (cpu type 7, subtype 3).

If you use a 486-specific opcode (say 'bswap'), it will emit a i486 Mach-O binary (cpu type 7, subtype 4).

All is good, all is groovy, Mach will handle it.

If you use something that is technically i586, such as 'cpuid', then an i586 Mach-O binary (cpu type 7, subtype 5) will be emitted... and... Mach doesn't know how to handle that!

Fun times!
Lisp Hacker

Rob Blessin Black Hole

Hello Verdraith: That is interesting i586 being  Pentium?  I know AMD processors in that time frame come up as 486 in the info panel.  Does NeXTSTEP recognize Core2Duo natively ? I think it might as Nitro has a box running Openstep on it .... what about I 3 , 5, 7 or 9 processors. Best Regards Rob Blessin
Rob Blessin President computerpowwow ebay  [email protected]
303-741-9998 Serving the NeXT Community  since 2/9/93


So, Mach itself isn't recognising the processor, something else is going on.

When GCC sees the 'cpuid' instruction in my code, it knows that that instruction is only supported on i586 and newer, and builds output targetting the i586.

The interesting part (well, for me) is that Mach seemingly knows about i586, but won't execute i586 binaries.

The Pentium was very much available by the time NEXTSTEP 3.3 was released... hell, early Pentium CPUs were available a few months before the initial x86 port of NEXTSTEP (3.1)... so I'd be curious to find out why Mach refuses to do anything with i586 binaries.

Lisp Hacker


Just looked at the headers, i586 is as far as it goes... no i686 or newer.

Though, it looks like Mach is also aware of the i586SX -- the Pentium Overdrive.

Hah, I doubt Mach will want to execute i586SX Mach-O binaries, though.

I wonder if they planned on supporting stuff, but just got sidetracked by something else, or maybe someone assumed the i586 was just a New and Improved(tm) i486 or something.

So, if you have to use inline assembler, throw away the Pentium version of the Intel IA-32 Instruction Set Architecture manuals and stick to i486 :D


As a side thought, I checked on all versions of NEXTSTEP back to 3.0.

NEXTSTEP 3.2 has i386, i486, i586, and i586SX
NEXTSTEP 3.1 has i386, i486, i586, and i586SX
NeXTSTEP 3.0 has i386, and i486.

So I wonder if they pre-emptively wanted to support the Pentium and Pentium Overdrive but never got around to having the Mach and the Mach Loader support binaries with those CPU subtypes.
Lisp Hacker


Maybe it just came 'free' with the compiler.


These are system headers, though -- a part of Mach.

GCC itself has its own stuff for determining what sort of Mach-O binary to build.
Lisp Hacker


Though, it could be because contemporary GCC supported i586, thus the Mach kernel would need to differentiate i586 binaries.

Although, that does not explain the presence of i586SX.

Nor does it explain why the Mach kernel refuses to load i586 binaries.

Maybe it was on a todo list somewhere and just got missed.
Lisp Hacker