Merge branch 'sm07'
This commit is contained in:
commit
1f6f002a7b
12
Makefile
12
Makefile
@ -1,10 +1,12 @@
|
||||
GDB=gdb
|
||||
OBJCOPY=objcopy
|
||||
|
||||
ifeq ($(shell uname -s),Darwin)
|
||||
AS=x86_64-elf-as
|
||||
LD=x86_64-elf-ld
|
||||
CC=x86_64-elf-gcc
|
||||
GDB=x86_64-elf-gdb
|
||||
OBJCOPY=x86_64-elf-objcopy
|
||||
endif
|
||||
|
||||
CFLAGS = -fno-pic -ffreestanding -static -fno-builtin -fno-strict-aliasing \
|
||||
@ -95,18 +97,18 @@ bootmain.o: bootmain.c
|
||||
%.o: %.S
|
||||
$(CC) $(ASMFLAGS) $^ -o $@
|
||||
|
||||
mbr.bin: mbr.raw tools/mbrpad
|
||||
cp $< $@
|
||||
mbr.bin: mbr.elf tools/mbrpad
|
||||
$(OBJCOPY) -S -O binary -j .text $< $@
|
||||
tools/mbrpad $@
|
||||
|
||||
mbr.raw: mbr.o bootmain.o
|
||||
$(LD) -m elf_i386 -Ttext=0x7c00 --oformat=binary $^ -o $@
|
||||
$(LD) -N -m elf_i386 -Ttext=0x7c00 --oformat=binary $^ -o $@
|
||||
|
||||
mbr.elf: mbr.o bootmain.o
|
||||
$(LD) -m elf_i386 -Ttext=0x7c00 $^ -o $@
|
||||
$(LD) -N -m elf_i386 -Ttext=0x7c00 $^ -o $@
|
||||
|
||||
clean:
|
||||
rm -f *.elf *.img *.bin *.o */*.o tools/mkfs ejudge.sh
|
||||
rm -f *.elf *.img *.bin *.raw *.o */*.o tools/mkfs ejudge.sh
|
||||
|
||||
tools/%: tools/%.c
|
||||
gcc -Wall -Werror -g $^ -o $@
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdio.h>
|
||||
#include <stdint.h>
|
||||
|
||||
int main(int argc, char* argv[]) {
|
||||
if (argc != 2) {
|
||||
@ -11,8 +12,8 @@ int main(int argc, char* argv[]) {
|
||||
int fd = open(filename, O_RDWR);
|
||||
off_t length = lseek(fd, 0, SEEK_END);
|
||||
if (length > 510) {
|
||||
fprintf(stderr, "file %s is larger than 510 bytes (size: %llu)\n",
|
||||
filename, length);
|
||||
fprintf(stderr, "file %s is larger than 510 bytes (size: %ju)\n",
|
||||
filename, (uintmax_t)length);
|
||||
return 1;
|
||||
}
|
||||
lseek(fd, 510, SEEK_SET);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user