406729c1638b36e990614d423d2de6cda2b214f8
[rrq/maintain_lilo.git] / debian / patches / 11_add-compile-flags.patch
1 Package:     lio
2 Subject:     add compile flags for hardening
3 Author:      Joachim Wiedorn <ad_debian at joonet.de>
4 Forwarded:   no
5 Last-Update: 2013-06-08
6
7 To support hardening CFLAGS and LDFLAGS must be used
8 by compiler executions.
9 ---
10
11 diff -urNa s10/src/Makefile s11/src/Makefile
12 --- s10/src/Makefile    2013-06-07 22:44:13.000000000 +0200
13 +++ s11/src/Makefile    2013-06-08 13:16:36.415275904 +0200
14 @@ -16,14 +16,14 @@
15  
16  SHELL=/bin/sh
17  CC=gcc
18 -CPP=$(CC) -E -P -ffreestanding
19 +CPP=$(CC) -E
20  AS86=as86 -0 -a
21  LD86=ld86 -0
22  NASM=nasm
23  G=`cat foo1 foo2 | grep version | cut -d " " -f 3`
24  
25 -CFLAGS=$(OPT) -Wall $(PCONFIG)
26 -LDFLAGS=#-Xlinker -qmagic
27 +FREE=-P -ffreestanding
28 +CFLAGS=$(FREE) $(OPT) -Wall $(PCONFIG)
29  LIBS=$(DEVMAPPER)
30  
31  OBJS=lilo.o raid.o map.o geometry.o boot.o device.o common.o bsect.o cfg.o \
32 @@ -79,7 +79,7 @@
33         echo $(MAN_DIR)
34  
35  .c.o:
36 -               $(CC) -c $(CFLAGS) $*.c
37 +               $(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
38  
39  .s.o:
40                 $(AS86) -w -l $*.lis -o $*.o $*.s
41 @@ -91,7 +91,7 @@
42                 dd if=$*.img of=$*.b bs=32 skip=1
43  
44  edit:          $(EDIT)
45 -               $(CC) $(CFLAGS) -DSTANDALONE -o edit $(EDIT) $(LDFLAGS)
46 +               $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -DSTANDALONE -o edit $(EDIT)
47  
48  loader.i:      mkloader first.b second.b third.b bitmap.b mbr.b chain.b mbr2.b
49                 ./mkloader >loader.i
50 @@ -100,30 +100,30 @@
51                 cp disk.b disk.com
52  
53  disk.s:                disk.S read.S bdata.h biosdata.S lilo.h Makefile
54 -               $(CPP) -traditional $(PCONFIG) -o disk.s  disk.S
55 +               $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) -o disk.s  disk.S
56  
57  mbr.s:         mbr.S lilo.h Makefile
58 -               $(CPP) -traditional $(PCONFIG) -DMBR=0xafbbe760 \
59 +               $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) -DMBR=0xafbbe760 \
60                         -o mbr.s  mbr.S
61  
62  mbr.b:         mbr.img
63                 dd if=$*.img of=$*.b bs=32 skip=49
64  
65  mbr2.s:                mbr.S lilo.h Makefile
66 -               $(CPP) -traditional $(PCONFIG) -DMBX=0x93c00848 \
67 +               $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) -DMBX=0x93c00848 \
68                         -o mbr2.s  mbr.S
69  
70  mbr2.b: mbr2.img
71         dd if=$*.img of=$*.b bs=32 skip=49
72  
73  bootsect.s: bootsect.S disk.b
74 -       $(CPP) -traditional $(PCONFIG) \
75 +       $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) \
76                 -DSIZEDISKB=`wc -c <disk.b | sed "s/ //g"` \
77                 -o bootsect.s  bootsect.S
78  
79  pseudo1.s: bootsect.S pseudo.S disk.com
80         cat bootsect.S pseudo.S >$(TMP).S
81 -       $(CPP) -traditional $(PCONFIG) \
82 +       $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) \
83                 -DSIZEKRNL=`wc -c <disk.com | sed "s/ //g"` \
84                 -DSIZEDISKB=512 -o pseudo1.s $(TMP).S
85         rm -f $(TMP).S
86 @@ -131,7 +131,7 @@
87  pseudo2.s: bootsect.S pseudo.S
88         $(MAKE) -C ../diagnose all
89         cat bootsect.S pseudo.S >$(TMP).S
90 -       $(CPP) -traditional $(PCONFIG) \
91 +       $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) \
92                 -DSIZEKRNL=`wc -c <../diagnose/test4.com | sed "s/ //g"` \
93                 -DSIZEDISKB=512 -o pseudo2.s $(TMP).S
94         rm -f $(TMP).S
95 @@ -139,7 +139,7 @@
96  pseudo3.s: bootsect.S pseudo.S
97         $(MAKE) -C ../diagnose all
98         cat bootsect.S pseudo.S >$(TMP).S
99 -       $(CPP) -traditional $(PCONFIG) \
100 +       $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) \
101                 -DSIZEKRNL=`wc -c <../diagnose/test5.com | sed "s/ //g"` \
102                 -DSIZEDISKB=512 -o pseudo3.s $(TMP).S
103         rm -f $(TMP).S
104 @@ -176,13 +176,13 @@
105                 cp -p dparam.S dparam.s
106  
107  lilo:          $(OBJS)
108 -               $(CC) -o lilo $(LDFLAGS) $(OBJS) $(LIBS)
109 +               $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o lilo $(OBJS) $(LIBS)
110  
111  lilo.static:   $(OBJS)
112 -               $(CC) -o lilo.static -static $(LDFLAGS) $(OBJS) $(LIBS)
113 +               $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o lilo.static -static $(OBJS) $(LIBS)
114  
115  common.s:      common.h
116 -               $(CPP) -C -traditional -DLILO_ASM -o common.s common.h
117 +               $(CPP) $(CPPFLAGS) -C -traditional -DLILO_ASM -o common.s common.h
118  
119  bitmap.o: bitmap.s common.s
120  third.o: third.s common.s
121 @@ -191,25 +191,25 @@
122  chain.o: chain.s common.s
123  
124  first.s:       first.S lilo.h version.h Makefile
125 -               $(CPP) $(PCONFIG) -DFIRST=0x62177489 -o first.s first.S
126 +               $(CPP) $(CPPFLAGS) $(PCONFIG) -DFIRST=0x62177489 -o first.s first.S
127  
128  second.s:      second.S read.S volume.S mapper.S biosdata.S shs3.S bdata.h lilo.h version.h \
129                         graph.S menu.S strlen.S bitmap.S crt.S display4.S Makefile
130 -               $(CPP) $(PCONFIG) -DTEXT=0x9dd476ec second.S -o second.s
131 +               $(CPP) $(CPPFLAGS) $(PCONFIG) -DTEXT=0x9dd476ec second.S -o second.s
132  
133  third.s:       second.S read.S volume.S mapper.S biosdata.S shs3.S bdata.h lilo.h version.h \
134                         graph.S menu.S strlen.S bitmap.S crt.S display4.S Makefile
135 -               $(CPP) $(PCONFIG) -DMENU=0x2012a4a7 second.S -o third.s
136 +               $(CPP) $(CPPFLAGS) $(PCONFIG) -DMENU=0x2012a4a7 second.S -o third.s
137  
138  bitmap.s:      second.S read.S volume.S mapper.S biosdata.S shs3.S bdata.h lilo.h version.h \
139                         graph.S menu.S strlen.S bitmap.S crt.S display4.S Makefile
140 -               $(CPP) $(PCONFIG) -DBITMAP=0x2ece2fbe second.S -o bitmap.s
141 +               $(CPP) $(CPPFLAGS) $(PCONFIG) -DBITMAP=0x2ece2fbe second.S -o bitmap.s
142  
143  chain.s:       chain.S lilo.h version.h first.b Makefile
144 -               $(CPP) $(PCONFIG) -DCHAIN=0x536a7646 chain.S -o chain.s
145 +               $(CPP) $(CPPFLAGS) $(PCONFIG) -DCHAIN=0x536a7646 chain.S -o chain.s
146  
147  xxx.s:         chain.S lilo.h Makefile
148 -               $(CPP) chain.S -DXXX -o xxx.s
149 +               $(CPP) $(CPPFLAGS) chain.S -DXXX -o xxx.s
150  
151  $(OBJS):       Makefile
152  
153 @@ -254,14 +254,14 @@
154  
155  dep:
156         sed '/\#\#\# Dependencies/q' <Makefile >tmp_make
157 -       $(CPP) $(CFLAGS) -MM *.c >>tmp_make
158 +       $(CPP) $(CFLAGS) $(CPPFLAGS) -MM *.c >>tmp_make
159         mv tmp_make Makefile
160  
161  version:       common.c lilo.h common.h
162 -       $(CC) $(CFLAGS) -DSHS_MAIN -o version common.c
163 +       $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -DSHS_MAIN -o version common.c
164  
165  mkloader:      temp.c
166 -       $(CC) $(CFLAGS) -DLILO_BINARY -o mkloader temp.c
167 +       $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -DLILO_BINARY -o mkloader temp.c
168  
169  
170  tidy: