Skip to content

Commit

Permalink
lsb: don't provide __dso_handle for static builds
Browse files Browse the repository at this point in the history
In static builds, __dso_handle should be provided by the
crtbegin.o/crtend.o that is linked into the executable. This patch also
fixes failing link tests when building a static gcc targeting mlibc.
  • Loading branch information
lzcunt committed Jan 12, 2025
1 parent f147924 commit 942c050
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions options/lsb/generic/dso_exit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ extern "C" void __cxa_finalize(void *dso) {
}
}

// In static builds, these should be provided by the crtbegin.o/crtend.o that
// is linked into the executable.
#ifndef MLIBC_STATIC_BUILD
// This is referenced by the compiler when generating constructors for global
// C++ objects so that it can call __cxa_finalize with a unique argument.
extern "C" { [[gnu::visibility("hidden")]] void *__dso_handle; }
Expand All @@ -56,6 +59,7 @@ extern "C" { [[gnu::visibility("hidden")]] void *__dso_handle; }
// In normal programs this call to __cxa_finalize is provided by libgcc.
__cxa_finalize(&__dso_handle);
}
#endif

void __mlibc_do_finalize() {
// Invoke any handlers registered with atexit (NOT associated with a DSO).
Expand Down

0 comments on commit 942c050

Please sign in to comment.