From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.71) id 1UMbA0-0002jj-1h for mharc-grub-devel@gnu.org; Mon, 01 Apr 2013 05:36:16 -0400 Received: from eggs.gnu.org ([208.118.235.92]:50969) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMb9v-0002hx-UN for grub-devel@gnu.org; Mon, 01 Apr 2013 05:36:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UMb9s-0001T5-O2 for grub-devel@gnu.org; Mon, 01 Apr 2013 05:36:11 -0400 Received: from mail-ea0-x22a.google.com ([2a00:1450:4013:c01::22a]:41218) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UMb9s-0001Sg-Gs for grub-devel@gnu.org; Mon, 01 Apr 2013 05:36:08 -0400 Received: by mail-ea0-f170.google.com with SMTP id a15so934074eae.1 for ; Mon, 01 Apr 2013 02:36:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=x-received:message-id:date:from:user-agent:mime-version:to:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=PSmbU3mLo3ujX1VZ/SutS9bDV+Jwy5M0PX9nf76NeVk=; b=EkT4U+EfNvyrOGO6dFVR5iz+AdlVSe5jFZsAfmz4wzo1tqjXj9RgIJOKoo9DPG6NFA Pxrc526LtnQsiNQ9XrGq5O/ze9jkNT4AKvNBG4fxK8fdBSrQE8bK0vyaBQgn7KUuId2W h9jqiiAEjWedRuMhPgvpMtYQylWfpv6d7uljOMQvLr+ZbdU0cQpnwXFzUCptSTYb/b2I 0OpGZQBMKGmw2wdkZnPIy3bfFNCV86VLT0mukpf8b81JLCEA1MTs0C0AVf9gnKimHaEo G8qODAciPZzgjCm3QHop2BhN5KrVYiqjBaEjLkZlhfSY5fBZ4xWBlx5VYTeFuW343106 IGGg== X-Received: by 10.15.32.67 with SMTP id z43mr35988829eeu.24.1364808966693; Mon, 01 Apr 2013 02:36:06 -0700 (PDT) Received: from [192.168.56.2] (adsl-ull-215-77.47-151.net24.it. [151.47.77.215]) by mx.google.com with ESMTPS id q5sm19975754eeo.17.2013.04.01.02.36.04 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 01 Apr 2013 02:36:05 -0700 (PDT) Message-ID: <5159550B.1020706@gmail.com> Date: Mon, 01 Apr 2013 11:36:11 +0200 From: Francesco Lavra User-Agent: Mozilla/5.0 (X11; Linux i686; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 MIME-Version: 1.0 To: grub-devel@gnu.org Subject: Re: [PATCH 2/7] Initial support for ARMv7 architecture References: <5158E2B1.4040505@gmail.com> In-Reply-To: <5158E2B1.4040505@gmail.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:4013:c01::22a X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list Reply-To: The development of GNU GRUB List-Id: The development of GNU GRUB List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Apr 2013 09:36:14 -0000 On 04/01/2013 03:28 AM, Vladimir 'φ-coder/phcoder' Serbinenko wrote: >> +grub_err_t >> +reloc_thm_call (grub_uint16_t *target, Elf32_Addr sym_addr) >> +{ >> + grub_int32_t offset, offset_low, offset_high; >> + grub_uint32_t sign, j1, j2, is_blx; >> + grub_uint32_t insword, insmask; >> + >> + /* Extract instruction word in alignment-safe manner */ >> + insword = (*target << 16) | (*(target + 1)); > > Why not use grub_get_unaligned32 It's not a simple unaligned access, it's actually about accessing two naturally aligned 16-bit halfwords, and concatenating them by putting the first value in the most significant bytes. Each halfword is encoded in little endian, but the set of two halfwords is encoded "most significant halfword first". The problem here is in the GRUB_UTIL case, where accessing each of the two halfwords could cause endianness issues. In this case two calls to grub_target_to_host16() should be used to retrieve the instruction word. >> +#ifdef GRUB_UTIL >> +#pragma GCC diagnostic ignored "-Wcast-align" >> + grub_util_info (" *target = 0x%08x", *((unsigned int *)target)); >> +#endif > > grub_get_unaligned. Ditto, it's not a simple unaligned access. > >> + *addr = insword >> 16; >> + *(addr + 1) = insword & 0xffff; > > Use grub_set_unaligned+ The same applies here, in the util case a couple of grub_host_to_target16() calls must be used to store back the instruction word. -- Francesco