BPFloader: Skip global map sections
Certain BPF progams have sections .rodata.str1.1 or <name>.data for global data. These sections are processed/loaded implicitly by libbpf, but it may be useful for the developer to pin them. Change the logic so if a descriptor for these sections is found, pin them. If not, ignore them and don't cause a failure. Bug: 401458418 Test: Manual: program with bpf_printk and global data loads. Change-Id: Ib3be55cf903e24c6692730b57b0ce90c9a9e0795 Signed-off-by: Neill Kapron <nkapron@google.com>
This commit is contained in:
parent
a23e772683
commit
2ba22f25e4
1 changed files with 6 additions and 4 deletions
|
|
@ -518,10 +518,6 @@ fn libbpf_worker(file_desc: &BpfFileDesc) -> Result<(), anyhow::Error> {
|
|||
let name =
|
||||
map.name().to_str().ok_or_else(|| anyhow!("Failed to parse map name into UTF-8"))?;
|
||||
let name = String::from(name);
|
||||
if name.ends_with(".rodata") {
|
||||
// Skip pinning map for .rodata section.
|
||||
continue;
|
||||
}
|
||||
for map_desc in file_desc.maps {
|
||||
if map_desc.name == name {
|
||||
desc_found = true;
|
||||
|
|
@ -556,6 +552,12 @@ fn libbpf_worker(file_desc: &BpfFileDesc) -> Result<(), anyhow::Error> {
|
|||
break;
|
||||
}
|
||||
}
|
||||
if !desc_found && (name.contains(".rodata") || name.contains(".data")) {
|
||||
// Skip required pinning map for .rodata, .rodata.str1.1, and .data sections.
|
||||
info!("Optional map descriptor for {name} not found, ignoring");
|
||||
continue;
|
||||
}
|
||||
|
||||
ensure!(desc_found, "Map descriptor for {name} not found!");
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue