Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | \ ========== Copyright Header Begin ========================================== |
2 | \ | |
3 | \ Hypervisor Software File: elf.fth | |
4 | \ | |
5 | \ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | \ | |
7 | \ - Do no alter or remove copyright notices | |
8 | \ | |
9 | \ - Redistribution and use of this software in source and binary forms, with | |
10 | \ or without modification, are permitted provided that the following | |
11 | \ conditions are met: | |
12 | \ | |
13 | \ - Redistribution of source code must retain the above copyright notice, | |
14 | \ this list of conditions and the following disclaimer. | |
15 | \ | |
16 | \ - Redistribution in binary form must reproduce the above copyright notice, | |
17 | \ this list of conditions and the following disclaimer in the | |
18 | \ documentation and/or other materials provided with the distribution. | |
19 | \ | |
20 | \ Neither the name of Sun Microsystems, Inc. or the names of contributors | |
21 | \ may be used to endorse or promote products derived from this software | |
22 | \ without specific prior written permission. | |
23 | \ | |
24 | \ This software is provided "AS IS," without a warranty of any kind. | |
25 | \ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES, | |
26 | \ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A | |
27 | \ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN | |
28 | \ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR | |
29 | \ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR | |
30 | \ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN | |
31 | \ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR | |
32 | \ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE | |
33 | \ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, | |
34 | \ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF | |
35 | \ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. | |
36 | \ | |
37 | \ You acknowledge that this software is not designed, licensed or | |
38 | \ intended for use in the design, construction, operation or maintenance of | |
39 | \ any nuclear facility. | |
40 | \ | |
41 | \ ========== Copyright Header End ============================================ | |
42 | id: @(#)elf.fth 1.9 01/05/18 | |
43 | purpose: | |
44 | copyright: Copyright 1991-2001 Sun Microsystems, Inc. All Rights Reserved | |
45 | ||
46 | decimal | |
47 | headerless | |
48 | ||
49 | \ | |
50 | \ ELF constants | |
51 | \ | |
52 | ||
53 | 1 constant ELFCLASS32 | |
54 | 2 constant ELFCLASS64 | |
55 | ||
56 | d# 2 constant EM_SPARC | |
57 | d# 11 constant EM_SPARC64 | |
58 | d# 18 constant EM_SPARC32PLUS | |
59 | ||
60 | 1 constant PT_LOAD | |
61 | ||
62 | 2 constant SHT_SYMTAB | |
63 | 3 constant SHT_STRTAB | |
64 | ||
65 | struct \ ELF32 File Header | |
66 | 0 field >e32_ident \ Alias for the next 16 bytes | |
67 | 4 field >e32_magicword \ \7fELF | |
68 | 1 field >e32_class \ 32- or 64-bit | |
69 | 1 field >e32_data \ endianness | |
70 | 1 field >e32_iversion \ | |
71 | 9 field >e32_pad \ ( reserved ) | |
72 | /w field >e32_type \ file type | |
73 | /w field >e32_machine \ target machine | |
74 | /l field >e32_version \ file version | |
75 | /l field >e32_entry \ start address | |
76 | /l field >e32_phoff \ phdr file offset | |
77 | /l field >e32_shoff \ shdr file offset | |
78 | /l field >e32_flags \ file flags | |
79 | /w field >e32_ehsize \ sizeof ehdr | |
80 | /w field >e32_phentsize \ sizeof phdr | |
81 | /w field >e32_phnum \ number phdrs | |
82 | /w field >e32_shentsize \ sizeof shdr | |
83 | /w field >e32_shnum \ number shdrs | |
84 | /w field >e32_shstrndx \ shdr string index | |
85 | constant /elf32-header | |
86 | ||
87 | /elf32-header buffer: elf32-header | |
88 | ||
89 | : e32_magicword ( -- n ) elf32-header >e32_magicword l@ ; | |
90 | : e32_machine ( -- n ) elf32-header >e32_machine w@ ; | |
91 | : e32_class ( -- n ) elf32-header >e32_class c@ ; | |
92 | : e32_entry ( -- n ) elf32-header >e32_entry l@ ; | |
93 | : e32_phoff ( -- n ) elf32-header >e32_phoff l@ ; | |
94 | : e32_phentsize ( -- n ) elf32-header >e32_phentsize w@ ; | |
95 | : e32_phnum ( -- n ) elf32-header >e32_phnum w@ ; | |
96 | : e32_shoff ( -- n ) elf32-header >e32_shoff l@ ; | |
97 | : e32_shentsize ( -- n ) elf32-header >e32_shentsize w@ ; | |
98 | : e32_shnum ( -- n ) elf32-header >e32_shnum w@ ; | |
99 | ||
100 | struct \ ELF32 Program Header | |
101 | /l field >p32_type \ entry type | |
102 | /l field >p32_offset \ file offset | |
103 | /l field >p32_vaddr \ virtual address | |
104 | /l field >p32_paddr \ physical address | |
105 | /l field >p32_filesz \ file size | |
106 | /l field >p32_memsz \ memory size | |
107 | /l field >p32_flags \ entry flags | |
108 | /l field >p32_align \ memory/file alignment | |
109 | constant /elf32-pheader | |
110 | ||
111 | /elf32-pheader buffer: elf32-pheader | |
112 | ||
113 | : p32_type ( -- n ) elf32-pheader >p32_type l@ ; | |
114 | : p32_offset ( -- n ) elf32-pheader >p32_offset l@ ; | |
115 | : p32_vaddr ( -- n ) elf32-pheader >p32_vaddr l@ ; | |
116 | : p32_filesz ( -- n ) elf32-pheader >p32_filesz l@ ; | |
117 | : p32_memsz ( -- n ) elf32-pheader >p32_memsz l@ ; | |
118 | : p32_flags ( -- n ) elf32-pheader >p32_flags l@ ; | |
119 | : p32_align ( -- n ) elf32-pheader >p32_align l@ ; | |
120 | ||
121 | struct \ ELF32 Section Header | |
122 | /l field >sh32_name \ section name | |
123 | /l field >sh32_type \ section type | |
124 | /l field >sh32_flags \ section flags | |
125 | /l field >sh32_addr \ virtual address | |
126 | /l field >sh32_offset \ file offset | |
127 | /l field >sh32_size \ section size | |
128 | /l field >sh32_link \ misc info | |
129 | /l field >sh32_info \ misc info | |
130 | /l field >sh32_addralign \ memory alignment | |
131 | /l field >sh32_entsize \ entry size if table | |
132 | constant /elf32-sheader | |
133 | ||
134 | /elf32-sheader buffer: elf32-sheader | |
135 | ||
136 | : sh32_flags ( -- n ) elf32-sheader >sh32_flags l@ ; | |
137 | : sh32_type ( -- n ) elf32-sheader >sh32_type l@ ; | |
138 | : sh32_offset ( -- n ) elf32-sheader >sh32_offset l@ ; | |
139 | : sh32_size ( -- n ) elf32-sheader >sh32_size l@ ; | |
140 | : sh32_link ( -- n ) elf32-sheader >sh32_link l@ ; | |
141 | ||
142 | struct \ ELF32 symbol table entry | |
143 | /l field st32_name | |
144 | /l field st32_value | |
145 | /l field st32_size | |
146 | /c field st32_info | |
147 | /c field st32_other | |
148 | /w field st32_shndx | |
149 | constant /elf32-symbol | |
150 | headers |