Rename -Zno-jump-tables to -Zjump-tables=<bool>
Both gcc and llvm accept -fjump-tables as well as -fno-jump-tables. For consistency, allow rustc to accept -Zjump-tables=yes too.
This commit is contained in:
parent
35ebdf9ba1
commit
4959d18a97
7 changed files with 31 additions and 29 deletions
|
|
@ -229,7 +229,7 @@ fn instrument_function_attr<'ll>(
|
|||
}
|
||||
|
||||
fn nojumptables_attr<'ll>(cx: &SimpleCx<'ll>, sess: &Session) -> Option<&'ll Attribute> {
|
||||
if !sess.opts.unstable_opts.no_jump_tables {
|
||||
if sess.opts.unstable_opts.jump_tables {
|
||||
return None;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -814,6 +814,7 @@ fn test_unstable_options_tracking_hash() {
|
|||
tracked!(inline_mir_threshold, Some(123));
|
||||
tracked!(instrument_mcount, true);
|
||||
tracked!(instrument_xray, Some(InstrumentXRay::default()));
|
||||
tracked!(jump_tables, false);
|
||||
tracked!(link_directives, false);
|
||||
tracked!(link_only, true);
|
||||
tracked!(lint_llvm_ir, true);
|
||||
|
|
@ -831,7 +832,6 @@ fn test_unstable_options_tracking_hash() {
|
|||
tracked!(mutable_noalias, false);
|
||||
tracked!(next_solver, NextSolverConfig { coherence: true, globally: true });
|
||||
tracked!(no_generate_arange_section, true);
|
||||
tracked!(no_jump_tables, true);
|
||||
tracked!(no_link, true);
|
||||
tracked!(no_profiler_runtime, true);
|
||||
tracked!(no_trait_vptr, true);
|
||||
|
|
|
|||
|
|
@ -2395,6 +2395,8 @@ options! {
|
|||
`=skip-entry`
|
||||
`=skip-exit`
|
||||
Multiple options can be combined with commas."),
|
||||
jump_tables: bool = (true, parse_bool, [TRACKED],
|
||||
"allow jump table and lookup table generation from switch case lowering (default: yes)"),
|
||||
layout_seed: Option<u64> = (None, parse_opt_number, [TRACKED],
|
||||
"seed layout randomization"),
|
||||
link_directives: bool = (true, parse_bool, [TRACKED],
|
||||
|
|
@ -2475,8 +2477,6 @@ options! {
|
|||
"omit DWARF address ranges that give faster lookups"),
|
||||
no_implied_bounds_compat: bool = (false, parse_bool, [TRACKED],
|
||||
"disable the compatibility version of the `implied_bounds_ty` query"),
|
||||
no_jump_tables: bool = (false, parse_no_value, [TRACKED],
|
||||
"disable the jump tables and lookup tables that can be generated from a switch case lowering"),
|
||||
no_leak_check: bool = (false, parse_no_value, [UNTRACKED],
|
||||
"disable the 'leak check' for subtyping; unsound, but useful for tests"),
|
||||
no_link: bool = (false, parse_no_value, [TRACKED],
|
||||
|
|
|
|||
19
src/doc/unstable-book/src/compiler-flags/jump-tables.md
Normal file
19
src/doc/unstable-book/src/compiler-flags/jump-tables.md
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
# `jump-tables`
|
||||
|
||||
The tracking issue for this feature is [#116592](https://github.com/rust-lang/rust/issues/116592)
|
||||
|
||||
---
|
||||
|
||||
When set to no, this option enables the `-fno-jump-tables` flag for LLVM, which makes the
|
||||
codegen backend avoid generating jump tables when lowering switches.
|
||||
|
||||
When set to no, this option adds the LLVM `no-jump-tables=true` attribute to every function.
|
||||
|
||||
Disabling jump tables can be used to help provide protection against
|
||||
jump-oriented-programming (JOP) attacks, such as with the linux kernel's [IBT].
|
||||
|
||||
```sh
|
||||
RUSTFLAGS="-Zjump-tables=no" cargo +nightly build -Z build-std
|
||||
```
|
||||
|
||||
[IBT]: https://www.phoronix.com/news/Linux-IBT-By-Default-Tip
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
# `no-jump-tables`
|
||||
|
||||
The tracking issue for this feature is [#116592](https://github.com/rust-lang/rust/issues/116592)
|
||||
|
||||
---
|
||||
|
||||
This option enables the `-fno-jump-tables` flag for LLVM, which makes the
|
||||
codegen backend avoid generating jump tables when lowering switches.
|
||||
|
||||
This option adds the LLVM `no-jump-tables=true` attribute to every function.
|
||||
|
||||
The option can be used to help provide protection against
|
||||
jump-oriented-programming (JOP) attacks, such as with the linux kernel's [IBT].
|
||||
|
||||
```sh
|
||||
RUSTFLAGS="-Zno-jump-tables" cargo +nightly build -Z build-std
|
||||
```
|
||||
|
||||
[IBT]: https://www.phoronix.com/news/Linux-IBT-By-Default-Tip
|
||||
|
|
@ -1,10 +1,10 @@
|
|||
// Test that jump tables are (not) emitted when the `-Zno-jump-tables`
|
||||
// Test that jump tables are (not) emitted when the `-Zjump-tables=no`
|
||||
// flag is (not) set.
|
||||
|
||||
//@ revisions: unset set
|
||||
//@ assembly-output: emit-asm
|
||||
//@ compile-flags: -Copt-level=3
|
||||
//@ [set] compile-flags: -Zno-jump-tables
|
||||
//@ [set] compile-flags: -Zjump-tables=no
|
||||
//@ only-x86_64
|
||||
//@ ignore-sgx
|
||||
|
||||
|
|
|
|||
|
|
@ -1,11 +1,12 @@
|
|||
// Test that the `no-jump-tables` function attribute are (not) emitted when
|
||||
// the `-Zno-jump-tables` flag is (not) set.
|
||||
// the `-Zjump-tables=no` flag is (not) set.
|
||||
|
||||
//@ add-minicore
|
||||
//@ revisions: unset set
|
||||
//@ revisions: unset set_no set_yes
|
||||
//@ needs-llvm-components: x86
|
||||
//@ compile-flags: --target x86_64-unknown-linux-gnu
|
||||
//@ [set] compile-flags: -Zno-jump-tables
|
||||
//@ [set_no] compile-flags: -Zjump-tables=no
|
||||
//@ [set_yes] compile-flags: -Zjump-tables=yes
|
||||
|
||||
#![crate_type = "lib"]
|
||||
#![feature(no_core, lang_items)]
|
||||
|
|
@ -19,5 +20,6 @@ pub fn foo() {
|
|||
// CHECK: @foo() unnamed_addr #0
|
||||
|
||||
// unset-NOT: attributes #0 = { {{.*}}"no-jump-tables"="true"{{.*}} }
|
||||
// set: attributes #0 = { {{.*}}"no-jump-tables"="true"{{.*}} }
|
||||
// set_yes-NOT: attributes #0 = { {{.*}}"no-jump-tables"="true"{{.*}} }
|
||||
// set_no: attributes #0 = { {{.*}}"no-jump-tables"="true"{{.*}} }
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue