mirror of
https://github.com/dynup/kpatch
synced 2024-12-27 15:52:02 +00:00
add debuginfo support
This commit adds basic debuginfo support. It is "basic" in as much as it does not try to parse the DWARF data to figure out which parts pertain to the changed code. It simply includes all .debug_ and .rela.debug_ section and strips out any rela entries that reference unchanged symbols. This corrupts the debuginfo for unchanged symbols but since they are not going to be included anyway, there should be no way to reference that information. Signed-off-by: Seth Jennings <sjenning@redhat.com>
This commit is contained in:
parent
cdd3486b20
commit
32b452aabe
@ -1266,6 +1266,33 @@ void kpatch_regenerate_special_section(struct special_section *special,
|
||||
sec->base->data->d_size = dest_offset;
|
||||
}
|
||||
|
||||
void kpatch_include_debug_sections(struct kpatch_elf *kelf)
|
||||
{
|
||||
struct section *sec;
|
||||
struct rela *rela, *saferela;
|
||||
|
||||
/* include all .debug_* sections */
|
||||
list_for_each_entry(sec, &kelf->sections, list) {
|
||||
if (!strncmp(sec->name, ".debug_", 7)) {
|
||||
sec->include = 1;
|
||||
if (sec->rela)
|
||||
sec->rela->include = 1;
|
||||
sec->secsym->include = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Go through the .rela.debug_ sections and strip entries
|
||||
* referencing unchanged symbols
|
||||
*/
|
||||
list_for_each_entry(sec, &kelf->sections, list) {
|
||||
if (strncmp(sec->name, ".rela.debug_", 12))
|
||||
continue;
|
||||
list_for_each_entry_safe(rela, saferela, &sec->relas, list)
|
||||
if (!rela->sym->sec->include)
|
||||
list_del(&rela->list);
|
||||
}
|
||||
}
|
||||
|
||||
void kpatch_process_special_sections(struct kpatch_elf *kelf)
|
||||
{
|
||||
@ -2098,6 +2125,7 @@ int main(int argc, char *argv[])
|
||||
|
||||
kpatch_include_standard_elements(kelf_patched);
|
||||
num_changed = kpatch_include_changed_functions(kelf_patched);
|
||||
kpatch_include_debug_sections(kelf_patched);
|
||||
kpatch_dump_kelf(kelf_patched);
|
||||
kpatch_verify_patchability(kelf_patched);
|
||||
|
||||
|
@ -43,7 +43,6 @@ ARCHVERSION="$(uname -r)"
|
||||
CPUS="$(grep -c ^processor /proc/cpuinfo)"
|
||||
CACHEDIR="$HOME/.kpatch"
|
||||
TEMPDIR=
|
||||
STRIPCMD="strip -d --keep-file-symbols"
|
||||
APPLIEDPATCHFILE="applied-patch"
|
||||
DEBUG=0
|
||||
|
||||
@ -356,7 +355,6 @@ cp "$OBJDIR/.config" "$OBJDIR2" || die
|
||||
mkdir "$TEMPDIR/patched"
|
||||
for i in $(cat $TEMPDIR/changed_objs); do
|
||||
KCFLAGS="-ffunction-sections -fdata-sections" make "$i" "O=$OBJDIR2" >> "$LOGFILE" 2>&1 || die
|
||||
$STRIPCMD "$OBJDIR2/$i" >> "$LOGFILE" 2>&1 || die
|
||||
mkdir -p "$TEMPDIR/patched/$(dirname $i)"
|
||||
cp -f "$OBJDIR2/$i" "$TEMPDIR/patched/$i" || die
|
||||
done
|
||||
@ -366,7 +364,6 @@ mkdir "$TEMPDIR/orig"
|
||||
for i in $(cat $TEMPDIR/changed_objs); do
|
||||
rm -f "$i"
|
||||
KCFLAGS="-ffunction-sections -fdata-sections" make "$i" "O=$OBJDIR2" >> "$LOGFILE" 2>&1 || die
|
||||
$STRIPCMD -d "$OBJDIR2/$i" >> "$LOGFILE" 2>&1 || die
|
||||
mkdir -p "$TEMPDIR/orig/$(dirname $i)"
|
||||
cp -f "$OBJDIR2/$i" "$TEMPDIR/orig/$i" || die
|
||||
done
|
||||
@ -404,7 +401,6 @@ cd "$TEMPDIR/output"
|
||||
ld -r -o ../patch/output.o $FILES >> "$LOGFILE" 2>&1 || die
|
||||
cd "$TEMPDIR/patch"
|
||||
KPATCH_BUILD="$SRCDIR" KPATCH_NAME="$PATCHNAME" KBUILD_EXTRA_SYMBOLS="$SYMVERSFILE" make "O=$OBJDIR" >> "$LOGFILE" 2>&1 || die
|
||||
$STRIPCMD "kpatch-$PATCHNAME.ko" >> "$LOGFILE" 2>&1 || die
|
||||
|
||||
cp -f "$TEMPDIR/patch/kpatch-$PATCHNAME.ko" "$BASE" || die
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user