Selaa lähdekoodia

fix: add assertion to ensure single rodata section

Vitor Py 1 kuukausi sitten
vanhempi
sitoutus
176617e9c5
1 muutettua tiedostoa jossa 6 lisäystä ja 0 poistoa
  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