Skip to content

kpatch: support eu-readelf as alternative to GNU readelf#1500

Open
stephenchengCloud wants to merge 1 commit intodynup:masterfrom
stephenchengCloud:private/stephencheng/dev
Open

kpatch: support eu-readelf as alternative to GNU readelf#1500
stephenchengCloud wants to merge 1 commit intodynup:masterfrom
stephenchengCloud:private/stephencheng/dev

Conversation

@stephenchengCloud
Copy link
Copy Markdown

The kpatch script is used to load live patches on production systems that may be stripped down, with binutils (which provides readelf) not installed while elfutils (which provides eu-readelf) is available. Add a get_module_section_string() helper that auto-detects the available tool at startup and uses the appropriate invocation for each.

Other readelf usages in the build tooling (kpatch-build, lookup.c, test infrastructure) are left unchanged, as a compiler toolchain including binutils can reasonably be expected in a build environment.

The kpatch script is used to load live patches on production systems
that may be stripped down, with binutils (which provides readelf) not
installed while elfutils (which provides eu-readelf) is available. Add
a get_module_section_string() helper that auto-detects the available
tool at startup and uses the appropriate invocation for each.

Other readelf usages in the build tooling (kpatch-build, lookup.c,
test infrastructure) are left unchanged, as a compiler toolchain
including binutils can reasonably be expected in a build environment.

Signed-off-by: Stephen Cheng <stephen.cheng@citrix.com>
@stephenchengCloud
Copy link
Copy Markdown
Author

Tested:
get module name:

[root@eu1-dt021 ~]#  eu-readelf --string-dump=.gnu.linkonce.this_module lp_6_6_98__23_xs9__6_6_98__24_xs9.ko | awk 'NF>=3 && /^\s*\[/ {print $3; exit}'
lp_6_6_98__23_xs9__6_6_98__24_xs9
[root@eu1-dt021 ~]#
[root@eu1-dt021 ~]# readelf -p .gnu.linkonce.this_module lp_6_6_98__23_xs9__6_6_98__24_xs9.ko | grep '\[.*\]' | awk '{print $3}'
lp_6_6_98__23_xs9__6_6_98__24_xs9

get checksum:

[root@eu1-dt021 ~]# readelf -p .kpatch.checksum test_module_with_checksum.ko | grep '\[.*\]' | awk '{print $3}'
d41d8cd98f00b204e9800998ecf8427e
[root@eu1-dt021 ~]#  eu-readelf --string-dump=.kpatch.checksum test_module_with_checksum.ko | awk 'NF>=3 && /^\s*\[/ {print $3; exit}'
d41d8cd98f00b204e9800998ecf8427e
[root@eu1-dt021 ~]#

empty checksum:

stephenche@40 kpatch (v0.9.9) $ readelf -p .kpatch.checksum lp_6_6_98__23_xs9__6_6_98__24_xs9.ko 2>/dev/null | grep '\[.*\]' | awk '{print $3}'
stephenche@40 kpatch (v0.9.9) $ eu-readelf --string-dump=.kpatch.checksum lp_6_6_98__23_xs9__6_6_98__24_xs9.ko 2>/dev/nul

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant