summaryrefslogtreecommitdiff
blob: a25ab552b513759df76ee7a4006507b51457478e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
	If compiler is PIE-default (which is indicated by the existing
	pic_default test, since setting -fPIE sets __PIC__), use the shared
	versions of crtbegin, crtend and crt1 objects.
	Kevin F. Quinn <kevquinn@gentoo.org> 15 Dec 2006

--- Makeconfig.orig	2006-12-19 21:40:06.000000000 +0100
+++ Makeconfig	2006-12-19 21:40:20.000000000 +0100
@@ -415,6 +415,19 @@
 
 # Command for linking programs with the C library.
 ifndef +link
+ifeq (yes,$(build-pic-default))
+# PIE version
++link = $(CC) -nostdlib -nostartfiles -pie -o $@ \
+	      $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
+	      $(combreloc-LDFLAGS) $(relro-LDFLAGS) \
+	      $(addprefix $(csu-objpfx),$(+starts)) \
+	      $(+preinit) $(+prectors) \
+	      $(filter-out $(addprefix $(csu-objpfx),start.o \
+						     $(+starts))\
+			   $(+preinit) $(link-extra-libs) \
+			   $(common-objpfx)libc% $(+postinit),$^) \
+	      $(link-extra-libs) $(link-libc) $(+postctors) $(+postinit)
+else
 +link = $(CC) -nostdlib -nostartfiles -o $@ \
 	      $(sysdep-LDFLAGS) $(config-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) \
 	      $(combreloc-LDFLAGS) $(relro-LDFLAGS) \
@@ -426,8 +439,20 @@
 			   $(common-objpfx)libc% $(+postinit),$^) \
 	      $(link-extra-libs) $(link-libc) $(+postctor) $(+postinit)
 endif
+endif
 # Command for statically linking programs with the C library.
 ifndef +link-static
+ifeq (yes,$(build-pic-default))
++link-static = $(CC) -nostdlib -nostartfiles -static -o $@ \
+	      $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F)) $(app-LDFLAGS) \
+	      $(addprefix $(csu-objpfx),$(+static-starts)) \
+	      $(+preinit) $(+prectors) \
+	      $(filter-out $(addprefix $(csu-objpfx),start.o \
+						     $(+starts))\
+			   $(+preinit) $(link-extra-libs-static) \
+			   $(common-objpfx)libc% $(+postinit),$^) \
+	      $(link-extra-libs-static) $(link-libc-static) $(+postctors) $(+postinit)
+else
 +link-static = $(CC) -nostdlib -nostartfiles -static -o $@ \
 	      $(sysdep-LDFLAGS) $(LDFLAGS) $(LDFLAGS-$(@F))  \
 	      $(addprefix $(csu-objpfx),$(static-start-installed-name)) \
@@ -438,6 +463,7 @@
 			   $(common-objpfx)libc% $(+postinit),$^) \
 	      $(link-extra-libs-static) $(link-libc-static) $(+postctor) $(+postinit)
 endif
+endif
 # Command for statically linking bounded-pointer programs with the C library.
 ifndef +link-bounded
 +link-bounded = $(CC) -nostdlib -nostartfiles -static -fbounded-pointers -o $@ \
@@ -530,6 +556,12 @@
 +postinit = $(addprefix $(csu-objpfx),crtn.o)
 +prector = `$(CC) --print-file-name=crtbegin.o`
 +postctor = `$(CC) --print-file-name=crtend.o`
+# PIE versions
++prectors = `$(CC) --print-file-name=crtbeginS.o`
++postctors = `$(CC) --print-file-name=crtendS.o`
++starts = S$(start-installed-name)
++static-starts = S$(static-start-installed-name)
+#
 +interp = $(addprefix $(elf-objpfx),interp.os)
 endif
 csu-objpfx = $(common-objpfx)csu/
--- configure.in.orig	2006-12-19 22:53:25.000000000 +0100
+++ configure.in	2006-12-19 22:53:41.000000000 +0100
@@ -2145,7 +2145,7 @@
 # error PIC is default.
 #endif
 EOF
-if eval "${CC-cc} -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
+if eval "${CC-cc} -fno-PIE -S conftest.c 2>&AS_MESSAGE_LOG_FD 1>&AS_MESSAGE_LOG_FD"; then
   pic_default=no
 fi
 rm -f conftest.*])