livepatch: set -f{function,data}-sections compiler option
authorRoger Pau Monne <roger.pau@citrix.com>
Wed, 9 Mar 2022 12:28:46 +0000 (13:28 +0100)
committerAndrew Cooper <andrew.cooper3@citrix.com>
Thu, 10 Mar 2022 18:47:55 +0000 (18:47 +0000)
commit6ff9a7e62b8c43fe3e9d360fbd49d5854787bc39
tree0ebc33fd728239fb5fea85fc14264155fce45941
parent4267a33b19d43c988fd4535093c426aa2aec70a1
livepatch: set -f{function,data}-sections compiler option

If livepatching support is enabled build the hypervisor with
-f{function,data}-sections compiler options, which is required by the
livepatching tools to detect changes and create livepatches.

This shouldn't result in any functional change on the hypervisor
binary image, but does however require some changes in the linker
script in order to handle that each function and data item will now be
placed into its own section in object files. As a result add catch-all
for .text, .data and .bss in order to merge each individual item
section into the final image.

The main difference will be that .text.startup will end up being part
of .text rather than .init, and thus won't be freed. .text.exit will
also be part of .text rather than dropped. Overall this could make the
image bigger, and package some .text code in a sub-optimal way.

On Arm the .data.read_mostly needs to be moved ahead of the .data
section like it's already done on x86, so the .data.* catch-all
doesn't also include .data.read_mostly. The alignment of
.data.read_mostly also needs to be set to PAGE_SIZE so it doesn't end
up being placed at the tail of a read-only page from the previous
section. While there move the alignment of the .data section ahead of
the section declaration, like it's done for other sections.

The benefit of having CONFIG_LIVEPATCH enable those compiler option
is that the livepatch build tools no longer need to fiddle with the
build system in order to enable them. Note the current livepatch tools
are broken after the recent build changes due to the way they
attempt to set  -f{function,data}-sections.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Acked-by: Julien Grall <jgrall@amazon.com>
Reviewed-by: Jan Beulich <jbeulich@suse.com>
xen/Kconfig
xen/Makefile
xen/arch/arm/xen.lds.S
xen/arch/x86/xen.lds.S
xen/common/Kconfig