From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-x233.google.com (mail-wm0-x233.google.com [IPv6:2a00:1450:400c:c09::233]) (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 383371A1E28 for ; Wed, 10 Aug 2016 01:56:18 -0700 (PDT) Received: by mail-wm0-x233.google.com with SMTP id q128so79711220wma.1 for ; Wed, 10 Aug 2016 01:56:18 -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=KUayATVU2l05455KAA5KEBYQ5xbxUcSXl27a85qi+pg=; b=ipKJ/1HU5R4pcOc6M2ipy/O6A/lqW7SZ9jP8JaNtXWjw6DUVQFLyPDR5KaC+ec/8ZW qNBlyQyGH9VqlmbqAJt10eeQavYIWg9AhsA7Rth7AWKS8ygAC4QvRyDkMiK06k7MyJ8m QxokbMviwecu/Rvj1cRt4DQi5pHe6b+U0/wBU= 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=KUayATVU2l05455KAA5KEBYQ5xbxUcSXl27a85qi+pg=; b=ETYRqYUDdcNyZEPKxji3z31+/JTGVtaY4r/w2ob5CuVNPUkpvZqR08l7+qj2ghlpUY 11QULfjsK+oCXryOawaTtoZ1oIuPAN3jvL7FKh8KV2Mn6K5DRgUeO105Bv6B8T/cGR9H 4tYiBDA0QslVse05n6uBqo4SkFCaNbx1UFBN4dfNtU3oWmvwJYRn+/yxR7D+LYRMTAz2 oZoZiAAt7tWlwVZ7zkujEuWDWo6lazFpyHU9gQzF8OGblpi31FwbXCEYiCiI38aWTBn7 1IjOqzILDNo11vIbKncwCAIMlx+i2R/359Lb6/jZCzNyb27wylTUzVvSzeBA4dzZVoVl 7bxw== X-Gm-Message-State: AEkoouuEqCBhEsNjjtGeByCSHHnvKtXOm2Y1Lxqatnx9jzP2HH/+y3rgyQdE1A2aTfJGv3Pc X-Received: by 10.28.98.135 with SMTP id w129mr1957046wmb.38.1470819376405; Wed, 10 Aug 2016 01:56:16 -0700 (PDT) Received: from localhost.localdomain (46.red-81-37-107.dynamicip.rima-tde.net. [81.37.107.46]) by smtp.gmail.com with ESMTPSA id x133sm7267641wmf.16.2016.08.10.01.56.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Wed, 10 Aug 2016 01:56:15 -0700 (PDT) From: Ard Biesheuvel To: steven.shi@intel.com, yonghong.zhu@intel.com, liming.gao@intel.com, edk2-devel@lists.01.org Cc: Ard Biesheuvel Date: Wed, 10 Aug 2016 10:55:30 +0200 Message-Id: <1470819330-7363-1-git-send-email-ard.biesheuvel@linaro.org> X-Mailer: git-send-email 2.7.4 Subject: [PATCH] BaseTools/GccBase.lds: don't copy RELA section to PE/COFF 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: Wed, 10 Aug 2016 08:56:18 -0000 The CLANG38 toolchain creates a PIE binary at link time. This is necessary since the LTO code generation may otherwise result in code that cannot execute correctly when loaded above 2 GB. PIE executables contain a RELA section consisting of dynamic relocation entries that are intended for consumption by the loader at runtime. For this reason, it has the SHF_ALLOC attribute set by default, and will be identified by GenFw as a section that needs to be copied into the PE/COFF binary, resulting in waste of space since the PE/COFF loader does not use this data at all. So mark the RELA section as informational: this will prevent the linker from setting the SHF_ALLOC attribute, causing GenFw to ignore it. DxeCore.efi before: Detected 'X64' type PE/COFF image consisting of 3 sections Section alignment: 0x40 File alignment: 0x40 Section '.text' @ 0x00000240 File offset: 0x240 Virtual size: 0x21000 Raw size: 0x21000 Section '.data' @ 0x00021240 File offset: 0x21240 Virtual size: 0x3640 Raw size: 0x3640 Section '.reloc' @ 0x00024880 File offset: 0x24880 Virtual size: 0x280 Raw size: 0x280 DxeCore.efi after: Detected 'X64' type PE/COFF image consisting of 3 sections Section alignment: 0x40 File alignment: 0x40 Section '.text' @ 0x00000240 File offset: 0x240 Virtual size: 0x1f440 Raw size: 0x1f440 Section '.data' @ 0x0001f680 File offset: 0x1f680 Virtual size: 0x3640 Raw size: 0x3640 Section '.reloc' @ 0x00022cc0 File offset: 0x22cc0 Virtual size: 0x280 Raw size: 0x280 Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Ard Biesheuvel --- BaseTools/Scripts/GccBase.lds | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/BaseTools/Scripts/GccBase.lds b/BaseTools/Scripts/GccBase.lds index 281af8a9bd33..900848747144 100644 --- a/BaseTools/Scripts/GccBase.lds +++ b/BaseTools/Scripts/GccBase.lds @@ -54,7 +54,7 @@ SECTIONS { KEEP (*(.eh_frame)) } - .rela ALIGN(CONSTANT(COMMONPAGESIZE)) : { + .rela (INFO) : { *(.rela .rela.*) } -- 2.7.4