Skip to content

Commit

Permalink
Cherry pick PR #1588: Create MUSL specific-rename of finalize and ate…
Browse files Browse the repository at this point in the history
…xit (#1675)

Refer to the original PR: #1588

These functions are given alternative signatures to avoid symbol
collision during linking of modular-toolchain versions of the NX
platform. During build, we will pass these defines via the toolchain
definition to switch the names over as desired.

b/246855300

Co-authored-by: Arjun Menon <[email protected]>
  • Loading branch information
cobalt-github-releaser-bot and arjungm authored Nov 29, 2023
1 parent 8aafd9e commit 9e7b58b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions third_party/musl/src/exit/atexit.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,23 @@ void __funcs_on_exit()
}

#if !defined(ADDRESS_SANITIZER)
#if defined(USE_CUSTOM_MUSL_FINALIZE_SIGNATURE)
void __musl_cxa_finalize(void *dso)
#else // defined(USE_CUSTOM_MUSL_FINALIZE_SIGNATURE)
void __cxa_finalize(void *dso)
#endif // defined(USE_CUSTOM_MUSL_FINALIZE_SIGNATURE)
{
#ifdef STARBOARD
__funcs_on_exit();
#endif // STARBOARD
}
#endif // !defined(ADDRESS_SANITIZER)

#if defined(USE_CUSTOM_MUSL_ATEXIT_SIGNATURE)
int __musl_cxa_atexit(void (*func)(void *), void *arg, void *dso)
#else // defined(USE_CUSTOM_MUSL_ATEXIT_SIGNATURE)
int __cxa_atexit(void (*func)(void *), void *arg, void *dso)
#endif // defined(USE_CUSTOM_MUSL_ATEXIT_SIGNATURE)
{
LOCK(lock);

Expand Down Expand Up @@ -98,5 +106,9 @@ static void call(void *p)

int atexit(void (*func)(void))
{
#if defined(USE_CUSTOM_MUSL_ATEXIT_SIGNATURE)
return __musl_cxa_atexit(call, (void *)(uintptr_t)func, 0);
#else // defined(USE_CUSTOM_MUSL_ATEXIT_SIGNATURE)
return __cxa_atexit(call, (void *)(uintptr_t)func, 0);
#endif // defined(USE_CUSTOM_MUSL_ATEXIT_SIGNATURE)
}

0 comments on commit 9e7b58b

Please sign in to comment.