x86/build32: Discard all orphaned sections

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 <jandryuk@gmail.com>
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
Tested-by: Jason Andryuk <jandryuk@gmail.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
This commit is contained in:
Andrew Cooper committed 2020-05-13 20:33:42 +01:00
1 parent 9f74a7b66b
commit 24f94fca23
1 file changed
+10 -2
+10 -2
View File
@@ -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
@@ -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.
*/
*(*)
}
}
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.