Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions libc/startup/baremetal/fini.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,16 @@
//===----------------------------------------------------------------------===//

#include "hdr/stdint_proxy.h"
#include "src/__support/macros/config.h"

// NOTE: The namespace is necessary here to set the correct symbol visibility.
namespace LIBC_NAMESPACE_DECL {
Copy link

@JonathonReinhart JonathonReinhart Sep 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Given that the only declarations inside this namespace are extern "C", it would be easy to overlook this namespace as being unnecessary for correctness -- especially if you don't realize the gnu::visibility("hidden") magic behind it. This probably facilitated the bug being introduced in #146863.

Perhaps a comment here would be warranted (and same on init.h of course).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.


extern "C" {
extern uintptr_t __fini_array_start[];
extern uintptr_t __fini_array_end[];

void __libc_fini_array(void);
} // extern "C"

} // namespace LIBC_NAMESPACE_DECL
6 changes: 6 additions & 0 deletions libc/startup/baremetal/init.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
//===----------------------------------------------------------------------===//

#include "hdr/stdint_proxy.h"
#include "src/__support/macros/config.h"

// NOTE: The namespace is necessary here to set the correct symbol visibility.
namespace LIBC_NAMESPACE_DECL {

extern "C" {
extern uintptr_t __preinit_array_start[];
Expand All @@ -16,3 +20,5 @@ extern uintptr_t __init_array_end[];

void __libc_init_array(void);
} // extern "C"

} // namespace LIBC_NAMESPACE_DECL
Loading