File: elf-virt-phys-clash

package info (click to toggle)
libkdumpfile 0.5.4-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,800 kB
  • sloc: ansic: 34,639; sh: 3,853; python: 1,490; makefile: 755
file content (50 lines) | stat: -rwxr-xr-x 985 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#! /bin/sh

#
# Create an ELF file which contains both virt addr 0x200 and
# phys addr 0x200 with different content, and verify that they
# are not confused.
#
# Note that it is necessary to create split segments, otherwise
#

mkdir -p out || exit 99

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

cat >"$datafile" <<EOF
@phdr type=LOAD offset=0x1000 vaddr=0x100 paddr=0x200 memsz=0x200
55*0x100
aa*0x100
EOF

./mkelf "$dumpfile" <<EOF
ei_class = 2
ei_data = 1
e_machine = 62
e_phoff = 64

DATA = $datafile
EOF
rc=$?
if [ $rc -ne 0 ]; then
    echo "Cannot create ELF file" >&2
    exit $rc
fi
echo "Created ELF dump: $dumpfile"

./dumpdata "$dumpfile" MACHPHYSADDR:0x200 16 KVADDR:0x200 16 >"$resultfile"
rc=$?
if [ $rc -ne 0 ]; then
    echo "Cannot dump ELF data" >&2
    exit $rc
fi

if ! diff "$expectfile" "$resultfile"; then
    echo "Results do not match" >&2
    exit 1
fi