Skip to main content

luaur_code_gen/methods/
unwind_builder_dwarf_2_start_function.rs

1use crate::functions::writeu_32::writeu_32;
2use crate::functions::writeu_64::writeu_64;
3use crate::records::unwind_builder_dwarf_2::UnwindBuilderDwarf2;
4use crate::records::unwind_function_dwarf_2::UnwindFunctionDwarf2;
5
6impl UnwindBuilderDwarf2 {
7    pub fn start_function(&mut self) {
8        // End offset is filled in later and everything gets adjusted at the end
9        let mut func = UnwindFunctionDwarf2::default();
10        func.begin_offset = 0;
11        func.end_offset = 0;
12        func.fde_entry_start_pos = (self.pos as usize - self.raw_data.as_ptr() as usize) as u32;
13        self.unwind_functions.push(func);
14
15        self.fde_entry_start = self.pos; // Will be written at the end
16        unsafe {
17            self.pos = writeu_32(self.pos, 0); // Length (to be filled later)
18            self.pos = writeu_32(
19                self.pos,
20                (self.pos as usize - self.raw_data.as_ptr() as usize) as u32,
21            ); // CIE pointer
22            self.pos = writeu_64(self.pos, 0); // Initial location (to be filled later)
23            self.pos = writeu_64(self.pos, 0); // Address range (to be filled later)
24        }
25
26        // Optional CIE augmentation section (not present)
27
28        // Function call frame instructions to follow
29    }
30}