[libc-commits] [libc] 5b1ad43 - [libc] Declare __dso_handle in the integration test instead of startup.

Siva Chandra Reddy via libc-commits libc-commits at lists.llvm.org
Mon Mar 13 00:47:38 PDT 2023


Author: Siva Chandra Reddy
Date: 2023-03-13T07:47:00Z
New Revision: 5b1ad43c2b40896efb06736a9ee4399dbda91fee

URL: https://github.com/llvm/llvm-project/commit/5b1ad43c2b40896efb06736a9ee4399dbda91fee
DIFF: https://github.com/llvm/llvm-project/commit/5b1ad43c2b40896efb06736a9ee4399dbda91fee.diff

LOG: [libc] Declare __dso_handle in the integration test instead of startup.

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.

Differential Revision: https://reviews.llvm.org/D145898

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/libc/startup/linux/aarch64/start.cpp b/libc/startup/linux/aarch64/start.cpp
index 3896822799566..b02ea7d3a6131 100644
--- a/libc/startup/linux/aarch64/start.cpp
+++ b/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

diff  --git a/libc/startup/linux/riscv64/start.cpp b/libc/startup/linux/riscv64/start.cpp
index c65407d06d64d..068658c4d0336 100644
--- a/libc/startup/linux/riscv64/start.cpp
+++ b/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 {
 

diff  --git a/libc/startup/linux/x86_64/start.cpp b/libc/startup/linux/x86_64/start.cpp
index 666cfeb657511..15d5de59d42c1 100644
--- a/libc/startup/linux/x86_64/start.cpp
+++ b/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 {
 

diff  --git a/libc/test/IntegrationTest/test.cpp b/libc/test/IntegrationTest/test.cpp
index 53f9c95423019..c52f9e6c295b7 100644
--- a/libc/test/IntegrationTest/test.cpp
+++ b/libc/test/IntegrationTest/test.cpp
@@ -34,4 +34,7 @@ void *realloc(void *ptr, size_t s) {
   return malloc(s);
 }
 
+// Integration tests are linked with -nostdlib. BFD linker expects
+// __dso_handle when -nostdlib is used.
+void *__dso_handle = nullptr;
 } // extern "C"


        


More information about the libc-commits mailing list