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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
Modifications to glibc-2.4 to allow it to build with stack-protection
enabled throughout.
debug/Makefile: build stack_chk_fail_local -fno-stack-protector
Leave stack_chk_fail alone, so checking __SSP__ will show whether
compiler is rigged to build SSP, and hence that we want the modified
handler (which will never trigger SSP because there are no function
calls).
csu/Makefile, linuxthreads/Makefile, nptl/Makefile: inihibit SSP on
crti/crtn (i.e. compilation of initfini)
elf/rtld-Rules: Add compilation rules for .oS targets (so that
stack_chk_fail_local will build for rtld).
elf/Makefile: Add libc_nonshared.a to rtld build set so that
stack_chk_fail_local can be found (and other modifications
so that static objects are considered).
Makerules: add stack_chk_fail_local.oS to libc_pic.os (needed for
SSP builds on x86 so that it can resolve __stack_chk_fail_local).
Note this is a whole-archive link so adding libc_nonshared.a
causes too much stuff to be included.
Kevin F. Quinn 2006-09-30
--- debug/Makefile.orig 2006-09-30 17:06:31.000000000 +0200
+++ debug/Makefile 2006-09-30 17:12:45.000000000 +0200
@@ -70,6 +71,7 @@
CFLAGS-pread64_chk.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-recv_chk.c = -fexceptions -fasynchronous-unwind-tables
CFLAGS-recvfrom_chk.c = -fexceptions -fasynchronous-unwind-tables
+CFLAGS-stack_chk_fail_local.c = -fno-stack-protector
tst-chk1-ENV = LOCPATH=$(common-objpfx)localedata
tst-chk2-ENV = LOCPATH=$(common-objpfx)localedata
--- csu/Makefile.orig 2006-09-30 13:22:19.000000000 +0200
+++ csu/Makefile 2006-09-30 13:22:38.000000000 +0200
@@ -93,7 +93,7 @@
$(crtstuff:%=$(objpfx)%.o): %.o: %.S $(objpfx)defs.h
$(compile.S) -g0 $(ASFLAGS-.os) -o $@
-CFLAGS-initfini.s = -g0 -fPIC -fno-inline-functions $(fno-unit-at-a-time)
+CFLAGS-initfini.s = -g0 -fPIC -fno-inline-functions -fno-stack-protector $(fno-unit-at-a-time)
vpath initfini.c $(sysdirs)
--- linuxthreads/Makefile.orig 2006-09-30 14:39:33.000000000 +0200
+++ linuxthreads/Makefile 2006-09-30 14:39:42.000000000 +0200
@@ -102,7 +102,7 @@
extra-objs += $(crti-objs) $(crtn-objs)
omit-deps += crti crtn
-CFLAGS-pt-initfini.s = -g0 -fPIC -fno-inline-functions $(fno-unit-at-a-time)
+CFLAGS-pt-initfini.s = -g0 -fPIC -fno-stack-protector -fno-inline-functions $(fno-unit-at-a-time)
endif
librt-tests = ex10 ex11 tst-clock1
--- nptl/Makefile.orig 2006-09-30 14:36:46.000000000 +0200
+++ nptl/Makefile 2006-09-30 14:37:06.000000000 +0200
@@ -335,7 +335,7 @@
extra-objs += $(crti-objs) $(crtn-objs)
omit-deps += crti crtn
-CFLAGS-pt-initfini.s = -g0 -fPIC -fno-inline-functions $(fno-unit-at-a-time)
+CFLAGS-pt-initfini.s = -g0 -fPIC -fno-stack-protector -fno-inline-functions $(fno-unit-at-a-time)
endif
CFLAGS-flockfile.c = -D_IO_MTSAFE_IO
--- elf/Makefile.orig 2006-10-01 01:37:29.000000000 +0200
+++ elf/Makefile 2006-10-01 01:44:19.000000000 +0200
@@ -263,7 +263,7 @@
# are compiled with special flags, and puts these modules into rtld-libc.a
# for us. Then we do the real link using rtld-libc.a instead of libc_pic.a.
-$(objpfx)librtld.map: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a
+$(objpfx)librtld.map: $(objpfx)dl-allobjs.os $(common-objpfx)libc_pic.a $(common-objpfx)libc_nonshared.a
@-rm -f $@T
$(reloc-link) -o $@.o '-Wl,-(' $^ -lgcc '-Wl,-)' -Wl,-Map,$@T
rm -f $@.o
@@ -271,7 +271,7 @@
$(objpfx)librtld.mk: $(objpfx)librtld.map Makefile
LC_ALL=C \
- sed -n 's@^$(common-objpfx)\([^(]*\)(\([^)]*\.os\)) *.*$$@\1 \2@p' \
+ sed -n 's@^$(common-objpfx)\([^(]*\)(\([^)]*\.o[Ss]\)) *.*$$@\1 \2@p' \
$< | \
while read lib file; do \
case $$lib in \
@@ -281,6 +281,12 @@
LC_ALL=C \
sed 's@^$(common-objpfx)\([^/]*\)/stamp\.os$$@rtld-\1'" +=$$file@"\
;; \
+ libc_nonshared.a) \
+ LC_ALL=C fgrep -l /$$file \
+ $(common-objpfx)stamp.oS $(common-objpfx)*/stamp.oS | \
+ LC_ALL=C \
+ sed 's@^$(common-objpfx)\([^/]*\)/stamp\.oS$$@rtld-\1'" +=$$file@"\
+ ;; \
*/*.a) \
echo rtld-$${lib%%/*} += $$file ;; \
*) echo "Wasn't expecting $$lib($$file)" >&2; exit 1 ;; \
--- elf/rtld-Rules.orig 2006-10-01 01:41:07.000000000 +0200
+++ elf/rtld-Rules 2006-10-01 01:41:40.000000000 +0200
@@ -96,11 +96,13 @@
$(objpfx)rtld-%.os: %.S $(before-compile); $(compile-command.S)
$(objpfx)rtld-%.os: %.s $(before-compile); $(compile-command.s)
$(objpfx)rtld-%.os: %.c $(before-compile); $(compile-command.c)
+$(objpfx)rtld-%.oS: %.c $(before-compile); $(compile-command.c)
# The rules for generated source files.
$(objpfx)rtld-%.os: $(objpfx)%.S $(before-compile); $(compile-command.S)
$(objpfx)rtld-%.os: $(objpfx)%.s $(before-compile); $(compile-command.s)
$(objpfx)rtld-%.os: $(objpfx)%.c $(before-compile); $(compile-command.c)
+$(objpfx)rtld-%.oS: $(objpfx)%.c $(before-compile); $(compile-command.c)
# The command line setting of rtld-modules (see above) tells us
# what we need to build, and that tells us what dependency files we need.
--- Makerules.orig 2006-10-01 11:26:40.000000000 +0200
+++ Makerules 2006-10-01 11:27:30.000000000 +0200
@@ -602,7 +602,7 @@
# from being allocated in libc.so, which introduces evil dependencies
# between libc.so and ld.so, which can make it impossible to upgrade.
ifeq ($(elf),yes)
-$(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a
+$(common-objpfx)libc_pic.os: $(common-objpfx)libc_pic.a $(common-objpfx)debug/stack_chk_fail_local.oS
$(LINK.o) -nostdlib -nostartfiles -r -o $@ \
$(LDFLAGS-c_pic.os) -Wl,-d -Wl,--whole-archive $^
# Use our own special initializer and finalizer files for libc.so.
|