Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 68bfda9

Browse files
committed
Stabilize -Zjump-tables=<bool> into -Cjump-table=<bool>
1 parent e642e09 commit 68bfda9

File tree

7 files changed

+22
-28
lines changed

7 files changed

+22
-28
lines changed

‎compiler/rustc_codegen_llvm/src/attributes.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ fn instrument_function_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> SmallVec<[&'ll Attr
208208
}
209209

210210
fn nojumptables_attr<'ll>(cx: &CodegenCx<'ll, '_>) -> Option<&'ll Attribute> {
211-
if cx.sess().opts.unstable_opts.jump_tables {
211+
if cx.sess().opts.cg.jump_tables {
212212
return None;
213213
}
214214

‎compiler/rustc_interface/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,6 +620,7 @@ fn test_codegen_options_tracking_hash() {
620620
tracked!(force_frame_pointers, FramePointer::Always);
621621
tracked!(force_unwind_tables, Some(true));
622622
tracked!(instrument_coverage, InstrumentCoverage::Yes);
623+
tracked!(jump_tables, false);
623624
tracked!(link_dead_code, Some(true));
624625
tracked!(linker_plugin_lto, LinkerPluginLto::LinkerPluginAuto);
625626
tracked!(llvm_args, vec![String::from("1"), String::from("2")]);
@@ -813,7 +814,6 @@ fn test_unstable_options_tracking_hash() {
813814
tracked!(inline_mir_threshold, Some(123));
814815
tracked!(instrument_mcount, true);
815816
tracked!(instrument_xray, Some(InstrumentXRay::default()));
816-
tracked!(jump_tables, false);
817817
tracked!(link_directives, false);
818818
tracked!(link_only, true);
819819
tracked!(lint_llvm_ir, true);

‎compiler/rustc_session/src/options.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2022,6 +2022,8 @@ options! {
20222022
"instrument the generated code to support LLVM source-based code coverage reports \
20232023
(note, the compiler build config must include `profiler = true`); \
20242024
implies `-C symbol-mangling-version=v0`"),
2025+
jump_tables: bool = (true, parse_bool, [TRACKED],
2026+
"Allow jump table and lookup table generation from switch case lowering (default: yes)"),
20252027
link_arg: (/* redirected to link_args */) = ((), parse_string_push, [UNTRACKED],
20262028
"a single extra argument to append to the linker invocation (can be used several times)"),
20272029
link_args: Vec<String> = (Vec::new(), parse_list, [UNTRACKED],
@@ -2324,8 +2326,6 @@ options! {
23242326
`=skip-entry`
23252327
`=skip-exit`
23262328
Multiple options can be combined with commas."),
2327-
jump_tables: bool = (true, parse_bool, [TRACKED],
2328-
"Allow jump table and lookup table generation from switch case lowering (default: yes)"),
23292329
layout_seed: Option<u64> = (None, parse_opt_number, [TRACKED],
23302330
"seed layout randomization"),
23312331
link_directives: bool = (true, parse_bool, [TRACKED],

‎src/doc/rustc/src/codegen-options/index.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -209,6 +209,19 @@ Note that while the `-C instrument-coverage` option is stable, the profile data
209209
format produced by the resulting instrumentation may change, and may not work
210210
with coverage tools other than those built and shipped with the compiler.
211211

212+
## jump-tables
213+
214+
This option is used to allow or prevent the codegen backend from creating
215+
jump tables when lowering switches.
216+
217+
* `y`, `yes`, `on`, `true` or no value: allow jump tables (the default).
218+
* `n`, `no`, `off` or `false`: disable jump tables.
219+
220+
Disabling jump tables can be used to help provide protection against
221+
jump-oriented-programming (JOP) attacks, such as with the linux kernel's [IBT].
222+
223+
[IBT]: https://www.phoronix.com/news/Linux-IBT-By-Default-Tip
224+
212225
## link-arg
213226

214227
This flag lets you append a single extra argument to the linker invocation.

‎src/doc/unstable-book/src/compiler-flags/jump-tables.md

Lines changed: 0 additions & 19 deletions
This file was deleted.

‎tests/assembly-llvm/x86_64-no-jump-tables.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
// Test that jump tables are (not) emitted when the `-Zjump-tables=no`
1+
// Test that jump tables are (not) emitted when the `-Cjump-tables=no`
22
// flag is (not) set.
33

44
//@ revisions: unset set
55
//@ assembly-output: emit-asm
66
//@ compile-flags: -Copt-level=3
7-
//@ [set] compile-flags: -Zjump-tables=no
7+
//@ [set] compile-flags: -Cjump-tables=no
88
//@ only-x86_64
99
//@ ignore-sgx
1010

‎tests/codegen-llvm/no-jump-tables.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
// Test that the `no-jump-tables` function attribute are (not) emitted when
2-
// the `-Zjump-tables=no` flag is (not) set.
2+
// the `-Cjump-tables=no` flag is (not) set.
33

44
//@ add-core-stubs
55
//@ revisions: unset set_no set_yes
66
//@ needs-llvm-components: x86
77
//@ compile-flags: --target x86_64-unknown-linux-gnu
8-
//@ [set_no] compile-flags: -Zjump-tables=no
9-
//@ [set_yes] compile-flags: -Zjump-tables=yes
8+
//@ [set_no] compile-flags: -Cjump-tables=no
9+
//@ [set_yes] compile-flags: -Cjump-tables=yes
1010

1111
#![crate_type = "lib"]
1212
#![feature(no_core, lang_items)]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /