[libc-commits] [PATCH] D145898: [libc] Declare __dso_handle in the integration test instead of startup.

Siva Chandra via Phabricator via libc-commits libc-commits at lists.llvm.org
Sun Mar 12 23:33:28 PDT 2023


sivachandra created this revision.
sivachandra added a reviewer: jhuber6.
Herald added subscribers: libc-commits, luke, frasercrmck, ecnelises, luismarques, apazos, sameer.abuasal, tschuett, s.egerton, Jim, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, niosHD, sabuasal, simoncook, johnrusso, rbar, asb.
Herald added projects: libc-project, All.
sivachandra requested review of this revision.
Herald added a subscriber: pcwang-thead.

Fixes #61355. The __dso_handle decl was introduced incorrectly into the startup
objects during the integration test cleanup which moved the integration tests
away from using an artificial sysroot to using -nostdlib. Having it in the
startup creates the duplicate symbol error when one does not use -nostdlib.
Since this is an integration test only problem, it is meaningful to keep it in
the integration test anyway.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D145898

Files:
  libc/startup/linux/aarch64/start.cpp
  libc/startup/linux/riscv64/start.cpp
  libc/startup/linux/x86_64/start.cpp
  libc/test/IntegrationTest/test.cpp


Index: libc/test/IntegrationTest/test.cpp
===================================================================
--- libc/test/IntegrationTest/test.cpp
+++ libc/test/IntegrationTest/test.cpp
@@ -34,4 +34,7 @@
   return malloc(s);
 }
 
+// Integration tests are linked with -nostdlib. BFD linker expects
+// __dso_handle when -nostdlib is used.
+void *__dso_handle = nullptr;
 } // extern "C"
Index: libc/startup/linux/x86_64/start.cpp
===================================================================
--- libc/startup/linux/x86_64/start.cpp
+++ libc/startup/linux/x86_64/start.cpp
@@ -22,9 +22,6 @@
 #include <unistd.h>
 
 extern "C" int main(int, char **, char **);
-// The BFD linker requires a reference to __dso_handle to trigger creating
-// a symbol for it when -nostdlib is used..
-extern "C" void *__dso_handle = nullptr;
 
 namespace __llvm_libc {
 
Index: libc/startup/linux/riscv64/start.cpp
===================================================================
--- libc/startup/linux/riscv64/start.cpp
+++ libc/startup/linux/riscv64/start.cpp
@@ -21,9 +21,6 @@
 #include <unistd.h>
 
 extern "C" int main(int, char **, char **);
-// The BFD linker requires a reference to __dso_handle to trigger creating
-// a symbol for it when -nostdlib is used..
-extern "C" void *__dso_handle = nullptr;
 
 namespace __llvm_libc {
 
Index: libc/startup/linux/aarch64/start.cpp
===================================================================
--- libc/startup/linux/aarch64/start.cpp
+++ libc/startup/linux/aarch64/start.cpp
@@ -23,9 +23,6 @@
 #include <unistd.h>
 
 extern "C" int main(int, char **, char **);
-// The BFD linker requires a reference to __dso_handle to trigger creating
-// a symbol for it when -nostdlib is used..
-extern "C" void *__dso_handle = nullptr;
 
 // Source documentation:
 // https://github.com/ARM-software/abi-aa/tree/main/sysvabi64


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D145898.504513.patch
Type: text/x-patch
Size: 1864 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20230313/c343b746/attachment.bin>


More information about the libc-commits mailing list