| 1 |
//! Non-WASM, non-Windows, non-Apple: orphan section start/end symbols. |
| 2 |
|
| 3 |
/// On LLVM/GCC platforms we can use orphan sections with _start and _end |
| 4 |
/// symbols. |
| 5 |
#[doc(hidden)] |
| 6 |
#[macro_export] |
| 7 |
macro_rules! __get_section_standard { |
| 8 |
(movable, name=$name:tt, type=$generic_ty:ty) => { |
| 9 |
{ |
| 10 |
$crate::__weak_section_symbols!(item data $name); |
| 11 |
$crate::__weak_section_symbols!(backref data $name); |
| 12 |
$crate::__support::MovableBounds::new( |
| 13 |
$crate::__support::PtrBounds::new( |
| 14 |
$crate::__address_of_symbol!(item data start $name), |
| 15 |
$crate::__address_of_symbol!(item data end $name), |
| 16 |
), |
| 17 |
$crate::__support::PtrBounds::new( |
| 18 |
$crate::__address_of_symbol!(backref data start $name), |
| 19 |
$crate::__address_of_symbol!(backref data end $name), |
| 20 |
), |
| 21 |
) |
| 22 |
} |
| 23 |
}; |
| 24 |
($section_type:ident, name=$name:tt, type=$generic_ty:ty) => { |
| 25 |
{ |
| 26 |
$crate::__weak_section_symbols!(item data $name); |
| 27 |
$crate::__support::PtrBounds::new( |
| 28 |
$crate::__address_of_symbol!(item data start $name), |
| 29 |
$crate::__address_of_symbol!(item data end $name), |
| 30 |
) |
| 31 |
} |
| 32 |
} |
| 33 |
} |
| 34 |
|
| 35 |
/// Declare a section's `__start_`/`__stop_` encapsulation symbols as weak. |
| 36 |
/// |
| 37 |
/// This ensures we can reference them even if the section is empty |
| 38 |
#[doc(hidden)] |
| 39 |
#[macro_export] |
| 40 |
#[cfg(all(not(miri), not(target_os = "aix"), not(target_family = "wasm")))] |
| 41 |
macro_rules! __weak_section_symbols { |
| 42 |
// `$ref_or_item` is `item` or `backref`; it both selects the symbol names |
| 43 |
// (via `section_name!`) and names the wrapper module, so the value- and |
| 44 |
// backref-symbol invocations in the `movable` arm don't collide. |
| 45 |
($ref_or_item:ident $section:ident $name:tt) => { |
| 46 |
mod $ref_or_item { |
| 47 |
::core::arch::global_asm!(::core::concat!( |
| 48 |
".weak ", |
| 49 |
$crate::__support::section_name!(string $ref_or_item $section start $name), |
| 50 |
"\n", |
| 51 |
".weak ", |
| 52 |
$crate::__support::section_name!(string $ref_or_item $section end $name), |
| 53 |
"\n", |
| 54 |
)); |
| 55 |
} |
| 56 |
}; |
| 57 |
} |
| 58 |
|
| 59 |
/// Declare a section's `__start_`/`__stop_` encapsulation symbols as weak. |
| 60 |
/// |
| 61 |
/// This ensures we can reference them even if the section is empty |
| 62 |
#[doc(hidden)] |
| 63 |
#[macro_export] |
| 64 |
#[cfg(not(all(not(miri), not(target_os = "aix"), not(target_family = "wasm"))))] |
| 65 |
macro_rules! __weak_section_symbols { |
| 66 |
($($args:tt)*) => {}; |
| 67 |
} |
| 68 |
|
| 69 |
pub use crate::__get_section_standard as get_section; |
| 70 |
|
| 71 |
crate::__def_section_name! { |
| 72 |
__section_name_standard, |
| 73 |
{ |
| 74 |
data bare => ( "_data" "_link_section_") __ (); |
| 75 |
data section => ( "_data" "_link_section_") __ (); |
| 76 |
data start => ("__start_" "_data" "_link_section_") __ (); |
| 77 |
data end => ("__stop_" "_data" "_link_section_") __ (); |
| 78 |
code bare => ( "_text" "_link_section_") __ (); |
| 79 |
code section => ( "_text" "_link_section_") __ (); |
| 80 |
code start => ("__start_" "_text" "_link_section_") __ (); |
| 81 |
code end => ("__stop_" "_text" "_link_section_") __ (); |
| 82 |
} |
| 83 |
AUXILIARY = "_"; |
| 84 |
REFS = "_r_"; |
| 85 |
MAX_LENGTH = 64; |
| 86 |
HASH_LENGTH = 10; |
| 87 |
VALID_SECTION_CHARS = "_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; |
| 88 |
} |