summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoretheisen <etheisen@cvs.openbsd.org>1996-05-22 07:44:30 +0000
committeretheisen <etheisen@cvs.openbsd.org>1996-05-22 07:44:30 +0000
commitf81cea35aade6dbde949e6ce0da380f0bf1a9bd2 (patch)
tree7fa423b6e5630bc920ae0a43747394e3276f042e
parenta6b26ed9660e431f0a82248e9d49d0ab3065c45b (diff)
Moved contents of elf_abi.h into exec_elf.h. Modified dependant files to
reflect this.
-rw-r--r--sys/kern/exec_elf.c42
-rw-r--r--sys/sys/exec_elf.h456
2 files changed, 380 insertions, 118 deletions
diff --git a/sys/kern/exec_elf.c b/sys/kern/exec_elf.c
index 38906cb449d..0e26a32fe40 100644
--- a/sys/kern/exec_elf.c
+++ b/sys/kern/exec_elf.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec_elf.c,v 1.5 1996/04/18 17:15:52 niklas Exp $ */
+/* $OpenBSD: exec_elf.c,v 1.6 1996/05/22 07:44:28 etheisen Exp $ */
/* $NetBSD: exec_elf.c,v 1.6 1996/02/09 18:59:18 christos Exp $ */
/*
@@ -159,17 +159,17 @@ elf_check_header(eh, type)
int type;
{
- if (bcmp(eh->e_ident, Elf32_e_ident, Elf32_e_siz) != 0)
+ if (bcmp(eh->e_ident, ELFMAG, SELFMAG) != 0)
return ENOEXEC;
switch (eh->e_machine) {
/* XXX */
#ifdef i386
- case Elf32_em_386:
- case Elf32_em_486:
+ case EM_386:
+ case EM_486:
#endif
#ifdef sparc
- case Elf32_em_sparc:
+ case EM_SPARC:
#endif
break;
@@ -217,9 +217,9 @@ elf_load_psection(vcset, vp, ph, addr, size, prot)
diff = uaddr - *addr;
}
- *prot |= (ph->p_flags & Elf32_pf_r) ? VM_PROT_READ : 0;
- *prot |= (ph->p_flags & Elf32_pf_w) ? VM_PROT_WRITE : 0;
- *prot |= (ph->p_flags & Elf32_pf_x) ? VM_PROT_EXECUTE : 0;
+ *prot |= (ph->p_flags & PF_R) ? VM_PROT_READ : 0;
+ *prot |= (ph->p_flags & PF_W) ? VM_PROT_WRITE : 0;
+ *prot |= (ph->p_flags & PF_X) ? VM_PROT_EXECUTE : 0;
offset = ph->p_offset - diff;
*size = ph->p_filesz + diff;
@@ -305,7 +305,7 @@ elf_load_file(p, path, vcset, entry, ap, last)
sizeof(eh))) != 0)
goto bad;
- if ((error = elf_check_header(&eh, Elf32_et_dyn)) != 0)
+ if ((error = elf_check_header(&eh, ET_DYN)) != 0)
goto bad;
phsize = eh.e_phnum * sizeof(Elf32_Phdr);
@@ -323,7 +323,7 @@ elf_load_file(p, path, vcset, entry, ap, last)
int prot = 0;
switch (ph[i].p_type) {
- case Elf32_pt_load:
+ case PT_LOAD:
elf_load_psection(vcset, nd.ni_vp, &ph[i], &addr,
&size, &prot);
/* If entry is within this section it must be text */
@@ -335,9 +335,9 @@ elf_load_file(p, path, vcset, entry, ap, last)
addr += size;
break;
- case Elf32_pt_dynamic:
- case Elf32_pt_phdr:
- case Elf32_pt_note:
+ case PT_DYNAMIC:
+ case PT_PHDR:
+ case PT_NOTE:
break;
default:
@@ -380,7 +380,7 @@ exec_elf_makecmds(p, epp)
if (epp->ep_hdrvalid < sizeof(Elf32_Ehdr))
return ENOEXEC;
- if (elf_check_header(eh, Elf32_et_exec))
+ if (elf_check_header(eh, ET_EXEC))
return ENOEXEC;
/*
@@ -413,7 +413,7 @@ exec_elf_makecmds(p, epp)
for (i = 0; i < eh->e_phnum; i++) {
pp = &ph[i];
- if (pp->p_type == Elf32_pt_interp) {
+ if (pp->p_type == PT_INTERP) {
if (pp->p_filesz >= sizeof(interp))
goto bad;
if ((error = elf_read_from(p, epp->ep_vp, pp->p_offset,
@@ -452,7 +452,7 @@ exec_elf_makecmds(p, epp)
pp = &ph[i];
switch (ph[i].p_type) {
- case Elf32_pt_load:
+ case PT_LOAD:
/*
* XXX
* Can handle only 2 sections: text and data
@@ -474,17 +474,17 @@ exec_elf_makecmds(p, epp)
}
break;
- case Elf32_pt_shlib:
+ case PT_SHLIB:
error = ENOEXEC;
goto bad;
- case Elf32_pt_interp:
+ case PT_INTERP:
/* Already did this one */
- case Elf32_pt_dynamic:
- case Elf32_pt_note:
+ case PT_DYNAMIC:
+ case PT_NOTE:
break;
- case Elf32_pt_phdr:
+ case PT_PHDR:
/* Note address of program headers (in text segment) */
phdr = pp->p_vaddr;
break;
diff --git a/sys/sys/exec_elf.h b/sys/sys/exec_elf.h
index 06738b6c5bd..9b920bb4ac2 100644
--- a/sys/sys/exec_elf.h
+++ b/sys/sys/exec_elf.h
@@ -1,8 +1,6 @@
-/* $OpenBSD: exec_elf.h,v 1.3 1996/03/03 12:11:42 niklas Exp $ */
-/* $NetBSD: exec_elf.h,v 1.2 1996/01/16 23:19:43 fvdl Exp $ */
-
+/* $OpenBSD: exec_elf.h,v 1.4 1996/05/22 07:44:29 etheisen Exp $ */
/*
- * Copyright (c) 1994 Christos Zoulas
+ * Copyright (c) 1995, 1996 Erik Theisen
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -28,129 +26,362 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+/*
+ * This is the ELF ABI header file
+ * formerly known as "elf_abi.h".
+ */
+
#ifndef _SYS_EXEC_ELF_H_
#define _SYS_EXEC_ELF_H_
#include <machine/types.h>
-typedef u_int32_t Elf32_Addr;
-typedef u_int32_t Elf32_Off;
-typedef int32_t Elf32_Sword;
-typedef u_int32_t Elf32_Word;
-typedef u_int16_t Elf32_Half;
+/*
+ * These typedefs need to be handled better -
+ * doesn't work on 64-bit machines. Note:
+ * there currently isn't a 64-bit ABI.
+ */
+typedef u_int32_t Elf32_Addr; /* Unsigned program address */
+typedef u_int32_t Elf32_Off; /* Unsigned file offset */
+typedef int32_t Elf32_Sword; /* Signed large integer */
+typedef u_int32_t Elf32_Word; /* Unsigned large integer */
+typedef u_int16_t Elf32_Half; /* Unsigned medium integer */
+/* e_ident[] identification indexes */
+#define EI_MAG0 0 /* file ID */
+#define EI_MAG1 1 /* file ID */
+#define EI_MAG2 2 /* file ID */
+#define EI_MAG3 3 /* file ID */
+#define EI_CLASS 4 /* file class */
+#define EI_DATA 5 /* data encoding */
+#define EI_VERSION 6 /* ELF header version */
+#define EI_PAD 7 /* start of pad bytes */
+#define EI_NIDENT 16 /* Size of e_ident[] */
-#define ELF_IDSIZE 16
+/* e_ident[] magic number */
+#define ELFMAG0 0x7f /* e_ident[EI_MAG0] */
+#define ELFMAG1 'E' /* e_ident[EI_MAG1] */
+#define ELFMAG2 'L' /* e_ident[EI_MAG2] */
+#define ELFMAG3 'F' /* e_ident[EI_MAG3] */
+#define ELFMAG "\177ELF" /* magic */
+#define SELFMAG 4 /* size of magic */
-enum Elf32_e_type {
- Elf32_et_none = 0,
- Elf32_et_rel,
- Elf32_et_exec,
- Elf32_et_dyn,
- Elf32_et_core,
- Elf32_et_num
-};
+/* e_ident[] file class */
+#define ELFCLASSNONE 0 /* invalid */
+#define ELFCLASS32 1 /* 32-bit objs */
+#define ELFCLASS64 2 /* 64-bit objs */
+#define ELFCLASSNUM 3 /* number of classes */
-enum Elf32_e_machine {
- Elf32_em_none = 0,
- Elf32_em_m32,
- Elf32_em_sparc,
- Elf32_em_386,
- Elf32_em_68k,
- Elf32_em_88k,
- Elf32_em_486,
- Elf32_em_860,
- Elf32_em_mips,
- Elf32_em_num
-};
+/* e_ident[] data encoding */
+#define ELFDATANONE 0 /* invalid */
+#define ELFDATA2LSB 1 /* Little-Endian */
+#define ELFDATA2MSB 2 /* Big-Endian */
+#define ELFDATANUM 3 /* number of data encode defines */
-typedef struct {
- unsigned char e_ident[ELF_IDSIZE]; /* Id bytes */
- Elf32_Half e_type; /* file type */
- Elf32_Half e_machine; /* machine type */
- Elf32_Word e_version; /* version number */
- Elf32_Addr e_entry; /* entry point */
- Elf32_Off e_phoff; /* Program hdr offset */
- Elf32_Off e_shoff; /* Section hdr offset */
- Elf32_Word e_flags; /* Processor flags */
- Elf32_Half e_ehsize; /* sizeof ehdr */
- Elf32_Half e_phentsize; /* Program header entry size */
- Elf32_Half e_phnum; /* Number of program headers */
- Elf32_Half e_shentsize; /* Section header entry size */
- Elf32_Half e_shnum; /* Number of section headers */
- Elf32_Half e_shstrndx; /* String table index */
+/* e_ident */
+#define IS_ELF(ehdr) ((ehdr).e_ident[EI_MAG0] == ELFMAG0 && \
+ (ehdr).e_ident[EI_MAG1] == ELFMAG1 && \
+ (ehdr).e_ident[EI_MAG2] == ELFMAG2 && \
+ (ehdr).e_ident[EI_MAG3] == ELFMAG3)
+
+/* ELF Header */
+typedef struct elfhdr{
+ unsigned char e_ident[EI_NIDENT]; /* ELF Identification */
+ Elf32_Half e_type; /* object file type */
+ Elf32_Half e_machine; /* machine */
+ Elf32_Word e_version; /* object file version */
+ Elf32_Addr e_entry; /* virtual entry point */
+ Elf32_Off e_phoff; /* program header table offset */
+ Elf32_Off e_shoff; /* section header table offset */
+ Elf32_Word e_flags; /* processor-specific flags */
+ Elf32_Half e_ehsize; /* ELF header size */
+ Elf32_Half e_phentsize; /* program header entry size */
+ Elf32_Half e_phnum; /* number of program header entries */
+ Elf32_Half e_shentsize; /* section header entry size */
+ Elf32_Half e_shnum; /* number of section header entries */
+ Elf32_Half e_shstrndx; /* section header table's "section
+ header string table" entry offset */
} Elf32_Ehdr;
+/* e_type */
+#define ET_NONE 0 /* No file type */
+#define ET_REL 1 /* relocatable file */
+#define ET_EXEC 2 /* executable file */
+#define ET_DYN 3 /* shared object file */
+#define ET_CORE 4 /* core file */
+#define ET_NUM 5 /* number of types */
+#define ET_LOPROC 0xff00 /* reserved range for processor */
+#define ET_HIPROC 0xffff /* specific e_type */
-enum Elf32_p_pf {
- Elf32_pf_r = 4,
- Elf32_pf_w = 2,
- Elf32_pf_x = 1
-};
+/* e_machine */
+#define EM_NONE 0 /* No Machine */
+#define EM_M32 1 /* AT&T WE 32100 */
+#define EM_SPARC 2 /* SPARC */
+#define EM_386 3 /* Intel 80386 */
+#define EM_68K 4 /* Motorola 68000 */
+#define EM_88K 5 /* Motorola 88000 */
+#define EM_486 6 /* Intel 80486 - unused? */
+#define EM_860 7 /* Intel 80860 */
+#define EM_MIPS 8 /* MIPS R3000 Big-Endian only */
+/*
+ * Don't know if EM_MIPS_RS4_BE,
+ * EM_SPARC64, EM_PARISC,
+ * or EM_PPC are ABI compliant
+ */
+#define EM_MIPS_RS4_BE 10 /* MIPS R4000 Big-Endian */
+#define EM_SPARC64 11 /* SPARC v9 64-bit unoffical */
+#define EM_PARISC 15 /* HPPA */
+#define EM_PPC 20 /* PowerPC */
+#define EM_NUM 13 /* number of machine types */
-enum Elf32_p_pt {
- Elf32_pt_nulli = 0, /* Program header table entry unused */
- Elf32_pt_load = 1, /* Loadable program segment */
- Elf32_pt_dynamic = 2, /* Dynamic linking information */
- Elf32_pt_interp = 3, /* Program interpreter */
- Elf32_pt_note = 4, /* Auxiliary information */
- Elf32_pt_shlib = 5, /* Reserved, unspecified semantics */
- Elf32_pt_phdr = 6, /* Entry for header table itself */
- Elf32_pt_loproc = 0x70000000, /* Processor-specific */
- Elf32_pt_hiproc = 0x7FFFFFFF /* Processor-specific */
+/* Version */
+#define EV_NONE 0 /* Invalid */
+#define EV_CURRENT 1 /* Current */
+#define EV_NUM 2 /* number of versions */
-};
+/* Section Header */
+typedef struct {
+ Elf32_Word sh_name; /* name - index into section header
+ string table section */
+ Elf32_Word sh_type; /* type */
+ Elf32_Word sh_flags; /* flags */
+ Elf32_Addr sh_addr; /* address */
+ Elf32_Off sh_offset; /* file offset */
+ Elf32_Word sh_size; /* section size */
+ Elf32_Word sh_link; /* section header table index link */
+ Elf32_Word sh_info; /* extra information */
+ Elf32_Word sh_addralign; /* address alignment */
+ Elf32_Word sh_entsize; /* section entry size */
+} Elf32_Shdr;
+
+/* Special Section Indexes */
+#define SHN_UNDEF 0 /* undefined */
+#define SHN_LORESERVE 0xff00 /* lower bounds of reserved indexes */
+#define SHN_LOPROC 0xff00 /* reserved range for processor */
+#define SHN_HIPROC 0xff1f /* specific section indexes */
+#define SHN_ABS 0xfff1 /* absolute value */
+#define SHN_COMMON 0xfff2 /* common symbol */
+#define SHN_HIRESERVE 0xffff /* upper bounds of reserved indexes */
+
+/* sh_type */
+#define SHT_NULL 0 /* inactive */
+#define SHT_PROGBITS 1 /* program defined information */
+#define SHT_SYMTAB 2 /* symbol table section */
+#define SHT_STRTAB 3 /* string table section */
+#define SHT_RELA 4 /* relocation section with addends*/
+#define SHT_HASH 5 /* symbol hash table section */
+#define SHT_DYNAMIC 6 /* dynamic section */
+#define SHT_NOTE 7 /* note section */
+#define SHT_NOBITS 8 /* no space section */
+#define SHT_REL 9 /* relation section without addends */
+#define SHT_SHLIB 10 /* reserved - purpose unknown */
+#define SHT_DYNSYM 11 /* dynamic symbol table section */
+
+#define SHT_NUM 13 /* number of section types */
+#define SHT_LOPROC 0x70000000 /* reserved range for processor */
+#define SHT_HIPROC 0x7fffffff /* specific section header types */
+#define SHT_LOUSER 0x80000000 /* reserved range for application */
+#define SHT_HIUSER 0xffffffff /* specific indexes */
+
+/* Section names */
+#define ELF_BSS ".bss" /* uninitialized data */
+#define ELF_DATA ".data" /* initialized data */
+#define ELF_DEBUG ".debug" /* debug */
+#define ELF_DYNAMIC ".dynamic" /* dynamic linking information */
+#define ELF_DYNSTR ".dynstr" /* dynamic string table */
+#define ELF_DYNSYM ".dynsym" /* dynamic symbol table */
+#define ELF_FINI ".fini" /* termination code */
+#define ELF_GOT ".got" /* global offset table */
+#define ELF_HASH ".hash" /* symbol hash table */
+#define ELF_INIT ".init" /* initialization code */
+#define ELF_REL_DATA ".rel.data" /* relocation data */
+#define ELF_REL_FINI ".rel.fini" /* relocation termination code */
+#define ELF_REL_INIT ".rel.init" /* relocation initialization code */
+#define ELF_REL_DYN ".rel.dyn" /* relocaltion dynamic link info */
+#define ELF_REL_RODATA ".rel.rodata" /* relocation read-only data */
+#define ELF_REL_TEXT ".rel.text" /* relocation code */
+#define ELF_RODATA ".rodata" /* read-only data */
+#define ELF_SHSTRTAB ".shstrtab" /* section header string table */
+#define ELF_STRTAB ".strtab" /* string table */
+#define ELF_SYMTAB ".symtab" /* symbol table */
+#define ELF_TEXT ".text" /* code */
+
+
+/* Section Attribute Flags - sh_flags */
+#define SHF_WRITE 0x1 /* Writable */
+#define SHF_ALLOC 0x2 /* occupies memory */
+#define SHF_EXECINSTR 0x4 /* executable */
+#define SHF_MASKPROC 0xf0000000 /* reserved bits for processor */
+ /* specific section attributes */
+
+/* Symbol Table Entry */
+typedef struct elf32_sym {
+ Elf32_Word st_name; /* name - index into string table */
+ Elf32_Addr st_value; /* symbol value */
+ Elf32_Word st_size; /* symbol size */
+ unsigned char st_info; /* type and binding */
+ unsigned char st_other; /* 0 - no defined meaning */
+ Elf32_Half st_shndx; /* section header index */
+} Elf32_Sym;
+
+/* Symbol table index */
+#define STN_UNDEF 0 /* undefined */
+
+/* Extract symbol info - st_info */
+#define ELF32_ST_BIND(x) ((x) >> 4)
+#define ELF32_ST_TYPE(x) (((unsigned int) x) & 0xf)
+#define ELF32_ST_INFO(b,t) (((b) << 4) + ((t) & 0xf))
+
+/* Symbol Binding - ELF32_ST_BIND - st_info */
+#define STB_LOCAL 0 /* Local symbol */
+#define STB_GLOBAL 1 /* Global symbol */
+#define STB_WEAK 2 /* like global - lower precedence */
+#define STB_NUM 3 /* number of symbol bindings */
+#define STB_LOPROC 13 /* reserved range for processor */
+#define STB_HIPROC 15 /* specific symbol bindings */
+
+/* Symbol type - ELF32_ST_TYPE - st_info */
+#define STT_NOTYPE 0 /* not specified */
+#define STT_OBJECT 1 /* data object */
+#define STT_FUNC 2 /* function */
+#define STT_SECTION 3 /* section */
+#define STT_FILE 4 /* file */
+#define STT_NUM 5 /* number of symbol types */
+#define STT_LOPROC 13 /* reserved range for processor */
+#define STT_HIPROC 15 /* specific symbol types */
+
+/* Relocation entry with implicit addend */
+typedef struct
+{
+ Elf32_Addr r_offset; /* offset of relocation */
+ Elf32_Word r_info; /* symbol table index and type */
+} Elf32_Rel;
+/* Relocation entry with explicit addend */
+typedef struct
+{
+ Elf32_Addr r_offset; /* offset of relocation */
+ Elf32_Word r_info; /* symbol table index and type */
+ Elf32_Sword r_addend;
+} Elf32_Rela;
+
+/* Extract relocation info - r_info */
+#define ELF32_R_SYM(i) ((i) >> 8)
+#define ELF32_R_TYPE(i) ((unsigned char) (i))
+#define ELF32_R_INFO(s,t) (((s) << 8) + (unsigned char)(t))
+
+/* Program Header */
typedef struct {
- Elf32_Word p_type; /* entry type */
- Elf32_Off p_offset; /* offset */
- Elf32_Addr p_vaddr; /* virtual address */
- Elf32_Addr p_paddr; /* physical address */
- Elf32_Word p_filesz; /* file size */
- Elf32_Word p_memsz; /* memory size */
+ Elf32_Word p_type; /* segment type */
+ Elf32_Off p_offset; /* segment offset */
+ Elf32_Addr p_vaddr; /* virtual address of segment */
+ Elf32_Addr p_paddr; /* physical address - ignored? */
+ Elf32_Word p_filesz; /* number of bytes in file for seg. */
+ Elf32_Word p_memsz; /* number of bytes in mem. for seg. */
Elf32_Word p_flags; /* flags */
- Elf32_Word p_align; /* memory & file alignment */
+ Elf32_Word p_align; /* memory alignment */
} Elf32_Phdr;
-#define Elf32_e_ident "\177ELF"
-#define Elf32_e_siz (sizeof(Elf32_e_ident) - 1)
+/* Segment types - p_type */
+#define PT_NULL 0 /* unused */
+#define PT_LOAD 1 /* loadable segment */
+#define PT_DYNAMIC 2 /* dynamic linking section */
+#define PT_INTERP 3 /* the RTLD */
+#define PT_NOTE 4 /* auxiliary information */
+#define PT_SHLIB 5 /* reserved - purpose undefined */
+#define PT_PHDR 6 /* program header */
+#define PT_NUM 8 /* Number of segment types */
+#define PT_LOPROC 0x70000000 /* reserved range for processor */
+#define PT_HIPROC 0x7fffffff /* specific segment types */
-typedef struct {
- int au_id;
- unsigned long au_v;
-} AuxInfo;
+/* Segment flags - p_flags */
+#define PF_X 0x1 /* Executable */
+#define PF_W 0x2 /* Writable */
+#define PF_R 0x4 /* Readable */
+#define PF_MASKPROC 0xf0000000 /* reserved bits for processor */
+ /* specific segment flags */
-enum AuxID {
- AUX_null = 0,
- AUX_ignore = 1,
- AUX_execfd = 2,
- AUX_phdr = 3, /* &phdr[0] */
- AUX_phent = 4, /* sizeof(phdr[0]) */
- AUX_phnum = 5, /* # phdr entries */
- AUX_pagesz = 6, /* PAGESIZE */
- AUX_base = 7, /* ld.so base addr */
- AUX_flags = 8, /* processor flags */
- AUX_entry = 9, /* a.out entry */
- AUX_sun_uid = 2000, /* euid */
- AUX_sun_ruid = 2001, /* ruid */
- AUX_sun_gid = 2002, /* egid */
- AUX_sun_rgid = 2003 /* rgid */
-};
+/* Dynamic structure */
+typedef struct
+{
+ Elf32_Sword d_tag; /* controls meaning of d_val */
+ union
+ {
+ Elf32_Word d_val; /* Multiple meanings - see d_tag */
+ Elf32_Addr d_ptr; /* program virtual address */
+ } d_un;
+} Elf32_Dyn;
-#define ELF_HDR_SIZE (sizeof(Elf32_Ehdr))
+extern Elf32_Dyn _DYNAMIC[];
+/* Dynamic Array Tags - d_tag */
+#define DT_NULL 0 /* marks end of _DYNAMIC array */
+#define DT_NEEDED 1 /* string table offset of needed lib */
+#define DT_PLTRELSZ 2 /* size of relocation entries in PLT */
+#define DT_PLTGOT 3 /* address PLT/GOT */
+#define DT_HASH 4 /* address of symbol hash table */
+#define DT_STRTAB 5 /* address of string table */
+#define DT_SYMTAB 6 /* address of symbol table */
+#define DT_RELA 7 /* address of relocation table */
+#define DT_RELASZ 8 /* size of relocation table */
+#define DT_RELAENT 9 /* size of relocation entry */
+#define DT_STRSZ 10 /* size of string table */
+#define DT_SYMENT 11 /* size of symbol table entry */
+#define DT_INIT 12 /* address of initialization func. */
+#define DT_FINI 13 /* address of termination function */
+#define DT_SONAME 14 /* string table offset of shared obj */
+#define DT_RPATH 15 /* string table offset of library
+ /* search path */
+#define DT_SYMBOLIC 16 /* start sym search in shared obj. */
+#define DT_REL 17 /* address of rel. tbl. w addends */
+#define DT_RELSZ 18 /* size of DT_REL relocation table */
+#define DT_RELENT 19 /* size of DT_REL relocation entry */
+#define DT_PLTREL 20 /* PLT referenced relocation entry */
+#define DT_DEBUG 21 /* bugger */
+#define DT_TEXTREL 22 /* Allow rel. mod. to unwritable seg */
+#define DT_JMPREL 23 /* add. of PLT's relocation entries */
+#define DT_LOPROC 0x70000000 /* reserved range for processor */
+#define DT_HIPROC 0x7fffffff /* specific dynamic array tags */
+
+/* Standard ELF hashing function */
+unsigned long elf_hash(const unsigned char *name);
+/*
+ * XXX - these _KERNEL items aren't part of the ABI!
+ */
#ifdef _KERNEL
#define ELF32_NO_ADDR ((u_long) ~0) /* Indicates addr. not yet filled in */
#define ELF_AUX_ENTRIES 8 /* Size of aux array passed to loader */
+typedef struct {
+ int au_id;
+ unsigned long au_v;
+} AuxInfo;
+
+enum AuxID {
+ AUX_null = 0,
+ AUX_ignore = 1,
+ AUX_execfd = 2,
+ AUX_phdr = 3, /* &phdr[0] */
+ AUX_phent = 4, /* sizeof(phdr[0]) */
+ AUX_phnum = 5, /* # phdr entries */
+ AUX_pagesz = 6, /* PAGESIZE */
+ AUX_base = 7, /* ld.so base addr */
+ AUX_flags = 8, /* processor flags */
+ AUX_entry = 9, /* a.out entry */
+ AUX_sun_uid = 2000, /* euid */
+ AUX_sun_ruid = 2001, /* ruid */
+ AUX_sun_gid = 2002, /* egid */
+ AUX_sun_rgid = 2003 /* rgid */
+};
+
struct elf_args {
- u_long arg_entry; /* progran entry point */
- u_long arg_interp; /* Interpreter load address */
- u_long arg_phaddr; /* program header address */
- u_long arg_phentsize; /* Size of program header */
- u_long arg_phnum; /* Number of program headers */
+ u_long arg_entry; /* progran entry point */
+ u_long arg_interp; /* Interpreter load address */
+ u_long arg_phaddr; /* program header address */
+ u_long arg_phentsize; /* Size of program header */
+ u_long arg_phnum; /* Number of program headers */
};
int exec_elf_makecmds __P((struct proc *, struct exec_package *));
@@ -159,6 +390,37 @@ void *elf_copyargs __P((struct exec_package *, struct ps_strings *, void *,
void *elf_copyargs __P((struct exec_package *, struct ps_strings *,
void *, void *));
+/*
+ * XXX - OpenBSD hack to determine
+ * target OS - This is NOT ABI
+ * compliant!!!
+ */
+struct elf_oshdr {
+ Elf32_Word os_name; /* name string - index into strtab */
+ Elf32_Word os_type; /* operating system type */
+ Elf32_Half os_major; /* major version tag */
+ Elf32_Half os_minor; /* minor version tag */
+ Elf32_Half os_subminor; /* sub minor version tag */
+ Elf32_Half os_nmisc; /* number of misc strings */
+ Elf32_Word os_misc; /* misc string - index into strtab */
+} Elf32_Oshdr;
+
+/* Program header type, section header type,
+ and section header name */
+#define PT_OS 0x7fffffff /* program header type */
+#define SHT_OS 0xffffffff /* section header type */
+#define ELF_OS ".os" /* section header name string */
+
+/* Operating system types */
+#define OST_NULL 0 /* Invalid */
+#define OST_OPENBSD 1 /* OpenBSD */
+#define OST_LINUX 2 /* Linux */
+#define OST_NUM 3 /* Number of operating system types */
+
+/* Operating system names */
+#define ELF_OPENBSD "openbsd" /* OpenBSD */
+#define ELF_LINUX "linux" /* Linux */
+
#endif /* _KERNEL */
-#endif /* !_SYS_EXEC_ELF_H_ */
+#endif /* _SYS_EXEC_ELF_H_ */