+ifeq ($(have-initfini),yes)
+
+CPPFLAGS += -DHAVE_INITFINI
+
+# These are the special initializer/finalizer files. They are always the
+# first and last file in the link. crti.o ... crtn.o define the global
+# "functions" _init and _fini to run the .init and .fini sections.
+crtstuff = crti crtn
+
+install-lib += $(crtstuff:=.o)
+extra-objs += $(crtstuff:=.o)
+generated += $(crtstuff:=.S) initfini.s defs.h
+omit-deps += $(crtstuff)
+
+# Special rules for the building of crti.o and crtn.o
+$(objpfx)crt%.o: $(objpfx)crt%.S $(objpfx)defs.h
+ $(compile.S) -g0 $(ASFLAGS-.os) -o $@
+
+CFLAGS-initfini.s = -g0 -fPIC -fno-inline-functions
+
+$(objpfx)initfini.s: initfini.c
+ $(compile.c) -S $(CFLAGS-initfini.s) -finhibit-size-directive \
+ $(no-exceptions) -o $@
+
+# We only have one kind of startup code files. Static binaries and
+# shared libraries are build using the PIC version.
+$(objpfx)crti.S: $(objpfx)initfini.s
+ sed -n -e '1,/@HEADER_ENDS/p' \
+ -e '/@_.*_PROLOG_BEGINS/,/@_.*_PROLOG_ENDS/p' \
+ -e '/@TRAILER_BEGINS/,$$p' $< > $@
+
+$(objpfx)crtn.S: $(objpfx)initfini.s
+ sed -n -e '1,/@HEADER_ENDS/p' \
+ -e '/@_.*_EPILOG_BEGINS/,/@_.*_EPILOG_ENDS/p' \
+ -e '/@TRAILER_BEGINS/,$$p' $< > $@
+
+$(objpfx)defs.h: $(objpfx)initfini.s
+ sed -n -e '/@TESTS_BEGIN/,/@TESTS_END/p' $< | \
+ awk -f defs.awk > $@
+
+endif
+
+ifeq (yes,$(elf))
+extra-objs += abi-note.o
+asm-CPPFLAGS += -I$(objpfx).
+endif