about summary refs log tree commit diff
path: root/Makeconfig
diff options
context:
space:
mode:
Diffstat (limited to 'Makeconfig')
-rw-r--r--Makeconfig13
1 files changed, 12 insertions, 1 deletions
diff --git a/Makeconfig b/Makeconfig
index 434f8b2d19..48a4a95ef8 100644
--- a/Makeconfig
+++ b/Makeconfig
@@ -254,11 +254,22 @@ endif
 # Command for linking programs with the C library.
 ifndef +link
 +link = $(CC) -nostdlib $(LDFLAGS) -o $@ \
-	$(common-objpfx)start.o $(^:lib=$(libc.a)) $(gnulib) $(libc.a)
+	$(addprefix $(csu-objpfx),start.o $(+preinit)) \
+	$(^:lib=$(libc.a)) $(gnulib) $(libc.a) \
+	$(addprefix $(csu-objpfx),$(+postinit))
 endif
 ifndef gnulib
 gnulib := -lgcc
 endif
+ifeq ($(elf),yes)
++preinit = crti.o
++postinit = crtn.o
+endif
+ifdef objpfx
+csu-objpfx = $(objpfx)
+else
+csu-objpfx = $(..)csu
+endif
 
 ifndef LD
 LD := ld -X