Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / obp / obp / os / sun / elf64.fth
CommitLineData
920dae64
AT
1\ ========== Copyright Header Begin ==========================================
2\
3\ Hypervisor Software File: elf64.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 ============================================
42id: @(#)elf64.fth 1.3 01/04/06
43purpose:
44copyright: Copyright 1991-2001 Sun Microsystems, Inc. All Rights Reserved
45
46\
47\ ELF-64
48\
49
50struct \ ELF64 File Header
51 0 field >e64_ident \ Alias for the next 16 bytes
52
53 \ Subfields within "ident"
54 4 field >e64_magicword \ <7f>ELF
55 1 field >e64_class \ 32- or 64-bit
56 1 field >e64_data \ endianness
57 1 field >e64_iversion \
58 9 field >e64_pad \ ( reserved )
59
60 /w field >e64_type \ file type
61 /w field >e64_machine \ target machine
62 /l field >e64_version \ file version
63 /x field >e64_entry \ start address
64 /x field >e64_phoff \ phdr file offset
65 /x field >e64_shoff \ shdr file offset
66 /l field >e64_flags \ file flags
67 /w field >e64_ehsize \ sizeof ehdr
68 /w field >e64_phentsize \ sizeof phdr
69 /w field >e64_phnum \ number phdrs
70 /w field >e64_shentsize \ sizeof shdr
71 /w field >e64_shnum \ number shdrs
72 /w field >e64_shstrndx \ shdr string index
73constant /elf64-header
74
75/elf64-header buffer: elf64-header
76
77: e64_magicword ( -- n ) elf64-header >e64_magicword l@ ;
78: e64_machine ( -- n ) elf64-header >e64_machine w@ ;
79: e64_class ( -- n ) elf64-header >e64_class c@ ;
80: e64_entry ( -- n ) elf64-header >e64_entry x@ ;
81: e64_phoff ( -- n ) elf64-header >e64_phoff x@ ;
82: e64_phentsize ( -- n ) elf64-header >e64_phentsize w@ ;
83: e64_phnum ( -- n ) elf64-header >e64_phnum w@ ;
84: e64_shoff ( -- n ) elf64-header >e64_shoff x@ ;
85: e64_shentsize ( -- n ) elf64-header >e64_shentsize w@ ;
86: e64_shnum ( -- n ) elf64-header >e64_shnum w@ ;
87
88struct \ ELF64 Program Header
89 /l field >p64_type \ entry type
90 /l field >p64_flags \ entry flags
91 /x field >p64_offset \ file offset
92 /x field >p64_vaddr \ virtual address
93 /x field >p64_paddr \ physical address
94 /x field >p64_filesz \ file size
95 /x field >p64_memsz \ memory size
96 /x field >p64_align \ memory/file alignment
97constant /elf64-pheader
98
99/elf64-pheader buffer: elf64-pheader
100
101: p64_type ( -- n ) elf64-pheader >p64_type l@ ;
102: p64_flags ( -- n ) elf64-pheader >p64_flags l@ ;
103: p64_offset ( -- n ) elf64-pheader >p64_offset x@ ;
104: p64_vaddr ( -- n ) elf64-pheader >p64_vaddr x@ ;
105: p64_paddr ( -- n ) elf64-pheader >p64_paddr x@ ;
106: p64_filesz ( -- n ) elf64-pheader >p64_filesz x@ ;
107: p64_memsz ( -- n ) elf64-pheader >p64_memsz x@ ;
108: p64_align ( -- n ) elf64-pheader >p64_align x@ ;
109
110struct \ ELF64 Section Header
111 /l field >sh64_name \ section name
112 /l field >sh64_type \ section type
113 /x field >sh64_flags \ section flags
114 /x field >sh64_addr \ virtual address
115 /x field >sh64_offset \ file offset
116 /x field >sh64_size \ section size
117 /l field >sh64_link \ misc info
118 /l field >sh64_info \ misc info
119 /x field >sh64_addralign \ memory alignment
120 /x field >sh64_entsize \ entry size if table
121constant /elf64-sheader
122
123/elf64-sheader buffer: elf64-sheader
124
125: sh64_flags ( -- n ) elf64-sheader >sh64_flags x@ ;
126: sh64_type ( -- n ) elf64-sheader >sh64_type l@ ;
127: sh64_offset ( -- n ) elf64-sheader >sh64_offset x@ ;
128: sh64_size ( -- n ) elf64-sheader >sh64_size x@ ;
129: sh64_link ( -- n ) elf64-sheader >sh64_link l@ ;
130
131struct \ ELF64 symbol table entry
132 /l field st64_name
133 /c field st64_info
134 /c field st64_other
135 /w field st64_shndx
136 /x field st64_value
137 /x field st64_size
138constant /elf64-symbol