1
0
mirror of https://github.com/rcore-os/rCore.git synced 2024-11-22 08:06:17 +04:00
rCore/tools/fill_symbols/aarch64.sh
gjz010 7b8252eb1b Basic loadable kernel module support, with a module template written in Rust.
Under aarch64 and x86_64, hello_rust can be built and loaded by `/busybox insmod hello_rust.ko`.
2019-06-07 20:59:51 +08:00

23 lines
986 B
Bash
Executable File

#!/bin/bash
echo "Filling kernel symbols."
rcore=$1
tmpfile=$(mktemp /tmp/rcore-symbols.txt.XXXXXX)
echo "Writing symbol table."
aarch64-elf-nm $1 >$tmpfile
gzip $tmpfile
tmpfile=$tmpfile.gz
symbol_table_loc=$((16#$(aarch64-elf-objdump -D $rcore -j .data -F |grep "<rcore_symbol_table>" |grep -oEi "0x[0-9a-f]+" |grep -oEi "[0-9a-f][0-9a-f]+")))
symbol_table_size_loc=$((16#$(aarch64-elf-objdump -D $rcore -j .data -F |grep "<rcore_symbol_table_size>" |grep -oEi "0x[0-9a-f]+" |grep -oEi "[0-9a-f][0-9a-f]+")))
echo $symbol_table_loc
echo $symbol_table_size_loc
FILESIZE=$(stat -c%s "$tmpfile")
echo $FILESIZE
dd bs=4096 count=$FILESIZE if=$tmpfile of=$rcore seek=$symbol_table_loc conv=notrunc iflag=count_bytes oflag=seek_bytes
echo "Writing size"
python3 -c "open('$tmpfile', 'wb').write(($FILESIZE).to_bytes(8,'little'))"
FILESIZE=$(stat -c%s "$tmpfile")
echo $FILESIZE
dd bs=1 count=$FILESIZE if=$tmpfile of=$rcore seek=$symbol_table_size_loc conv=notrunc
rm $tmpfile
echo "Done."