From owner-freebsd-arch@FreeBSD.ORG Tue Aug 28 08:57:52 2012 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id B6B7D106566C for ; Tue, 28 Aug 2012 08:57:52 +0000 (UTC) (envelope-from andrey@zonov.org) Received: from mail-lpp01m010-f54.google.com (mail-lpp01m010-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id 2BC918FC0A for ; Tue, 28 Aug 2012 08:57:51 +0000 (UTC) Received: by lage12 with SMTP id e12so3636783lag.13 for ; Tue, 28 Aug 2012 01:57:51 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=sender:message-id:date:from:user-agent:mime-version:to:subject :x-enigmail-version:content-type:x-gm-message-state; bh=4lG1wZvlksUYIOlwna4failhumkiEX52ITraAh9scqw=; b=gfxXDIcWWsLsqE/oLyiZ/2Pj9e8tIVKbuug9g0SMAZggUYYdbEPXKXG/EbbESf338X aepMQ4NuUg7b1TjY50QF8hBuMrEGeBN8IzY2QHwxNeq5NLqGfwqbGT62NjdkjU0x8VE0 QIdAtgUdtygLPMFpCA5YCVWSnvO2wqVZOW4DNI8xm4HtHmumVLpLNSGvyucz5C9iSZvI mB140FZyOwPKeP6UEeTvDeUEUVuD6m9qvo1Qj9bBqqhJARpHZsk0hVGs8p/GCjfXNtRR 7muJ4MwviWpASnBwr7g2nAItCY+lY29G2Z4s+akJ66Gdt+N2yhrF1+BzIFP6pjeFVCns xBxA== Received: by 10.152.104.172 with SMTP id gf12mr1020121lab.56.1346144270948; Tue, 28 Aug 2012 01:57:50 -0700 (PDT) Received: from zont-osx.local (ppp95-165-143-86.pppoe.spdop.ru. [95.165.143.86]) by mx.google.com with ESMTPS id sy1sm21487084lab.13.2012.08.28.01.57.49 (version=SSLv3 cipher=OTHER); Tue, 28 Aug 2012 01:57:50 -0700 (PDT) Sender: Andrey Zonov Message-ID: <503C8809.3050507@FreeBSD.org> Date: Tue, 28 Aug 2012 12:57:45 +0400 From: Andrey Zonov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: freebsd-arch@freebsd.org X-Enigmail-Version: 1.4.3 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig0788A89F08941CC5D4233F50" X-Gm-Message-State: ALoCoQmLk2trTzpCmgHtG3IqyR8rFGfMDTdZa5QeLnd8qvajE8Qm+Xw2YxJdpDeR9o+XYYS+3dSG Subject: warning: cast increases required alignment of target type X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 28 Aug 2012 08:57:52 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig0788A89F08941CC5D4233F50 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi, Does anyone know how to correctly fix this warning for arm/ia64/mips/sparc64? usr.bin/elf2aout/elf2aout.c: In function 'main': usr.bin/elf2aout/elf2aout.c:129: warning: cast increases required alignment of target type I found this explanation from bde, but still don't understand how to correctly fix this issue. ------------------------------------------------------------------------ r99799 | bde | 2002-07-11 22:06:09 +0400 (Thu, 11 Jul 2002) | 10 lines Set NO_WERROR to ignore the following warning which is emitted on alphas: .../elf2aout.c:130: warning: cast increases required alignment of target type The warning is about casting ((char *)e + phoff) to a struct pointer, where e is aligned but phoff might be garbage, so I think the warning should be emitted on most machines (even on i386's, alignment checking might be on) and the correct fix would involve validation phoff before using it. Is this fix correct? Index: usr.bin/elf2aout/elf2aout.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- usr.bin/elf2aout/elf2aout.c (revision 239611) +++ usr.bin/elf2aout/elf2aout.c (working copy) @@ -126,7 +126,7 @@ entry =3D xe64toh(e->e_entry); phoff =3D xe64toh(e->e_phoff); phnum =3D xe16toh(e->e_phnum); - p =3D (Elf64_Phdr *)((char *)e + phoff); + p =3D (Elf64_Phdr *)(void *)((char *)e + phoff); bzero(&a, sizeof(a)); for (i =3D 0; i < phnum; i++) { type =3D xe32toh(p[i].p_type); --=20 Andrey Zonov --------------enig0788A89F08941CC5D4233F50 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.18 (Darwin) Comment: GPGTools - http://gpgtools.org iQEcBAEBAgAGBQJQPIgNAAoJEBWLemxX/CvT84YH/ifd1jhi4TimbVr6Ze9roCeF Jy5iZu0mY+0aW6w1guUSrJPE1K5DTqlRlgpWIhRcRogEyCfM6Ami8E4+aCts2OWT BlEXJeHasvzWLuC64KtDLNtl0GLIlFNSk18wxWmRkI1QsfAOy1x94XPcladB9JDV E07lpKJWlFEZfUmSCVSI6/Ui4R0RqHzHh86CaxziOnBgHqKt0s0TJD/UaM0IRf93 T/OzBdp6n/Pivt72CRu45/sbCDrhtGn4yTLTQ4KOjbDTOwBAPoOOyYCgdTk/k+Pe ScGvDubxVWKQJkQToPMB05LWZ206i2Z96L3z253YIIES8dE9rhE3VGARmZPok60= =pGE6 -----END PGP SIGNATURE----- --------------enig0788A89F08941CC5D4233F50--