From bb8a813eefd86fbdb218174ccb7bfd2578ab9692 Mon Sep 17 00:00:00 2001 From: Will Date: Fri, 3 Dec 2021 05:26:10 +0000 Subject: [PATCH] aya: use correct program name when relocating --- aya/src/obj/btf/relocation.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/aya/src/obj/btf/relocation.rs b/aya/src/obj/btf/relocation.rs index c20890ff..74fcd2c3 100644 --- a/aya/src/obj/btf/relocation.rs +++ b/aya/src/obj/btf/relocation.rs @@ -2,6 +2,7 @@ use std::{ collections::HashMap, convert::{TryFrom, TryInto}, io, mem, ptr, + str::FromStr, }; use thiserror::Error; @@ -16,7 +17,7 @@ use crate::{ fields_are_compatible, member_bit_field_size, member_bit_offset, types_are_compatible, BtfType, MAX_SPEC_LEN, }, - Btf, BtfError, Object, Program, + Btf, BtfError, Object, Program, ProgramSection, }, BpfError, }; @@ -161,12 +162,12 @@ impl Object { for (sec_name_off, relos) in btf_ext.relocations() { let section_name = local_btf.string_at(*sec_name_off)?; - // FIXME - let parts = section_name.split('/').collect::>(); - if parts.len() < 2 { - continue; - } - let section_name = parts[1]; + let program_section = match ProgramSection::from_str(§ion_name) { + Ok(program) => program, + Err(_) => continue, + }; + let section_name = program_section.name(); + let program = self .programs .get_mut(section_name)