pef.h revision 1.3 1 1.3 phx /* $NetBSD: pef.h,v 1.3 2014/04/22 21:37:52 phx Exp $ */
2 1.1 garbled
3 1.1 garbled /*-
4 1.1 garbled * Copyright (C) 1995-1997 Gary Thomas (gdt (at) linuxppc.org)
5 1.1 garbled * All rights reserved.
6 1.1 garbled *
7 1.1 garbled * Structure of a PEF format file
8 1.1 garbled *
9 1.1 garbled * Redistribution and use in source and binary forms, with or without
10 1.1 garbled * modification, are permitted provided that the following conditions
11 1.1 garbled * are met:
12 1.1 garbled * 1. Redistributions of source code must retain the above copyright
13 1.1 garbled * notice, this list of conditions and the following disclaimer.
14 1.1 garbled * 2. Redistributions in binary form must reproduce the above copyright
15 1.1 garbled * notice, this list of conditions and the following disclaimer in the
16 1.1 garbled * documentation and/or other materials provided with the distribution.
17 1.1 garbled * 3. All advertising materials mentioning features or use of this software
18 1.1 garbled * must display the following acknowledgement:
19 1.1 garbled * This product includes software developed by Gary Thomas.
20 1.1 garbled * 4. The name of the author may not be used to endorse or promote products
21 1.1 garbled * derived from this software without specific prior written permission.
22 1.1 garbled *
23 1.1 garbled * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
24 1.1 garbled * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
25 1.1 garbled * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
26 1.1 garbled * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
27 1.1 garbled * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
28 1.1 garbled * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
29 1.1 garbled * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
30 1.1 garbled * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
31 1.1 garbled * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
32 1.1 garbled * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 1.1 garbled */
34 1.2 kiyohara
35 1.1 garbled struct FileHeader
36 1.1 garbled {
37 1.3 phx uint32_t magic;
38 1.3 phx uint32_t fileTypeID;
39 1.3 phx uint32_t archID;
40 1.3 phx uint32_t versionNumber;
41 1.3 phx uint32_t dateTimeStamp;
42 1.3 phx uint32_t definVersion;
43 1.3 phx uint32_t implVersion;
44 1.3 phx uint32_t currentVersion;
45 1.3 phx uint16_t numSections;
46 1.3 phx uint16_t loadableSections;
47 1.3 phx uint32_t memoryAddress;
48 1.1 garbled };
49 1.1 garbled
50 1.1 garbled #define PEF_MAGIC 0x4A6F7921 /* Joy! */
51 1.1 garbled #define PEF_FILE 0x70656666 /* peff */
52 1.2 kiyohara #define PEF_PPC 0x70777063 /* pwpc */
53 1.1 garbled
54 1.1 garbled struct SectionHeader
55 1.1 garbled {
56 1.3 phx uint32_t sectionName;
57 1.3 phx uint32_t sectionAddress;
58 1.3 phx uint32_t execSize;
59 1.3 phx uint32_t initSize;
60 1.3 phx uint32_t rawSize;
61 1.3 phx uint32_t fileOffset;
62 1.3 phx uint8_t regionKind;
63 1.3 phx uint8_t shareKind;
64 1.3 phx uint8_t alignment;
65 1.3 phx uint8_t _reserved;
66 1.1 garbled };
67 1.1 garbled
68 1.1 garbled #define CodeSection 0
69 1.1 garbled #define DataSection 1
70 1.1 garbled #define PIDataSection 2
71 1.1 garbled #define ConstantSection 3
72 1.1 garbled #define LoaderSection 4
73 1.1 garbled
74 1.1 garbled #define NeverShare 0
75 1.1 garbled #define ContextShare 1
76 1.1 garbled #define TeamShare 2
77 1.1 garbled #define TaskShare 3
78 1.2 kiyohara #define GlobalShare 4
79 1.1 garbled
80 1.1 garbled struct LoaderHeader
81 1.1 garbled {
82 1.3 phx uint32_t entryPointSection;
83 1.3 phx uint32_t entryPointOffset;
84 1.3 phx uint32_t initPointSection;
85 1.3 phx uint32_t initPointOffset;
86 1.3 phx uint32_t termPointSection;
87 1.3 phx uint32_t termPointOffset;
88 1.3 phx uint32_t numImportFiles;
89 1.3 phx uint32_t numImportSyms;
90 1.3 phx uint32_t numSections;
91 1.3 phx uint32_t relocationsOffset;
92 1.3 phx uint32_t stringsOffset;
93 1.3 phx uint32_t hashSlotTable;
94 1.3 phx uint32_t hashSlotTableSize;
95 1.3 phx uint32_t numExportSyms;
96 1.1 garbled };
97