BaseTools GCC: drop GNU notes section from EFI image

Recent versions of GNU ld automatically emit a .notes section into
the ELF binary containing a build id. Since this is an allocatable
section by default, it will be identified by GenFw as a section
that requires PE/COFF conversion, which may cause sections to be
moved around unexpectedly.

So retain the section, but tag it as INFO, which tells the linker
that it should not be accounted for in the binary's memory layout.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Acked-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
This commit is contained in:
Ard Biesheuvel 2016-07-27 11:13:58 +02:00
parent e1458aaded
commit 7fd5d61980
1 changed files with 6 additions and 0 deletions

View File

@ -62,6 +62,12 @@ SECTIONS {
KEEP (*(.hii)) KEEP (*(.hii))
} }
/*
* Retain the GNU build id but in a non-allocatable section so GenFw
* does not copy it into the PE/COFF image.
*/
.build-id (INFO) : { *(.note.gnu.build-id) }
/DISCARD/ : { /DISCARD/ : {
*(.note.GNU-stack) *(.note.GNU-stack)
*(.gnu_debuglink) *(.gnu_debuglink)