aboutsummaryrefslogtreecommitdiff
path: root/exec/priv.h
diff options
context:
space:
mode:
Diffstat (limited to 'exec/priv.h')
-rw-r--r--exec/priv.h71
1 files changed, 60 insertions, 11 deletions
diff --git a/exec/priv.h b/exec/priv.h
index 0ded21eb..7cee15e4 100644
--- a/exec/priv.h
+++ b/exec/priv.h
@@ -1,5 +1,5 @@
/* GNU Hurd standard exec server, private declarations.
- Copyright (C) 1992, 1993, 1994, 1995 Free Software Foundation, Inc.
+ Copyright (C) 1992,93,94,95,96,99,2000,02, 04 Free Software Foundation, Inc.
Written by Roland McGrath.
This file is part of the GNU Hurd.
@@ -9,7 +9,7 @@ it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
-The GNU Hurd is distributed in the hope that it will be useful,
+The GNU Hurd is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
@@ -22,12 +22,18 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
+#include <sys/mman.h>
#include <hurd/trivfs.h>
#include <hurd/ports.h>
#include <hurd/lookup.h>
#include <rwlock.h>
+
+#ifdef BFD
#include <bfd.h>
+#endif
+
#include <elf.h>
+#include <link.h> /* This gives us the ElfW macro. */
#include <fcntl.h>
#include "exec_S.h"
@@ -35,11 +41,11 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
#ifndef exec_priv_h
#define exec_priv_h
+#ifdef BFD
/* A BFD whose architecture and machine type are those of the host system. */
extern bfd_arch_info_type host_bfd_arch_info;
extern bfd host_bfd;
-extern Elf32_Half elf_machine; /* ELF e_machine for the host. */
-
+#endif
/* Information kept around to be given to a new task
in response to a message on the task's bootstrap port. */
@@ -62,11 +68,14 @@ struct bootinfo
struct port_bucket *port_bucket;
struct port_class *execboot_portclass;
-
-typedef struct trivfs_protid *trivfs_protid_t; /* For MiG. */
-
extern mach_port_t procserver; /* Our proc port. */
+#ifdef BFD
+#define EXECDATA_STREAM /* BFD uses stdio to access the executable. */
+#else
+typedef void asection;
+#endif
+
/* Data shared between check, check_section,
load, load_section, and finish. */
@@ -77,16 +86,46 @@ struct execdata
/* Set by check. */
vm_address_t entry;
- FILE stream;
file_t file;
+#ifndef EXECDATA_STREAM
+
+ /* Note that if `file_data' (below) is set, then these just point
+ into that and should not be deallocated (file_data is malloc'd). */
+ char *map_buffer; /* Our mapping window or read buffer. */
+ size_t map_vsize; /* Page-aligned size allocated there. */
+ size_t map_fsize; /* Bytes from there to end of mapped data. */
+ off_t map_filepos; /* Position `map_buffer' maps to. */
+#define map_buffer(e) ((e)->map_buffer)
+#define map_fsize(e) ((e)->map_fsize)
+#define map_vsize(e) ((e)->map_vsize)
+#define map_filepos(e) ((e)->map_filepos)
+#define map_set_fsize(e, fsize) ((e)->map_fsize = (fsize))
+
+#else
+
+#ifdef _STDIO_USES_IOSTREAM
+# error implement me for libio!
+#else
+ FILE stream;
+#define map_buffer(e) ((e)->stream.__buffer)
+#define map_fsize(e) ((e)->stream.__get_limit - (e)->stream.__buffer)
+#define map_vsize(e) ((e)->stream.__bufsize)
+#define map_filepos(e) ((e)->stream.__offset)
+#define map_set_fsize(e, fsize) \
+ ((e)->stream.__get_limit = (e)->stream.__buffer + (fsize))
+#endif
+
+#endif
+
#ifdef BFD
bfd *bfd;
#endif
+
union /* Interpreter section giving name of file. */
{
asection *section;
- const Elf32_Phdr *phdr;
+ const ElfW(Phdr) *phdr;
} interp;
memory_object_t filemap, cntlmap;
struct shared_io *cntl;
@@ -108,16 +147,26 @@ struct execdata
/* Program header table read from the executable.
After `check' this is a pointer into the mapping window.
By `load' it is local alloca'd storage. */
- Elf32_Phdr *phdr;
- Elf32_Word phnum; /* Number of program header table elements. */
+ ElfW(Phdr) *phdr;
+ ElfW(Addr) phdr_addr;
+ ElfW(Word) phnum; /* Number of program header table elements. */
int anywhere; /* Nonzero if image can go anywhere. */
vm_address_t loadbase; /* Actual mapping location. */
+ int execstack; /* Zero if stack can be nonexecutable. */
} elf;
} info;
};
+error_t elf_machine_matches_host (ElfW(Half) e_machine);
+
void finish (struct execdata *, int dealloc_file_port);
+/* Make sure our mapping window (or read buffer) covers
+ LEN bytes of the file starting at POSN, and return
+ a pointer into the window corresponding to POSN. */
+void *map (struct execdata *e, off_t posn, size_t len);
+
+
void check_hashbang (struct execdata *e,
file_t file,
task_t oldtask,