Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752888AbcD0Tjy (ORCPT ); Wed, 27 Apr 2016 15:39:54 -0400 Received: from pandora.arm.linux.org.uk ([78.32.30.218]:54425 "EHLO pandora.arm.linux.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752388AbcD0Tjx (ORCPT ); Wed, 27 Apr 2016 15:39:53 -0400 Date: Wed, 27 Apr 2016 20:39:41 +0100 From: Russell King - ARM Linux To: Alexandre Belloni Cc: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Ard Biesheuvel , Dave Martin , Olof Johansson , Doug Anderson , Heiko Stuebner , Russ Dill , Nicolas Ferre Subject: Re: [PATCH 1/2] ARM: PIE infrastructure Message-ID: <20160427193941.GR19428@n2100.arm.linux.org.uk> References: <1459668234-16033-1-git-send-email-alexandre.belloni@free-electrons.com> <1459668234-16033-2-git-send-email-alexandre.belloni@free-electrons.com> <20160404100052.GS19428@n2100.arm.linux.org.uk> <20160422231503.GE17051@piout.net> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20160422231503.GE17051@piout.net> User-Agent: Mutt/1.5.23 (2014-03-12) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1393 Lines: 30 On Sat, Apr 23, 2016 at 01:15:03AM +0200, Alexandre Belloni wrote: > Well, do you want me to iterate and use fncpy on all the functions from > the generated binary? No, because that will break the image too. > I'm not sure this is necessary as the generated binary is self contained > and doing so will force me to also ensure the offsets are kept the same. > Doing only one copy is much more convenient. However, I still need to > ensure the destination address is properly 8-byte aligned and the > flush_icache_range(). What you need to do is to immitate being an ELF loader - in other words, copy the blob according to the alignment rules of the blob (which may be greater than 8-byte alignment) and use the symbol table to find the functions and the type of the function (ARM vs ELF). > I understand this is abusing fncpy() but it does want I need (still, I'm > planning to avoid the BUG() by always passing a properly aligned > destination address). Yea yea yea, such arguments don't wash with me, sorry. The "but it does what I need" is total bollocks, sorry. fncpy() is designed for a purpose, and what you're doing is an abuse of it, one which I will not stand for for the sake of long term maintainability. -- RMK's Patch system: http://www.arm.linux.org.uk/developer/patches/ FTTC broadband for 0.8mile line: currently at 9.6Mbps down 400kbps up according to speedtest.net.