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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
// devela::sys::os::linux::point_entry
//
//! Configures the global assembly for target-architecture-specific program entry points.
//!
//! This module defines the low-level assembly routines that serve as the initial execution point
//! for the program. These routines are architecture-specific and handle:
//! 1. Setting up the minimal execution environment
//! 2. Transferring control to the Rust entry point
//! 3. Properly exiting with the program's return status
//!
//! The implementations match the system's calling conventions and use architecture-specific
//! syscall instructions for process termination.
/// Defines the program entry point and main fn translation layer for Linux systems.
///
/// Handles architecture-specific entry point setup and Rust-to-C ABI translation.
];
};
=> ;
=> ;
}
pub use linux_entry;
// WIP
// /// Configures the Linux program entry point with customizable initialization
// #[macro_export]
// macro_rules! linux_entry {
// // Basic version with default behavior
// () => {
// $crate::linux_entry!(main => |_| {});
// };
//
// // // Version with custom main wrapper
// // (main => $wrapper:expr) => {
// // $crate::__linux_internal_entry! {
// // pre_main: || {},
// // post_main: || {},
// // main_wrapper: $wrapper,
// // panic_handler: || loop {}
// // }
// // };
// //
// // // Full version with all customization points
// // (
// // pre_main: $pre:expr,
// // post_main: $post:expr,
// // main_wrapper: $wrapper:expr,
// // panic_handler: $panic:expr
// // ) => {
// // $crate::__linux_internal_entry! {
// // pre_main: $pre,
// // post_main: $post,
// // main_wrapper: $wrapper,
// // panic_handler: $panic
// // }
// // };
// }
// /// Internal implementation macro
// #[doc(hidden)]
// #[macro_export]
// macro_rules! __linux_internal_entry {.
// ($($config:tt)*) => {
// // Architecture-specific entry point
// $crate::global_asm!(
// ".global _start",
// ".hidden _start",
// ".type _start,@function",
// "_start:",
// $crate::__arch_entry_asm!($($config)*)
// );
//
// // Rust-level components
// $crate::__linux_entry_components!($($config)*);
// };
// }
// pub use __linux_internal_entry;
//
// /// Architecture-specific ASM generation.
// #[doc(hidden)]
// #[macro_export]
// macro_rules! __arch_entry_asm {
// (
// pre_main: $pre:expr,
// post_main: $post:expr,
// main_wrapper: $wrapper:expr,
// panic_handler: $panic:expr
// ) => {
// #[cfg(target_arch = "x86_64")]
// {
// concat!(
// "call {PRE_MAIN}\n",
// "call {WRAPPER_MAIN}\n",
// "mov rdi, rax\n",
// "mov rax, {EXIT}\n",
// "syscall",
// // PRE_MAIN = sym $pre,
// // WRAPPER_MAIN = sym $wrapper,
// EXIT = const $crate::LINUX_SYS::EXIT
// )
// }
// // Other architectures would follow similar patterns...
// };
// }
// pub use __arch_entry_asm;