17c478bd9Sstevel@tonic-gate 27c478bd9Sstevel@tonic-gate /*- 37c478bd9Sstevel@tonic-gate * Copyright (c) 1992, 1993 47c478bd9Sstevel@tonic-gate * The Regents of the University of California. All rights reserved. 57c478bd9Sstevel@tonic-gate * 67c478bd9Sstevel@tonic-gate * Redistribution and use in source and binary forms, with or without 77c478bd9Sstevel@tonic-gate * modification, are permitted provided that the following conditions 87c478bd9Sstevel@tonic-gate * are met: 97c478bd9Sstevel@tonic-gate * 1. Redistributions of source code must retain the above copyright 107c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer. 117c478bd9Sstevel@tonic-gate * 2. Redistributions in binary form must reproduce the above copyright 127c478bd9Sstevel@tonic-gate * notice, this list of conditions and the following disclaimer in the 137c478bd9Sstevel@tonic-gate * documentation and/or other materials provided with the distribution. 147c478bd9Sstevel@tonic-gate * 3. All advertising materials mentioning features or use of this software 157c478bd9Sstevel@tonic-gate * must display the following acknowledgement: 167c478bd9Sstevel@tonic-gate * This product includes software developed by the University of 177c478bd9Sstevel@tonic-gate * California, Berkeley and its contributors. 187c478bd9Sstevel@tonic-gate * 4. Neither the name of the University nor the names of its contributors 197c478bd9Sstevel@tonic-gate * may be used to endorse or promote products derived from this software 207c478bd9Sstevel@tonic-gate * without specific prior written permission. 217c478bd9Sstevel@tonic-gate * 227c478bd9Sstevel@tonic-gate * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 237c478bd9Sstevel@tonic-gate * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 247c478bd9Sstevel@tonic-gate * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 257c478bd9Sstevel@tonic-gate * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 267c478bd9Sstevel@tonic-gate * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 277c478bd9Sstevel@tonic-gate * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 287c478bd9Sstevel@tonic-gate * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 297c478bd9Sstevel@tonic-gate * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 307c478bd9Sstevel@tonic-gate * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 317c478bd9Sstevel@tonic-gate * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 327c478bd9Sstevel@tonic-gate * SUCH DAMAGE. 337c478bd9Sstevel@tonic-gate * 347c478bd9Sstevel@tonic-gate * from: @(#)exec.h 8.1 (Berkeley) 6/11/93 357c478bd9Sstevel@tonic-gate * $Id: imgact_aout.h,v 1.1.1.1 2003/11/20 02:04:59 fengshuo Exp $ 367c478bd9Sstevel@tonic-gate */ 377c478bd9Sstevel@tonic-gate /* 387c478bd9Sstevel@tonic-gate * 11/23/95 - Kludge to get "ntohl" null macro added. -- ESB 397c478bd9Sstevel@tonic-gate * - and for __LDPGSZ 407c478bd9Sstevel@tonic-gate */ 417c478bd9Sstevel@tonic-gate 427c478bd9Sstevel@tonic-gate #ifndef _IMGACT_AOUT_H_ 437c478bd9Sstevel@tonic-gate #define _IMGACT_AOUT_H_ 447c478bd9Sstevel@tonic-gate 457c478bd9Sstevel@tonic-gate /* XXX ESB */ 467c478bd9Sstevel@tonic-gate #define ntohl(x) ((x << 24) | ((x & 0xFF00) << 8) \ 477c478bd9Sstevel@tonic-gate | ((x >> 8) & 0xFF00) | (x >> 24)) 487c478bd9Sstevel@tonic-gate #define htonl(x) ntohl(x) 497c478bd9Sstevel@tonic-gate #define __LDPGSZ 0x1000 507c478bd9Sstevel@tonic-gate 517c478bd9Sstevel@tonic-gate #define N_GETMAGIC(ex) \ 527c478bd9Sstevel@tonic-gate ( (ex).a_midmag & 0xffff ) 537c478bd9Sstevel@tonic-gate #define N_GETMID(ex) \ 547c478bd9Sstevel@tonic-gate ( (N_GETMAGIC_NET(ex) == ZMAGIC) ? N_GETMID_NET(ex) : \ 557c478bd9Sstevel@tonic-gate ((ex).a_midmag >> 16) & 0x03ff ) 567c478bd9Sstevel@tonic-gate #define N_GETFLAG(ex) \ 577c478bd9Sstevel@tonic-gate ( (N_GETMAGIC_NET(ex) == ZMAGIC) ? N_GETFLAG_NET(ex) : \ 587c478bd9Sstevel@tonic-gate ((ex).a_midmag >> 26) & 0x3f ) 597c478bd9Sstevel@tonic-gate #define N_SETMAGIC(ex,mag,mid,flag) \ 607c478bd9Sstevel@tonic-gate ( (ex).a_midmag = (((flag) & 0x3f) <<26) | (((mid) & 0x03ff) << 16) | \ 617c478bd9Sstevel@tonic-gate ((mag) & 0xffff) ) 627c478bd9Sstevel@tonic-gate 637c478bd9Sstevel@tonic-gate #define N_GETMAGIC_NET(ex) \ 647c478bd9Sstevel@tonic-gate (ntohl((ex).a_midmag) & 0xffff) 657c478bd9Sstevel@tonic-gate #define N_GETMID_NET(ex) \ 667c478bd9Sstevel@tonic-gate ((ntohl((ex).a_midmag) >> 16) & 0x03ff) 677c478bd9Sstevel@tonic-gate #define N_GETFLAG_NET(ex) \ 687c478bd9Sstevel@tonic-gate ((ntohl((ex).a_midmag) >> 26) & 0x3f) 697c478bd9Sstevel@tonic-gate #define N_SETMAGIC_NET(ex,mag,mid,flag) \ 707c478bd9Sstevel@tonic-gate ( (ex).a_midmag = htonl( (((flag)&0x3f)<<26) | (((mid)&0x03ff)<<16) | \ 717c478bd9Sstevel@tonic-gate (((mag)&0xffff)) ) ) 727c478bd9Sstevel@tonic-gate 737c478bd9Sstevel@tonic-gate #define N_ALIGN(ex,x) \ 747c478bd9Sstevel@tonic-gate (N_GETMAGIC(ex) == ZMAGIC || N_GETMAGIC(ex) == QMAGIC || \ 757c478bd9Sstevel@tonic-gate N_GETMAGIC_NET(ex) == ZMAGIC || N_GETMAGIC_NET(ex) == QMAGIC ? \ 767c478bd9Sstevel@tonic-gate ((x) + __LDPGSZ - 1) & ~(unsigned long)(__LDPGSZ - 1) : (x)) 777c478bd9Sstevel@tonic-gate 787c478bd9Sstevel@tonic-gate /* Valid magic number check. */ 797c478bd9Sstevel@tonic-gate #define N_BADMAG(ex) \ 807c478bd9Sstevel@tonic-gate (N_GETMAGIC(ex) != OMAGIC && N_GETMAGIC(ex) != NMAGIC && \ 817c478bd9Sstevel@tonic-gate N_GETMAGIC(ex) != ZMAGIC && N_GETMAGIC(ex) != QMAGIC && \ 827c478bd9Sstevel@tonic-gate N_GETMAGIC_NET(ex) != OMAGIC && N_GETMAGIC_NET(ex) != NMAGIC && \ 837c478bd9Sstevel@tonic-gate N_GETMAGIC_NET(ex) != ZMAGIC && N_GETMAGIC_NET(ex) != QMAGIC) 847c478bd9Sstevel@tonic-gate 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate /* Address of the bottom of the text segment. */ 877c478bd9Sstevel@tonic-gate #define N_TXTADDR(ex) \ 887c478bd9Sstevel@tonic-gate ((N_GETMAGIC(ex) == OMAGIC || N_GETMAGIC(ex) == NMAGIC || \ 897c478bd9Sstevel@tonic-gate N_GETMAGIC(ex) == ZMAGIC) ? 0 : __LDPGSZ) 907c478bd9Sstevel@tonic-gate 917c478bd9Sstevel@tonic-gate /* Address of the bottom of the data segment. */ 927c478bd9Sstevel@tonic-gate #define N_DATADDR(ex) \ 937c478bd9Sstevel@tonic-gate N_ALIGN(ex, N_TXTADDR(ex) + (ex).a_text) 947c478bd9Sstevel@tonic-gate 957c478bd9Sstevel@tonic-gate /* Text segment offset. */ 967c478bd9Sstevel@tonic-gate #define N_TXTOFF(ex) \ 977c478bd9Sstevel@tonic-gate (N_GETMAGIC(ex) == ZMAGIC ? __LDPGSZ : (N_GETMAGIC(ex) == QMAGIC || \ 987c478bd9Sstevel@tonic-gate N_GETMAGIC_NET(ex) == ZMAGIC) ? 0 : sizeof(struct exec)) 997c478bd9Sstevel@tonic-gate 1007c478bd9Sstevel@tonic-gate /* Data segment offset. */ 1017c478bd9Sstevel@tonic-gate #define N_DATOFF(ex) \ 1027c478bd9Sstevel@tonic-gate N_ALIGN(ex, N_TXTOFF(ex) + (ex).a_text) 1037c478bd9Sstevel@tonic-gate 1047c478bd9Sstevel@tonic-gate /* Relocation table offset. */ 1057c478bd9Sstevel@tonic-gate #define N_RELOFF(ex) \ 1067c478bd9Sstevel@tonic-gate N_ALIGN(ex, N_DATOFF(ex) + (ex).a_data) 1077c478bd9Sstevel@tonic-gate 1087c478bd9Sstevel@tonic-gate /* Symbol table offset. */ 1097c478bd9Sstevel@tonic-gate #define N_SYMOFF(ex) \ 1107c478bd9Sstevel@tonic-gate (N_RELOFF(ex) + (ex).a_trsize + (ex).a_drsize) 1117c478bd9Sstevel@tonic-gate 1127c478bd9Sstevel@tonic-gate /* String table offset. */ 1137c478bd9Sstevel@tonic-gate #define N_STROFF(ex) (N_SYMOFF(ex) + (ex).a_syms) 1147c478bd9Sstevel@tonic-gate 1157c478bd9Sstevel@tonic-gate /* 1167c478bd9Sstevel@tonic-gate * Header prepended to each a.out file. 1177c478bd9Sstevel@tonic-gate * only manipulate the a_midmag field via the 1187c478bd9Sstevel@tonic-gate * N_SETMAGIC/N_GET{MAGIC,MID,FLAG} macros in a.out.h 1197c478bd9Sstevel@tonic-gate */ 1207c478bd9Sstevel@tonic-gate 1217c478bd9Sstevel@tonic-gate struct exec 1227c478bd9Sstevel@tonic-gate { 1237c478bd9Sstevel@tonic-gate unsigned long a_midmag; /* htonl(flags<<26 | mid<<16 | magic) */ 1247c478bd9Sstevel@tonic-gate unsigned long a_text; /* text segment size */ 1257c478bd9Sstevel@tonic-gate unsigned long a_data; /* initialized data size */ 1267c478bd9Sstevel@tonic-gate unsigned long a_bss; /* uninitialized data size */ 1277c478bd9Sstevel@tonic-gate unsigned long a_syms; /* symbol table size */ 1287c478bd9Sstevel@tonic-gate unsigned long a_entry; /* entry point */ 1297c478bd9Sstevel@tonic-gate unsigned long a_trsize; /* text relocation size */ 1307c478bd9Sstevel@tonic-gate unsigned long a_drsize; /* data relocation size */ 1317c478bd9Sstevel@tonic-gate }; 1327c478bd9Sstevel@tonic-gate #define a_magic a_midmag /* XXX Hack to work with current kern_execve.c */ 1337c478bd9Sstevel@tonic-gate 1347c478bd9Sstevel@tonic-gate /* a_magic */ 1357c478bd9Sstevel@tonic-gate #define OMAGIC 0x107 /* 0407 old impure format */ 1367c478bd9Sstevel@tonic-gate #define NMAGIC 0x108 /* 0410 read-only text */ 1377c478bd9Sstevel@tonic-gate #define ZMAGIC 0x10b /* 0413 demand load format */ 1387c478bd9Sstevel@tonic-gate #define QMAGIC 0xcc /* 0314 "compact" demand load format */ 1397c478bd9Sstevel@tonic-gate 1407c478bd9Sstevel@tonic-gate /* a_mid */ 1417c478bd9Sstevel@tonic-gate #define MID_ZERO 0 /* unknown - implementation dependent */ 1427c478bd9Sstevel@tonic-gate #define MID_SUN010 1 /* sun 68010/68020 binary */ 1437c478bd9Sstevel@tonic-gate #define MID_SUN020 2 /* sun 68020-only binary */ 1447c478bd9Sstevel@tonic-gate #define MID_I386 134 /* i386 BSD binary */ 1457c478bd9Sstevel@tonic-gate #define MID_SPARC 138 /* sparc */ 1467c478bd9Sstevel@tonic-gate #define MID_HP200 200 /* hp200 (68010) BSD binary */ 1477c478bd9Sstevel@tonic-gate #define MID_HP300 300 /* hp300 (68020+68881) BSD binary */ 1487c478bd9Sstevel@tonic-gate #define MID_HPUX 0x20C /* hp200/300 HP-UX binary */ 1497c478bd9Sstevel@tonic-gate #define MID_HPUX800 0x20B /* hp800 HP-UX binary */ 1507c478bd9Sstevel@tonic-gate 1517c478bd9Sstevel@tonic-gate /* 1527c478bd9Sstevel@tonic-gate * a_flags 1537c478bd9Sstevel@tonic-gate */ 1547c478bd9Sstevel@tonic-gate #define EX_PIC 0x10 /* contains position independant code */ 1557c478bd9Sstevel@tonic-gate #define EX_DYNAMIC 0x20 /* contains run-time link-edit info */ 1567c478bd9Sstevel@tonic-gate #define EX_DPMASK 0x30 /* mask for the above */ 1577c478bd9Sstevel@tonic-gate 1587c478bd9Sstevel@tonic-gate #endif /* !_IMGACT_AOUT_H_ */ 159