x86/build: use --orphan-handling linker option if available
authorJan Beulich <jbeulich@suse.com>
Mon, 14 Mar 2022 09:33:35 +0000 (10:33 +0100)
committerJan Beulich <jbeulich@suse.com>
Mon, 14 Mar 2022 09:33:35 +0000 (10:33 +0100)
commitdedb0aa42c6d1ee31805dfc61630db2c41117330
tree1cd8cd005a62f71748d2b17c1e3df388dca0664c
parente2589ef65283f475b3c980020a2d1d79ab593d65
x86/build: use --orphan-handling linker option if available

As was e.g. making necessary 4b7fd8153ddf ("x86: fold sections in final
binaries"), arbitrary sections appearing without our linker script
placing them explicitly can be a problem. Have the linker make us aware
of such sections, so we would know that the script needs adjusting.

To deal with the resulting warnings:
- Retain .note.* explicitly for ELF, and discard all of them (except the
  earlier consumed .note.gnu.build-id) for PE/COFF.
- Have explicit statements for .got, .plt, and alike and add assertions
  that they're empty. No output sections will be created for these as
  long as they remain empty (or else the assertions would cause early
  failure anyway).
- Collect all .rela.* into a single section, with again an assertion
  added for the resulting section to be empty.
- Extend the enumerating of .debug_* to ELF. Note that for Clang adding
  of .debug_macinfo is necessary. Amend this by its Dwarf5 counterpart,
  .debug_macro, then as well (albeit more may need adding for full
  coverage).
- For LLVM ld also enumerate .symtab, .strtab, and .shstrtab.

Suggested-by: Roger Pau Monné <roger.pau@citrix.com>
Signed-off-by: Jan Beulich <jbeulich@suse.com>
Reviewed-by: Roger Pau Monné <roger.pau@citrix.com>
xen/arch/x86/Makefile
xen/arch/x86/xen.lds.S