summaryrefslogtreecommitdiff
path: root/plugins/svd/src/mapper.rs
diff options
context:
space:
mode:
authorMason Reed <mason@vector35.com>2025-04-18 14:42:05 -0400
committerMason Reed <mason@vector35.com>2025-05-04 21:31:04 -0400
commit42bb3938df78686b6d1ceae003ce8c149f8dc9d8 (patch)
treecb3f66bc6e396cfd8f6d5c68b24a80f19fc51ead /plugins/svd/src/mapper.rs
parent178887ba4d503838c444a0c976ac5538117fd2fb (diff)
Add a setting to disable creating a backing memory region for SVD regions
This is apart of https://github.com/Vector35/binaryninja-api/issues/6678
Diffstat (limited to 'plugins/svd/src/mapper.rs')
-rw-r--r--plugins/svd/src/mapper.rs37
1 files changed, 21 insertions, 16 deletions
diff --git a/plugins/svd/src/mapper.rs b/plugins/svd/src/mapper.rs
index c0ca5e99..0a476481 100644
--- a/plugins/svd/src/mapper.rs
+++ b/plugins/svd/src/mapper.rs
@@ -163,24 +163,29 @@ impl DeviceMapper {
let memory_info =
self.peripheral_block_memory_info(peripheral, address_block, block_name.clone());
- // Add the block segment, section and backing memory.
- let data_memory = DataBuffer::new(&vec![0; address_block.size as usize]).unwrap();
- let added_memory = view.memory_map().add_data_memory_region(
- &block_name,
- block_addr,
- &data_memory,
- Some(memory_info.segment_flags),
- );
- view.add_segment(memory_info.segment);
- view.add_section(memory_info.section);
-
- if !added_memory {
- log::error!(
- "Failed to add memory for peripheral block! {} @ 0x{:x}",
- block_name,
- block_addr
+ // Add the block segment, section and backing memory (optional).
+ if self.settings.add_backing_regions {
+ // Because adding a memory region will add a possibly large memory buffer in the BNDB, this
+ // is optional. if a user disables this, they cannot write to the segment until they add a backing memory region.
+ let data_memory = DataBuffer::new(&vec![0; address_block.size as usize]).unwrap();
+ let added_memory = view.memory_map().add_data_memory_region(
+ &block_name,
+ block_addr,
+ &data_memory,
+ Some(memory_info.segment_flags),
);
+
+ if !added_memory {
+ log::error!(
+ "Failed to add memory for peripheral block! {} @ 0x{:x}",
+ block_name,
+ block_addr
+ );
+ }
}
+
+ view.add_segment(memory_info.segment);
+ view.add_section(memory_info.section);
// Handle usage specific stuff like adding registers.
match address_block.usage {