From 435aa54b3b9c1c87498e8bb3831394fd42220fa7 Mon Sep 17 00:00:00 2001 From: "H.J. Lu" Date: Tue, 16 Jun 2009 09:19:59 -0700 Subject: Consolidate PIE linking Makefile rules. --- Makeconfig | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'Makeconfig') diff --git a/Makeconfig b/Makeconfig index 875fb679aa..9f134cc137 100644 --- a/Makeconfig +++ b/Makeconfig @@ -434,6 +434,19 @@ ifndef +link $(common-objpfx)libc% $(+postinit),$^) \ $(link-extra-libs) $(link-libc) $(+postctor) $(+postinit) endif +# Command for linking PIE programs with the C library. +ifndef +link-pie ++link-pie = $(CC) -pie -Wl,-O1 -nostdlib -nostartfiles -o $@ \ + $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \ + $(combreloc-LDFLAGS) $(relro-LDFLAGS) $(hashstyle-LDFLAGS) \ + $(addprefix $(csu-objpfx),S$(start-installed-name)) \ + $(+preinit) $(+prectorS) \ + $(filter-out $(addprefix $(csu-objpfx),start.o \ + S$(start-installed-name))\ + $(+preinit) $(link-extra-libs) \ + $(common-objpfx)libc% $(+postinit),$^) \ + $(link-extra-libs) $(link-libc) $(+postctorS) $(+postinit) +endif # Command for statically linking programs with the C library. ifndef +link-static +link-static = $(CC) -nostdlib -nostartfiles -static -o $@ \ @@ -538,6 +551,9 @@ ifeq ($(elf),yes) +postinit = $(addprefix $(csu-objpfx),crtn.o) +prector = `$(CC) --print-file-name=crtbegin.o` +postctor = `$(CC) --print-file-name=crtend.o` +# Variants of the two previous definitions for linking PIE programs. ++prectorS = `$(CC) --print-file-name=crtbeginS.o` ++postctorS = `$(CC) --print-file-name=crtendS.o` +interp = $(addprefix $(elf-objpfx),interp.os) endif csu-objpfx = $(common-objpfx)csu/ -- cgit v1.2.3