1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
//! Freestanding Syscall
//!
//! This example shows a freestanding linux application with no runtime nor
//! standard library linked. It directly provides the `_start` entry-point
//! picked by the linux linker as ELF entry-point. It then simply invokes the
//! `EXIT` syscall with an exit-code of 71.
//!
//! We need to provide a panic-handler for rust-core to link successfully. For
//! simplicity we just loop in case of panic. Since no core-symbols are called,
//! anyway, this is just about linking successfully. In case you did not
//! specify `abort` as panic-strategy, we also need to provide the exception
//! handler personality routine. Similarly to the panic-handler, we also just
//! provide a dummy, since we never raise exceptions. Note that the exception
//! handler requires unstable rust, so you need to compile via nightly or
//! specify `panic-strategy = "abort"`.
//!
//! Note that our test-suite uses this example to check for cross-language
//! link-time-optimization. It uses the exported symbol-list as reference, so
//! be careful not to pull in symbols from this example other than the ones
//! already there.
//!
//! Note that this example is guarded by the `freestanding` flag, since it
//! cannot be linked with the standard runtime (crt0), as we do not provide the
//! necessary hooks. Instead, you must compile it with `-nostartfiles`. Make
//! sure to provide this when enabling the `freestanding` feature.
use r_linux;
extern "C"
!
pub extern "C" !