From patchwork Tue Jan 26 17:10:42 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 60485 Delivered-To: patch@linaro.org Received: by 10.112.130.2 with SMTP id oa2csp2089010lbb; Tue, 26 Jan 2016 09:12:00 -0800 (PST) X-Received: by 10.98.67.153 with SMTP id l25mr3610808pfi.111.1453828313694; Tue, 26 Jan 2016 09:11:53 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id wb3si3082437pab.114.2016.01.26.09.11.53; Tue, 26 Jan 2016 09:11:53 -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 S967087AbcAZRLr (ORCPT + 30 others); Tue, 26 Jan 2016 12:11:47 -0500 Received: from mail-wm0-f51.google.com ([74.125.82.51]:37315 "EHLO mail-wm0-f51.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S967064AbcAZRLk (ORCPT ); Tue, 26 Jan 2016 12:11:40 -0500 Received: by mail-wm0-f51.google.com with SMTP id n5so141757194wmn.0 for ; Tue, 26 Jan 2016 09:11:38 -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=LgRrFI2wuHi9/Avnd0/yN3SMUKweKebITt4V5CkVknMWbpyJiSc7XxR2u5zL0QAHcf YwldTE9/zfg885E0uSGDtKjUVPc+/qkm7K2Dwm2KityDeiDnFxJpReUnFTKXXdmDw+pF eXlvqUS3ksLrS7zvuFaYiGGlT5mHvOk/KBYdY= 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=AAlJqfv2pGA0dTRCkfyUvwFqJI79nnkVdk2xQmFLk07u43fn9qs8wU6mw8VRmgvMUc gKJii8zgVKF9ng2sea/0obzZ3hoM3sT6r7suD0PcCgIUBFA7gh5JpBOW4norIY6mC9Fz MF/8ZScLCrVSV4iFuMMqdRrCpJfoymZGOPUPC0QwxNWDRN8AFf1QX4FK3g3E2L2atppv rKlCdXfRzO/yd9Jl/GkMCfL1+PDgYrD8OHcYDX6pgzt8t+4TE99/z2WoUv8weVZm6LDM QxtcfdFwTLV14819uB/ssvbzMzg2ji+bllTZvElI23VZygkLaVpRe2NzC2spR2TYhL8C eOEQ== X-Gm-Message-State: AG10YORBWQAqy/wbfLwMq/yelcBXhm7oFNqZbXKIN/UWl38PXYefrN7Pua0W1yH3eI/vnDR9 X-Received: by 10.28.146.8 with SMTP id u8mr24131247wmd.72.1453828297936; Tue, 26 Jan 2016 09:11:37 -0800 (PST) Received: from localhost.localdomain ([195.55.142.58]) by smtp.gmail.com with ESMTPSA id ko2sm2328617wjc.9.2016.01.26.09.11.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 26 Jan 2016 09:11:37 -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, labbott@fedoraproject.org, matt@codeblueprint.co.uk, Ard Biesheuvel Subject: [PATCH v4 15/22] scripts/sortextable: add support for ET_DYN binaries Date: Tue, 26 Jan 2016 18:10:42 +0100 Message-Id: <1453828249-14467-16-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.5.0 In-Reply-To: <1453828249-14467-1-git-send-email-ard.biesheuvel@linaro.org> References: <1453828249-14467-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);