From patchwork Tue Dec 11 09:37:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 153410 Delivered-To: patch@linaro.org Received: by 2002:a2e:299d:0:0:0:0:0 with SMTP id p29-v6csp408831ljp; Tue, 11 Dec 2018 01:37:22 -0800 (PST) X-Google-Smtp-Source: AFSGD/U6N6wzeGTuDBKB1l+f1pOS2NARJNjCAQtFVkNbbC8hoWSKHoEUGabuh084qsN68e1fMw2D X-Received: by 2002:a65:4683:: with SMTP id h3mr13349235pgr.225.1544521041960; Tue, 11 Dec 2018 01:37:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1544521041; cv=none; d=google.com; s=arc-20160816; b=wWhSN0sAiKPIIIRSgbEkwWh3P2LSzVeD2IGvk7+tKQGEKfCRZt1791pXjwxT7Aru4a lyBolCDRXQP9qw2mLam8/HUZ++sbOLLu8oTUvl+RuM2X3HG9niMrXm7XlnpzyMyVbHzi 7pBg7gofl8WDp0f6avv3+sm5nylO6y/6UqYZcc9fJ0JcpLRJMo/Qk+iqaYVVHo2x4WwJ rfCe3SjaTAywJPXGLQfd8QfvxsfKz6tyMCu7WPvXTXuRHJwtQ4i0PyVcq6z3KhS4Sq9z GsFYw0C7rN9ftxRGeSqg4VtNyd9Mqt/AVklPRANxENZ8o0FIhZe31MSVG9yhD0CV9gva V2cQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:message-id:date:to:from :dkim-signature:delivered-to; bh=nZY92WIaip2wxcobWR21QeiPMWRTmm0/y+9GZ9xOAjI=; b=JnaPvto1hwk2EXK6XhOxWeBDTQ4VywDGyWxQC+ioGFLuX2vUgYoZ8zVmCnPRqbK35y oUENW3PhLWKpmnM9gyk4Cot7C0ahxox6ahuUTk9Y5RmVTilg5mWyfMZ+Xx43O7JXx5/g rt0Zbq8q9lG1/qtxf65DgZqJTw75zxnsnrdZzggU572RSGY6oSy18SGiXBll2En848YW iX4B0yiFFmjZo5C6luwN8zgNio0RT0vgvPXw+5T8lG1uuDu80oDC5j0t5hzRqEY2Zpx0 O3lWNb1RI9TFQKJ71tyxn5gKLe9ewq9I/kuJ+IbXUTLt5N+eR93GhgmeOvtdVjlpCK5S CGYA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FNLYBhRa; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from ml01.01.org (ml01.01.org. [198.145.21.10]) by mx.google.com with ESMTPS id x5si10912054pga.440.2018.12.11.01.37.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 01:37:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) client-ip=198.145.21.10; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=FNLYBhRa; spf=pass (google.com: best guess record for domain of edk2-devel-bounces@lists.01.org designates 198.145.21.10 as permitted sender) smtp.mailfrom=edk2-devel-bounces@lists.01.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8AFBC21198CD4; Tue, 11 Dec 2018 01:37:21 -0800 (PST) X-Original-To: edk2-devel@lists.01.org Delivered-To: edk2-devel@lists.01.org Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:4864:20::442; helo=mail-wr1-x442.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wr1-x442.google.com (mail-wr1-x442.google.com [IPv6:2a00:1450:4864:20::442]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 809E321198CC2 for ; Tue, 11 Dec 2018 01:37:20 -0800 (PST) Received: by mail-wr1-x442.google.com with SMTP id 96so13332262wrb.2 for ; Tue, 11 Dec 2018 01:37:20 -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:mime-version :content-transfer-encoding; bh=se8UsiLMKJumxugeYKzEZCfWDnU3uH7+WdfqF0w7ygY=; b=FNLYBhRamLJDDrwQSA/3Y0Yi3+cpWloOFpU/hUfTsSs11kGHfO7ZbmhAXoKuDtDOe1 H9IO+pmYqqp/jT1x1PMcmxL0/BnwUxHXcKKas3/54/plMDN9Fs/W7GNtzYSdOiviebib GvfUflLl1lDTxeOYItXbyG8IxPFE5ro8aVq5s= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=se8UsiLMKJumxugeYKzEZCfWDnU3uH7+WdfqF0w7ygY=; b=GgQcbKMRh5iufeJiJVteik0i+op7KhCAnSG9Larn3MWQ//YYgKBqg9xO98ZJ0ue+St VQI6irh0okbWG0tXzHvBnZ8OZaOzmbvMTvXfBvYsmDxJyvyvI8/VeDndgtdAWi8s5Yre 0lRzsSqJSa+UVkHD8pg4e519FluEwje8zyodP48Zv9netFIdB4gEdkmL0VZ9B0stPgf9 Q33pE67ATci4hYG522/CcvjanmqBz6ivw0E758HR681gpPS4Odl/1QHiGvzU5z6Sq4c8 9rIyN6Cz7yTaYOrlDYjzjByCODp1+OoaLzY1vru2tI6BEv0wnlIZThQMuUpkpnTYfgtb UyeA== X-Gm-Message-State: AA+aEWYKhBN1Gi+Nv2g+GySz5BVJ3Wu14Nydc9hYGlBdr9YU+GqLqH2y e/UiKp4wCtyrabBEoVhRf6myognBk86i+w== X-Received: by 2002:a5d:5443:: with SMTP id w3mr11817140wrv.4.1544521038357; Tue, 11 Dec 2018 01:37:18 -0800 (PST) Received: from harold.home ([2a01:cb1d:112:6f00:8c3:6b9d:cbc9:58c6]) by smtp.gmail.com with ESMTPSA id y34sm42589313wrd.68.2018.12.11.01.37.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 11 Dec 2018 01:37:17 -0800 (PST) From: Ard Biesheuvel To: edk2-devel@lists.01.org Date: Tue, 11 Dec 2018 10:37:15 +0100 Message-Id: <20181211093715.6048-1-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.19.2 MIME-Version: 1.0 Subject: [edk2] [PATCH] BaseTools/GenFw ARM: don't permit R_ARM_GOT_PREL relocations X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: lersek@redhat.com, Liming Gao Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" We currently permit R_ARM_GOT_PREL relocations in the ELF32 conversion routines, under the assumption that relative relocations are fine as long as the section layout is the same between ELF and PE/COFF. However, as is the case with any proxy generating relocation, it is up to the linker to emit an entry in the GOT table and populate it with the correct absolute address, which should also be fixed up at PE/COFF load time. Unfortunately, the relocations covering the GOT section are not emitted into the static relocation sections processed by GenFw, but only in the dynamic relocation section as a R_ARM_RELATIVE relocation, and so GenFw fails to emit the correct PE/COFF relocation data for GOT entries. Since GOT indirection is pointless anyway for PE/COFF modules running in UEFI context, let's just drop the references to R_ARM_GOT_PREL from GenFw, resulting in a build time failure rather than a runtime failure if such relocations do occur. Cc: Bob Feng Cc: Liming Gao Cc: Leif Lindholm Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- Without this patch, CLANG38 builds of ArmVirtQemuKernel-ARM (in LTO mode) succeed, but the resulting binaries are broken. This is due to the fact that the PIE linker running in LTO mode insists on emitting GOT based relocations, while we don't have the code to fix up the contents of the GOT. This change puts it in line with the AARCH64 build of the same platform/toolchains, which chokes on GOT based relocations as well. Since the use of the PIE linker is a peculiarity of ArmVirtQemuKernel/ArmVirtXen, and the fact that it is impossible to prevent the linker from emitting GOT based relocations, let's not go out of our way to fix it in the tools, but just drop CLANG38 support from those platforms. BaseTools/Source/C/GenFw/Elf32Convert.c | 2 -- 1 file changed, 2 deletions(-) -- 2.19.2 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel Reviewed-by: Leif Lindholm Acked-by: Laszlo Ersek diff --git a/BaseTools/Source/C/GenFw/Elf32Convert.c b/BaseTools/Source/C/GenFw/Elf32Convert.c index 3d7de6d5c123..23e8065756e6 100644 --- a/BaseTools/Source/C/GenFw/Elf32Convert.c +++ b/BaseTools/Source/C/GenFw/Elf32Convert.c @@ -837,7 +837,6 @@ WriteSections32 ( case R_ARM_LDC_PC_G0: case R_ARM_LDC_PC_G1: case R_ARM_LDC_PC_G2: - case R_ARM_GOT_PREL: case R_ARM_THM_JUMP11: case R_ARM_THM_JUMP8: case R_ARM_TLS_GD32: @@ -964,7 +963,6 @@ WriteRelocations32 ( case R_ARM_LDC_PC_G0: case R_ARM_LDC_PC_G1: case R_ARM_LDC_PC_G2: - case R_ARM_GOT_PREL: case R_ARM_THM_JUMP11: case R_ARM_THM_JUMP8: case R_ARM_TLS_GD32: