Skip to content

Commit

Permalink
x86/build32: Discard all orphaned sections
Browse files Browse the repository at this point in the history
Linkers may put orphaned sections ahead of .text, which breaks the calling
requirements.  A concrete example is Ubuntu's GCC-9 default of enabling
-fcf-protection which causes us to try and execute .note.gnu.properties during
Xen's boot.

Put .got.plt in its own section as it specifically needs preserving from the
linkers point of view, and discard everything else.  This will hopefully be
more robust to other unexpected toolchain properties.

Fixes boot from an Ubuntu build of Xen.

Reported-by: Jason Andryuk <[email protected]>
Signed-off-by: Andrew Cooper <[email protected]>
Tested-by: Jason Andryuk <[email protected]>
Acked-by: Jan Beulich <[email protected]>
  • Loading branch information
andyhhp committed May 13, 2020
1 parent 9f74a7b commit 24f94fc
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions xen/arch/x86/boot/build32.lds
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ SECTIONS
*(.bss.*)
}

/DISCARD/ : {
.got.plt : {
/*
* PIC/PIE executable contains .got.plt section even if it is not linked
* with dynamic libraries. In such case it is just placeholder for
Expand All @@ -47,6 +47,14 @@ SECTIONS
*
* Please check build32.mk for more details.
*/
/* *(.got.plt) */
*(.got.plt)
}

/DISCARD/ : {
/*
* Discard everything else, to prevent linkers from putting
* orphaned sections ahead of .text, which needs to be first.
*/
*(*)
}
}

0 comments on commit 24f94fc

Please sign in to comment.