[libc-commits] [libc] [LIBC][ARM] Enable MMU setup and alignment fault handling during startup. (PR #204803)

Simi Pallipurath via libc-commits libc-commits at lists.llvm.org
Mon Jun 22 14:14:41 PDT 2026


================
@@ -32,9 +32,66 @@ extern uintptr_t __data_start[];
 extern uintptr_t __data_size[];
 extern uintptr_t __bss_start[];
 extern uintptr_t __bss_size[];
+[[gnu::weak]] extern uintptr_t __heap_start;
 } // extern "C"
 
 namespace {
+constexpr uint64_t PAGE_TABLE_ENTRY_COUNT = 512;
+constexpr uint64_t PAGE_TABLE_ALIGNMENT = 4096;
+
+// Put the page table in a no-init section so it doesn't later get
+// zero-initialized.
+[[gnu::section(".noinit.page_table"), gnu::aligned(PAGE_TABLE_ALIGNMENT), gnu::used]]
+volatile uint64_t page_table[PAGE_TABLE_ENTRY_COUNT];
+
+uintptr_t get_stackheap_start() {
+  if (reinterpret_cast<uintptr_t>(&__heap_start))
+    return reinterpret_cast<uintptr_t>(&__heap_start);
----------------
simpal01 wrote:

__heap_start is a symbol provided in the linker script. __heap_start is declared weak. If no linker script defines it, the symbol address resolves to 0.I f this symbol  __heap_start is provided in the linker script , it return the address where the linker placed that symbol. That address is the heap base.

https://github.com/llvm/llvm-project/pull/204803


More information about the libc-commits mailing list