pull/1017/merge^2
Davide Bertola 4 months ago
parent a9175127e9
commit 8b2ef5d5c1

@ -544,22 +544,23 @@ impl Btf {
target_var_name: &str, target_var_name: &str,
) -> Result<(String, Var), BtfError> { ) -> Result<(String, Var), BtfError> {
for t in &self.types.types { for t in &self.types.types {
if let BtfType::DataSec(d) = t { let BtfType::DataSec(d) = t else {
let sec_name = self.string_at(d.name_offset)?; continue;
};
for d in &d.entries { let sec_name = self.string_at(d.name_offset)?;
if let BtfType::Var(var) = self.types.type_by_id(d.btf_type)? {
let var_name = self.string_at(var.name_offset)?;
if target_var_name == var_name {
if var.linkage != VarLinkage::Extern {
return Err(BtfError::InvalidExternalSymbol {
symbol_name: var_name.into(),
});
}
return Ok((sec_name.into(), var.clone())); for d in &d.entries {
} let BtfType::Var(var) = self.types.type_by_id(d.btf_type)? else {
continue;
};
if target_var_name == self.string_at(var.name_offset)? {
if var.linkage == VarLinkage::Extern {
return Ok((sec_name.into(), var.clone()));
} else {
return Err(BtfError::InvalidExternalSymbol {
symbol_name: target_var_name.into(),
});
} }
} }
} }

Loading…
Cancel
Save