These build-id sections cause the Pintos ELF loader to reject
binaries. The preferred way to eliminate them would be to add
/DISCARD/ : { *(.note.gnu.build-id) }
to the linker script, but (as reported by Godmar Back) this causes a
segmentation fault in ld, as reported in a bug filed at:
http://sourceware.org/bugzilla/show_bug.cgi?id=5025
CFLAGS += -fno-stack-protector
endif
+# Turn off --build-id in the linker, which confuses the Pintos loader.
+ifeq ($(strip $(shell $(LD) --build-id=none -e 0 /dev/null -o /dev/null 2>&1; echo $$?)),0)
+LDFLAGS += -Wl,--build-id=none
+endif
+
%.o: %.c
$(CC) -c $< -o $@ $(CFLAGS) $(CPPFLAGS) $(WARNINGS) $(DEFINES) $(DEPS)
$(PROGS): CPPFLAGS += -I$(SRCDIR)/lib/user -I.
# Linker flags.
-$(PROGS): LDFLAGS = -nostdlib -static -Wl,-T,$(LDSCRIPT)
+$(PROGS): LDFLAGS += -nostdlib -static -Wl,-T,$(LDSCRIPT)
$(PROGS): LDSCRIPT = $(SRCDIR)/lib/user/user.lds
# Library code shared between kernel and user programs.