From: Stas Boukarev Date: Tue, 6 Aug 2013 17:11:16 +0000 (+0400) Subject: Fix undefined function errors on PPC and MIPS. X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=1540c1c1d517c58fa9a41629beb65cdce7dfafb6;p=sbcl.git Fix undefined function errors on PPC and MIPS. undefined_tramp hardcodes the register in which FDEFN resides, but the format was recently changed (f69e89d..). Other platforms can be susceptible to this. A proper fix would avoid hardcoding this by exporting sc-offset-scn-byte/sc-offset-offset-byte, and register offsets. Thanks to the GCC Compile Farm project for providing machines for testing and uncovering this. --- diff --git a/NEWS b/NEWS index c90875e..912f5b9 100644 --- a/NEWS +++ b/NEWS @@ -2,6 +2,8 @@ changes relative to sbcl-1.1.10 * enhancement: support building the manual under texinfo version 5. (lp#1189146) + * bug fix: undefined function errors are now properly reported on PPC and MIPS. + (regression since 1.1.9) changes in sbcl-1.1.10 relative to sbcl-1.1.9: * enhancement: ASDF has been updated to 3.0.2. diff --git a/src/code/sc-offset.lisp b/src/code/sc-offset.lisp index 1811dd6..0f20089 100644 --- a/src/code/sc-offset.lisp +++ b/src/code/sc-offset.lisp @@ -16,6 +16,9 @@ ;;;; We represent the place where some value is stored with a SC-OFFSET, ;;;; which is the SC number and offset encoded as an integer. +;;;; FIXME: this layout is hardcoded in some .S files, +;;;; undefined_tramp in at least ppc-assem.S and mips-assem.S uses it. +;;;; Ideally, it shouldn't be hardcoded. (defconstant-eqx sc-offset-scn-byte (byte 6 0) #'equalp) (defconstant-eqx sc-offset-offset-byte (byte 21 6) #'equalp) (def!type sc-offset () '(unsigned-byte 27)) diff --git a/src/runtime/mips-assem.S b/src/runtime/mips-assem.S index 1982ee8..62b3672 100644 --- a/src/runtime/mips-assem.S +++ b/src/runtime/mips-assem.S @@ -392,8 +392,8 @@ lra: .word RETURN_PC_HEADER_WIDETAG See debug-var-io.lisp. */ .byte 254 /* reg_FDEFN is #14. */ - .byte ((14 << 5) + sc_DescriptorReg) % 0x100 - .byte ((14 << 5) + sc_DescriptorReg) / 0x100 + .byte ((14 << 6) + sc_DescriptorReg) % 0x100 + .byte ((14 << 6) + sc_DescriptorReg) / 0x100 .align 2 .set reorder 1: lw reg_CODE, FDEFN_FUN_OFFSET(reg_FDEFN) diff --git a/src/runtime/ppc-assem.S b/src/runtime/ppc-assem.S index 51b6b32..3b6e53f 100644 --- a/src/runtime/ppc-assem.S +++ b/src/runtime/ppc-assem.S @@ -654,7 +654,7 @@ CSYMBOL(undefined_tramp): twllei reg_ZERO,trap_Cerror .byte 4 .byte UNDEFINED_FUN_ERROR - .byte 254, sc_DescriptorReg+0x40, 1 /* 140? sparc says sc_descriptorReg */ + .byte 254, sc_DescriptorReg+0x80, 0x2 /* 280 */ /* This stuff is for the continuable error. I don't think there's * any support for it on the lisp side */ .align 2 diff --git a/tests/compiler.pure.lisp b/tests/compiler.pure.lisp index aa8861d..16436ff 100644 --- a/tests/compiler.pure.lisp +++ b/tests/compiler.pure.lisp @@ -150,10 +150,11 @@ ;;; on the PPC, we got the magic numbers in undefined_tramp wrong for ;;; a while; fixed by CSR 2002-07-18 -(multiple-value-bind (value error) - (ignore-errors (some-undefined-function)) - (assert (null value)) - (assert (eq (cell-error-name error) 'some-undefined-function))) +(with-test (:name :undefined-function-error) + (multiple-value-bind (value error) + (ignore-errors (some-undefined-function)) + (assert (null value)) + (assert (eq (cell-error-name error) 'some-undefined-function)))) ;;; Non-symbols shouldn't be allowed as VARs in lambda lists. (Where VAR ;;; is a variable name, as in section 3.4.1 of the ANSI spec.)