[libc-commits] [libc] [libc] Add `Scrt1.o` to `startup_components` (PR #97497)

via libc-commits libc-commits at lists.llvm.org
Tue Jul 2 17:44:56 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-libc

Author: Izaak Schroeder (izaakschroeder)

<details>
<summary>Changes</summary>

Needs for `-fpie` targets. Don't know if this is safe or not... but it seems to run compiled executables.

---
Full diff: https://github.com/llvm/llvm-project/pull/97497.diff


1 Files Affected:

- (modified) libc/startup/linux/CMakeLists.txt (+10-1) 


``````````diff
diff --git a/libc/startup/linux/CMakeLists.txt b/libc/startup/linux/CMakeLists.txt
index 336c5d0f6bfa2..b721d15091227 100644
--- a/libc/startup/linux/CMakeLists.txt
+++ b/libc/startup/linux/CMakeLists.txt
@@ -118,6 +118,15 @@ merge_relocatable_object(
   .do_start
 )
 
+# HACK: Is this even ok?
+# For reference: `Scrt1` is used when `-fpie` vs `crt1` for `-fno-pie`
+merge_relocatable_object(
+  Scrt1
+  .${LIBC_TARGET_ARCHITECTURE}.start
+  .${LIBC_TARGET_ARCHITECTURE}.tls
+  .do_start
+)
+
 add_startup_object(
   crti
   SRC
@@ -131,7 +140,7 @@ add_startup_object(
 )
 
 add_custom_target(libc-startup)
-set(startup_components crt1 crti crtn)
+set(startup_components Scrt1 crt1 crti crtn)
 foreach(target IN LISTS startup_components)
   set(fq_target_name libc.startup.linux.${target})
   add_dependencies(libc-startup ${fq_target_name})

``````````

</details>


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


More information about the libc-commits mailing list