[libc-commits] [libc] [libc] Minimal crt1 for baremetal RISC-V (PR #224714)
Jessica Clarke via libc-commits
libc-commits at lists.llvm.org
Fri Sep 18 13:51:31 PDT 2026
================
@@ -0,0 +1,85 @@
+//===-- Implementation of crt for riscv -----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "hdr/stdint_proxy.h"
+#include "src/__support/macros/config.h"
+#include "src/stdlib/atexit.h"
+#include "src/stdlib/exit.h"
+#include "src/string/memcpy.h"
+#include "src/string/memset.h"
+#include "startup/baremetal/fini.h"
+#include "startup/baremetal/init.h"
+
+extern "C" {
+int main(int argc, char **argv);
+void _start();
+
+// Semihosting library initialisation if applicable. Required for printf, etc.
+[[gnu::weak]] void _platform_init() {}
+
+// These symbols are provided by the linker. The exact names are not defined by
+// a standard.
+extern uintptr_t __stack;
+extern uintptr_t __data_source[];
+extern uintptr_t __data_start[];
+extern uintptr_t __data_size[];
----------------
jrtc27 wrote:
It also doesn't work for -mcmodel=medany if you link at high enough base address, since a size symbol is effectively absolute
https://github.com/llvm/llvm-project/pull/224714
More information about the libc-commits
mailing list