Vector35 / Vector35/binaryninja-api

Relax SVD file parsing to allow for loading of more files

Open
#7,455 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Component: Plugin Effort: Low Impact: Low
Dominant language
C++
Stars
1.3k
Forks
298
Avg merge
5d 5h
Merged PRs (30d)
19

Description

SVD files are just xml files that follow a spec defined here, as such many vendors do not actually follow the spec 🥹. Right now our parser we use for SVD import (https://github.com/rust-embedded/svd) expects the parsed file to not have empty children for certain fields:

[SVD] Failed to parse SVD file: In device `MT7697`
[SVD] 
[SVD] Caused by:
[SVD]     0: Parsing unknown addressUnitBits at 18:3
[SVD]     1: Expected content in <addressUnitBits> tag, found none

We will need to fork the svd parser and then try and get the relaxations upstreamed, as I am sure there are some other people who would like to parse these malformed svd files.

Some interesting places to look (specifically for the error above):

https://github.com/rust-embedded/svd/blob/63cdf6c06c86feebb36bac7927f5aba3f16368df/svd-parser/src/device.rs#L40-L42

https://github.com/rust-embedded/svd/blob/63cdf6c06c86feebb36bac7927f5aba3f16368df/svd-parser/src/lib.rs#L95-L111

I don't think this is very high priority because you can usually just get away with fixing up the svd file, but it would be nice if we just let them be loaded, with maybe some warning about it being invalid.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reading svd-parser/src/device.rs around lines 40-42 and svd-parser/src/lib.rs around lines 95-111, then reproduce the empty addressUnitBits failure with a malformed SVD file. Determine how to fork the parser so these empty fields can load, with an optional invalid-file warning, and verify that the affected SVD imports complete successfully. Upstream the relaxation when the behavior is confirmed.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp, rust
Domain
reverse-engineering, tooling
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.