ca518e7dfe376f592891c563dd53033970910ad3
[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-07-02
6
7 To support hardening CFLAGS and LDFLAGS must be usable
8 for all compiler commands.
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-07-02 21:08:53.456876190 +0200
14 @@ -23,7 +23,6 @@
15  G=`cat foo1 foo2 | grep version | cut -d " " -f 3`
16  
17  CFLAGS=$(OPT) -Wall $(PCONFIG)
18 -LDFLAGS=#-Xlinker -qmagic
19  LIBS=$(DEVMAPPER)
20  
21  OBJS=lilo.o raid.o map.o geometry.o boot.o device.o common.o bsect.o cfg.o \
22 @@ -79,7 +78,7 @@
23         echo $(MAN_DIR)
24  
25  .c.o:
26 -               $(CC) -c $(CFLAGS) $*.c
27 +               $(CC) -c $(CPPFLAGS) $(CFLAGS) $*.c
28  
29  .s.o:
30                 $(AS86) -w -l $*.lis -o $*.o $*.s
31 @@ -91,7 +90,7 @@
32                 dd if=$*.img of=$*.b bs=32 skip=1
33  
34  edit:          $(EDIT)
35 -               $(CC) $(CFLAGS) -DSTANDALONE -o edit $(EDIT) $(LDFLAGS)
36 +               $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -DSTANDALONE -o edit $(EDIT)
37  
38  loader.i:      mkloader first.b second.b third.b bitmap.b mbr.b chain.b mbr2.b
39                 ./mkloader >loader.i
40 @@ -100,30 +99,30 @@
41                 cp disk.b disk.com
42  
43  disk.s:                disk.S read.S bdata.h biosdata.S lilo.h Makefile
44 -               $(CPP) -traditional $(PCONFIG) -o disk.s  disk.S
45 +               $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) -o disk.s  disk.S
46  
47  mbr.s:         mbr.S lilo.h Makefile
48 -               $(CPP) -traditional $(PCONFIG) -DMBR=0xafbbe760 \
49 +               $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) -DMBR=0xafbbe760 \
50                         -o mbr.s  mbr.S
51  
52  mbr.b:         mbr.img
53                 dd if=$*.img of=$*.b bs=32 skip=49
54  
55  mbr2.s:                mbr.S lilo.h Makefile
56 -               $(CPP) -traditional $(PCONFIG) -DMBX=0x93c00848 \
57 +               $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) -DMBX=0x93c00848 \
58                         -o mbr2.s  mbr.S
59  
60  mbr2.b: mbr2.img
61         dd if=$*.img of=$*.b bs=32 skip=49
62  
63  bootsect.s: bootsect.S disk.b
64 -       $(CPP) -traditional $(PCONFIG) \
65 +       $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) \
66                 -DSIZEDISKB=`wc -c <disk.b | sed "s/ //g"` \
67                 -o bootsect.s  bootsect.S
68  
69  pseudo1.s: bootsect.S pseudo.S disk.com
70         cat bootsect.S pseudo.S >$(TMP).S
71 -       $(CPP) -traditional $(PCONFIG) \
72 +       $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) \
73                 -DSIZEKRNL=`wc -c <disk.com | sed "s/ //g"` \
74                 -DSIZEDISKB=512 -o pseudo1.s $(TMP).S
75         rm -f $(TMP).S
76 @@ -131,7 +130,7 @@
77  pseudo2.s: bootsect.S pseudo.S
78         $(MAKE) -C ../diagnose all
79         cat bootsect.S pseudo.S >$(TMP).S
80 -       $(CPP) -traditional $(PCONFIG) \
81 +       $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) \
82                 -DSIZEKRNL=`wc -c <../diagnose/test4.com | sed "s/ //g"` \
83                 -DSIZEDISKB=512 -o pseudo2.s $(TMP).S
84         rm -f $(TMP).S
85 @@ -139,7 +138,7 @@
86  pseudo3.s: bootsect.S pseudo.S
87         $(MAKE) -C ../diagnose all
88         cat bootsect.S pseudo.S >$(TMP).S
89 -       $(CPP) -traditional $(PCONFIG) \
90 +       $(CPP) $(CPPFLAGS) -traditional $(PCONFIG) \
91                 -DSIZEKRNL=`wc -c <../diagnose/test5.com | sed "s/ //g"` \
92                 -DSIZEDISKB=512 -o pseudo3.s $(TMP).S
93         rm -f $(TMP).S
94 @@ -176,13 +175,13 @@
95                 cp -p dparam.S dparam.s
96  
97  lilo:          $(OBJS)
98 -               $(CC) -o lilo $(LDFLAGS) $(OBJS) $(LIBS)
99 +               $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o lilo $(OBJS) $(LIBS)
100  
101  lilo.static:   $(OBJS)
102 -               $(CC) -o lilo.static -static $(LDFLAGS) $(OBJS) $(LIBS)
103 +               $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -o lilo.static -static $(OBJS) $(LIBS)
104  
105  common.s:      common.h
106 -               $(CPP) -C -traditional -DLILO_ASM -o common.s common.h
107 +               $(CPP) $(CPPFLAGS) -C -traditional -DLILO_ASM -o common.s common.h
108  
109  bitmap.o: bitmap.s common.s
110  third.o: third.s common.s
111 @@ -191,25 +190,25 @@
112  chain.o: chain.s common.s
113  
114  first.s:       first.S lilo.h version.h Makefile
115 -               $(CPP) $(PCONFIG) -DFIRST=0x62177489 -o first.s first.S
116 +               $(CPP) $(CPPFLAGS) $(PCONFIG) -DFIRST=0x62177489 -o first.s first.S
117  
118  second.s:      second.S read.S volume.S mapper.S biosdata.S shs3.S bdata.h lilo.h version.h \
119                         graph.S menu.S strlen.S bitmap.S crt.S display4.S Makefile
120 -               $(CPP) $(PCONFIG) -DTEXT=0x9dd476ec second.S -o second.s
121 +               $(CPP) $(CPPFLAGS) $(PCONFIG) -DTEXT=0x9dd476ec second.S -o second.s
122  
123  third.s:       second.S read.S volume.S mapper.S biosdata.S shs3.S bdata.h lilo.h version.h \
124                         graph.S menu.S strlen.S bitmap.S crt.S display4.S Makefile
125 -               $(CPP) $(PCONFIG) -DMENU=0x2012a4a7 second.S -o third.s
126 +               $(CPP) $(CPPFLAGS) $(PCONFIG) -DMENU=0x2012a4a7 second.S -o third.s
127  
128  bitmap.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) -DBITMAP=0x2ece2fbe second.S -o bitmap.s
131 +               $(CPP) $(CPPFLAGS) $(PCONFIG) -DBITMAP=0x2ece2fbe second.S -o bitmap.s
132  
133  chain.s:       chain.S lilo.h version.h first.b Makefile
134 -               $(CPP) $(PCONFIG) -DCHAIN=0x536a7646 chain.S -o chain.s
135 +               $(CPP) $(CPPFLAGS) $(PCONFIG) -DCHAIN=0x536a7646 chain.S -o chain.s
136  
137  xxx.s:         chain.S lilo.h Makefile
138 -               $(CPP) chain.S -DXXX -o xxx.s
139 +               $(CPP) $(CPPFLAGS) chain.S -DXXX -o xxx.s
140  
141  $(OBJS):       Makefile
142  
143 @@ -254,14 +253,14 @@
144  
145  dep:
146         sed '/\#\#\# Dependencies/q' <Makefile >tmp_make
147 -       $(CPP) $(CFLAGS) -MM *.c >>tmp_make
148 +       $(CPP) $(CFLAGS) $(CPPFLAGS) -MM *.c >>tmp_make
149         mv tmp_make Makefile
150  
151  version:       common.c lilo.h common.h
152 -       $(CC) $(CFLAGS) -DSHS_MAIN -o version common.c
153 +       $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -DSHS_MAIN -o version common.c
154  
155  mkloader:      temp.c
156 -       $(CC) $(CFLAGS) -DLILO_BINARY -o mkloader temp.c
157 +       $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) -DLILO_BINARY -o mkloader temp.c
158  
159  
160  tidy: