|
|
@ -410,6 +410,7 @@ struct Section<'a> {
|
|
|
|
address: u64,
|
|
|
|
address: u64,
|
|
|
|
name: &'a str,
|
|
|
|
name: &'a str,
|
|
|
|
data: &'a [u8],
|
|
|
|
data: &'a [u8],
|
|
|
|
|
|
|
|
size: u64,
|
|
|
|
relocations: Vec<Relocation>,
|
|
|
|
relocations: Vec<Relocation>,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -428,6 +429,7 @@ impl<'data, 'file, 'a> TryFrom<&'a ObjSection<'data, 'file>> for Section<'a> {
|
|
|
|
address: section.address(),
|
|
|
|
address: section.address(),
|
|
|
|
name: section.name().map_err(map_err)?,
|
|
|
|
name: section.name().map_err(map_err)?,
|
|
|
|
data: section.data().map_err(map_err)?,
|
|
|
|
data: section.data().map_err(map_err)?,
|
|
|
|
|
|
|
|
size: section.size(),
|
|
|
|
relocations: section
|
|
|
|
relocations: section
|
|
|
|
.relocations()
|
|
|
|
.relocations()
|
|
|
|
.map(|(offset, r)| {
|
|
|
|
.map(|(offset, r)| {
|
|
|
@ -505,7 +507,9 @@ fn parse_map(section: &Section, name: &str) -> Result<Map, ParseError> {
|
|
|
|
let def = bpf_map_def {
|
|
|
|
let def = bpf_map_def {
|
|
|
|
map_type: BPF_MAP_TYPE_ARRAY as u32,
|
|
|
|
map_type: BPF_MAP_TYPE_ARRAY as u32,
|
|
|
|
key_size: mem::size_of::<u32>() as u32,
|
|
|
|
key_size: mem::size_of::<u32>() as u32,
|
|
|
|
value_size: section.data.len() as u32,
|
|
|
|
// We need to use section.size here since
|
|
|
|
|
|
|
|
// .bss will always have data.len() == 0
|
|
|
|
|
|
|
|
value_size: section.size as u32,
|
|
|
|
max_entries: 1,
|
|
|
|
max_entries: 1,
|
|
|
|
map_flags: 0, /* FIXME: set rodata readonly */
|
|
|
|
map_flags: 0, /* FIXME: set rodata readonly */
|
|
|
|
..Default::default()
|
|
|
|
..Default::default()
|
|
|
@ -607,6 +611,7 @@ mod tests {
|
|
|
|
address: 0,
|
|
|
|
address: 0,
|
|
|
|
name,
|
|
|
|
name,
|
|
|
|
data,
|
|
|
|
data,
|
|
|
|
|
|
|
|
size: data.len() as u64,
|
|
|
|
relocations: Vec::new(),
|
|
|
|
relocations: Vec::new(),
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|