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 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#! /bin/sh
#
# Create an ELF file with overlapping LOAD segments and verify that
# the page map is merged correctly
#
mkdir -p out || exit 99
name=$( basename "$0" )
datafile="out/${name}.data"
dumpfile="out/${name}.dump"
cat >"$datafile" <<EOF
# first LOAD |####|
# second LOAD |####|
@phdr type=LOAD offset=0x1000 vaddr=0x1000 paddr=0x1000 memsz=0x4000
55*0x1000
@phdr type=LOAD vaddr=0x3000 paddr=0x3000 memsz=0x4000
# first LOAD |########|
# second LOAD |####|
@phdr type=LOAD vaddr=0xa000 paddr=0xa000 memsz=0x8000
55*0x2000
@phdr type=LOAD vaddr=0xc000 paddr=0xc000 memsz=0x4000
aa*0x2000
# first LOAD |####|
# second LOAD |##|
@phdr type=LOAD vaddr=0x18000 paddr=0x18000 memsz=0x4000
@phdr type=LOAD vaddr=0x1c000 paddr=0x1c000 memsz=0x2000
aa*0x1000
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"
./checkattr "$dumpfile" <<EOF
file = directory:
file.set.number = number:1
file.set.0 = directory:
file.set.0.fd = number
file.format = string: elf
file.pagemap = bitmap:0x02 0x3c 0x00 0x10
memory.pagemap = bitmap:0x7e 0xfc 0x03 0x3f
EOF
rc=$?
if [ $rc -ne 0 ]; then
echo "Attribute check failed" >&2
exit $rc
fi
exit 0
|