From owner-p4-projects@FreeBSD.ORG Wed Aug 16 01:31:19 2006 Return-Path: X-Original-To: p4-projects@freebsd.org Delivered-To: p4-projects@freebsd.org Received: by hub.freebsd.org (Postfix, from userid 32767) id 482AB16A4E0; Wed, 16 Aug 2006 01:31:19 +0000 (UTC) X-Original-To: perforce@freebsd.org Delivered-To: perforce@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 2384B16A4DE for ; Wed, 16 Aug 2006 01:31:19 +0000 (UTC) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (repoman.freebsd.org [216.136.204.115]) by mx1.FreeBSD.org (Postfix) with ESMTP id E145543D5C for ; Wed, 16 Aug 2006 01:31:17 +0000 (GMT) (envelope-from jb@freebsd.org) Received: from repoman.freebsd.org (localhost [127.0.0.1]) by repoman.freebsd.org (8.13.6/8.13.6) with ESMTP id k7G1VHPv094572 for ; Wed, 16 Aug 2006 01:31:17 GMT (envelope-from jb@freebsd.org) Received: (from perforce@localhost) by repoman.freebsd.org (8.13.6/8.13.4/Submit) id k7G1VHNC094569 for perforce@freebsd.org; Wed, 16 Aug 2006 01:31:17 GMT (envelope-from jb@freebsd.org) Date: Wed, 16 Aug 2006 01:31:17 GMT Message-Id: <200608160131.k7G1VHNC094569@repoman.freebsd.org> X-Authentication-Warning: repoman.freebsd.org: perforce set sender to jb@freebsd.org using -f From: John Birrell To: Perforce Change Reviews Cc: Subject: PERFORCE change 104167 for review X-BeenThere: p4-projects@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: p4 projects tree changes List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 16 Aug 2006 01:31:19 -0000 http://perforce.freebsd.org/chv.cgi?CH=104167 Change 104167 by jb@jb_freebsd2 on 2006/08/16 01:30:34 Revert back to using my memcpy version of this file which works on sun4v. Revision 5 certainly stopped the compiler warnings about alignment, but the compiler was doing the right thing. Adding another cast to avoid the warning just masked the problem. Affected files ... .. //depot/projects/dtrace/src/lib/libelf/libelf_convert.m4#6 edit Differences ... ==== //depot/projects/dtrace/src/lib/libelf/libelf_convert.m4#6 (text+ko) ==== @@ -1,3 +1,4 @@ +//depot/projects/dtrace/src/lib/libelf/libelf_convert.m4#4 - edit change 103978 (text+ko) /*- * Copyright (c) 2006 Joseph Koshy * All rights reserved. @@ -152,7 +153,7 @@ (X) = _t; \ } while (0) #define READ_WORD(P,X) do { \ - uint16_t _t; \ + uint32_t _t; \ unsigned char *const _q = (unsigned char *) &_t; \ const unsigned char *const _p = \ (const unsigned char *) (P); \ @@ -167,7 +168,7 @@ #define READ_OFF32(P,X) READ_WORD(P,X) #define READ_SWORD(P,X) READ_WORD(P,X) #define READ_WORD64(P,X) do { \ - uint16_t _t; \ + uint64_t _t; \ unsigned char *const _q = (unsigned char *) &_t; \ const unsigned char *const _p = \ (const unsigned char *) (P); \ @@ -188,6 +189,7 @@ #define READ_XWORD(P,X) READ_WORD64(P,X) #define READ_IDENT(P,X) do { \ (void) memcpy((X), (P), sizeof((X))); \ + (P) = (P) + sizeof((X)); \ } while (0) divert(-1) @@ -201,16 +203,9 @@ * casting to work as expected. On the other hand the `file' * representation of an ELF data structure could be packed tighter * than its `in-memory' representation, and could be of a differing - * byte order. An additional complication is that `ar' only pads data + * byte order. An additinal complication is that `ar' only pads data * to even addresses and so ELF archive member data being read from * inside an `ar' archive could end up at misaligned memory addresses. - * - * Consequently, casting the `char *' pointers that point to memory - * representations (i.e., source pointers for the *_tof() functions - * and the destination pointers for the *_tom() functions), is safe, - * as these pointers should be correctly aligned for the memory type - * already. However, pointers to file representations have to be - * treated as being potentially unaligned and no casting can be done. */ include(SRCDIR`/elf_types.m4') @@ -257,19 +252,20 @@ static void libelf_cvt_$1$3_tof(char *dst, char *src, int count, int byteswap) { - Elf64_$2 t, *s = (Elf64_$2 *) (uintptr_t) src; + Elf64_$2 t; int c; if (dst == src && !byteswap) return; if (!byteswap) { - (void) memcpy(dst, src, count * sizeof(*s)); + (void) memcpy(dst, src, count * sizeof(t)); return; } for (c = 0; c < count; c++) { - t = *s++; + memcpy(&t, src, sizeof(t)); + src += sizeof(t); SWAP_$1$3(t); WRITE_$1$3(dst,t); } @@ -280,21 +276,22 @@ static void libelf_cvt_$1$3_tom(char *dst, char *src, int count, int byteswap) { - Elf64_$2 t, *d = (Elf64_$2 *) (uintptr_t) dst; + Elf64_$2 t; int c; if (dst == src && !byteswap) return; if (!byteswap) { - (void) memcpy(dst, src, count * sizeof(*d)); + (void) memcpy(dst, src, count * sizeof(t)); return; } for (c = 0; c < count; c++) { READ_$1$3(src,t); SWAP_$1$3(t); - *d++ = t; + memcpy(dst, &t, sizeof(t)); + dst += sizeof(t); } } ') @@ -370,12 +367,12 @@ static void libelf_cvt$3_$1_tof(char *dst, char *src, int count, int byteswap) { - Elf$3_$2 t, *s; + Elf$3_$2 t; int c; - s = (Elf$3_$2 *) (uintptr_t) src; for (c = 0; c < count; c++) { - t = *s++; + memcpy(&t, src, sizeof(t)); + src += sizeof(t); if (byteswap) { SWAP_STRUCT($2,$3) } @@ -389,21 +386,22 @@ static void libelf_cvt$3_$1_tom(char *dst, char *src, int count, int byteswap) { - Elf$3_$2 t, *d; - unsigned char *s,*s0; + Elf$3_$2 t; + unsigned char *s; + int i; size_t fsz; fsz = elf$3_fsize(ELF_T_$1, 1, EV_CURRENT); - d = ((Elf$3_$2 *) (uintptr_t) dst) + (count - 1); - s0 = (unsigned char *) src + (count - 1) * fsz; - while (count--) { - s = s0; + for (i = 0; i < count; i++) { + s = (unsigned char *) src; READ_STRUCT($2,$3) if (byteswap) { SWAP_STRUCT($2,$3) } - *d-- = t; s0 -= fsz; + memcpy(dst, &t, sizeof(t)); + dst += sizeof(t); + src += fsz; } } ')')