From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2a00:1450:400c:c09::22b; helo=mail-wm0-x22b.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-wm0-x22b.google.com (mail-wm0-x22b.google.com [IPv6:2a00:1450:400c:c09::22b]) (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 7BE7E21295CB2 for ; Tue, 12 Jun 2018 08:23:41 -0700 (PDT) Received: by mail-wm0-x22b.google.com with SMTP id e16-v6so21288855wmd.0 for ; Tue, 12 Jun 2018 08:23:41 -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:in-reply-to:references; bh=l0vlCCucNOK9ayAX59EvpjIqjByCrKqyJoU8qyQROEs=; b=fhsmiN/p8/ZSGluUwKhHdFPEgvrnraqRh/qWjOUEOpNVMd7PuCi3B4dlfY2+xZPR8x D1UHB6cxaPDBMMLFe3qpAmutBRNul+HBS7BLWLI8BmCCoU/0w3TA3eodZiv8qs/ukMW5 4bFE/3B5komxkg5lizkvJXffPJhnzGZsJMQIM= 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:in-reply-to :references; bh=l0vlCCucNOK9ayAX59EvpjIqjByCrKqyJoU8qyQROEs=; b=AzCV/h9BIR/nharepxtrAIVLOWiTRawe+Z2d7mgc9k+jwEoFpLRgFAt81+7KtUV4FV +rC4grSWAQlifQWlPXYoCEAZGOon9PIoC9wlhOc2abOPZzdETI7YW57K4QWmyqTKdD+N bHDZ5bsuIJRh6V3GeSEXZKgkVzrPmRjswiWhKyfCjcwnxBqftZF/w5iGHphl9s64zI45 173QDmpQVOgMm1RNH7de8O+bOtSiaLugmImosRJlCZz28fwlbhw6Q1ZvGjthTu/AC1NJ 2nhcQ3FeE+otlAUcYfZR++qNQcqmoK0ihvlHJpW7eJIcK3skX+XZvo8AUOF0dc2d/MAo Z/3w== X-Gm-Message-State: APt69E2kKFaA+OqCy793ps5wtHp3FnFE1DxorV1E/E+fic0oL71etP0k /tTiVt1VAeSLsei9lViyDTpg0Kl5e+Q= X-Google-Smtp-Source: ADUXVKIgH7Y/FP28dbRu0SJUtwwKgmzQ/oyBsJvG3wsLw18t/xEhjSskw2x0NL3ZkRGj62TCltB+cw== X-Received: by 2002:a1c:3fc2:: with SMTP id m185-v6mr538995wma.37.1528817019694; Tue, 12 Jun 2018 08:23:39 -0700 (PDT) Received: from dogfood.home ([2a01:cb1d:112:6f00:3c84:18ae:27f2:d03]) by smtp.gmail.com with ESMTPSA id e2-v6sm500983wro.97.2018.06.12.08.23.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 12 Jun 2018 08:23:38 -0700 (PDT) From: Ard Biesheuvel To: edk2-devel@lists.01.org Cc: Ard Biesheuvel , Michael D Kinney , Liming Gao , Ruiyu Ni , Hao Wu , Leif Lindholm , Jordan Justen , Andrew Fish , Star Zeng , Eric Dong , Laszlo Ersek , Zenith432 , "Shi, Steven" Date: Tue, 12 Jun 2018 17:23:06 +0200 Message-Id: <20180612152306.25998-12-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180612152306.25998-1-ard.biesheuvel@linaro.org> References: <20180612152306.25998-1-ard.biesheuvel@linaro.org> Subject: [RFC PATCH 11/11] MdePkg/ProcessorBind.h X64: drop non-LTO limitation on visiblity override X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.26 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Jun 2018 15:23:41 -0000 When LTO is in effect, overriding the symbol visibility to 'hidden' using a GCC pragma used to result in module entry points being discarded, and along with them all other code in the binary. Now that we annotated all module entry points explicitly as having 'default' visibility, this is no longer the case, and we can drop this restriction. This prevents GCC's LTO code generator from emitting GOT based relocations that are non-trivial to deal with in GenFw. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Ard Biesheuvel --- MdePkg/Include/X64/ProcessorBind.h | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/MdePkg/Include/X64/ProcessorBind.h b/MdePkg/Include/X64/ProcessorBind.h index 38ef2665390f..7f78489bc2c4 100644 --- a/MdePkg/Include/X64/ProcessorBind.h +++ b/MdePkg/Include/X64/ProcessorBind.h @@ -27,18 +27,24 @@ #pragma pack() #endif -#if defined(__GNUC__) && defined(__pic__) && !defined(USING_LTO) +#if defined(__GNUC__) && defined(__pic__) // // 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. // -// The LTO linker will not emit GOT based relocations when all symbol -// references can be resolved locally, and so there is no need to set the -// pragma in that case (and doing so will cause other issues). -// #pragma GCC visibility push (hidden) + +// +// When LTO is in effect, symbols with hidden visibility will get discarded, +// since by definition, they cannot be referenced externally, even if they +// are the entry point of the executable. So we will have to change the +// visibility back to 'default' explicitly for all such entry points. +// +#ifdef USING_LTO +#define EFI_ENTRYPOINT __attribute__((__visibility__("default"))) +#endif #endif #if defined(__INTEL_COMPILER) -- 2.17.1