From patchwork Mon Jan 11 13:19:10 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 59483 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2106066lbb; Mon, 11 Jan 2016 05:22:54 -0800 (PST) X-Received: by 10.66.120.200 with SMTP id le8mr180757225pab.61.1452518574073; Mon, 11 Jan 2016 05:22:54 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id bx1si19250487pab.57.2016.01.11.05.22.53; Mon, 11 Jan 2016 05:22:54 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dkim=pass header.i=@linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1760061AbcAKNWv (ORCPT + 29 others); Mon, 11 Jan 2016 08:22:51 -0500 Received: from mail-wm0-f49.google.com ([74.125.82.49]:36952 "EHLO mail-wm0-f49.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759887AbcAKNUL (ORCPT ); Mon, 11 Jan 2016 08:20:11 -0500 Received: by mail-wm0-f49.google.com with SMTP id f206so268044394wmf.0 for ; Mon, 11 Jan 2016 05:20:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=z67To+qs5azAklcF3Exz2hEu6eSuUHNUH08oPoesVhk=; b=F5b68zqoKBQzoYl1JjG0esIeWQmB2Eqg7XZmyN01bhD4X007OJ4KLnUt62P3gIGs7i vvEYsBTsqGQBdVCR7ukma3C3diCx5OGojuBdyzp2rXOIOSdx+bvTDU8pe8gEHkpnYPrS rNeqn4EeJWNQZIFE8+2pC6L/PpGPsO6PIJDaU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=z67To+qs5azAklcF3Exz2hEu6eSuUHNUH08oPoesVhk=; b=XITPCglAFkPZEHw3zTlHTm+jI2Y0mPz8VRat3JbXz2fTSCw7NRJSgoZQdPi0ns/zaM xhBM5wUGB6aGJuh5qPT3SX9d1I2UeumrN71uGuRGbA0Z7XWZ6E5d7GI2sQd1mkF7pdn6 Yfbsz7MWGh74zUxnJ0biwFTVFk2MGj8zLqA0jLdyzUeQtmB0hr2sw7FDlYLK04L0NO2s RmC8A/f40KS4VQ5dCODgKM5rnklpVx/tO9yaJx/O4vHIlkOEZ2iAPxrAJjv+8FNPQshG ZPlPirZGruw91i7V3fZVhnFKAwuNHaU1nKYi5yYwx0b1TiyqauiZBiafEaQDWhk4FJRW gleA== X-Gm-Message-State: ALoCoQmBYslDSdzeF26RPLhgdgMkE8ONp/sayThLnNzP+ypFCHt7tkCkAN8ExVbuN8ul0KR/4nrx2yEkibZYGf17Bw1D4f58IA== X-Received: by 10.194.179.228 with SMTP id dj4mr10136748wjc.112.1452518409938; Mon, 11 Jan 2016 05:20:09 -0800 (PST) Received: from localhost.localdomain (cag06-7-83-153-85-71.fbx.proxad.net. [83.153.85.71]) by smtp.gmail.com with ESMTPSA id c15sm12766055wmd.19.2016.01.11.05.20.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 11 Jan 2016 05:20:09 -0800 (PST) From: Ard Biesheuvel To: linux-arm-kernel@lists.infradead.org, kernel-hardening@lists.openwall.com, will.deacon@arm.com, catalin.marinas@arm.com, mark.rutland@arm.com, leif.lindholm@linaro.org, keescook@chromium.org, linux-kernel@vger.kernel.org Cc: stuart.yoder@freescale.com, bhupesh.sharma@freescale.com, arnd@arndb.de, marc.zyngier@arm.com, christoffer.dall@linaro.org, Ard Biesheuvel Subject: [PATCH v3 16/21] scripts/sortextable: add support for ET_DYN binaries Date: Mon, 11 Jan 2016 14:19:10 +0100 Message-Id: <1452518355-4606-18-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1452518355-4606-1-git-send-email-ard.biesheuvel@linaro.org> References: <1452518355-4606-1-git-send-email-ard.biesheuvel@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add support to scripts/sortextable for handling relocatable (PIE) executables, whose ELF type is ET_DYN, not ET_EXEC. Other than adding support for the new type, no changes are needed. Signed-off-by: Ard Biesheuvel --- scripts/sortextable.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) -- 2.5.0 diff --git a/scripts/sortextable.c b/scripts/sortextable.c index af247c70fb66..19d83647846c 100644 --- a/scripts/sortextable.c +++ b/scripts/sortextable.c @@ -266,9 +266,9 @@ do_file(char const *const fname) break; } /* end switch */ if (memcmp(ELFMAG, ehdr->e_ident, SELFMAG) != 0 - || r2(&ehdr->e_type) != ET_EXEC + || (r2(&ehdr->e_type) != ET_EXEC && r2(&ehdr->e_type) != ET_DYN) || ehdr->e_ident[EI_VERSION] != EV_CURRENT) { - fprintf(stderr, "unrecognized ET_EXEC file %s\n", fname); + fprintf(stderr, "unrecognized ET_EXEC/ET_DYN file %s\n", fname); fail_file(); } @@ -304,7 +304,7 @@ do_file(char const *const fname) if (r2(&ehdr->e_ehsize) != sizeof(Elf32_Ehdr) || r2(&ehdr->e_shentsize) != sizeof(Elf32_Shdr)) { fprintf(stderr, - "unrecognized ET_EXEC file: %s\n", fname); + "unrecognized ET_EXEC/ET_DYN file: %s\n", fname); fail_file(); } do32(ehdr, fname, custom_sort); @@ -314,7 +314,7 @@ do_file(char const *const fname) if (r2(&ghdr->e_ehsize) != sizeof(Elf64_Ehdr) || r2(&ghdr->e_shentsize) != sizeof(Elf64_Shdr)) { fprintf(stderr, - "unrecognized ET_EXEC file: %s\n", fname); + "unrecognized ET_EXEC/ET_DYN file: %s\n", fname); fail_file(); } do64(ghdr, fname, custom_sort);