[libc-commits] [libc] [LIBC][ARM] Enable MMU setup and alignment fault handling during startup. (PR #204803)
Victor Campos via libc-commits
libc-commits at lists.llvm.org
Fri Jun 19 05:22:57 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);
+
+ uintptr_t page = reinterpret_cast<uintptr_t>(&get_stackheap_start) >> 30;
+ return (page + 1) << 30;
+}
----------------
vhscampos wrote:
This function is confusing. Can you add comments to explain its semantics?
https://github.com/llvm/llvm-project/pull/204803
More information about the libc-commits
mailing list