Legacy Documentclose button

Important: The information in this document is obsolete and should not be used for new development.

Previous Book Contents Book Index Next

Inside Macintosh: Mac OS Runtime Architectures /


Chapter 1 CFM-Based Runtime Architecture 1-1

Figure 1-1 A closure 1-6

Figure 1-2 Multiple closures in a process 1-7

Figure 1-3 Sections associated with a connection 1-8

Figure 1-4 Fragments shared between processes 1-9

Figure 1-5 Using kReferenceCFrag 1-12

Figure 1-6 Using kFindCFrag 1-13

Figure 1-7 Using private connections 1-14

Figure 1-8 Linking to a definition stub library 1-19

Figure 1-9 Using the implementation version of a library at runtime 1-20

Figure 1-10 Library versions compatible with each other 1-22

Figure 1-11 Library versions incompatible with each other 1-22

Figure 1-12 Three fragments with initialization functions 1-36

Table 1-1 Two import libraries and their version numbers 1-21

Listing 1-1 Pseudocode for the CFM version-checking algorithm 1-23

Listing 1-2 The code fragment resource 1-25

Listing 1-3 A code fragment resource entry 1-26

Listing 1-4 Structure of a sample code fragment resource extension 1-29

Listing 1-5 The code fragment resource extension header 1-29

Listing 1-6 A code fragment resource extension of type 30EE 1-30

Listing 1-7 A sample 'cfrg'0 resource for a PowerPC runtime application 1-31

Listing 1-8 A sample 'cfrg'0 resource for a CFM-68K runtime application 1-32

Listing 1-9 A sample 'cfrg'0 resource for an import library 1-33

Chapter 2 Indirect Addressing in the CFM-Based Architecture 2-1

Figure 2-1 Direct addressing of data 2-4

Figure 2-2 Indirect addressing of data 2-5

Figure 2-3 A transition vector 2-7

Figure 2-4 Unprepared and prepared PowerPC transition vectors 2-9

Listing 2-1 Glue code for a cross-fragment call 2-10

Listing 2-2 Glue code for a pointer-based call 2-11

Listing 2-3 Glue code for a simple function 2-14

Listing 2-4 Making an indirect call from within an indirectly called function 2-14

Chapter 3 Programming for the CFM-Based Runtime Architecture 3-1

Figure 3-1 Two names for a single fragment 3-13

Figure 3-2 Changes to import library version numbers 3-17

Figure 3-3 Version numbering with weak imports 3-19

Figure 3-4 Multiple logical names for a single library 3-21

Figure 3-5 Using a reexport library 3-22

Figure 3-6 The reexport library removed at runtime 3-23

Figure 3-7 Systemwide sharing in a fragment containing code and data 3-25

Figure 3-8 Systemwide sharing using a data-only fragment 3-26

Figure 3-9 Identical but independent fragments 3-27

Table 3-1 Methods for maintaining import library compatibility 3-14

Listing 3-1 Preparing a fragment using GetSharedLibrary 3-4

Listing 3-2 Preparing a disk-based fragment 3-4

Listing 3-3 Preparing a resource-based fragment 3-5

Listing 3-4 Finding symbol names 3-7

Listing 3-5 Sample code found in a shadow library 3-8

Listing 3-6 Testing for weak imports 3-12

Chapter 4 PowerPC Runtime Conventions 4-1

Figure 4-1 The PowerPC stack 4-6

Figure 4-2 A stack frame's linkage area 4-7

Figure 4-3 The Red Zone 4-10

Figure 4-4 The organization of the parameter area of the stack 4-14

Figure 4-5 Parameter layout in registers and the parameter area 4-15

Figure 4-6 Passing a variable number of parameters 4-16

Table 4-1 Data types in the PowerPC runtime environment 4-3

Table 4-2 Embedded alignment modes 4-5

Table 4-3 Volatile and nonvolatile registers 4-17

Listing 4-1 Sample prolog code 4-9

Listing 4-2 Sample epilog code 4-10

Listing 4-3 A variable-argument routine 4-16

Chapter 5 CFM-68K Runtime Conventions 5-1

Table 5-1 Data types in the CFM-68K runtime environment 5-3

Table 5-2 Volatile and nonvolatile registers 5-8

Chapter 6 The Mixed Mode Manager 6-1

Figure 6-1 Calling path from classic 68K code to a CFM-based routine 6-8

Figure 6-2 The stack before a mode switch 6-11

Figure 6-3 A classic 68K to PowerPC switch frame 6-12

Figure 6-4 A PowerPC to classic 68K switch frame 6-14

Figure 6-5 A classic 68K to CFM-68K switch frame 6-16

Figure 6-6 A CFM-68K to classic 68K switch frame 6-17

Chapter 7 Fat Binary Programs 7-1

Figure 7-1 The structure of an accelerated resource 7-5

Figure 7-2 The structure of a fat resource 7-6

Listing 7-1 Rez input for a stub list definition resource 7-8

Listing 7-2 Using an accelerated resource 7-9

Listing 7-3 Acceptable global declarations in an accelerated resource 7-11

Listing 7-4 Unacceptable global declarations and code in an accelerated resource 7-12

Chapter 8 PEF Structure 8-1

Figure 8-1 Structure of a PEF container 8-3

Figure 8-2 A pattern-initialization instruction 8-11

Figure 8-3 Argument storage in pattern-initialized data 8-12

Figure 8-4 Data section after executing interleaveRepeatBlockWithBlockCopy 8-14

Figure 8-5 Data section after executing interleaveRepeatBlockWithZero 8-14

Figure 8-6 PEF loader section 8-15

Figure 8-7 An imported symbol table entry 8-20

Figure 8-8 A symbol class field 8-20

Figure 8-9 Unprepared fragments 8-25

Figure 8-10 Relocations for the calling fragment 8-26

Figure 8-11 Relocations for the called fragment 8-27

Figure 8-12 Structure of the RelocBySectDWithSkip instruction 8-29

Figure 8-13 Structure of the Relocate Value opcode group 8-29

Figure 8-14 Structure of the Relocate By Index opcode group 8-31

Figure 8-15 Structure of the RelocIncrPosition instruction 8-32

Figure 8-16 Structure of the RelocSmRepeat instruction 8-32

Figure 8-17 Structure of the RelocSetPosition instruction 8-33

Figure 8-18 Structure of the RelocLgByImport instruction 8-33

Figure 8-19 Structure of the RelocLgRepeat instruction 8-34

Figure 8-20 Structure of the RelocLgSetOrBySection instruction 8-35

Figure 8-21 A traditional hash table 8-36

Figure 8-22 Flattened hash table implementation 8-37

Figure 8-23 A hash table entry 8-39

Figure 8-24 A hash word 8-39

Table 8-1 Section types 8-8

Table 8-2 Sharing options 8-9

Table 8-3 Symbol classes 8-21

Table 8-4 Relocation variables 8-22

Table 8-5 Subopcodes for the RelocateValue opcode group 8-30

Table 8-6 Subopcodes for the Relocate By Index opcode group 8-31

Table 8-7 Subopcodes for the RelocLgSetOrBySection instruction 8-35

Listing 8-1 PEF container header data structure 8-4

Listing 8-2 Section header data structure 8-6

Listing 8-3 Loader header data structure 8-16

Listing 8-4 Imported library description data structure 8-18

Listing 8-5 Relocation header entry data structure 8-23

Listing 8-6 Relocation opcode values 8-28

Listing 8-7 Exported symbol table entry data structure 8-40

Listing 8-8 Hash word function 8-41

Listing 8-9 Hash word to hash index function 8-42

Listing 8-10 Exported symbol count to hash table size function 8-43

Chapter 9 CFM-68K Application and Shared Library Structure 9-1

Figure 9-1 Structure of a CFM-68K runtime segment header 9-4

Figure 9-2 CFM-68K runtime jump table structure 9-5

Figure 9-3 An application transition vector 9-6

Figure 9-4 The 'CODE'0 resource 9-7

Figure 9-5 The 'rseg'0 resource 9-9

Figure 9-6 Segmented versus flattened jump table entries 9-12

Figure 9-7 A transition vector before and after flattening 9-12

Figure 9-8 A transition vector at runtime 9-13

Chapter 10 Classic 68K Runtime Architecture 10-1

Figure 10-1 Classic 68K A5 world 10-4

Figure 10-2 Using the jump table and using self-relative branching 10-7

Figure 10-3 The 'CODE'0 resource 10-9

Figure 10-4 An unloaded jump table entry 10-10

Figure 10-5 A loaded jump table entry 10-11

Figure 10-6 Near model segment header 10-12

Figure 10-7 Branch islands and intersegment references 10-16

Figure 10-8 Far model unloaded jump table entry 10-21

Figure 10-9 Separation of near and far references in the far model jump table 10-22

Figure 10-10 The far model jump table structure 10-23

Figure 10-11 The far model segment header 10-24

Table 10-1 Classic 68K runtime architecture limits and solutions 10-13

Table 10-2 Relocation information 10-26

Listing 10-1 Using 32-bit references for the target address of an instruction 10-18

Chapter 11 Classic 68K Runtime Conventions 11-1

Figure 11-1 A 68K stack frame before and after calling a routine 11-5

Figure 11-2 Passing parameters onto the stack in Pascal 11-7

Figure 11-3 Passing parameters onto the stack in C 11-8

Table 11-1 Data types in the classic 68K runtime environment 11-3

Table 11-2 Volatile and nonvolatile registers 11-9

Appendix A Terminology Changes A-1

Table A-1 Changes to terminology A-1

Table A-2 Changes to names in the CodeFragments.h header file A-2

Table A-3 Changes to names of data types A-3

Appendix B The RTLib.o and NuRTLib.o Libraries B-1

Figure B-1 The stack when a user error handler is called B-8

Table B-1 Runtime routine operation values B-3

Table B-2 Runtime routine error values B-4

Table B-3 Error handler action codes B-9

Table B-4 Current version numbers B-10

Listing B-1 A preload handler example B-13


Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 MARCH 1997