2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
23 * Copyright (c) 1997 Apple Computer, Inc.
28 * sdouglas 22 Oct 97 - first checked in.
29 * sdouglas 21 July 98 - start IOKit
36 Contains: PEF format declarations.
40 Copyright: © 1992-1996 by Apple Computer, Inc., all rights reserved.
46 Other Contact: <<unknown>>
48 Technology: Core Runtime
55 Change History (most recent first):
57 <7> 2/28/96 AWL Adapt for new container handler model.
58 <6> 4/12/95 AWL Fix bit field problem.
59 <5> 8/29/94 AWL Remove "never" share mode.
60 <4> 8/23/94 AWL Update section sharing constants.
61 <3> 4/28/94 AWL Simplify cross address space use for booting.
62 <2> 4/11/94 AWL Use 68K alignment for the export symbol structure.
63 <1> 2/15/94 AWL Initial checkin for kernel based CFM.
65 -------------------------------------------------------------------------------------
67 <7> 8/26/93 AWL Move CFTypes.h and CFLoader.h up with other Apple private headers.
68 <5> 7/8/93 AWL (&ELE) Fixed version field names in import file IDs
69 <4> 6/9/93 JRG ELE & AWL Changes:
70 <4> 06/08/93 AWL (&ELE) Added more standard section types and packed data opcodes.
71 <3> 9/23/92 ELE added precomputed hash table for improved runtime performance.
73 Version 1.3 Erik Eidt 9/23/92 updated for new hash table capabilities
74 Version 1.2 Erik Eidt 7/8/92 updated for new relocations and other loader section size optimizations
75 Version 1.1 Cheryl Lins 5/27/92 updated for PEF 1.2 definition
76 Version 1.0 Cheryl Lins 4/7/92 initial version
80 #ifndef __IOPEFINTERNALS__
81 #define __IOPEFINTERNALS__ 1
83 #include "IOPEFLoader.h"
86 typedef signed int PEF_SBits32
; // ! Can't use SInt32, it is "signed long".
87 typedef unsigned int PEF_UBits32
; // ! Can't use UInt32, it is "unsigned long".
90 #pragma options align=mac68k
92 /*========== File Header ==========*/
95 UInt16 magic1
; /* magic flag describing execution machine and environment */
96 UInt16 magic2
; /* magic flag describing execution machine and environment */
97 OSType fileTypeID
; /* OSType identifier = 'pef' */
98 OSType architectureID
; /* OSType identifier = 'pwpc' */
99 UInt32 versionNumber
; /* version number of this file format */
100 UInt32 dateTimeStamp
; /* Macintosh date/time stamp */
101 UInt32 oldDefVersion
; /* old definition version number */
102 UInt32 oldImpVersion
; /* old implementation version number */
103 UInt32 currentVersion
; /* current version number */
104 SInt16 numberSections
; /* number of sections */
105 SInt16 loadableSections
; /* number of sections that are loadable for execution,
106 also the section # of first non-loadable section */
107 BytePtr memoryAddress
; /* the location this container was last loaded */
108 } FileHeader
, *FileHeaderPtr
;
110 #define kPEFVersion 1 /* current version number */
111 #define kPEFMagic1 0x4A6F /* value of magic1 for PEF */
112 #define kPEFMagic2 0x7921 /* value of magic2 for PEF */
113 #define kPEFTypeID 0x70656666 /* value of fileTypeID for 'peff' */
114 #define kPowerPCID 0x70777063 /* value of architecture ID 'pwpc' */
116 /*========== Section Header ==========*/
119 ByteCount sectionName
; /* offset into global string table for section name */
120 BytePtr sectionAddress
; /* preferred base address for the section */
121 ByteCount execSize
; /* section size in bytes during execution in memory including zero initialization */
122 ByteCount initSize
; /* section size in bytes during execution in memory before zero initialization */
123 ByteCount rawSize
; /* section size in bytes in container before loading */
124 ByteCount containerOffset
;/* container offest to section's raw data */
125 UInt8 regionKind
; /* section/region classification */
126 UInt8 shareKind
; /* sharing classification */
127 UInt8 alignment
; /* execution alignment requirement (0=byte,1=half,2=word,3=doubleword,4=quadword..) */
129 } SectionHeader
, *SectionHeaderPtr
;
131 /* TCFLSectionKind */
132 #define kPEFCodeSection 0
133 #define kPEFDataSection 1
134 #define kPEFPIDataSection 2
135 #define kPEFConstantSection 3
136 #define kPEFLoaderSection 4
137 #define kPEFDebugSection 5
138 #define kPEFExecDataSection 6
139 #define kPEFExceptionSection 7
140 #define kPEFTracebackSection 8
143 #define kPEFContextShare 1
144 #define kPEFGlobalShare 4
145 #define kPEFProtectedShare 5
147 /* Defines for PIDataSections */
151 #define kPEFRepeatBlock 3
152 #define kPEFRepeatZero 4
153 #define kPEFNoOpcode 0x0fff
154 #define kPEFOpcodeShift 5
155 #define kPEFFirstOperandMask 31
158 /*========== Loader Header ==========*/
161 SInt32 entryPointSection
; /* section number containing entry point descriptor */
162 ByteCount entryPointOffset
; /* offset to entry point descriptor within section */
164 SInt32 initPointSection
; /* section number containing entry point descriptor */
165 ByteCount initPointOffset
; /* offset to entry point descriptor within section */
167 SInt32 termPointSection
; /* section number containing entry point descriptor */
168 ByteCount termPointOffset
; /* offset to entry point descriptor within section */
170 ItemCount numImportFiles
; /* number of import file id entries */
171 ItemCount numImportSyms
; /* number of import symbol table entries */
172 ItemCount numSections
; /* number of sections with load-time relocations */
173 ByteCount relocationsOffset
; /* offset to relocation descriptions table */
175 ByteCount stringsOffset
; /* offset to loader string table */
177 ByteCount hashSlotTable
; /* offset to hash slot table */
178 ItemCount hashSlotTabSize
; /* number of hash slot entries */
179 ItemCount numExportSyms
; /* number of export symbol table entries */
180 } LoaderHeader
, *LoaderHeaderPtr
;
182 /*========== Loader Section Header ==========*/
185 SInt16 sectionNumber
; /* reference to primary section number */
186 SInt16 reservedA
; /* if TSectNum were 16 bits, which it isn't */
187 ItemCount numRelocations
; /* number of loader relocations for this section */
188 ByteCount relocationsOffset
; /* offset to relocation descriptions for this section */
189 } LoaderRelExpHeader
, *LoaderRelExpHeaderPtr
;
191 /*========== Loader Import File ID's Entry ==========*/
194 ByteCount fileNameOffset
; /* offset into loader string table for file name */
195 UInt32 oldImpVersion
; /* oldest compatible implementation library */
196 UInt32 linkedVersion
; /* current version at link time */
197 ItemCount numImports
; /* number of imports from this file */
198 ItemCount impFirst
; /* number of the first imports from this file (relative to all imports) */
199 UInt8 options
; /* call this libraries initialization routine before mine */
202 } LoaderImportFileID
, *LoaderImportFileIDPtr
;
204 #define kPEFInitBeforeMask 0x80
205 #define kPEFWeakLibraryMask 0x40
206 #define kPEFDeferredBindMask 0x20
208 /*========== Loader Import Symbol Table Entry ==========*/
211 PEF_UBits32 symClass
: 8; // Actually ot type TCFLSymbolClass.
212 PEF_UBits32 nameOffset
: 24;
213 } LoaderImport
, *LoaderImportPtr
;
215 #define kPEFWeakSymbolMask 0x80
217 /*========== Loader Export Hash Slot Table Entry ==========*/
220 PEF_UBits32 chainCount
: 14;
221 PEF_UBits32 chainIndex
: 18;
222 } HashSlotEntry
, *HashSlotEntryPtr
;
224 #define PEFHashHighBits(hashword,bitCount) ((hashword) >> (bitCount))
225 #define PEFHashMaskBits(hashword,bitCount) (((UInt32)(1) << (bitCount)) - 1)
227 #define GetPEFHashSlot(hashword,bitCount) \
228 ( (ItemCount) (((hashword) ^ PEFHashHighBits((hashword),(bitCount))) & PEFHashMaskBits((hashword),(bitCount))) )
230 /*========== Loader Export Hash Chain Table Entry ==========*/
233 UInt32 hashword
; /* (hashword >> 16) == nameLength !! */
234 } HashChainEntry
, *HashChainEntryPtr
;
236 /*========== Loader Export Symbol Table Entry ==========*/
238 /* Section number controls how 'address' is interpreted.
239 >=0: section number exporting the symbol; 'address' is offset from start of the section to
240 the symbol being exported (ie address of a routine or data item)
241 -1: value is absolute (non-relocatable)
242 -2: value is a physical address (non-relocatable)
243 -3: re-export imported symbol whose number is in 'address'
246 /* this struct is stored in the file, non-aligned: size = 10 */
248 PEF_UBits32 symClass
: 8; // Actually ot type TCFLSymbolClass.
249 PEF_UBits32 nameOffset
: 24;
250 ByteCount offset
; /* offset into section to exported symbol */
251 SInt16 sectionNumber
;
252 } LoaderExport
, *LoaderExportPtr
;
254 #define SIZEOF_LoaderExport (sizeof (TUnsigned32)*2 + sizeof (SInt16))
257 #define kPEFAbsoluteExport -1
258 #define kPEFPhysicalExport -2
259 #define kPEFReExportImport -3
261 /*========== Loader Relocation Entry ==========*/
263 typedef UInt16 RelocInstr
;
266 struct { unsigned op
:7, rest
:9; } opcode
;
267 struct { unsigned op
:2, delta_d4
:8, cnt
:6; } deltadata
;
268 struct { unsigned op
:7, cnt_m1
:9; } run
;
269 struct { unsigned op
:7, idx
:9; } glp
;
270 struct { unsigned op
:4, delta_m1
:12; } delta
;
271 struct { unsigned op
:4, icnt_m1
:4, rcnt_m1
:8; } rpt
;
272 struct { unsigned op
:6, idx_top
:10; } large1
;
273 struct { unsigned op
:6, cnt_m1
:4, idx_top
:6; } large2
;
278 // opcode definitions which can be used with
279 // Relocation.opcode.op:7, if masked properly
280 // by the up coming table
281 // (NOTE: a half word of 0 is garunteed to be an unused relocation instruction)
283 #define krDDAT 0x00 // type deltadata
285 #define krCODE 0x20 // type run
286 #define krDATA 0x21 // type run
287 #define krDESC 0x22 // type run
288 #define krDSC2 0x23 // type run
289 #define krVTBL 0x24 // type run
290 #define krSYMR 0x25 // type run
294 #define krSYMB 0x30 // type glp
295 #define krCDIS 0x31 // type glp
296 #define krDTIS 0x32 // type glp
297 #define krSECN 0x33 // type glp
301 #define krDELT 0x40 // type delta
302 #define krRPT 0x48 // type rpt
304 #define krLABS 0x50 // type large1
305 #define krLSYM 0x52 // type large1
309 #define krLRPT 0x58 // type large2
310 #define krLSEC 0x5A // type large2
315 // LSEC 0, n -- Long SECN
316 // LSEC 1, n -- Long CDIS
317 // LSEC 2, n -- Long DTIS
319 // LSEC 15, n -- free
321 // constants that indicate the maximum sizes of fields
322 // (before packing, ie: subtracting one, in some cases)
324 #define ksDELTA 4096 // delta max for DELTA from
326 #define ksDDDMAX 1023 // delta max for DELTA-DAT (DDAT) form
327 #define ksDDRMAX 63 // run max for DELTA-DAT (DDAT) form
329 #define ksCODE 512 // count max for CODE form
330 #define ksDATA 512 // count max for DATA form
331 #define ksDEMAX 512 // count max for DESC form
332 #define ksVTMAX 512 // count max for VTBL form
333 #define ksISMAX 512 // count max for IMPS form
334 #define ksRPTMAX 256 // count max for RPT form
336 #define IsLARG(op) (((op) & 0x70) == 0x50)
340 #define ksDVDMAX 0 // (63) delta max for DELTA-VTBL (DVBL) form
341 #define ksDVRMAX 0 // (256) run max for DELTA-VTBL (DVBL) form
347 From: PEFBinaryFormat.i
352 /* The packed data opcodes. */
353 kPEFPkDataZero
= 0, /* Zero fill "count" bytes. */
354 kPEFPkDataBlock
= 1, /* Block copy "count" bytes. */
355 kPEFPkDataRepeat
= 2, /* Repeat "count" bytes "count2"+1 times. */
356 kPEFPkDataRepeatBlock
= 3, /* Interleaved repeated and unique data. */
357 kPEFPkDataRepeatZero
= 4 /* Interleaved zero and unique data. */
362 kPEFPkDataOpcodeShift
= 5,
363 kPEFPkDataCount5Mask
= 0x1F,
364 kPEFPkDataMaxCount5
= 31,
365 kPEFPkDataVCountShift
= 7,
366 kPEFPkDataVCountMask
= 0x7F,
367 kPEFPkDataVCountEndMask
= 0x80
370 #define PEFPkDataOpcode(byte) ( ((UInt8)(byte)) >> kPEFPkDataOpcodeShift )
372 #define PEFPkDataCount5(byte) ( ((UInt8)(byte)) & kPEFPkDataCount5Mask )
374 #define PEFPkDataComposeInstr(opcode,count5) \
375 ( (((UInt8)(opcode)) << kPEFPkDataOpcodeShift) | ((UInt8)(count5)) )
382 File: CodeFragmentContainerPriv.h
384 Contains: Physical container routines of the ModernOS version of CFM.
390 Copyright: © 1984-1996 by Apple Computer, Inc.
393 BuildInfo: Built by: Simon Douglas
394 With Interfacer: 2.0d13 (PowerPC native)
395 From: CodeFragmentContainerPriv.i
399 Last comment: Remove special SMP sharing, using prepare option instead.
401 Bugs: Report bugs to Radar component ÒSystem InterfacesÓ, ÒLatestÓ
402 List the version information (from above) in the Problem Description.
406 -------------------------------------------------------------------------------------------
407 This file contains what used to be called the CFLoader interface. The name was changed to
408 fit the newer convention of having CodeFragment as a common prefix, and to reduce pervasive
409 confusion between the Code Fragment Manager and the Code Fragment Loaders, promulgated by
410 the long history of the Segment Loader. This file defines the abstract interface to the
411 physical representation of code fragments.
412 !!! This version has minimal comments, the main purpose is to get things compiled.
418 ===========================================================================================
419 General Types and Constants
420 ===========================
422 typedef SInt32 CFContSignedIndex
;
423 typedef UInt32 CFContStringHash
;
424 #define CFContStringHashLength(hashValue) ((hashValue) >> 16)
425 struct CFContHashedName
{
426 CFContStringHash nameHash
; /* ! Includes the name length.*/
429 typedef struct CFContHashedName CFContHashedName
;
432 ------------------------------------------
433 Declarations for code fragment containers.
437 kCFContContainerInfoVersion
= 0x00010001
440 struct CFContContainerInfo
{
441 CFContHashedName cfragName
;
442 UInt32 modDate
; /* !!! Abstract type?*/
444 CFragVersionNumber currentVersion
;
445 CFragVersionNumber oldImpVersion
;
446 CFragVersionNumber oldDefVersion
;
450 typedef struct CFContContainerInfo CFContContainerInfo
;
453 ----------------------------------------
454 Declarations for code fragment sections.
456 struct CFContLogicalLocation
{
457 CFContSignedIndex section
; /* "Real" sections use zero based indices, special ones are negative.*/
460 typedef struct CFContLogicalLocation CFContLogicalLocation
;
464 kCFContNoSectionIndex
= -1,
465 kCFContAbsoluteSectionIndex
= -2,
466 kCFContReexportSectionIndex
= -3
469 typedef UInt8 CFContSectionSharing
;
472 kCFContShareSectionInClosure
= 0, /* ! Not supported at present!*/
473 kCFContShareSectionInProcess
= 1,
474 kCFContShareSectionAcrossSystem
= 4,
475 kCFContShareSectionWithProtection
= 5
478 typedef UInt8 CFContMemoryAccess
;
481 kCFContMemReadMask
= 0x01, /* Readable memory can also be executed.*/
482 kCFContMemWriteMask
= 0x02,
483 kCFContMemExecuteMask
= 0x04, /* ! Affects cache actions, not protection!*/
484 kCFContReadOnlyData
= kCFContMemReadMask
,
485 kCFContWriteableData
= kCFContMemReadMask
| kCFContMemWriteMask
,
486 kCFContNormalCode
= kCFContMemReadMask
| kCFContMemExecuteMask
,
487 kCFContExcludedMemory
= 0
490 typedef UInt32 CFContSectionOptions
;
493 /* Values for CFContSectionOptions.*/
494 kPackedCFContSectionMask
= 0x01, /* Stored contents are compressed.*/
495 kRelocatedCFContSectionMask
= 0x02, /* Section contents have relocations.*/
496 kEmptyFillCFContSectionMask
= 0x04, /* The extension part may be left untouched.*/
497 kResidentCFContSectionMask
= 0x08,
498 kPrefaultCFContSectionMask
= 0x10
503 kCFContSectionInfoVersion
= 0x00010001
506 struct CFContSectionInfo
{
507 CFContHashedName sectionName
;
508 CFContMemoryAccess access
;
509 CFContSectionSharing sharing
;
510 UInt8 alignment
; /* ! The power of 2, a.k.a. number of low order zero bits.*/
512 CFContSectionOptions options
;
513 ByteCount containerOffset
;
514 ByteCount containerLength
;
515 ByteCount unpackedLength
;
516 ByteCount totalLength
;
517 LogicalAddress defaultAddress
;
521 typedef struct CFContSectionInfo CFContSectionInfo
;
524 ----------------------------------
525 Declarations for exported symbols.
527 typedef UInt32 CFContExportedSymbolOptions
;
529 ! enum { // Values for CFContExportedSymbolOptions.
530 ! // ! No options at present.
535 kCFContExportedSymbolInfoVersion
= 0x00010001
538 struct CFContExportedSymbolInfo
{
539 CFContHashedName symbolName
;
540 CFContLogicalLocation location
;
541 CFContExportedSymbolOptions options
;
542 CFragSymbolClass symbolClass
;
548 typedef struct CFContExportedSymbolInfo CFContExportedSymbolInfo
;
551 ------------------------------------------------
552 Declarations for imported libraries and symbols.
554 typedef UInt32 CFContImportedLibraryOptions
;
557 /* Values for CFContImportedLibraryOptions.*/
558 kCFContWeakLibraryMask
= 0x01, /* ! Same as kCFContWeakSymbolMask to reduce errors.*/
559 kCFContInitBeforeMask
= 0x02,
560 kCFContDeferredBindMask
= 0x04
565 kCFContImportedLibraryInfoVersion
= 0x00010001
568 struct CFContImportedLibraryInfo
{
569 CFContHashedName libraryName
;
570 CFragVersionNumber linkedVersion
;
571 CFragVersionNumber oldImpVersion
;
572 CFContImportedLibraryOptions options
;
574 typedef struct CFContImportedLibraryInfo CFContImportedLibraryInfo
;
576 typedef UInt32 CFContImportedSymbolOptions
;
579 /* Values for CFContImportedSymbolOptions.*/
580 kCFContWeakSymbolMask
= 0x01 /* ! Same as kCFContWeakLibraryMask to reduce errors.*/
585 kCFContImportedSymbolInfoVersion
= 0x00010001
588 struct CFContImportedSymbolInfo
{
589 CFContHashedName symbolName
;
590 ItemCount libraryIndex
;
591 CFContImportedSymbolOptions options
;
592 CFragSymbolClass symbolClass
;
598 typedef struct CFContImportedSymbolInfo CFContImportedSymbolInfo
;
601 -------------------------------------------------
602 Declarations for dealing with container handlers.
604 typedef UInt32 CFContOpenOptions
;
607 /* Values for CFContOpenOptions.*/
608 kCFContPrepareInPlaceMask
= 0x01,
609 kCFContMinimalOpenMask
= 0x02
612 typedef UInt32 CFContCloseOptions
;
615 /* Values for CFContCloseOptions.*/
616 kCFContPartialCloseMask
= 0x01
619 typedef struct OpaqueCFContHandlerRef
* CFContHandlerRef
;
620 typedef struct CFContHandlerProcs CFContHandlerProcs
;
621 typedef CFContHandlerProcs
*CFContHandlerProcsPtr
;
622 typedef LogicalAddress (*CFContAllocateMem
)(ByteCount size
);
623 typedef void (*CFContReleaseMem
)(LogicalAddress address
);
626 ===========================================================================================
627 Container Handler Routines
628 ==========================
630 typedef OSStatus (*CFCont_OpenContainer
)(LogicalAddress mappedAddress
, LogicalAddress runningAddress
, ByteCount containerLength
, KernelProcessID runningProcessID
, const CFContHashedName
*cfragName
, CFContOpenOptions options
, CFContAllocateMem Allocate
, CFContReleaseMem Release
, CFContHandlerRef
*containerRef
, CFContHandlerProcsPtr
*handlerProcs
);
631 typedef OSStatus (*CFCont_CloseContainer
)(CFContHandlerRef containerRef
, CFContCloseOptions options
);
632 typedef OSStatus (*CFCont_GetContainerInfo
)(CFContHandlerRef containerRef
, PBVersion infoVersion
, CFContContainerInfo
*containerInfo
);
633 /* -------------------------------------------------------------------------------------------*/
634 typedef OSStatus (*CFCont_GetSectionCount
)(CFContHandlerRef containerRef
, ItemCount
*sectionCount
);
635 typedef OSStatus (*CFCont_GetSectionInfo
)(CFContHandlerRef containerRef
, ItemCount sectionIndex
, PBVersion infoVersion
, CFContSectionInfo
*sectionInfo
);
636 typedef OSStatus (*CFCont_FindSectionInfo
)(CFContHandlerRef containerRef
, const CFContHashedName
*sectionName
, PBVersion infoVersion
, ItemCount
*sectionIndex
, CFContSectionInfo
*sectionInfo
);
637 typedef OSStatus (*CFCont_SetSectionAddress
)(CFContHandlerRef containerRef
, ItemCount sectionIndex
, LogicalAddress mappedAddress
, LogicalAddress runningAddress
);
638 /* -------------------------------------------------------------------------------------------*/
639 typedef OSStatus (*CFCont_GetAnonymousSymbolLocations
)(CFContHandlerRef containerRef
, CFContLogicalLocation
*mainLocation
, CFContLogicalLocation
*initLocation
, CFContLogicalLocation
*termLocation
);
640 /* -------------------------------------------------------------------------------------------*/
641 typedef OSStatus (*CFCont_GetExportedSymbolCount
)(CFContHandlerRef containerRef
, ItemCount
*exportCount
);
642 typedef OSStatus (*CFCont_GetExportedSymbolInfo
)(CFContHandlerRef containerRef
, CFContSignedIndex exportedIndex
, PBVersion infoVersion
, CFContExportedSymbolInfo
*exportInfo
);
643 typedef OSStatus (*CFCont_FindExportedSymbolInfo
)(CFContHandlerRef containerRef
, const CFContHashedName
*exportName
, PBVersion infoVersion
, ItemCount
*exportIndex
, CFContExportedSymbolInfo
*exportInfo
);
644 /* -------------------------------------------------------------------------------------------*/
645 typedef OSStatus (*CFCont_GetImportCounts
)(CFContHandlerRef containerRef
, ItemCount
*libraryCount
, ItemCount
*symbolCount
);
646 typedef OSStatus (*CFCont_GetImportedLibraryInfo
)(CFContHandlerRef containerRef
, ItemCount libraryIndex
, PBVersion infoVersion
, CFContImportedLibraryInfo
*libraryInfo
);
647 typedef OSStatus (*CFCont_GetImportedSymbolInfo
)(CFContHandlerRef containerRef
, ItemCount symbolIndex
, PBVersion infoVersion
, CFContImportedSymbolInfo
*symbolInfo
);
648 typedef OSStatus (*CFCont_SetImportedSymbolAddress
)(CFContHandlerRef containerRef
, ItemCount symbolIndex
, LogicalAddress symbolAddress
);
649 /* -------------------------------------------------------------------------------------------*/
650 typedef OSStatus (*CFCont_UnpackSection
)(CFContHandlerRef containerRef
, ItemCount sectionIndex
, ByteCount sectionOffset
, LogicalAddress bufferAddress
, ByteCount bufferLength
);
651 typedef OSStatus (*CFCont_RelocateSection
)(CFContHandlerRef containerRef
, ItemCount sectionIndex
);
652 typedef OSStatus (*CFCont_RelocateImportsOnly
)(CFContHandlerRef containerRef
, ItemCount sectionIndex
, ItemCount libraryIndex
);
653 typedef OSStatus (*CFCont_MakeSectionExecutable
)(CFContHandlerRef containerRef
, ItemCount sectionIndex
);
654 typedef OSStatus (*CFCont_AllocateSection
)(CFContHandlerRef containerRef
, ItemCount sectionIndex
, LogicalAddress
*mappedAddress
, LogicalAddress
*runningAddress
);
655 typedef OSStatus (*CFCont_ReleaseSection
)(CFContHandlerRef containerRef
, ItemCount sectionIndex
);
656 /* -------------------------------------------------------------------------------------------*/
659 struct CFContHandlerInfo
{
660 OrderedItemName orderedName
;
661 OrderRequirements orderedReq
;
662 CFCont_OpenContainer OpenHandler
;
664 typedef struct CFContHandlerInfo CFContHandlerInfo
;
667 struct CFContHandlerProcs
{
669 CFragShortVersionPair abiVersion
;
671 CFCont_OpenContainer OpenContainer
; /* 1*/
672 CFCont_CloseContainer CloseContainer
; /* 2*/
673 CFCont_GetContainerInfo GetContainerInfo
; /* 3*/
675 CFCont_GetSectionCount GetSectionCount
; /* 4*/
676 CFCont_GetSectionInfo GetSectionInfo
; /* 5*/
677 CFCont_FindSectionInfo FindSectionInfo
; /* 6*/
678 CFCont_SetSectionAddress SetSectionAddress
; /* 7*/
680 CFCont_GetAnonymousSymbolLocations GetAnonymousSymbolLocations
; /* 8*/
682 CFCont_GetExportedSymbolCount GetExportedSymbolCount
; /* 9*/
683 CFCont_GetExportedSymbolInfo GetExportedSymbolInfo
; /* 10*/
684 CFCont_FindExportedSymbolInfo FindExportedSymbolInfo
; /* 11*/
686 CFCont_GetImportCounts GetImportCounts
; /* 12*/
687 CFCont_GetImportedLibraryInfo GetImportedLibraryInfo
; /* 13*/
688 CFCont_GetImportedSymbolInfo GetImportedSymbolInfo
; /* 14*/
689 CFCont_SetImportedSymbolAddress SetImportedSymbolAddress
; /* 15*/
691 CFCont_UnpackSection UnpackSection
; /* 16*/
692 CFCont_RelocateSection RelocateSection
; /* 17*/
693 CFCont_RelocateImportsOnly RelocateImportsOnly
; /* 18*/
694 CFCont_MakeSectionExecutable MakeSectionExecutable
; /* 19 (Opt.)*/
695 CFCont_AllocateSection AllocateSection
; /* 20 (Opt.)*/
696 CFCont_ReleaseSection ReleaseSection
; /* 21 (Opt.)*/
701 kCFContMinimumProcCount
= 18,
702 kCFContCurrentProcCount
= 21,
703 kCFContHandlerABIVersion
= 0x00010001
707 -----------------------------------------------------------------------------------------
708 The ABI version is a pair of UInt16s used as simple counters. The high order part is the
709 current version number, the low order part is the oldest compatible definition version.
710 number. This pair is to be used by the specific container handlers to describe what
711 version of the container handler ABI they support.
714 The initial release of this ABI. (The old CFLoader ABI does not count.)
716 ===========================================================================================
720 extern CFContStringHash
CFContHashName(BytePtr nameText
, ByteCount nameLength
);
724 /* -------------------------------------------------------------------------------------------*/
725 extern OSStatus
CFContOpenContainer(LogicalAddress mappedAddress
, LogicalAddress runningAddress
, ByteCount containerLength
, KernelProcessID runningProcessID
, const CFContHashedName
*cfragName
, CFContOpenOptions options
, CFContAllocateMem Allocate
, CFContReleaseMem Release
, CFContHandlerRef
*containerRef
, CFContHandlerProcsPtr
*handlerProcs
);
727 /* -------------------------------------------------------------------------------------------*/
728 extern OSStatus
CFContRegisterContainerHandler(const OrderedItemName
*orderedName
, const OrderRequirements
*orderedReq
, CFCont_OpenContainer OpenHandler
, OrderedItemName
*rejectingHandler
);
730 extern OSStatus
CFContUnregisterContainerHandler(const OrderedItemName
*orderedName
);
732 extern OSStatus
CFContGetContainerHandlers(ItemCount requestedCount
, ItemCount
*totalCount
, CFContHandlerInfo
*handlers
);
734 /* -------------------------------------------------------------------------------------------*/
745 Contains: PEF Loader Interface.
749 Copyright: © 1992-1996 by Apple Computer, Inc., all rights reserved.
755 Other Contact: <<unknown>>
757 Technology: Core Runtime
764 Change History (most recent first):
766 <7> 8/23/96 AWL (1379028) Propagate changes from CodeFragmentContainerPriv.
767 <6> 2/28/96 AWL Adapt for new container handler model.
768 <5> 6/20/94 AWL Move private PEF loader info struct here to be visible to the
769 booting "wacky" PEF loader.
770 <4> 6/8/94 AWL Make all CFL routines visible for direct use in special cases
772 <3> 5/16/94 AWL Fix typo.
773 <2> 2/25/94 AWL Update for Q&D solution to loading across address spaces.
774 <1> 2/15/94 AWL Initial checkin for kernel based CFM.
777 // ===========================================================================================
780 kBuiltinSectionArraySize
= 4
783 struct PEFPrivateInfo
{ // !!! Clean up field names, collapse Booleans, etc.
784 CFContAllocateMem Allocate
;
785 CFContReleaseMem Release
;
786 BytePtr mappedContainer
;
787 BytePtr runningContainer
;
788 ItemCount sectionCount
; // Just the instantiated sections.
789 SectionHeader
* sections
;
791 ItemCount ldrSectionNo
;
792 LoaderHeader
* ldrHeader
;
793 BytePtr ldrStringTable
;
794 LoaderRelExpHeader
* ldrSections
;
795 LoaderImportFileID
* ldrImportFiles
;
796 LoaderImport
* ldrImportSymbols
;
797 HashSlotEntry
* ldrHashSlot
;
798 HashChainEntry
* ldrHashChain
;
799 LoaderExport
* ldrExportSymbols
;
800 BytePtr ldrRelocations
;
801 BytePtr
* mappedOrigins
; // Mapped base address for each section.
802 ByteCount
* runningOffsets
; // Running offset from presumed address.
804 BytePtr originArray
[kBuiltinSectionArraySize
]; // ! Only used if big enough.
805 ByteCount offsetArray
[kBuiltinSectionArraySize
]; // ! Only used if big enough.
810 typedef struct PEFPrivateInfo PEFPrivateInfo
;
813 // ===========================================================================================
816 extern OSStatus
PEF_OpenContainer ( LogicalAddress mappedAddress
,
817 LogicalAddress runningAddress
,
818 ByteCount containerLength
,
819 KernelProcessID runningProcessID
,
820 const CFContHashedName
* cfragName
,
821 CFContOpenOptions options
,
822 CFContAllocateMem Allocate
,
823 CFContReleaseMem Release
,
824 CFContHandlerRef
* containerRef_o
,
825 CFContHandlerProcs
* * handlerProcs_o
);
827 extern OSStatus
PEF_CloseContainer ( CFContHandlerRef containerRef
,
828 CFContCloseOptions options
);
830 extern OSStatus
PEF_GetContainerInfo ( CFContHandlerRef containerRef
,
831 PBVersion infoVersion
,
832 CFContContainerInfo
* containerInfo
);
834 // -------------------------------------------------------------------------------------------
836 extern OSStatus
PEF_GetSectionCount ( CFContHandlerRef containerRef
,
837 ItemCount
* sectionCount
);
839 extern OSStatus
PEF_GetSectionInfo ( CFContHandlerRef containerRef
,
840 ItemCount sectionIndex
,
841 PBVersion infoVersion
,
842 CFContSectionInfo
* sectionInfo
);
844 extern OSStatus
PEF_FindSectionInfo ( CFContHandlerRef containerRef
,
845 const CFContHashedName
* sectionName
,
846 PBVersion infoVersion
,
847 ItemCount
* sectionIndex
, // May be null.
848 CFContSectionInfo
* sectionInfo
); // May be null.
850 extern OSStatus
PEF_SetSectionAddress ( CFContHandlerRef containerRef
,
851 ItemCount sectionIndex
,
852 LogicalAddress mappedAddress
,
853 LogicalAddress runningAddress
);
855 // -------------------------------------------------------------------------------------------
857 extern OSStatus
PEF_GetAnonymousSymbolLocations ( CFContHandlerRef containerRef
,
858 CFContLogicalLocation
* mainLocation
, // May be null.
859 CFContLogicalLocation
* initLocation
, // May be null.
860 CFContLogicalLocation
* termLocation
); // May be null.
862 // -------------------------------------------------------------------------------------------
864 extern OSStatus
PEF_GetExportedSymbolCount ( CFContHandlerRef containerRef
,
865 ItemCount
* exportCount
);
867 extern OSStatus
PEF_GetExportedSymbolInfo ( CFContHandlerRef containerRef
,
868 CFContSignedIndex exportIndex
,
869 PBVersion infoVersion
,
870 CFContExportedSymbolInfo
* exportInfo
);
872 extern OSStatus
PEF_FindExportedSymbolInfo ( CFContHandlerRef containerRef
,
873 const CFContHashedName
* exportName
,
874 PBVersion infoVersion
,
875 ItemCount
* exportIndex
, // May be null.
876 CFContExportedSymbolInfo
* exportInfo
); // May be null.
878 // -------------------------------------------------------------------------------------------
880 extern OSStatus
PEF_GetImportCounts ( CFContHandlerRef containerRef
,
881 ItemCount
* libraryCount
, // May be null.
882 ItemCount
* symbolCount
); // May be null.
884 extern OSStatus
PEF_GetImportedLibraryInfo ( CFContHandlerRef containerRef
,
885 ItemCount libraryIndex
,
886 PBVersion infoVersion
,
887 CFContImportedLibraryInfo
* libraryInfo
);
889 extern OSStatus
PEF_GetImportedSymbolInfo ( CFContHandlerRef containerRef
,
890 ItemCount symbolIndex
,
891 PBVersion infoVersion
,
892 CFContImportedSymbolInfo
* symbolInfo
);
894 extern OSStatus
PEF_SetImportedSymbolAddress ( CFContHandlerRef containerRef
,
895 ItemCount symbolIndex
,
896 LogicalAddress symbolAddress
);
898 // -------------------------------------------------------------------------------------------
900 extern OSStatus
PEF_UnpackSection ( CFContHandlerRef containerRef
,
901 ItemCount sectionIndex
,
902 ByteCount sectionOffset
,
903 LogicalAddress bufferAddress
,
904 ByteCount bufferLength
);
906 extern OSStatus
PEF_RelocateSection ( CFContHandlerRef containerRef
,
907 ItemCount sectionIndex
);
909 extern OSStatus
PEF_RelocateImportsOnly ( CFContHandlerRef containerRef
,
910 ItemCount sectionIndex
,
911 ItemCount libraryIndex
);
913 struct CFragInitBlock
{
917 SInt32 where
; // locator rec
918 LogicalAddress address
;
926 typedef struct CFragInitBlock CFragInitBlock
;
928 #pragma options align=reset
930 #endif // __IOPEFINTERNALS__