Explorar o código

fix: add assertion to ensure single rodata section

Vitor Py hai 1 mes
pai
achega
176617e9c5
Modificáronse 1 ficheiros con 6 adicións e 0 borrados
  1. 6 0
      src/byteparser.rs

+ 6 - 0
src/byteparser.rs

@@ -22,6 +22,12 @@ pub fn parse_bytecode(bytes: &[u8]) -> Result<ParseResult, SbpfLinkerError> {
         s.name().map(|name| name.starts_with(".rodata")).unwrap_or(false)
     });
 
+    // Ensure there's only one .rodata section
+    let rodata_count = obj.sections().filter(|s| {
+        s.name().map(|name| name.starts_with(".rodata")).unwrap_or(false)
+    }).count();
+    assert!(rodata_count <= 1, "Multiple .rodata sections found");
+
     let mut rodata_table = HashMap::new();
     if let Some(ref ro_section) = ro_section {
         // only handle symbols in the .rodata section for now