\ ========== Copyright Header Begin ==========================================
\ Hypervisor Software File: common.fth
\ Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
\ - Do no alter or remove copyright notices
\ - Redistribution and use of this software in source and binary forms, with
\ or without modification, are permitted provided that the following
\ - Redistribution of source code must retain the above copyright notice,
\ this list of conditions and the following disclaimer.
\ - Redistribution in binary form must reproduce the above copyright notice,
\ this list of conditions and the following disclaimer in the
\ documentation and/or other materials provided with the distribution.
\ Neither the name of Sun Microsystems, Inc. or the names of contributors
\ may be used to endorse or promote products derived from this software
\ without specific prior written permission.
\ This software is provided "AS IS," without a warranty of any kind.
\ ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND WARRANTIES,
\ INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY, FITNESS FOR A
\ PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY EXCLUDED. SUN
\ MICROSYSTEMS, INC. ("SUN") AND ITS LICENSORS SHALL NOT BE LIABLE FOR
\ ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
\ DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES. IN NO EVENT WILL SUN
\ OR ITS LICENSORS BE LIABLE FOR ANY LOST REVENUE, PROFIT OR DATA, OR
\ FOR DIRECT, INDIRECT, SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE
\ DAMAGES, HOWEVER CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY,
\ ARISING OUT OF THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF
\ SUN HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
\ You acknowledge that this software is not designed, licensed or
\ intended for use in the design, construction, operation or maintenance of
\ ========== Copyright Header End ============================================
id: @(#)common.fth 1.2 06/02/16
copyright: Copyright 2006 Sun Microsystems, Inc. All Rights Reserved
copyright: Use is subject to license terms.
here over allot place-cstr drop
<# u#s u#> here over allot place-cstr drop
obp-release count ,string
compile-signature compile-date$ ,string
banner-name$ dup if " " ,string ,string else 2drop then
sub-release count ?dup if " " ,string ,string else drop then
also assembler definitions
: >prom-addr ( symbol -- pa ) obj-base - eprom-pa + ;
: $set-external ( name$ register -- )
0 r@ sethi ( $name ) ( r: reg )
2>r here obj-base - 4 - 2r> ( adr $name ) ( r: reg )
3dup ( adr $name adr $name ) ( r: reg )
$set-reference-hi22 ( adr name$ ) ( r: reg )
here obj-base - 4 - -rot ( adr adr2 name$ )
$set-reference-lo10 ( adr )
: $export-procedure ( adr name$ -- )
rot obj-base - -rot external-procedure $add-symbol
: $acall ( procedure-name$ -- )
here call \ make space for relocatable addr
here 4 - obj-base - ( procedure-name$ offset )
-rot $add-call \ symtab entry
also srassembler alias $export-procedure $export-procedure previous
h# 20 - \ Drop-in Header Size
dropin-magic obj-base 0 la+ l! \ MAGIC
dropin-size obj-base 1 la+ l! \ Size
0 obj-base 2 la+ l! \ Reserved
0 obj-base 3 la+ l! \ Reserved
" OBP" obj-base 4 la+ place-cstr drop
compile-signature xlsplit obj-base d# 11 wa+ w!
( date.time ) obj-base d# 6 la+ l!
major-release# obj-base d# 28 ca+ c!
minor-release# obj-base d# 29 ca+ c!
patch-release# obj-base d# 30 ca+ c!
h# 7f obj-base d# 31 ca+ c!
/elf32-header /section-headers + ( first-offset )
/section-names 1 !loc \ Section name table size
obj-size 2 !loc \ Text size
/relocation-table 5 !loc \ Text reloc. table size
0 6 !loc \ Data reloc. table size
/symbol-table 7 !loc \ Symbol table size
/string-table 8 !loc \ String table size
default-elf-header /elf32-header ofd @ fputs \ ELF header
section-headers /section-headers ofd @ fputs \ Section headers
section-names /section-names ofd @ fputs \ Section name table
obj-base obj-size ofd @ fputs
relocation-table /relocation-table ofd @ fputs
symbol-table /symbol-table ofd @ fputs
string-table /string-table ofd @ fputs
[ also assembler ] init-labels [ previous ]
h# 1000 [ also assembler ] .align [ previous ]
p" reset.symbols" new-file ofd @ is symbol.fd
" # This is a machine generated file"r"n" symbol.fd fputs
end-code here obj-base - to obj-size
symbol.fd ?dup if fclose then
depth 0< if ." underflowed" else ." mangled" then
" trace: " symbol.fd fputs
here obj-base - push-hex (u.) pop-base symbol.fd fputs
push-hex (u.) pop-base symbol.fd fputs
." end-code missing from " lastacf .name
." .. Sequential labels are not allowed!!" cr
align here transient value resident
lastacf >name name>string symbol.fd fputs
lastacf execute obj-base - push-hex (u.) pop-base symbol.fd fputs
also assembler definitions
0 to in-label? (check-stack)