Use gimli to get the values of DWARF constants needed by codegen

The `gimli` crate is already a dependency of `thorin-dwp`, which is already a
dependency of `rustc_codegen_ssa`.
This commit is contained in:
Zalathar
2025-01-05 11:38:43 +11:00
parent 8417f8311f
commit e267106104
6 changed files with 42 additions and 24 deletions

View File

@@ -0,0 +1,29 @@
//! Definitions of various DWARF-related constants.
use libc::c_uint;
/// Helper macro to let us redeclare gimli's constants as our own constants
/// with a different type, with less risk of copy-paste errors.
macro_rules! declare_constant {
(
$name:ident : $type:ty
) => {
#[allow(non_upper_case_globals)]
pub(crate) const $name: $type = ::gimli::constants::$name.0 as $type;
// Assert that as-cast probably hasn't changed the value.
const _: () = assert!($name as i128 == ::gimli::constants::$name.0 as i128);
};
}
declare_constant!(DW_TAG_const_type: c_uint);
// DWARF languages.
declare_constant!(DW_LANG_Rust: c_uint);
// DWARF attribute type encodings.
declare_constant!(DW_ATE_boolean: c_uint);
declare_constant!(DW_ATE_float: c_uint);
declare_constant!(DW_ATE_signed: c_uint);
declare_constant!(DW_ATE_unsigned: c_uint);
declare_constant!(DW_ATE_UTF: c_uint);