summaryrefslogtreecommitdiff
path: root/build_helpers
diff options
context:
space:
mode:
authoriximeow <me@iximeow.net>2015-09-28 03:33:19 -0700
committeriximeow <me@iximeow.net>2015-09-28 03:36:28 -0700
commit74057dac1d460574f0b7edb89e9e4125a69c885a (patch)
tree8bd43ea888b33272d21719c7f97c51db1bc58c57 /build_helpers
parent4f63bab19769e2aedb9721322501cecf9934156c (diff)
add awful support for non-0x7e00 start, prefix real start address to kernel
Diffstat (limited to 'build_helpers')
-rwxr-xr-xbuild_helpers/compile.sh14
1 files changed, 12 insertions, 2 deletions
diff --git a/build_helpers/compile.sh b/build_helpers/compile.sh
index 40cd293..f00549f 100755
--- a/build_helpers/compile.sh
+++ b/build_helpers/compile.sh
@@ -10,8 +10,18 @@ OUTNAME="src._kernel._main"
echo -n "[*] Building '$INPATH' to 'tmp/$OUTNAME'... "
gcc -T linker.ld -m32 -Wl,--build-id=none -nostartfiles -nostdlib -ffreestanding $INPATH -o "tmp/$OUTNAME".o
echo " OK!"
+echo -n "[+] Start address is... "
+BIN_START=$(objdump tmp/src._kernel._main.o -f | grep start | cut -b 15-)
+echo "$BIN_START"
+# this actually writes three extra nulls, not sure why...
+echo "$BIN_START" | xxd -r - | od -t x --endian=little | head | xxd -r - > "bin/$OUTNAME".bin
echo -n "[+] Stripping unnecessary sections... "
-objcopy -R .note.gnu.build-id -R .comment -O binary "tmp/$OUTNAME".o "bin/$OUTNAME".bin
+objcopy -R .note.gnu.build-id -R .comment -O binary "tmp/$OUTNAME".o "tmp/converted_$OUTNAME".bin
echo " OK!"
-rm "tmp/$OUTNAME".o
+
+echo -n "[+] Joining kernel and start address... "
+# adjust for the three extra nulls above
+dd if="tmp/converted_$OUTNAME".bin of="bin/$OUTNAME".bin seek=4 oflag=seek_bytes conv=notrunc 2>/dev/null
+echo " OK!"
+#rm "tmp/$OUTNAME".o