From patchwork Fri Jan 3 11:39:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ard Biesheuvel X-Patchwork-Id: 206655 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-10.1 required=3.0 tests=DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B1027C2D0C2 for ; Fri, 3 Jan 2020 11:41:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 7E78E21835 for ; Fri, 3 Jan 2020 11:41:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578051697; bh=Q8weF/ruccANz+AO9p5Pr5ibKl+2BRCize4l+859iBI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=wkIzt5hXvNiKuO3P+2NJnVIFJEuHcp9ql+Se4vK9P3furR5IvfpKsnEm67ur22fbq 6Oy5dqot/o9T9csI5Qd+rPqtE479TzSf6tKDvg2MyJJqpBoaGePQR0LytEGAgq1bpW oAkMLudZWqfpG7oNAN7ORYmTm6oX0oUKwHl1Juks= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727698AbgACLkV (ORCPT ); Fri, 3 Jan 2020 06:40:21 -0500 Received: from mail.kernel.org ([198.145.29.99]:39482 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727664AbgACLkU (ORCPT ); Fri, 3 Jan 2020 06:40:20 -0500 Received: from localhost.localdomain (amontpellier-657-1-18-247.w109-210.abo.wanadoo.fr [109.210.65.247]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 71BF2227BF; Fri, 3 Jan 2020 11:40:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578051620; bh=Q8weF/ruccANz+AO9p5Pr5ibKl+2BRCize4l+859iBI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WKzWMJ3sXj5aMPCAFO9ldnSsZWwqlS6jfhWhT9E5IFN+Etoevmz9b/SaZj4HnXr6n 04JwbjqnQf+QVUjYoHnoEFU8UJB1AXAmsi/YNlNr6MFhF5oxw647weHxtxhce2AM5x YHmrwhM5NR1qylSYfAQE1TSQoKhS8pdiCyj34e10= From: Ard Biesheuvel To: linux-efi@vger.kernel.org, Ingo Molnar , Thomas Gleixner Cc: Ard Biesheuvel , Ard Biesheuvel , linux-kernel@vger.kernel.org, Andy Lutomirski , Arvind Sankar , Matthew Garrett Subject: [PATCH 02/20] efi/libstub/x86: force 'hidden' visibility for extern declarations Date: Fri, 3 Jan 2020 12:39:35 +0100 Message-Id: <20200103113953.9571-3-ardb@kernel.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20200103113953.9571-1-ardb@kernel.org> References: <20200103113953.9571-1-ardb@kernel.org> MIME-Version: 1.0 Sender: linux-efi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-efi@vger.kernel.org Commit c3710de5065d ("efi/libstub/x86: Drop __efi_early() export and efi_config struct") introduced a reference from C code in eboot.c to the startup_32 symbol defined in the .S startup code. This results in a GOT based reference to startup_32, and since GOT entries carry absolute addresses, they need to be fixed up before they can be used. On modern toolchains (binutils 2.26 or later), this reference is relaxed into a R_386_GOTOFF relocation (or the analogous X86_64 one) which never uses the absolute address in the entry, and so we get away with not fixing up the GOT table before calling the EFI entry point. However, GCC 4.6 combined with a binutils of the era (2.24) will produce a true GOT indirected reference, resulting in a wrong value to be returned for the address of startup_32() if the boot code is not running at the address it was linked at. Fortunately, we can easily override this behavior, and force GCC to emit the GOTOFF relocations explicitly, by setting the visibility pragma 'hidden'. Signed-off-by: Ard Biesheuvel --- arch/x86/boot/compressed/eboot.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/arch/x86/boot/compressed/eboot.c b/arch/x86/boot/compressed/eboot.c index da04948d75ed..565ee4733579 100644 --- a/arch/x86/boot/compressed/eboot.c +++ b/arch/x86/boot/compressed/eboot.c @@ -6,6 +6,8 @@ * * ----------------------------------------------------------------------- */ +#pragma GCC visibility push(hidden) + #include #include