]> xenbits.xensource.com Git - livepatch-build-tools.git/commit
create-diff-object: also include relas that point to changed sections
authorRoger Pau Monne <roger.pau@citrix.com>
Thu, 7 Nov 2024 10:58:57 +0000 (11:58 +0100)
committerRoger Pau Monne <roger.pau@citrix.com>
Tue, 21 Jan 2025 13:11:17 +0000 (14:11 +0100)
commit950b79a5e9c90747130955b8e32a665c9374f5e5
treefa1e0a2c6780cf1adba69313db249ae44bebc13b
parentcec5394e3c327d431cd482fd68ee5dde374bc470
create-diff-object: also include relas that point to changed sections

create-diff-object has a special handling for some specific sections, like
.altinstructions or .livepatch.hooks.*.  The contents of those sections are in
the form of array elements, where each element can be processed independently
of the rest.  For example an element in .altinstructions is a set of
replacement coordinates, with the layout specified by the alt_instr struct.  In
the case of .livepatch.hooks.* each element is a pointer to a hook function to
call.

The contents of this array is processed element wise, so that
create-diff-object can decide whether the element relates to the content in the
livepatch and thus needs keeping.  Such relation is driven based on the
contents of the relocations for the special sections.  If a relocation to be
applied to a special section element depends on any symbol to be included in
the livepatch then the special element is also considered required and thus
added to the livepatch contents.

However relocations don't always reference function type symbols, they can also
reference sections type symbols, and that's usually the case with hook symbols
that have relocations based on section symbols, as an example:

RELOCATION RECORDS FOR [.livepatch.hooks.load]:
OFFSET           TYPE              VALUE
0000000000000000 R_X86_64_64       .text.foobar

Symbol information for .text.foobar:

0000000000000000 l    d  .text.foobar      0000000000000000 .text.foobar

As seen above, the .livepatch.hooks.load relocation uses a non-function symbol,
which given the current code in should_keep_rela_group() would mean it's not
considered for inclusion in the livepatch.

Fix this by allowing should_keep_rela_group() to also keep relocations if they
either point to function or section symbols.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reviewed-by: Ross Lagerwall <ross.lagerwall@citrix.com>
create-diff-object.c