From 61f43e7530fd22c9381a6a4e18c2d38431ebb72d Mon Sep 17 00:00:00 2001 From: Roland McGrath Date: Mon, 13 Mar 2000 22:31:24 +0000 Subject: 2000-03-13 Roland McGrath * priv.h (EXECDATA_STREAM): New macro, always defined for now. (struct execdata) [! EXECDATA_STREAM]: Add members map_buffer, map_bsize, map_fsize, map_filepos in place of stream. (map_buffer, map_filepos, map_set_fsize): New macros for accessing those or stream. [! EXECDATA_STREAM] (map_fsize, map_vsize): Define using new members. * exec.c (map): Rewritten purely using those accessor macros. (input_room): Set the __target, __bufp, __error, and __eof members, which are no longer set by map. [! EXECDATA_STREAM] (prepare_stream, prepare_in_memory): Make no-ops. (input_room, close_exec_stream, fake_seek, prepare_stream, prepare_in_memory): Conditionalize these defns on [EXECDATA_STREAM]. (load_section): Always use map instead of stdio. Replace bcopy with memcpy. (check_gzip: zipread): Rewrite using map instead of stdio. (check_bzip2: zipread): Likewise. --- exec/priv.h | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'exec/priv.h') diff --git a/exec/priv.h b/exec/priv.h index 75a350f1..1e836c55 100644 --- a/exec/priv.h +++ b/exec/priv.h @@ -72,10 +72,15 @@ typedef struct trivfs_protid *trivfs_protid_t; /* For MiG. */ extern mach_port_t procserver; /* Our proc port. */ -#ifndef BFD +#define EXECDATA_STREAM /* XXX */ + +#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. */ struct execdata @@ -87,11 +92,34 @@ struct execdata vm_address_t entry; 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 @@ -136,11 +164,11 @@ error_t elf_machine_matches_host (Elf32_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. */ + 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, -- cgit v1.2.3