From f81e2453b23453f3081c37db14cb7d735c022625 Mon Sep 17 00:00:00 2001 From: Brendan Hansknecht Date: Sat, 23 Jul 2022 09:59:39 -0700 Subject: [PATCH] add support for .data.rel.ro and absolute relocations to surgical linker --- crates/linker/src/lib.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/linker/src/lib.rs b/crates/linker/src/lib.rs index 6423bc19259..4dbd0a42cf7 100644 --- a/crates/linker/src/lib.rs +++ b/crates/linker/src/lib.rs @@ -2540,7 +2540,10 @@ pub fn surgery_elf( // in development builds for caching the results of top-level constants let rodata_sections: Vec
= app_obj .sections() - .filter(|sec| sec.name().unwrap_or_default().starts_with(".rodata")) + .filter(|sec| { + sec.name().unwrap_or_default().starts_with(".rodata") + || sec.name().unwrap_or_default().starts_with(".data.rel.ro") + }) .collect(); // bss section is like rodata section, but it has zero file size and non-zero virtual size. @@ -2683,6 +2686,7 @@ pub fn surgery_elf( RelocationKind::Relative | RelocationKind::PltRelative => { target_offset - virt_base as i64 + rel.1.addend() } + RelocationKind::Absolute => target_offset + rel.1.addend(), x => { internal_error!("Relocation Kind not yet support: {:?}", x); }