@@ -150,7 +150,7 @@ randomization (ASLR). This is also referred to as “full ASLR”.
150
150
The Rust compiler supports position-independent executable and enables it by
151
151
default since version 0.12.0 (2014-10-09)[ 10] –[ 13] .
152
152
153
- ```
153
+ ``` text
154
154
$ readelf -h target/release/hello-rust | grep Type:
155
155
Type: DYN (Shared object file)
156
156
```
@@ -171,15 +171,15 @@ resulting in an overflow or wraparound.
171
171
The Rust compiler supports integer overflow checks, and enables it when
172
172
debug assertions are enabled since version 1.1.0 (2015-06-25)[ 14] –[ 20] .
173
173
174
- ``` rust
174
+ ``` compile_fail
175
175
fn main() {
176
176
let u: u8 = 255;
177
177
println!("u: {}", u + 1);
178
178
}
179
179
```
180
180
Fig. 2. hello-rust-integer program.
181
181
182
- ```
182
+ ``` text
183
183
$ cargo run
184
184
Compiling hello-rust-integer v0.1.0 (/home/rcvalle/hello-rust-integer)
185
185
Finished dev [unoptimized + debuginfo] target(s) in 0.23s
@@ -189,7 +189,7 @@ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
189
189
```
190
190
Fig. 3. Build and execution of hello-rust-integer with debug assertions enabled.
191
191
192
- ```
192
+ ``` text
193
193
$ cargo run --release
194
194
Compiling hello-rust-integer v0.1.0 (/home/rcvalle/hello-rust-integer)
195
195
Finished release [optimized] target(s) in 0.23s
@@ -232,7 +232,7 @@ default since its initial release, version 0.1 (2012-01-20)[21], [22], but
232
232
has regressed since then[ 23] –[ 25] , and enforced by default since version
233
233
1.8.0 (2016-04-14)[ 25] .
234
234
235
- ```
235
+ ``` text
236
236
$ readelf -l target/release/hello-rust | grep -A 1 GNU_STACK
237
237
GNU_STACK 0x0000000000000000 0x0000000000000000 0x0000000000000000
238
238
0x0000000000000000 0x0000000000000000 RW 0x10
@@ -299,7 +299,7 @@ also referred to as “partial RELRO”.
299
299
The Rust compiler supports read-only relocations, and enables it by default
300
300
since version 1.21.0 (2017-10-12)[ 30] , [ 31] .
301
301
302
- ```
302
+ ``` text
303
303
$ readelf -l target/release/hello-rust | grep GNU_RELRO
304
304
GNU_RELRO 0x000000000002ee00 0x000000000002fe00 0x000000000002fe00
305
305
```
@@ -321,7 +321,7 @@ RELRO”.
321
321
The Rust compiler supports immediate binding, and enables it by default
322
322
since version 1.21.0 (2017-10-12)[ 30] , [ 31] .
323
323
324
- ```
324
+ ``` text
325
325
$ readelf -d target/release/hello-rust | grep BIND_NOW
326
326
0x000000000000001e (FLAGS) BIND_NOW
327
327
```
@@ -366,7 +366,7 @@ C library default allocator<sup id="fnref:5" role="doc-noteref"><a
366
366
href="#fn:5" class="footnote">5</a ></sup > since version 1.32.0
367
367
(2019-01-17)[ 39] .
368
368
369
- ``` rust
369
+ ``` should_panic
370
370
fn main() {
371
371
let mut x = Box::new([0; 1024]);
372
372
@@ -380,7 +380,7 @@ fn main() {
380
380
```
381
381
Fig. 11. hello-rust-heap program.
382
382
383
- ```
383
+ ``` text
384
384
$ cargo run
385
385
Compiling hello-rust-heap v0.1.0 (/home/rcvalle/hello-rust-heap)
386
386
Finished dev [unoptimized + debuginfo] target(s) in 0.25s
@@ -390,7 +390,7 @@ Aborted
390
390
```
391
391
Fig. 12. Build and execution of hello-rust-heap with debug assertions enabled.
392
392
393
- ```
393
+ ``` text
394
394
$ cargo run --release
395
395
Compiling hello-rust-heap v0.1.0 (/home/rcvalle/hello-rust-heap)
396
396
Finished release [optimized] target(s) in 0.25s
@@ -456,7 +456,7 @@ class="footnote">6</a></sup>. There is work currently ongoing to add support
456
456
for the [ sanitizers] ( https://github.com/google/sanitizers ) [ 40] , which may or
457
457
may not include support for LLVM CFI.
458
458
459
- ```
459
+ ``` text
460
460
$ readelf -s target/release/hello-rust | grep __cfi_init
461
461
```
462
462
Fig. 15. Checking if LLVM CFI is enabled for a given binary.
@@ -502,7 +502,7 @@ currently ongoing to add support for the sanitizers[40], which may or may
502
502
not include support for safe stack<sup id =" fnref:7 " role =" doc-noteref " ><a
503
503
href="#fn:7" class="footnote">7</a ></sup >.
504
504
505
- ```
505
+ ``` text
506
506
$ readelf -s target/release/hello-rust | grep __safestack_init
507
507
```
508
508
Fig. 16. Checking if LLVM SafeStack is enabled for a given binary.
0 commit comments