Skip to content

Commit

Permalink
notes: process the ERASEINFO note
Browse files Browse the repository at this point in the history
ELF dumps store ERASEINFO in an ELF note. Interestingly, this note is not
part of the other notes saved in compressed makedumpfile format v4+, so
this new code does not supersede file-format-specific eraseinfo parsing.

Signed-off-by: Petr Tesarik <[email protected]>
  • Loading branch information
ptesarik committed Jul 17, 2023
1 parent c44c5ae commit ae8b9f1
Show file tree
Hide file tree
Showing 4 changed files with 46 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/kdumpfile/notes.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ do_noarch_note(kdump_ctx_t *ctx, Elf32_Word type,
else if (note_equal("VMCOREINFO_XEN", name, namesz))
return set_blob_attr(ctx, GKI_xen_vmcoreinfo_raw,
desc, descsz, "VMCOREINFO_XEN");
else if (note_equal("ERASEINFO", name, namesz))
return set_blob_attr(ctx, GKI_file_eraseinfo_raw,
desc, descsz, "ERASEINFO");

return KDUMP_OK;
}
Expand Down
2 changes: 2 additions & 0 deletions tests/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,7 @@ test_scripts = \
elf-empty-s390 \
elf-empty-s390x \
elf-empty-x86_64 \
elf-eraseinfo \
elf-prstatus-aarch64 \
elf-prstatus-arm \
elf-prstatus-i386 \
Expand Down Expand Up @@ -332,6 +333,7 @@ dist_check_DATA = \
early-version-code.data \
early-version-code.expect \
elf-empty.data \
elf-eraseinfo.data \
elf-prstatus-aarch64.data \
elf-prstatus-arm.data \
elf-prstatus-i386.data \
Expand Down
35 changes: 35 additions & 0 deletions tests/elf-eraseinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#! /bin/sh

mkdir -p out || exit 99

name=$( basename "$0" )
datafile="$srcdir/${name}.data"
dumpfile="out/${name}.dump"
resultfile="out/${name}.result"
expectfile="$srcdir/${name}.expect"

./mkelf "$dumpfile" <<EOF
ei_class = 2
ei_data = 1
e_machine = 62
e_phoff = 0x1000
DATA = $datafile
EOF
rc=$?
if [ $rc -ne 0 ]; then
echo "Cannot create ELF file" >&2
exit $rc
fi
echo "Created ELF dump: $dumpfile"

./checkattr "$dumpfile" <<EOF
file.set.number = number: 1
file.format = string: elf
file.eraseinfo.raw = blob:6572617365206d6f64756c65732073697a652031360a
EOF
rc=$?
if [ $rc -ne 0 ]; then
echo "Attribute check failed" >&2
exit $rc
fi
6 changes: 6 additions & 0 deletions tests/elf-eraseinfo.data
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
@phdr type=NOTE offset=0x1800
0000000a 00000016 00000000 "ERASEINFO" 00*3
"erase modules size 16\n" 00*2

@phdr type=LOAD offset=0x9000 paddr=0x3000000 vaddr=0xffff880003000000 memsz=0x1000
41 42 43 44 45 46 47 48

0 comments on commit ae8b9f1

Please sign in to comment.