@@ -39,16 +39,6 @@ static struct plugin_info randomize_layout_plugin_info = {
39
39
"performance-mode\tenable cacheline-aware layout randomization\n"
40
40
};
41
41
42
- struct whitelist_entry {
43
- const char * pathname ;
44
- const char * lhs ;
45
- const char * rhs ;
46
- };
47
-
48
- static const struct whitelist_entry whitelist [] = {
49
- { }
50
- };
51
-
52
42
/* from old Linux dcache.h */
53
43
static inline unsigned long
54
44
partial_name_hash (unsigned long c , unsigned long prevhash )
@@ -734,60 +724,6 @@ static void handle_local_var_initializers(void)
734
724
}
735
725
}
736
726
737
- static bool type_name_eq (gimple stmt , const_tree type_tree , const char * wanted_name )
738
- {
739
- const char * type_name ;
740
-
741
- if (type_tree == NULL_TREE )
742
- return false;
743
-
744
- switch (TREE_CODE (type_tree )) {
745
- case RECORD_TYPE :
746
- type_name = TYPE_NAME_POINTER (type_tree );
747
- break ;
748
- case INTEGER_TYPE :
749
- if (TYPE_PRECISION (type_tree ) == CHAR_TYPE_SIZE )
750
- type_name = "char" ;
751
- else {
752
- INFORM (gimple_location (stmt ), "found non-char INTEGER_TYPE cast comparison: %qT\n" , type_tree );
753
- debug_tree (type_tree );
754
- return false;
755
- }
756
- break ;
757
- case POINTER_TYPE :
758
- if (TREE_CODE (TREE_TYPE (type_tree )) == VOID_TYPE ) {
759
- type_name = "void *" ;
760
- break ;
761
- } else {
762
- INFORM (gimple_location (stmt ), "found non-void POINTER_TYPE cast comparison %qT\n" , type_tree );
763
- debug_tree (type_tree );
764
- return false;
765
- }
766
- default :
767
- INFORM (gimple_location (stmt ), "unhandled cast comparison: %qT\n" , type_tree );
768
- debug_tree (type_tree );
769
- return false;
770
- }
771
-
772
- return strcmp (type_name , wanted_name ) == 0 ;
773
- }
774
-
775
- static bool whitelisted_cast (gimple stmt , const_tree lhs_tree , const_tree rhs_tree )
776
- {
777
- const struct whitelist_entry * entry ;
778
- expanded_location xloc = expand_location (gimple_location (stmt ));
779
-
780
- for (entry = whitelist ; entry -> pathname ; entry ++ ) {
781
- if (!strstr (xloc .file , entry -> pathname ))
782
- continue ;
783
-
784
- if (type_name_eq (stmt , lhs_tree , entry -> lhs ) && type_name_eq (stmt , rhs_tree , entry -> rhs ))
785
- return true;
786
- }
787
-
788
- return false;
789
- }
790
-
791
727
/*
792
728
* iterate over all statements to find "bad" casts:
793
729
* those where the address of the start of a structure is cast
@@ -864,10 +800,7 @@ static unsigned int find_bad_casts_execute(void)
864
800
#ifndef __DEBUG_PLUGIN
865
801
if (lookup_attribute ("randomize_performed" , TYPE_ATTRIBUTES (ptr_lhs_type )))
866
802
#endif
867
- {
868
- if (!whitelisted_cast (stmt , ptr_lhs_type , ptr_rhs_type ))
869
- MISMATCH (gimple_location (stmt ), "rhs" , ptr_lhs_type , ptr_rhs_type );
870
- }
803
+ MISMATCH (gimple_location (stmt ), "rhs" , ptr_lhs_type , ptr_rhs_type );
871
804
continue ;
872
805
}
873
806
@@ -890,10 +823,7 @@ static unsigned int find_bad_casts_execute(void)
890
823
#ifndef __DEBUG_PLUGIN
891
824
if (lookup_attribute ("randomize_performed" , TYPE_ATTRIBUTES (op0_type )))
892
825
#endif
893
- {
894
- if (!whitelisted_cast (stmt , ptr_lhs_type , op0_type ))
895
- MISMATCH (gimple_location (stmt ), "op0" , ptr_lhs_type , op0_type );
896
- }
826
+ MISMATCH (gimple_location (stmt ), "op0" , ptr_lhs_type , op0_type );
897
827
} else {
898
828
const_tree ssa_name_var = SSA_NAME_VAR (rhs1 );
899
829
/* skip bogus type casts introduced by container_of */
@@ -903,10 +833,7 @@ static unsigned int find_bad_casts_execute(void)
903
833
#ifndef __DEBUG_PLUGIN
904
834
if (lookup_attribute ("randomize_performed" , TYPE_ATTRIBUTES (ptr_rhs_type )))
905
835
#endif
906
- {
907
- if (!whitelisted_cast (stmt , ptr_lhs_type , ptr_rhs_type ))
908
- MISMATCH (gimple_location (stmt ), "ssa" , ptr_lhs_type , ptr_rhs_type );
909
- }
836
+ MISMATCH (gimple_location (stmt ), "ssa" , ptr_lhs_type , ptr_rhs_type );
910
837
}
911
838
912
839
}
0 commit comments