From 02a77989c2d0ab155581f051b6344860146cdca5 Mon Sep 17 00:00:00 2001 From: garenchan <1412950785@qq.com> Date: Fri, 16 Nov 2018 15:46:00 +0800 Subject: [PATCH] Use ld through global variable. --- 14-checkpoint/Makefile | 5 +++-- 15-video-ports/Makefile | 5 +++-- 16-video-driver/Makefile | 5 +++-- 17-video-scroll/Makefile | 5 +++-- 18-interrupts/Makefile | 5 +++-- 19-interrupts-irqs/Makefile | 5 +++-- 20-interrupts-timer/Makefile | 5 +++-- 21-shell/Makefile | 5 +++-- 22-malloc/Makefile | 5 +++-- 23-fixes/Makefile | 5 +++-- 10 files changed, 30 insertions(+), 20 deletions(-) diff --git a/14-checkpoint/Makefile b/14-checkpoint/Makefile index 45cc9e4..5ff0d03 100644 --- a/14-checkpoint/Makefile +++ b/14-checkpoint/Makefile @@ -6,6 +6,7 @@ OBJ = ${C_SOURCES:.c=.o} # Change this if your cross-compiler is somewhere else CC = /usr/local/i386elfgcc/bin/i386-elf-gcc GDB = /usr/local/i386elfgcc/bin/i386-elf-gdb +LD = /usr/local/i386elfgcc/bin/i386-elf-ld # -g: Use debugging symbols in gcc CFLAGS = -g @@ -16,11 +17,11 @@ os-image.bin: boot/bootsect.bin kernel.bin # '--oformat binary' deletes all symbols as a collateral, so we don't need # to 'strip' them manually on this case kernel.bin: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ --oformat binary + ${LD} -o $@ -Ttext 0x1000 $^ --oformat binary # Used for debugging purposes kernel.elf: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ + ${LD} -o $@ -Ttext 0x1000 $^ run: os-image.bin qemu-system-i386 -fda os-image.bin diff --git a/15-video-ports/Makefile b/15-video-ports/Makefile index 45cc9e4..5ff0d03 100644 --- a/15-video-ports/Makefile +++ b/15-video-ports/Makefile @@ -6,6 +6,7 @@ OBJ = ${C_SOURCES:.c=.o} # Change this if your cross-compiler is somewhere else CC = /usr/local/i386elfgcc/bin/i386-elf-gcc GDB = /usr/local/i386elfgcc/bin/i386-elf-gdb +LD = /usr/local/i386elfgcc/bin/i386-elf-ld # -g: Use debugging symbols in gcc CFLAGS = -g @@ -16,11 +17,11 @@ os-image.bin: boot/bootsect.bin kernel.bin # '--oformat binary' deletes all symbols as a collateral, so we don't need # to 'strip' them manually on this case kernel.bin: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ --oformat binary + ${LD} -o $@ -Ttext 0x1000 $^ --oformat binary # Used for debugging purposes kernel.elf: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ + ${LD} -o $@ -Ttext 0x1000 $^ run: os-image.bin qemu-system-i386 -fda os-image.bin diff --git a/16-video-driver/Makefile b/16-video-driver/Makefile index 45cc9e4..5ff0d03 100644 --- a/16-video-driver/Makefile +++ b/16-video-driver/Makefile @@ -6,6 +6,7 @@ OBJ = ${C_SOURCES:.c=.o} # Change this if your cross-compiler is somewhere else CC = /usr/local/i386elfgcc/bin/i386-elf-gcc GDB = /usr/local/i386elfgcc/bin/i386-elf-gdb +LD = /usr/local/i386elfgcc/bin/i386-elf-ld # -g: Use debugging symbols in gcc CFLAGS = -g @@ -16,11 +17,11 @@ os-image.bin: boot/bootsect.bin kernel.bin # '--oformat binary' deletes all symbols as a collateral, so we don't need # to 'strip' them manually on this case kernel.bin: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ --oformat binary + ${LD} -o $@ -Ttext 0x1000 $^ --oformat binary # Used for debugging purposes kernel.elf: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ + ${LD} -o $@ -Ttext 0x1000 $^ run: os-image.bin qemu-system-i386 -fda os-image.bin diff --git a/17-video-scroll/Makefile b/17-video-scroll/Makefile index 45cc9e4..5ff0d03 100644 --- a/17-video-scroll/Makefile +++ b/17-video-scroll/Makefile @@ -6,6 +6,7 @@ OBJ = ${C_SOURCES:.c=.o} # Change this if your cross-compiler is somewhere else CC = /usr/local/i386elfgcc/bin/i386-elf-gcc GDB = /usr/local/i386elfgcc/bin/i386-elf-gdb +LD = /usr/local/i386elfgcc/bin/i386-elf-ld # -g: Use debugging symbols in gcc CFLAGS = -g @@ -16,11 +17,11 @@ os-image.bin: boot/bootsect.bin kernel.bin # '--oformat binary' deletes all symbols as a collateral, so we don't need # to 'strip' them manually on this case kernel.bin: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ --oformat binary + ${LD} -o $@ -Ttext 0x1000 $^ --oformat binary # Used for debugging purposes kernel.elf: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ + ${LD} -o $@ -Ttext 0x1000 $^ run: os-image.bin qemu-system-i386 -fda os-image.bin diff --git a/18-interrupts/Makefile b/18-interrupts/Makefile index d7e16c5..fd48e28 100644 --- a/18-interrupts/Makefile +++ b/18-interrupts/Makefile @@ -6,6 +6,7 @@ OBJ = ${C_SOURCES:.c=.o cpu/interrupt.o} # Change this if your cross-compiler is somewhere else CC = /usr/local/i386elfgcc/bin/i386-elf-gcc GDB = /usr/local/i386elfgcc/bin/i386-elf-gdb +LD = /usr/local/i386elfgcc/bin/i386-elf-ld # -g: Use debugging symbols in gcc CFLAGS = -g @@ -16,11 +17,11 @@ os-image.bin: boot/bootsect.bin kernel.bin # '--oformat binary' deletes all symbols as a collateral, so we don't need # to 'strip' them manually on this case kernel.bin: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ --oformat binary + ${LD} -o $@ -Ttext 0x1000 $^ --oformat binary # Used for debugging purposes kernel.elf: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ + ${LD} -o $@ -Ttext 0x1000 $^ run: os-image.bin qemu-system-i386 -fda os-image.bin diff --git a/19-interrupts-irqs/Makefile b/19-interrupts-irqs/Makefile index d7e16c5..fd48e28 100644 --- a/19-interrupts-irqs/Makefile +++ b/19-interrupts-irqs/Makefile @@ -6,6 +6,7 @@ OBJ = ${C_SOURCES:.c=.o cpu/interrupt.o} # Change this if your cross-compiler is somewhere else CC = /usr/local/i386elfgcc/bin/i386-elf-gcc GDB = /usr/local/i386elfgcc/bin/i386-elf-gdb +LD = /usr/local/i386elfgcc/bin/i386-elf-ld # -g: Use debugging symbols in gcc CFLAGS = -g @@ -16,11 +17,11 @@ os-image.bin: boot/bootsect.bin kernel.bin # '--oformat binary' deletes all symbols as a collateral, so we don't need # to 'strip' them manually on this case kernel.bin: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ --oformat binary + ${LD} -o $@ -Ttext 0x1000 $^ --oformat binary # Used for debugging purposes kernel.elf: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ + ${LD} -o $@ -Ttext 0x1000 $^ run: os-image.bin qemu-system-i386 -fda os-image.bin diff --git a/20-interrupts-timer/Makefile b/20-interrupts-timer/Makefile index 3abf8ce..d1922a7 100644 --- a/20-interrupts-timer/Makefile +++ b/20-interrupts-timer/Makefile @@ -6,6 +6,7 @@ OBJ = ${C_SOURCES:.c=.o cpu/interrupt.o} # Change this if your cross-compiler is somewhere else CC = /usr/local/i386elfgcc/bin/i386-elf-gcc GDB = /usr/local/i386elfgcc/bin/i386-elf-gdb +LD = /usr/local/i386elfgcc/bin/i386-elf-ld # -g: Use debugging symbols in gcc CFLAGS = -g @@ -16,11 +17,11 @@ os-image.bin: boot/bootsect.bin kernel.bin # '--oformat binary' deletes all symbols as a collateral, so we don't need # to 'strip' them manually on this case kernel.bin: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ --oformat binary + ${LD} -o $@ -Ttext 0x1000 $^ --oformat binary # Used for debugging purposes kernel.elf: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ + ${LD} -o $@ -Ttext 0x1000 $^ run: os-image.bin qemu-system-i386 -fda os-image.bin diff --git a/21-shell/Makefile b/21-shell/Makefile index b347fc8..23e9d9a 100644 --- a/21-shell/Makefile +++ b/21-shell/Makefile @@ -6,6 +6,7 @@ OBJ = ${C_SOURCES:.c=.o cpu/interrupt.o} # Change this if your cross-compiler is somewhere else CC = /usr/local/i386elfgcc/bin/i386-elf-gcc GDB = /usr/local/i386elfgcc/bin/i386-elf-gdb +LD = /usr/local/i386elfgcc/bin/i386-elf-ld # -g: Use debugging symbols in gcc CFLAGS = -g -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs \ -Wall -Wextra -Werror @@ -17,11 +18,11 @@ os-image.bin: boot/bootsect.bin kernel.bin # '--oformat binary' deletes all symbols as a collateral, so we don't need # to 'strip' them manually on this case kernel.bin: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ --oformat binary + ${LD} -o $@ -Ttext 0x1000 $^ --oformat binary # Used for debugging purposes kernel.elf: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ + ${LD} -o $@ -Ttext 0x1000 $^ run: os-image.bin qemu-system-i386 -fda os-image.bin diff --git a/22-malloc/Makefile b/22-malloc/Makefile index b347fc8..23e9d9a 100644 --- a/22-malloc/Makefile +++ b/22-malloc/Makefile @@ -6,6 +6,7 @@ OBJ = ${C_SOURCES:.c=.o cpu/interrupt.o} # Change this if your cross-compiler is somewhere else CC = /usr/local/i386elfgcc/bin/i386-elf-gcc GDB = /usr/local/i386elfgcc/bin/i386-elf-gdb +LD = /usr/local/i386elfgcc/bin/i386-elf-ld # -g: Use debugging symbols in gcc CFLAGS = -g -m32 -nostdlib -nostdinc -fno-builtin -fno-stack-protector -nostartfiles -nodefaultlibs \ -Wall -Wextra -Werror @@ -17,11 +18,11 @@ os-image.bin: boot/bootsect.bin kernel.bin # '--oformat binary' deletes all symbols as a collateral, so we don't need # to 'strip' them manually on this case kernel.bin: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ --oformat binary + ${LD} -o $@ -Ttext 0x1000 $^ --oformat binary # Used for debugging purposes kernel.elf: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ + ${LD} -o $@ -Ttext 0x1000 $^ run: os-image.bin qemu-system-i386 -fda os-image.bin diff --git a/23-fixes/Makefile b/23-fixes/Makefile index 7c244b6..a678f60 100644 --- a/23-fixes/Makefile +++ b/23-fixes/Makefile @@ -6,6 +6,7 @@ OBJ = ${C_SOURCES:.c=.o cpu/interrupt.o} # Change this if your cross-compiler is somewhere else CC = /usr/local/i386elfgcc/bin/i386-elf-gcc GDB = /usr/local/i386elfgcc/bin/i386-elf-gdb +LD = /usr/local/i386elfgcc/bin/i386-elf-ld # -g: Use debugging symbols in gcc CFLAGS = -g -ffreestanding -Wall -Wextra -fno-exceptions -m32 @@ -16,11 +17,11 @@ os-image.bin: boot/bootsect.bin kernel.bin # '--oformat binary' deletes all symbols as a collateral, so we don't need # to 'strip' them manually on this case kernel.bin: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ --oformat binary + ${LD} -o $@ -Ttext 0x1000 $^ --oformat binary # Used for debugging purposes kernel.elf: boot/kernel_entry.o ${OBJ} - i386-elf-ld -o $@ -Ttext 0x1000 $^ + ${LD} -o $@ -Ttext 0x1000 $^ run: os-image.bin qemu-system-i386 -fda os-image.bin