From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x22c.google.com (mail-wm0-x22c.google.com [IPv6:2a00:1450:400c:c09::22c]) (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 9F1411A1E11 for ; Sun, 31 Jul 2016 23:57:27 -0700 (PDT) Received: by mail-wm0-x22c.google.com with SMTP id q128so357215570wma.1 for ; Sun, 31 Jul 2016 23:57:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=n90edvK9Qf0uWFO2w0CoimnnXn1vFEFjVvSVvgjLsJA=; b=CfeolE1MC9VbhRFAClpFNpLAyH1dmd7djrmd011pY8oX6FMM6GnKUkuYSgWpYIMrg5 0x8zxdhg+Kx+CLmf41JrnvWbgJOLFmXj6WB3EAdOZFWjy91Izxqj/qDEPDvf7Q34AGe9 OLbrfsaIZUgYAE6VwSuxFynd74uppj4hOeBJc= 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; bh=n90edvK9Qf0uWFO2w0CoimnnXn1vFEFjVvSVvgjLsJA=; b=BqF4C9Cye7US4zp6U6WHo9u99MQrC5BN29d7RskXryjzqIaj49AZGBFXK4MA7J0kp/ 9tta9bMtTZmPrUDkqp/I2qxyi3LNqXXU677RgOTZ1pwDlcv2A2P/TUL374ASztM/Z5II SputuWR11/92omvkGP3TlUnZa3LzVxniGRJclt3yKtkZbHrOOpT+1/vOdzrAII7cVspj YFqsFEr87IezzzTaT8pQEbqmnI0IUTlSyaT9ERAwiXC4bQtIcnr7GihonOzMiSIqPKSA SN3DrfcI+q6opXK8Hm0c0akLNT8eiDiw1NrRuR/I7s9UYNdRkZpwQeAmoiQhp9TLJT7c sf0g== X-Gm-Message-State: AEkoouuY4ynthUHzZ++GgGTA2E3z1h1EFp58wjU/R0Mqp7KidgzGXFVTLl5I5SEw+cVMIYKv X-Received: by 10.194.77.97 with SMTP id r1mr52796162wjw.83.1470034645579; Sun, 31 Jul 2016 23:57:25 -0700 (PDT) Received: from localhost.localdomain (3.red-81-34-118.dynamicip.rima-tde.net. [81.34.118.3]) by smtp.gmail.com with ESMTPSA id b186sm15398821wmg.23.2016.07.31.23.57.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Sun, 31 Jul 2016 23:57:24 -0700 (PDT) From: Ard Biesheuvel To: steven.shi@intel.com, yonghong.zhu@intel.com, liming.gao@intel.com, jordan.l.justen@intel.com, edk2-devel@lists.01.org Cc: Ard Biesheuvel Date: Mon, 1 Aug 2016 08:57:20 +0200 Message-Id: <1470034640-3912-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [PATCH] MdePkg: move to 'hidden' visibility for all symbols under GCC/X64 X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 01 Aug 2016 06:57:28 -0000 When using GCC to build for X64, we switched to the position independent small code model, which is much more efficient in terms of code generation and runtime relocation footprint, and produces binaries that can execute correctly from any offset. However, the PIC routines are by default geared towards hosted binaries containing symbol references that may resolve to definitions in other dynamic objects, and for this reason, external symbol references are indirected via a GOT entry by default (which also results in a .reloc fixup entry) unless we annotate them. For this reason, we introduced the 'protected' visibility annotation for all symbol definitions and references, by setting the GCC visibility pragma. However, as it turns out, this is not sufficient for all versions of GCC, and in some cases (GCC 5.x using the GCC49 toolchain tag), may still result in GOT based relocations. So switch to 'hidden' visibility instead, which is slightly stronger, and fixes this issue for the versions of GCC that exhibit the problem. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- MdePkg/Include/X64/ProcessorBind.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/MdePkg/Include/X64/ProcessorBind.h b/MdePkg/Include/X64/ProcessorBind.h index a4aad3e524e8..666cc8e8bd16 100644 --- a/MdePkg/Include/X64/ProcessorBind.h +++ b/MdePkg/Include/X64/ProcessorBind.h @@ -29,12 +29,12 @@ #if defined(__GNUC__) && defined(__pic__) // -// Mark all symbol declarations and references as protected, meaning they will +// Mark all symbol declarations and references as hidden, meaning they will // not be subject to symbol preemption. This allows the compiler to refer to // symbols directly using relative references rather than via the GOT, which // contains absolute symbol addresses that are subject to runtime relocation. // -#pragma GCC visibility push (protected) +#pragma GCC visibility push (hidden) #endif #if defined(__INTEL_COMPILER) -- 2.7.4