don't try to parse `_defmt_version_` as JSON
@@ -26,6 +26,9 @@ pub fn parse(elf: &[u8]) -> Result<Option<Table>, anyhow::Error> {
let elf = object::File::parse(elf)?;
// first pass to extract the `_defmt_version`
let mut version = None;
+ let is_defmt_version = |name: &str| {
+ name.starts_with("\"_defmt_version_ = ") || name.starts_with("_defmt_version_ = ")
+ };
for (_, entry) in elf.symbols() {
let name = match entry.name() {
Some(name) => name,
@@ -36,7 +39,7 @@ pub fn parse(elf: &[u8]) -> Result<Option<Table>, anyhow::Error> {
// in `.defmt`.
// Note that we check for a quoted and unquoted version symbol, since LLD has a bug that
// makes it keep the quotes from the linker script.
- if name.starts_with("\"_defmt_version_ = ") || name.starts_with("_defmt_version_ = ") {
+ if is_defmt_version(name) {
let new_version = name
.trim_start_matches("\"_defmt_version_ = ")
.trim_start_matches("_defmt_version_ = ")
@@ -73,6 +76,11 @@ pub fn parse(elf: &[u8]) -> Result<Option<Table>, anyhow::Error> {
_ => continue,
};
+ if is_defmt_version(name) {
+ // not a defmt symbol
+ continue;
+ }
+
if entry.section_index() == Some(defmt_shndx) {
let sym = symbol::Symbol::demangle(name)?;
if let symbol::SymbolTag::Defmt(tag) = sym.tag() {
