Skip to content

Commit 8055e6c

Browse files
committed
Fix loading local variables from DWARF in non-relocatable images
1 parent 3afb333 commit 8055e6c

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,6 @@ pub(crate) type TypeUID = usize;
4242
/////////////////////////
4343
// FunctionInfoBuilder
4444

45-
// TODO : Function local variables
4645
#[derive(PartialEq, Eq, Hash)]
4746
pub(crate) struct FunctionInfoBuilder {
4847
pub(crate) full_name: Option<String>,

plugins/dwarf/dwarf_import/src/lib.rs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -377,39 +377,40 @@ where
377377
{
378378
let mut bases = gimli::BaseAddresses::default();
379379

380-
let view_start = view.start();
380+
// DWARF info is stored relative to the original image base (0 for relocatable images), normalize entries to the original image base
381+
let section_adjustment = view.original_image_base().wrapping_sub(view.image_base());
381382

382383
if let Some(section) = view
383384
.section_by_name(".eh_frame_hdr")
384385
.or(view.section_by_name("__eh_frame_hdr"))
385386
{
386-
bases = bases.set_eh_frame_hdr(section.start() - view_start);
387+
bases = bases.set_eh_frame_hdr(section.start().wrapping_add(section_adjustment));
387388
}
388389

389390
if let Some(section) = view
390391
.section_by_name(".eh_frame")
391392
.or(view.section_by_name("__eh_frame"))
392393
{
393-
bases = bases.set_eh_frame(section.start() - view_start);
394+
bases = bases.set_eh_frame(section.start().wrapping_add(section_adjustment));
394395
} else if let Some(section) = view
395396
.section_by_name(".debug_frame")
396397
.or(view.section_by_name("__debug_frame"))
397398
{
398-
bases = bases.set_eh_frame(section.start() - view_start);
399+
bases = bases.set_eh_frame(section.start().wrapping_add(section_adjustment));
399400
}
400401

401402
if let Some(section) = view
402403
.section_by_name(".text")
403404
.or(view.section_by_name("__text"))
404405
{
405-
bases = bases.set_text(section.start() - view_start);
406+
bases = bases.set_text(section.start().wrapping_add(section_adjustment));
406407
}
407408

408409
if let Some(section) = view
409410
.section_by_name(".got")
410411
.or(view.section_by_name("__got"))
411412
{
412-
bases = bases.set_got(section.start() - view_start);
413+
bases = bases.set_got(section.start().wrapping_add(section_adjustment));
413414
}
414415

415416
let mut cies = HashMap::new();

0 commit comments

Comments
 (0)