| 1015 | self.symbol_table |
| 1016 | .entry("__bss_start".to_owned()) |
| 1017 | .or_insert(start); |
| 1018 | self.symbol_table.insert("__bss_end".to_owned(), end); |
| 1019 | |
| 1020 | // Heap starts immediately after BSS, aligned to 16 bytes. |
| 1021 | let heap_start = (end + 15) & !15; |
| 1022 | self.symbol_table |
| 1023 | .insert("__heap_start".to_owned(), heap_start); |
| 1024 | if layout.heap_size > 0 { |
| 1025 | self.symbol_table |
| 1026 | .insert("__heap_end".to_owned(), heap_start + layout.heap_size); |
| 1027 | } |
| 1028 | } |
| 1029 | _ => {} |
| 1030 | } |
| 1031 | running = end; |
| 1032 | } |
| 1033 | } |
| 1034 | } |
| 1035 | |
| 1036 | // If no BSS section exists, place the heap after the last section. |
| 1037 | if !self.symbol_table.contains_key("__bss_start") { |
| 1038 | let heap_start = (running + 15) & !15; |
| 1039 | self.symbol_table |
| 1040 | .insert("__heap_start".to_owned(), heap_start); |
| 1041 | if layout.heap_size > 0 { |
| 1042 | self.symbol_table |
| 1043 | .insert("__heap_end".to_owned(), heap_start + layout.heap_size); |
| 1044 | } |
| 1045 | } |