russellallen / self

Making the world safe for objects
http://selflanguage.org
707 stars 76 forks source link

asmPrims_sparc.S: work around broken v8 .mul stub on NetBSD #153

Closed nbuwe closed 10 months ago

nbuwe commented 1 year ago

Sparc v7 has no multiplication instruction so a .mul function is used to do the multiplication. Typically dynamic linker detects v8 and interposes a DSO where .mul is implemented using the v8 multiplication instruction.

Unfortunately the NetBSD .mul stub doesn't follow the ABI. .mul is defined to return the upper bits in %o1, but smul instruction returns it in %y. Nothing in the gcc generated code uses the upper half, but Self does and garbage in %o1 makes it think multiplication failed.

As a quick kludge provide and always use a local copy of .mul that behaves as expected.

Works around #152.