aya/obj: fix incorrect section size for .bss

pull/90/head
William Findlay 3 years ago
parent 27d803b634
commit 1e6b1afbe4
No known key found for this signature in database
GPG Key ID: 7162B44E9E560373

@ -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(),
} }
} }

Loading…
Cancel
Save