mirror of
				https://github.com/rust-lang/rust.git
				synced 2025-10-31 13:04:42 +00:00 
			
		
		
		
	 004aa15b47
			
		
	
	
		004aa15b47
		
	
	
	
	
		
			
			This commit adds cross-language LLVM Control Flow Integrity (CFI) support to the Rust compiler by adding the `-Zsanitizer-cfi-normalize-integers` option to be used with Clang `-fsanitize-cfi-icall-normalize-integers` for normalizing integer types (see https://reviews.llvm.org/D139395). It provides forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space). For more information about LLVM CFI and cross-language LLVM CFI support for the Rust compiler, see design document in the tracking issue #89653. Cross-language LLVM CFI can be enabled with -Zsanitizer=cfi and -Zsanitizer-cfi-normalize-integers, and requires proper (i.e., non-rustc) LTO (i.e., -Clinker-plugin-lto).
		
			
				
	
	
		
			47 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
			
		
		
	
	
			47 lines
		
	
	
		
			2.6 KiB
		
	
	
	
		
			Rust
		
	
	
	
	
	
| // Verifies that pointer types are generalized.
 | |
| //
 | |
| // needs-sanitizer-cfi
 | |
| // compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers
 | |
| 
 | |
| #![crate_type="lib"]
 | |
| 
 | |
| extern crate core;
 | |
| 
 | |
| pub fn foo0(_: &mut i32) { }
 | |
| // CHECK: define{{.*}}foo0{{.*}}!type ![[TYPE0:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
 | |
| pub fn foo1(_: &mut i32, _: &mut i32) { }
 | |
| // CHECK: define{{.*}}foo1{{.*}}!type ![[TYPE1:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
 | |
| pub fn foo2(_: &mut i32, _: &mut i32, _: &mut i32) { }
 | |
| // CHECK: define{{.*}}foo2{{.*}}!type ![[TYPE2:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
 | |
| pub fn foo3(_: &i32) { }
 | |
| // CHECK: define{{.*}}foo3{{.*}}!type ![[TYPE3:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
 | |
| pub fn foo4(_: &i32, _: &i32) { }
 | |
| // CHECK: define{{.*}}foo4{{.*}}!type ![[TYPE4:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
 | |
| pub fn foo5(_: &i32, _: &i32, _: &i32) { }
 | |
| // CHECK: define{{.*}}foo5{{.*}}!type ![[TYPE5:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
 | |
| pub fn foo6(_: *mut i32) { }
 | |
| // CHECK: define{{.*}}foo6{{.*}}!type ![[TYPE6:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
 | |
| pub fn foo7(_: *mut i32, _: *mut i32) { }
 | |
| // CHECK: define{{.*}}foo7{{.*}}!type ![[TYPE7:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
 | |
| pub fn foo8(_: *mut i32, _: *mut i32, _: *mut i32) { }
 | |
| // CHECK: define{{.*}}foo8{{.*}}!type ![[TYPE8:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
 | |
| pub fn foo9(_: *const i32) { }
 | |
| // CHECK: define{{.*}}foo9{{.*}}!type ![[TYPE9:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
 | |
| pub fn foo10(_: *const i32, _: *const i32) { }
 | |
| // CHECK: define{{.*}}foo10{{.*}}!type ![[TYPE10:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
 | |
| pub fn foo11(_: *const i32, _: *const i32, _: *const i32) { }
 | |
| // CHECK: define{{.*}}foo11{{.*}}!type ![[TYPE11:[0-9]+]] !type !{{[0-9]+}} !type !{{[0-9]+}}
 | |
| 
 | |
| // CHECK: ![[TYPE0]] = !{i64 0, !"_ZTSFvU3mutu3refIvEE.generalized"}
 | |
| // CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvU3mutu3refIvES0_E.generalized"}
 | |
| // CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvU3mutu3refIvES0_S0_E.generalized"}
 | |
| // CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFvu3refIvEE.generalized"}
 | |
| // CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFvu3refIvES_E.generalized"}
 | |
| // CHECK: ![[TYPE5]] = !{i64 0, !"_ZTSFvu3refIvES_S_E.generalized"}
 | |
| // CHECK: ![[TYPE6]] = !{i64 0, !"_ZTSFvPvE.generalized"}
 | |
| // CHECK: ![[TYPE7]] = !{i64 0, !"_ZTSFvPvS_E.generalized"}
 | |
| // CHECK: ![[TYPE8]] = !{i64 0, !"_ZTSFvPvS_S_E.generalized"}
 | |
| // CHECK: ![[TYPE9]] = !{i64 0, !"_ZTSFvPKvE.generalized"}
 | |
| // CHECK: ![[TYPE10]] = !{i64 0, !"_ZTSFvPKvS0_E.generalized"}
 | |
| // CHECK: ![[TYPE11]] = !{i64 0, !"_ZTSFvPKvS0_S0_E.generalized"}
 |