summaryrefslogtreecommitdiff
path: root/plugins/dwarf
diff options
context:
space:
mode:
authorJosh Ferrell <josh@vector35.com>2025-08-18 17:27:25 -0400
committerJosh Ferrell <josh@vector35.com>2025-08-18 17:27:37 -0400
commit8055e6c09ab7b0319b6dd3c3cdc6569077caa0df (patch)
tree9c84384b504ccc194511a1bdc068dd28b864378c /plugins/dwarf
parent3afb333272dd7133236d5fbffc64ec3e61ee2af8 (diff)
Fix loading local variables from DWARF in non-relocatable images
Diffstat (limited to 'plugins/dwarf')
-rw-r--r--plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs1
-rw-r--r--plugins/dwarf/dwarf_import/src/lib.rs13
2 files changed, 7 insertions, 7 deletions
diff --git a/plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs b/plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs
index 44826e39..2dff2b35 100644
--- a/plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs
+++ b/plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs
@@ -42,7 +42,6 @@ pub(crate) type TypeUID = usize;
/////////////////////////
// FunctionInfoBuilder
-// TODO : Function local variables
#[derive(PartialEq, Eq, Hash)]
pub(crate) struct FunctionInfoBuilder {
pub(crate) full_name: Option<String>,
diff --git a/plugins/dwarf/dwarf_import/src/lib.rs b/plugins/dwarf/dwarf_import/src/lib.rs
index 1e3d02d5..6e6613a0 100644
--- a/plugins/dwarf/dwarf_import/src/lib.rs
+++ b/plugins/dwarf/dwarf_import/src/lib.rs
@@ -377,39 +377,40 @@ where
{
let mut bases = gimli::BaseAddresses::default();
- let view_start = view.start();
+ // DWARF info is stored relative to the original image base (0 for relocatable images), normalize entries to the original image base
+ let section_adjustment = view.original_image_base().wrapping_sub(view.image_base());
if let Some(section) = view
.section_by_name(".eh_frame_hdr")
.or(view.section_by_name("__eh_frame_hdr"))
{
- bases = bases.set_eh_frame_hdr(section.start() - view_start);
+ bases = bases.set_eh_frame_hdr(section.start().wrapping_add(section_adjustment));
}
if let Some(section) = view
.section_by_name(".eh_frame")
.or(view.section_by_name("__eh_frame"))
{
- bases = bases.set_eh_frame(section.start() - view_start);
+ bases = bases.set_eh_frame(section.start().wrapping_add(section_adjustment));
} else if let Some(section) = view
.section_by_name(".debug_frame")
.or(view.section_by_name("__debug_frame"))
{
- bases = bases.set_eh_frame(section.start() - view_start);
+ bases = bases.set_eh_frame(section.start().wrapping_add(section_adjustment));
}
if let Some(section) = view
.section_by_name(".text")
.or(view.section_by_name("__text"))
{
- bases = bases.set_text(section.start() - view_start);
+ bases = bases.set_text(section.start().wrapping_add(section_adjustment));
}
if let Some(section) = view
.section_by_name(".got")
.or(view.section_by_name("__got"))
{
- bases = bases.set_got(section.start() - view_start);
+ bases = bases.set_got(section.start().wrapping_add(section_adjustment));
}
let mut cies = HashMap::new();