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