From 6d175fbd76ecc6de2bcb284c1c2800b6803e0846 Mon Sep 17 00:00:00 2001 From: bde Date: Wed, 15 Jul 1998 05:00:26 +0000 Subject: [PATCH] Cast u_longs to uintptr_t before casting them to pointers. Don't attempt to even partially support systems with function pointers larger than object pointers. --- sys/kern/imgact_aout.c | 7 ++++--- sys/kern/imgact_elf.c | 6 +++--- sys/kern/imgact_gzip.c | 13 +++++++------ 3 files changed, 14 insertions(+), 12 deletions(-) diff --git a/sys/kern/imgact_aout.c b/sys/kern/imgact_aout.c index dec3eeb6bf47..15f613dcd02d 100644 --- a/sys/kern/imgact_aout.c +++ b/sys/kern/imgact_aout.c @@ -23,7 +23,7 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * - * $Id: imgact_aout.c,v 1.39 1998/02/03 21:41:12 bde Exp $ + * $Id: imgact_aout.c,v 1.40 1998/02/20 13:11:48 bde Exp $ */ #include @@ -187,8 +187,9 @@ exec_aout_imgact(imgp) /* Fill in process VM information */ vmspace->vm_tsize = a_out->a_text >> PAGE_SHIFT; vmspace->vm_dsize = (a_out->a_data + bss_size) >> PAGE_SHIFT; - vmspace->vm_taddr = (caddr_t) virtual_offset; - vmspace->vm_daddr = (caddr_t) virtual_offset + a_out->a_text; + vmspace->vm_taddr = (caddr_t) (uintptr_t) virtual_offset; + vmspace->vm_daddr = (caddr_t) (uintptr_t) + (virtual_offset + a_out->a_text); /* Fill in image_params */ imgp->interpreted = 0; diff --git a/sys/kern/imgact_elf.c b/sys/kern/imgact_elf.c index 7bd98b8ea3d9..0235b5918b1a 100644 --- a/sys/kern/imgact_elf.c +++ b/sys/kern/imgact_elf.c @@ -26,7 +26,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * - * $Id: imgact_elf.c,v 1.26 1998/06/08 09:19:35 dfr Exp $ + * $Id: imgact_elf.c,v 1.27 1998/07/11 10:28:47 bde Exp $ */ #include "opt_rlimit.h" @@ -533,9 +533,9 @@ exec_elf_imgact(struct image_params *imgp) } vmspace->vm_tsize = text_size >> PAGE_SHIFT; - vmspace->vm_taddr = (caddr_t)text_addr; + vmspace->vm_taddr = (caddr_t)(uintptr_t)text_addr; vmspace->vm_dsize = data_size >> PAGE_SHIFT; - vmspace->vm_daddr = (caddr_t)data_addr; + vmspace->vm_daddr = (caddr_t)(uintptr_t)data_addr; addr = 2L*MAXDSIZ; /* May depend on OS type XXX */ diff --git a/sys/kern/imgact_gzip.c b/sys/kern/imgact_gzip.c index 3c9b6a47b709..df68edb1e338 100644 --- a/sys/kern/imgact_gzip.c +++ b/sys/kern/imgact_gzip.c @@ -6,7 +6,7 @@ * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp * ---------------------------------------------------------------------------- * - * $Id: imgact_gzip.c,v 1.32 1997/12/14 19:36:24 jdp Exp $ + * $Id: imgact_gzip.c,v 1.33 1998/06/16 14:36:40 bde Exp $ * * This module handles execution of a.out files which have been run through * "gzip". This saves diskspace, but wastes cpu-cycles and VM. @@ -260,8 +260,9 @@ do_aout_hdr(struct imgact_gzip * gz) /* Fill in process VM information */ vmspace->vm_tsize = gz->a_out.a_text >> PAGE_SHIFT; vmspace->vm_dsize = (gz->a_out.a_data + gz->bss_size) >> PAGE_SHIFT; - vmspace->vm_taddr = (caddr_t) gz->virtual_offset; - vmspace->vm_daddr = (caddr_t) gz->virtual_offset + gz->a_out.a_text; + vmspace->vm_taddr = (caddr_t) (uintptr_t) gz->virtual_offset; + vmspace->vm_daddr = (caddr_t) (uintptr_t) + (gz->virtual_offset + gz->a_out.a_text); /* Fill in image_params */ gz->ip->interpreted = 0; @@ -340,7 +341,7 @@ Flush(void *vp, u_char * ptr, u_long siz) return ENOEXEC; } if (gz->file_offset == 0) { - q = (u_char *) gz->virtual_offset; + q = (u_char *) (uintptr_t) gz->virtual_offset; copyout(&gz->a_out, q, sizeof gz->a_out); } } @@ -355,8 +356,8 @@ Flush(void *vp, u_char * ptr, u_long siz) } if (gz->output >= gz->file_offset && gz->output < gz->file_end) { i = min(siz, gz->file_end - gz->output); - q = (u_char *) gz->virtual_offset + - gz->output - gz->file_offset; + q = (u_char *) (uintptr_t) + (gz->virtual_offset + gz->output - gz->file_offset); copyout(p, q, i); gz->output += i; p += i;