[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

MCL/Shared Library Mgr. query



Greetings....

As one of the hordes of users disappointed in Apple's plans for
MCL, one transition strategy might be to use the shared library
manager as a way of integrating native PPC code into MCL. The 
shared library manager has other uses as well (it is the 
recommended way to attach SNMP agents...).

If we can get this to work we'd be glad to post it... but we
haven't quite gotten there yet. The code below only gets us
to MacsBug on a 68040 machine (it might be even faster on a 
PPC machine :-).

Suggestions welcomed...

Sean Doyle
RSTAR, Inc.
doyle@sisu.mgh.harvard.edu

;;;
;;; Hacking of the ASLM (Shared Library Manager)
;;; [Code written by Hai Wang]

(defconstant kCurrentZone 4)            ; See file "LibraryManager.h"
(defconstant kNormalMemory 1)           ; See file "LibraryManager.h"

(defparameter *c-libraries*
  '("KSQ402:MPW Folder:Libraries:Libraries:Interface.o"
    "KSQ402:MPW Folder:Libraries:CLibraries:StdCLib.o"
    ))

(defparameter *aslm-libraries* 
  '("KSQ402:MPW Folder:Libraries:Libraries:LibraryManager.o"
    "KSQ402:MPW Folder:Libraries:Libraries:LibraryManager.n.o"
    ))

(ff-load '("KSQ402:MPW Folder:Libraries:Libraries:LibraryManager.o"
           )
         :ffenv-name 'aslm
         :entry-names '("InitLibraryManager" 
                        "LoadFunctionSet"
                        "UnloadFunctionSet"
                        "CleanupLibraryManager")
         :libraries *c-libraries*)

(ff-load '("KSQ402:Desktop Folder:CSample:Objects:SampleLibrary6.cl.o")
         :ffenv-name 'sample-lib
         :libraries *aslm-libraries*
         )

(deffcfun (@InitLibraryManager "InitLibraryManager")
  ((fixnum :long) (fixnum :long) (fixnum :long)) :long)

(@InitLibraryManager 0 kCurrentZone kNormalMemory)
#|
 When excuting the above function, Macsbug came up.

Address error at 007DE5E4
while fetching instructions from 007DE5E5 and 007DE5E7

The current instructions are as the following. Note the first instruction. 
It jumps to an odd address.

 Disassembling from 007DE5E4
  No procedure name
007DE5E4  *JSR        *+$0001                    ; 007DE5E5   | 4EBA FFFF
007DE5E8   DC.W       $FEDA                      ; ????       | FEDA
007DE5EA   TST.B      D0                                      | 4A00
007DE5EC   BNE.S      *+$000A                    ; 007DE5F6   | 6608
007DE5EE   MOVE.W     #$F3C4,D7                               | 3E3C F3C4
007DE5F2   BRA        *+$0098                    ; 007DE68A   | 6000 0096
007DE5F6   MOVEA.L    A3,A0                                   | 204B
007DE5F8   LEA        *+$000A,A1                 ; 007DE602   | 43FA 0008
007DE5FC   MOVEM.L    D2-D7/A1-A4/A6/A7,(A0)                  | 48D0 DEFC
007DE600   MOVEQ      #$00,D0                                 | 7000
007DE602   TST.L      D0                                      | 4A80
007DE604   BNE.S      *+$007E                    ; 007DE682   | 667C
007DE606   MOVEA.L    ExpandMem,A0                            | 2078 02B6
007DE60A   MOVEA.L    $010C(A0),A0                            | 2068 010C
007DE60E   MOVEA.L    $0010(A0),A4                            | 2868 0010
007DE612   MOVE.L     $0010(A6),-(A7)                         | 2F2E 0010
007DE616   MOVE.L     $000C(A6),-(A7)                         | 2F2E 000C
007DE61A   MOVE.L     $0008(A6),-(A7)                         | 2F2E 0008
007DE61E   MOVE.L     A3,-(A7)                                | 2F0B
007DE620   PEA        $FFFFFFFC                               | 4879 FFFF FFFC
007DE626   MOVE.L     A4,-(A7)                                | 2F0C
007DE628   MOVEA.L    (A4),A0                                 | 2054
007DE62A   MOVEA.L    $006C(A0),A1                            | 2268 006C
007DE62E   JSR        (A1)                                    | 4E91
007DE630   MOVE.W     D0,D7                                   | 3E00
007DE632   LEA        $0018(A7),A7                            | 4FEF 0018
007DE636   BNE.S      *+$0054                    ; 007DE68A   | 6652
007DE638   JSR        *+$0001                    ; 007DE639   | 4EBA FFFF
007DE63C   DC.W       $FF1A                      ; ????       | FF1A
007DE63E   MOVEA.L    D0,A0                                   | 2040
007DE640   TST.L      (A0)                                    | 4A90
007DE642   BNE.S      *+$0048                    ; 007DE68A   | 6646
007DE644   MOVE.L     A5,D0                                   | 200D
007DE646   CMP.L      CurrentA5,D0                            | B0B8 0904
007DE64A   BNE.S      *+$0040                    ; 007DE68A   | 663E
007DE64C   MOVEA.L    ExpandMem,A0                            | 2078 02B6
007DE650   MOVEA.L    $010C(A0),A0                            | 2068 010C
007DE654   MOVEQ      #$00,D0                                 | 7000
007DE656   MOVE.L     D0,$000C(A0)                            | 2140 000C
007DE65A   JSR        *+$0001                    ; 007DE65B   | 4EBA FFFF
007DE65E   DC.W       $FDBA                      ; ????       | FDBA
007DE660   MOVEQ      #$00,D0                                 | 7000
007DE662   MOVE.L     D0,-(A7)                                | 2F00
007DE664   PEA        *+$0001                    ; 007DE665   | 487A FFFF
007DE668   DC.W       $FDBC                      ; ????       | FDBC
007DE66A   MOVE.L     #$FFFFA9F4,-(A7)                        | 2F3C FFFF A9F4
007DE670   JSR        *+$0001                    ; 007DE671   | 4EBA FFFF
007DE674   DC.W       $FC66                      ; ????       | FC66
007DE676   MOVE.L     D0,$FFFFFFF8                            | 23C0 FFFF FFF8
007DE67C   LEA        $000C(A7),A7                            | 4FEF 000C
007DE680   BRA.S      *+$000A                    ; 007DE68A   | 6008
007DE682   JSR        *+$0002                    ; 007DE684   | 4EBA 0000
007DE686   ORI.B      #$A9F4,(A2)                             | 0012 A9F4
007DE68A   MOVE.W     D7,D0                                   | 3007
007DE68C   MOVEM.L    -$003C(A6),D7/A3/A4                     | 4CEE 1880 FFC4
007DE692   UNLK       A6                                      | 4E5E
007DE694   RTS                                                | 4E75
007DE696   LINK       A6,#$0000                               | 4E56 0000
007DE69A   MOVEM.L    D7/A4,-(A7)                             | 48E7 0108
007DE69E   CLR.B      D7                                      | 4207
007DE6A0   JSR        *+$0001                    ; 007DE6A1   | 4EBA FFFF
007DE6A4   DC.W       $FEF4                      ; ????       | FEF4

 Return addresses on the stack
  Stack Addr  Frame Addr   Caller
   0114F24C               40811842 _vFileReal
   0114F234               011561B4 01234567+3724
   0114F20C               40836064 _DisposeRgn+0004

 Calling chain using A6 links
  A6 Frame   Caller
  top level 011561B4 01234567+3724

|#