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 8 - PEF Structure


PEF Sections

A PEF container can contain any number of sections. A section usually contains code or data. A special case is the loader section, which is discussed separately in "The Loader Section" (page 8-15). For each section there is a header, which includes information such as the type of section, its presumed runtime address, its size, and so on, and a corresponding section contents area.

Sections are numbered from 0, based on the position of their header, and the sections are identified by these numbers. However, the corresponding section contents do not have to be in the same order as the section headers. The only requirement is that instantiated section headers (that is, headers for sections containing code or data) must precede noninstantiated ones in the section header array.

The section header data structure is of fixed size (28 bytes) and has the form shown in Listing 8-2.

Listing 8-2 Section header data structure

struct PEFSectionHeader {
   SInt32nameOffset;  
   UInt32defaultAddress; 
   UInt32totalSize;   
   UInt32unpackedSize; 
   UInt32packedSize;  
   UInt32containerOffset; 
   UInt8 sectionKind; 
   UInt8 shareKind;   
   UInt8 alignment;   
   UInt8 reservedA;   
};
The fields in the section header are as follows:

Table 8-1 shows the various types of sections that can appear in PEF containers and the corresponding value in the sectionKind field.
Table 8-1 Section types
ValueTypeInstantiated?Description
0CodeYesContains read-only executable code in an uncompressed binary format. A container can have any number of code sections.

Code sections are always shared.

1Unpacked dataYesContains uncompressed, initialized, read/write data followed by zero-initialized read/write data.

A container can have any number of data sections, each with a different sharing option.

2Pattern- initialized dataYesContains read/write data initialized by a pattern specification contained in the section's contents. The contents essentially contain a small program that tells the Code Fragment Manager how to initialize the raw data in memory.

A container can have any number of pattern-initialized data sections, each with its own sharing option.

See "Pattern-Initialized Data" (page 8-10) for more information about creating pattern specifications.

3ConstantYesContains uncompressed, initialized, read-only data.

A container can have any number of constant sections, and they are implicitly shared.

 
4LoaderNoContains information about imports, exports, and entry points. See "The Loader Section" (page 8-15) for more details.

A container can have only one loader section.

5DebugN/AReserved for future use.
6Executable
data
YesContains information that is both executable and modifiable. For example, this section can store code that contains embedded data.

A container can have any number of executable data sections, each with a different sharing option.

7ExceptionN/AReserved for future use.
8TracebackN/AReserved for future use.

Table 8-2 shows the sharing options available for PEF sections and the corresponding value in the shareKind field.
Table 8-2 Sharing options
TypeValueDescription
Process share1Indicates that the section is shared within a process, but a fresh copy is created for different processes.
Global share4Indicates that the section is shared between all processes in the system.
Protected share5Indicates that the section is shared between all processes, but is protected. Protected sections are read/write in privileged mode and read-only in user mode.

This option is not available in System 7.


Subtopics
The Section Name Table
Section Contents

Previous Book Contents Book Index Next

© Apple Computer, Inc.
11 MARCH 1997