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>