diff options
Diffstat (limited to 'Makefile.main')
-rw-r--r-- | Makefile.main | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/Makefile.main b/Makefile.main index 2b5a686..46af374 100644 --- a/Makefile.main +++ b/Makefile.main @@ -50,7 +50,16 @@ CPPFLAGS += -DBITS_PER_LONG=64 -m64 -DHAVE_BIG_ENDIAN # causing all our printf's to warn CPPFLAGS += -ffreestanding -CFLAGS := -fno-strict-aliasing -fno-stack-protector -pie +CFLAGS := -fno-strict-aliasing -fstack-protector-all -pie + +ifeq ($(STACK_CHECK),1) +CFLAGS += -fstack-protector-all -pg +CPPFLAGS += -DSTACK_CHECK_ENABLED +else +# XXX Add -fstack-protector-strong on gcc 4.9 +CFLAGS += -fstack-protector +endif + CFLAGS += $(CWARNS) $(OPTS) $(DBG) LDFLAGS := -m64 -static -nostdlib -Wl,--gc-sections -pie @@ -112,14 +121,19 @@ OBJS += $(LIBC) $(CCAN) $(DEVSRC_OBJ) OBJS_NO_VER = $(OBJS) ALL_OBJS = $(OBJS) version.o +ALL_OBJS_1 = $(ALL_OBJS) asm/dummy_map.o +ALL_OBJS_2 = $(ALL_OBJS) asm/real_map.o + $(TARGET).lid: $(TARGET).elf $(call Q,OBJCOPY, $(OBJCOPY) -O binary -S $^ $@, $@) -$(TARGET).elf: $(ALL_OBJS) $(TARGET).lds $(KERNEL) - $(call Q,LD, $(CC) $(LDFLAGS) -T $(TARGET).lds $(ALL_OBJS) -o $@, $@) +$(TARGET).tmp.elf: $(ALL_OBJS_1) $(TARGET).lds $(KERNEL) + $(call Q,LD, $(CC) $(LDFLAGS) -T $(TARGET).lds $(ALL_OBJS_1) -o $@, $@) + +asm/real_map.o : $(TARGET).tmp.map -$(TARGET).map: $(TARGET).elf - $(call Q,NM, $(NM) -n $< | grep -v '\( [aNUw] \)\|\(__crc_\)\|\( \$[adt]\)' > $@, $@) +$(TARGET).elf: $(ALL_OBJS_2) $(TARGET).lds $(KERNEL) + $(call Q,LD, $(CC) $(LDFLAGS) -T $(TARGET).lds $(ALL_OBJS_2) -o $@, $@) $(SUBDIRS): $(call Q,MKDIR,mkdir $@, $@) @@ -168,7 +182,7 @@ cscope: clean: $(RM) *.[odsa] $(SUBDIRS:%=%/*.[odsa]) - $(RM) $(TARGET).elf $(TARGET).lid $(TARGET).map $(TARGET).lds + $(RM) *.elf $(TARGET).lid *.map $(TARGET).lds $(RM) include/asm-offsets.h version.c distclean: clean |