Skip to content

Commit a92f4fe

Browse files
GCC8: Merging fixes from Minipli's tree, found here: https://github.com/minipli/linux-unofficial_grsec/commits/gcc8_compat_fixes
1 parent 856fe0e commit a92f4fe

7 files changed

+86
-31
lines changed

patches/a_scripts_gcc-plugins_gcc-common.h.patch

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,25 @@ index 12262c0..aab4a5e 100644
7575
#include "predict.h"
7676
#include "ipa-utils.h"
7777

78-
@@ -90,6 +111,7 @@
78+
@@ -84,16 +84,17 @@
79+
#include "ipa-utils.h"
80+
81+
#if BUILDING_GCC_VERSION >= 4009
82+
+#include "stringpool.h"
83+
#include "attribs.h"
84+
#include "varasm.h"
85+
#include "stor-layout.h"
7986
#include "internal-fn.h"
8087
#include "gimple-expr.h"
8188
#include "gimple-fold.h"
8289
+//#include "diagnostic-color.h"
8390
#include "context.h"
8491
#include "tree-ssa-alias.h"
8592
#include "tree-ssa.h"
93+
-#include "stringpool.h"
94+
#if BUILDING_GCC_VERSION >= 7000
95+
#include "tree-vrp.h"
96+
#endif
8697
@@ -115,28 +137,34 @@
8798
#include "ssa-iterators.h"
8899
#endif
@@ -270,3 +281,41 @@ index 12262c0..aab4a5e 100644
270281
#if BUILDING_GCC_VERSION >= 7000
271282
#define get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep, keep_aligning) \
272283
get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep)
284+
@@ -913,4 +913,37 @@ static inline void debug_gimple_stmt(const_gimple s)
285+
get_inner_reference(exp, pbitsize, pbitpos, poffset, pmode, punsignedp, preversep, pvolatilep)
286+
#endif
287+
288+
+#if BUILDING_GCC_VERSION < 8000
289+
+#define E_HImode HImode
290+
+#define E_SImode SImode
291+
+#define E_DImode DImode
292+
+#define E_TImode TImode
293+
+#define E_QImode QImode
294+
+#endif
295+
+
296+
+#if BUILDING_GCC_VERSION < 5000
297+
+#define SCALAR_INT_MODE enum machine_mode
298+
+#define MACHINE_MODE enum machine_mode
299+
+#elif BUILDING_GCC_VERSION < 8000
300+
+#define SCALAR_INT_MODE machine_mode
301+
+#define MACHINE_MODE machine_mode
302+
+#else
303+
+#define SCALAR_INT_MODE scalar_int_mode
304+
+#define MACHINE_MODE machine_mode
305+
+#endif
306+
+
307+
+#if BUILDING_GCC_VERSION >= 8000
308+
+#define empty_string ""
309+
+
310+
+static inline profile_probability probability(int prob)
311+
+{
312+
+ return profile_probability::from_reg_br_prob_base(prob);
313+
+}
314+
+#else
315+
+static inline int probability(int prob)
316+
+{
317+
+ return prob;
318+
+}
319+
+#endif
320+
+
321+
#endif

patches/b_scripts_gcc-plugins_checker_plugin.c.patch

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ new file mode 100644
33
index 0000000..33f4af8
44
--- /dev/null
55
+++ b/scripts/gcc-plugins/checker_plugin.c
6-
@@ -0,0 +1,491 @@
6+
@@ -0,0 +1,493 @@
77
+/*
88
+ * Copyright 2011-2017 by the PaX Team <pageexec@freemail.hu>
99
+ * Licensed under the GPL v2
@@ -25,11 +25,11 @@ index 0000000..33f4af8
2525
+#include "gcc-common.h"
2626
+
2727
+extern void c_register_addr_space (const char *str, addr_space_t as);
28-
+extern enum machine_mode default_addr_space_pointer_mode (addr_space_t);
29-
+extern enum machine_mode default_addr_space_address_mode (addr_space_t);
30-
+extern bool default_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as);
31-
+extern bool default_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as);
32-
+extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as);
28+
+extern SCALAR_INT_MODE default_addr_space_pointer_mode (addr_space_t);
29+
+extern SCALAR_INT_MODE default_addr_space_address_mode (addr_space_t);
30+
+extern bool default_addr_space_valid_pointer_mode(SCALAR_INT_MODE mode, addr_space_t as);
31+
+extern bool default_addr_space_legitimate_address_p(MACHINE_MODE mode, rtx mem, bool strict, addr_space_t as);
32+
+extern rtx default_addr_space_legitimize_address(rtx x, rtx oldx, MACHINE_MODE mode, addr_space_t as);
3333
+
3434
+__visible int plugin_is_GPL_compatible;
3535
+
@@ -50,27 +50,27 @@ index 0000000..33f4af8
5050
+#define ADDR_SPACE_RCU 0
5151
+#define ADDR_SPACE_FORCE_RCU 0
5252
+
53-
+static enum machine_mode checker_addr_space_pointer_mode(addr_space_t addrspace)
53+
+static SCALAR_INT_MODE checker_addr_space_pointer_mode(addr_space_t addrspace)
5454
+{
5555
+ return default_addr_space_pointer_mode(ADDR_SPACE_GENERIC);
5656
+}
5757
+
58-
+static enum machine_mode checker_addr_space_address_mode(addr_space_t addrspace)
58+
+static SCALAR_INT_MODE checker_addr_space_address_mode(addr_space_t addrspace)
5959
+{
6060
+ return default_addr_space_address_mode(ADDR_SPACE_GENERIC);
6161
+}
6262
+
63-
+static bool checker_addr_space_valid_pointer_mode(enum machine_mode mode, addr_space_t as)
63+
+static bool checker_addr_space_valid_pointer_mode(SCALAR_INT_MODE mode, addr_space_t as)
6464
+{
6565
+ return default_addr_space_valid_pointer_mode(mode, as);
6666
+}
6767
+
68-
+static bool checker_addr_space_legitimate_address_p(enum machine_mode mode, rtx mem, bool strict, addr_space_t as)
68+
+static bool checker_addr_space_legitimate_address_p(MACHINE_MODE mode, rtx mem, bool strict, addr_space_t as)
6969
+{
7070
+ return default_addr_space_legitimate_address_p(mode, mem, strict, ADDR_SPACE_GENERIC);
7171
+}
7272
+
73-
+static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, enum machine_mode mode, addr_space_t as)
73+
+static rtx checker_addr_space_legitimize_address(rtx x, rtx oldx, MACHINE_MODE mode, addr_space_t as)
7474
+{
7575
+ return default_addr_space_legitimize_address(x, oldx, mode, as);
7676
+}
@@ -286,7 +286,7 @@ index 0000000..33f4af8
286286
+ cond_bb = e->src;
287287
+ join_bb = e->dest;
288288
+ e->flags = EDGE_FALSE_VALUE;
289-
+ e->probability = REG_BR_PROB_BASE;
289+
+ e->probability = probability(REG_BR_PROB_BASE);
290290
+
291291
+ true_bb = create_empty_bb(EXIT_BLOCK_PTR_FOR_FN(cfun)->prev_bb);
292292
+ make_edge(cond_bb, true_bb, EDGE_TRUE_VALUE);
@@ -424,6 +424,8 @@ index 0000000..33f4af8
424424
+
425425
+ free_dominance_info(CDI_DOMINATORS);
426426
+ free_dominance_info(CDI_POST_DOMINATORS);
427+
+ //if (current_loops)
428+
+ // loops_state_set(LOOPS_NEED_FIXUP);
427429
+ loop_optimizer_finalize();
428430
+ return 0;
429431
+}

patches/b_scripts_gcc-plugins_rap_plugin_rap_fptr_pass.c.patch

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ new file mode 100644
33
index 0000000..09e1377
44
--- /dev/null
55
+++ b/scripts/gcc-plugins/rap_plugin/rap_fptr_pass.c
6-
@@ -0,0 +1,278 @@
6+
@@ -0,0 +1,281 @@
77
+/*
88
+ * Copyright 2012-2017 by PaX Team <pageexec@freemail.hu>
99
+ * Licensed under the GPL v2
@@ -142,7 +142,7 @@ index 0000000..09e1377
142142
+ cond_bb = e->src;
143143
+ join_bb = e->dest;
144144
+ e->flags = EDGE_FALSE_VALUE;
145-
+ e->probability = REG_BR_PROB_BASE;
145+
+ e->probability = probability(REG_BR_PROB_BASE);
146146
+
147147
+ true_bb = create_empty_bb(EXIT_BLOCK_PTR_FOR_FN(cfun)->prev_bb);
148148
+ make_edge(cond_bb, true_bb, EDGE_TRUE_VALUE | EDGE_PRESERVE);
@@ -274,6 +274,8 @@ index 0000000..09e1377
274274
+
275275
+ free_dominance_info(CDI_DOMINATORS);
276276
+ free_dominance_info(CDI_POST_DOMINATORS);
277+
+ if (current_loops)
278+
+ loops_state_set(LOOPS_NEED_FIXUP);
277279
+ loop_optimizer_finalize();
278280
+
279281
+ return 0;

patches/b_scripts_gcc-plugins_rap_plugin_rap_ret_pass.c.patch

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ new file mode 100644
33
index 0000000..690f8d3
44
--- /dev/null
55
+++ b/scripts/gcc-plugins/rap_plugin/rap_ret_pass.c
6-
@@ -0,0 +1,343 @@
6+
@@ -0,0 +1,345 @@
77
+/*
88
+ * Copyright 2012-2017 by PaX Team <pageexec@freemail.hu>
99
+ * Licensed under the GPL v2
@@ -115,7 +115,7 @@ index 0000000..690f8d3
115115
+ cond_bb = e->src;
116116
+ join_bb = e->dest;
117117
+ e->flags = EDGE_FALSE_VALUE;
118-
+ e->probability = REG_BR_PROB_BASE;
118+
+ e->probability = probability(REG_BR_PROB_BASE);
119119
+
120120
+ true_bb = create_empty_bb(join_bb);
121121
+ make_edge(cond_bb, true_bb, EDGE_TRUE_VALUE | EDGE_PRESERVE);
@@ -173,6 +173,8 @@ index 0000000..690f8d3
173173
+
174174
+ free_dominance_info(CDI_DOMINATORS);
175175
+ free_dominance_info(CDI_POST_DOMINATORS);
176+
+ if (current_loops)
177+
+ loops_state_set(LOOPS_NEED_FIXUP);
176178
+ loop_optimizer_finalize();
177179
+ return 0;
178180
+}

patches/b_scripts_gcc-plugins_size_overflow_plugin_intentional_overflow.c.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -541,16 +541,16 @@ index 0000000..26899bd
541541
+ return true;
542542
+
543543
+ switch (TYPE_MODE(type)) {
544-
+ case QImode:
544+
+ case E_QImode:
545545
+ new_type = intQI_type_node;
546546
+ break;
547-
+ case HImode:
547+
+ case E_HImode:
548548
+ new_type = intHI_type_node;
549549
+ break;
550-
+ case SImode:
550+
+ case E_SImode:
551551
+ new_type = intSI_type_node;
552552
+ break;
553-
+ case DImode:
553+
+ case E_DImode:
554554
+ new_type = intDI_type_node;
555555
+ break;
556556
+ default:

patches/b_scripts_gcc-plugins_size_overflow_plugin_remove_unnecessary_dup.c.patch

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,16 +82,16 @@ index 0000000..5c26862
8282
+
8383
+ type = TREE_TYPE(node);
8484
+ switch (TYPE_MODE(type)) {
85-
+ case HImode:
85+
+ case E_HImode:
8686
+ new_type = unsigned_intQI_type_node;
8787
+ break;
88-
+ case SImode:
88+
+ case E_SImode:
8989
+ new_type = unsigned_intHI_type_node;
9090
+ break;
91-
+ case DImode:
91+
+ case E_DImode:
9292
+ new_type = unsigned_intSI_type_node;
9393
+ break;
94-
+ case TImode:
94+
+ case E_TImode:
9595
+ new_type = unsigned_intDI_type_node;
9696
+ break;
9797
+ default:

patches/b_scripts_gcc-plugins_size_overflow_plugin_size_overflow_transform_core.c.patch

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,20 +43,20 @@ index 0000000..7b24aea
4343
+ return TREE_TYPE(node);
4444
+
4545
+ switch (TYPE_MODE(type)) {
46-
+ case QImode:
47-
+ case HImode:
46+
+ case E_QImode:
47+
+ case E_HImode:
4848
+ new_type = size_overflow_type_SI;
4949
+ break;
50-
+ case SImode:
50+
+ case E_SImode:
5151
+ new_type = size_overflow_type_DI;
5252
+ break;
53-
+ case DImode:
53+
+ case E_DImode:
5454
+ if (LONG_TYPE_SIZE == GET_MODE_BITSIZE(SImode))
5555
+ new_type = TYPE_UNSIGNED(type) ? unsigned_intDI_type_node : intDI_type_node;
5656
+ else
5757
+ new_type = size_overflow_type_TI;
5858
+ break;
59-
+ case TImode:
59+
+ case E_TImode:
6060
+ gcc_assert(!TYPE_UNSIGNED(type));
6161
+ new_type = size_overflow_type_TI;
6262
+ break;
@@ -513,7 +513,7 @@ index 0000000..7b24aea
513513
+ cond_bb = e->src;
514514
+ join_bb = e->dest;
515515
+ e->flags = EDGE_FALSE_VALUE;
516-
+ e->probability = REG_BR_PROB_BASE;
516+
+ e->probability = probability(REG_BR_PROB_BASE);
517517
+
518518
+ bb_true = create_empty_bb(cond_bb);
519519
+ make_edge(cond_bb, bb_true, EDGE_TRUE_VALUE);

0 commit comments

Comments
 (0)