From cb9c097bccb60e55313ced3533a1350668f08d25 Mon Sep 17 00:00:00 2001 From: mintsuki Date: Wed, 11 May 2022 15:49:04 +0200 Subject: [PATCH] gensyms: Use as instead of nasm --- common/GNUmakefile | 8 ++++++++ common/gensyms.sh | 21 ++++++++++----------- 2 files changed, 18 insertions(+), 11 deletions(-) diff --git a/common/GNUmakefile b/common/GNUmakefile index 351c54fb..3b27196d 100644 --- a/common/GNUmakefile +++ b/common/GNUmakefile @@ -220,10 +220,14 @@ $(call MKESCAPE,$(BUILDDIR))/stage2.bin: $(call MKESCAPE,$(BUILDDIR))/limine.sys $(call MKESCAPE,$(BUILDDIR))/stage2.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_stage2only.elf cd '$(call SHESCAPE,$(BUILDDIR))' && \ '$(call SHESCAPE,$(SRCDIR))/gensyms.sh' '$(call SHESCAPE,$<)' stage2 32 '\.text' + $(LIMINE_CC) $(LIMINE_CFLAGS) $(INTERNAL_CFLAGS) -c '$(call SHESCAPE,$(BUILDDIR))/stage2.map.S' -o '$(call SHESCAPE,$@)' + rm -f '$(call SHESCAPE,$(BUILDDIR))/stage2.map.S' '$(call SHESCAPE,$(BUILDDIR))/stage2.map.d' $(call MKESCAPE,$(BUILDDIR))/full.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf cd '$(call SHESCAPE,$(BUILDDIR))' && \ '$(call SHESCAPE,$(SRCDIR))/gensyms.sh' '$(call SHESCAPE,$<)' full 32 '\.text' + $(LIMINE_CC) $(LIMINE_CFLAGS) $(INTERNAL_CFLAGS) -c '$(call SHESCAPE,$(BUILDDIR))/full.map.S' -o '$(call SHESCAPE,$@)' + rm -f '$(call SHESCAPE,$(BUILDDIR))/full.map.S' '$(call SHESCAPE,$(BUILDDIR))/full.map.d' $(call MKESCAPE,$(BUILDDIR))/limine.sys: $(call MKESCAPE,$(BUILDDIR))/limine.elf $(LIMINE_OBJCOPY) -O binary '$(call SHESCAPE,$<)' '$(call SHESCAPE,$@)' @@ -280,6 +284,8 @@ ifeq ($(TARGET), uefi64) $(call MKESCAPE,$(BUILDDIR))/full.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf cd '$(call SHESCAPE,$(BUILDDIR))' && \ '$(call SHESCAPE,$(SRCDIR))/gensyms.sh' '$(call SHESCAPE,$<)' full 64 '\.text' + $(LIMINE_CC) $(LIMINE_CFLAGS) $(INTERNAL_CFLAGS) -c '$(call SHESCAPE,$(BUILDDIR))/full.map.S' -o '$(call SHESCAPE,$@)' + rm -f '$(call SHESCAPE,$(BUILDDIR))/full.map.S' '$(call SHESCAPE,$(BUILDDIR))/full.map.d' $(call MKESCAPE,$(BUILDDIR))/BOOTX64.EFI: $(call MKESCAPE,$(BUILDDIR))/limine.elf $(LIMINE_OBJCOPY) -O binary '$(call SHESCAPE,$<)' '$(call SHESCAPE,$@)' @@ -327,6 +333,8 @@ ifeq ($(TARGET), uefi32) $(call MKESCAPE,$(BUILDDIR))/full.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf cd '$(call SHESCAPE,$(BUILDDIR))' && \ '$(call SHESCAPE,$(SRCDIR))/gensyms.sh' '$(call SHESCAPE,$<)' full 32 '\.text' + $(LIMINE_CC) $(LIMINE_CFLAGS) $(INTERNAL_CFLAGS) -c '$(call SHESCAPE,$(BUILDDIR))/full.map.S' -o '$(call SHESCAPE,$@)' + rm -f '$(call SHESCAPE,$(BUILDDIR))/full.map.S' '$(call SHESCAPE,$(BUILDDIR))/full.map.d' $(call MKESCAPE,$(BUILDDIR))/BOOTIA32.EFI: $(call MKESCAPE,$(BUILDDIR))/limine.elf $(LIMINE_OBJCOPY) -O binary '$(call SHESCAPE,$<)' '$(call SHESCAPE,$@)' diff --git a/common/gensyms.sh b/common/gensyms.sh index 70a4b28b..9312c9ec 100755 --- a/common/gensyms.sh +++ b/common/gensyms.sh @@ -30,20 +30,19 @@ TMP4=$(mktemp) "$GREP" "$4" < "$TMP1" | cut -d' ' -f1 > "$TMP2" "$GREP" "$4" < "$TMP1" | "$AWK" 'NF{ print $NF }' > "$TMP3" -echo "section .$2_map" > "$TMP4" -echo "global $2_map" >> "$TMP4" +echo ".section .$2_map" > "$TMP4" +echo ".globl $2_map" >> "$TMP4" echo "$2_map:" >> "$TMP4" if [ "$3" = "32" ]; then - paste -d'$' "$TMP2" "$TMP3" | "$SED" 's/^/dd 0x/g;s/$/", 0/g;s/\$/\ -db "/g' >> "$TMP4" - echo "dd 0xffffffff" >> "$TMP4" - nasm -f elf32 "$TMP4" -o $2.map.o + paste -d'$' "$TMP2" "$TMP3" | "$SED" 's/^/.long 0x/g;s/$/"/g;s/\$/\ +.asciz "/g' >> "$TMP4" + echo ".long 0xffffffff" >> "$TMP4" elif [ "$3" = "64" ]; then - paste -d'$' "$TMP2" "$TMP3" | "$SED" 's/^/dq 0x/g;s/$/", 0/g;s/\$/\ -db "/g' >> "$TMP4" - echo "dq 0xffffffffffffffff" >> "$TMP4" - nasm -f elf64 "$TMP4" -o $2.map.o + paste -d'$' "$TMP2" "$TMP3" | "$SED" 's/^/.quad 0x/g;s/$/"/g;s/\$/\ +.asciz "/g' >> "$TMP4" + echo ".quad 0xffffffffffffffff" >> "$TMP4" fi -rm "$TMP1" "$TMP2" "$TMP3" "$TMP4" +mv "$TMP4" "$2.map.S" +rm "$TMP1" "$TMP2" "$TMP3"