Message ID | 20190916113056.16592-7-wipawel@amazon.de (mailing list archive) |
---|---|
State | New, archived |
Headers | show |
Series | livepatch-build-tools: new features and fixes | expand |
On 9/16/19 12:30 PM, Pawel Wieczorkiewicz wrote: > In the process of creating a final hotpatch module file make sure to > strip all transient symbols that have not been caught and removed by > create-diff-object processing. For now these are only the hooks > kpatch load/unload symbols. > > For all new object files that are carried along for the final linking > the transient hooks symbols are not stripped and neither are any > unneeded symbols. Strip them explicitly from resulting object file. > > Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de> > --- > livepatch-build | 25 +++++++++++++++++++++++++ > 1 file changed, 25 insertions(+) > > diff --git a/livepatch-build b/livepatch-build > index b8a1728..816064c 100755 > --- a/livepatch-build > +++ b/livepatch-build > @@ -111,6 +111,28 @@ function build_special() > unset LIVEPATCH_CAPTURE_DIR > } > > +strip_extra_symbols () > +{ > + local -r FILE="$1" > + local -a STRIP_CMD_OPTS=() > + local -a SYM_PREFIX=("livepatch_load_data_" > + "livepatch_unload_data_" > + "livepatch_preapply_data_" > + "livepatch_apply_data_" > + "livepatch_postapply_data_" > + "livepatch_prerevert_data_" > + "livepatch_revert_data_" > + "livepatch_postrevert_data_") > + > + STRIP_CMD_OPTS+=("-w") > + for sym in "${SYM_PREFIX[@]}"; do > + STRIP_CMD_OPTS+=("-N") > + STRIP_CMD_OPTS+=("\"${sym}*\"") > + done > + > + strip "${STRIP_CMD_OPTS[@]}" "$FILE" > +} > + > function create_patch() > { > echo "Extracting new and modified ELF sections..." > @@ -150,6 +172,7 @@ function create_patch() > NEW_FILES=$(comm -23 <(cd patched/xen && find . -type f -name '*.o' | sort) <(cd original/xen && find . -type f -name '*.o' | sort)) > for i in $NEW_FILES; do > cp "patched/$i" "output/$i" > + strip --strip-unneeded "output/$i" This strips debug symbols too which is not necessarily desirable and I think for most software is normally left a high level process (e.g. rpmbuild). Can you make this optional please? Thanks,
> On 25. Nov 2019, at 15:38, Ross Lagerwall <ross.lagerwall@citrix.com> wrote: > > On 9/16/19 12:30 PM, Pawel Wieczorkiewicz wrote: >> In the process of creating a final hotpatch module file make sure to >> strip all transient symbols that have not been caught and removed by >> create-diff-object processing. For now these are only the hooks >> kpatch load/unload symbols. >> >> snip >> function create_patch() >> { >> echo "Extracting new and modified ELF sections..." >> @@ -150,6 +172,7 @@ function create_patch() >> NEW_FILES=$(comm -23 <(cd patched/xen && find . -type f -name '*.o' | sort) <(cd original/xen && find . -type f -name '*.o' | sort)) >> for i in $NEW_FILES; do >> cp "patched/$i" "output/$i" >> + strip --strip-unneeded "output/$i" > > This strips debug symbols too which is not necessarily desirable and I think for most software is normally left a high level process (e.g. rpmbuild). Can you make this optional please? > Yes, will do. Thanks for looking. > Thanks, > -- > Ross Lagerwall Best Regards, Pawel Wieczorkiewicz Amazon Development Center Germany GmbH Krausenstr. 38 10117 Berlin Geschaeftsfuehrung: Christian Schlaeger, Ralf Herbrich Eingetragen am Amtsgericht Charlottenburg unter HRB 149173 B Sitz: Berlin Ust-ID: DE 289 237 879
diff --git a/livepatch-build b/livepatch-build index b8a1728..816064c 100755 --- a/livepatch-build +++ b/livepatch-build @@ -111,6 +111,28 @@ function build_special() unset LIVEPATCH_CAPTURE_DIR } +strip_extra_symbols () +{ + local -r FILE="$1" + local -a STRIP_CMD_OPTS=() + local -a SYM_PREFIX=("livepatch_load_data_" + "livepatch_unload_data_" + "livepatch_preapply_data_" + "livepatch_apply_data_" + "livepatch_postapply_data_" + "livepatch_prerevert_data_" + "livepatch_revert_data_" + "livepatch_postrevert_data_") + + STRIP_CMD_OPTS+=("-w") + for sym in "${SYM_PREFIX[@]}"; do + STRIP_CMD_OPTS+=("-N") + STRIP_CMD_OPTS+=("\"${sym}*\"") + done + + strip "${STRIP_CMD_OPTS[@]}" "$FILE" +} + function create_patch() { echo "Extracting new and modified ELF sections..." @@ -150,6 +172,7 @@ function create_patch() NEW_FILES=$(comm -23 <(cd patched/xen && find . -type f -name '*.o' | sort) <(cd original/xen && find . -type f -name '*.o' | sort)) for i in $NEW_FILES; do cp "patched/$i" "output/$i" + strip --strip-unneeded "output/$i" CHANGED=1 done @@ -176,6 +199,8 @@ function create_patch() "${TOOLSDIR}"/prelink $debugopt output.o "${PATCHNAME}.livepatch" "$XENSYMS" &>> "${OUTPUT}/prelink.log" || die fi + strip_extra_symbols "${PATCHNAME}.livepatch" + objcopy --add-section .livepatch.depends=depends.bin "${PATCHNAME}.livepatch" objcopy --set-section-flags .livepatch.depends=alloc,readonly "${PATCHNAME}.livepatch"
In the process of creating a final hotpatch module file make sure to strip all transient symbols that have not been caught and removed by create-diff-object processing. For now these are only the hooks kpatch load/unload symbols. For all new object files that are carried along for the final linking the transient hooks symbols are not stripped and neither are any unneeded symbols. Strip them explicitly from resulting object file. Signed-off-by: Pawel Wieczorkiewicz <wipawel@amazon.de> --- livepatch-build | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)