[libc] Move preinit/init/fini arrays to namespace (#158746)

In change #146863 we moved definitions of preinit/init/fini arrays to
header but unintentionally moved outside of the namespace. Since the
namespace also controls the visibility (through LIBC_NAMESPACE_DECL), as
a consequence these symbols no longer have the hidden visibility which
changes the codegen from:

```
 4: 4c11          ldr     r4, [pc, #0x44]         @ 0x4c <__libc_init_array+0x4c>
 6: 4812          ldr     r0, [pc, #0x48]         @ 0x50 <__libc_init_array+0x50>
 8: 447c          add     r4, pc
 a: 4478          add     r0, pc
 c: 1b00          subs    r0, r0, r4
```

to:

```
 4: 4813          ldr     r0, [pc, #0x4c]         @ 0x54 <__libc_init_array+0x54>
 6: 4914          ldr     r1, [pc, #0x50]         @ 0x58 <__libc_init_array+0x58>
 8: 4478          add     r0, pc
 a: 4479          add     r1, pc
 c: 6804          ldr     r4, [r0]
 e: 6808          ldr     r0, [r1]
10: 1b00          subs    r0, r0, r4
```

The `ldr` will trigger a fault in case where these symbols aren't
pointing to a valid memory location which is sometimes the case when the
array is empty.
2 files changed
tree: 82ed6e1aa42ffe28af1bab3d1eb33167d89e3f72
  1. .ci/
  2. .github/
  3. bolt/
  4. clang/
  5. clang-tools-extra/
  6. cmake/
  7. compiler-rt/
  8. cross-project-tests/
  9. flang/
  10. flang-rt/
  11. libc/
  12. libclc/
  13. libcxx/
  14. libcxxabi/
  15. libsycl/
  16. libunwind/
  17. lld/
  18. lldb/
  19. llvm/
  20. llvm-libgcc/
  21. mlir/
  22. offload/
  23. openmp/
  24. orc-rt/
  25. polly/
  26. runtimes/
  27. third-party/
  28. utils/
  29. .clang-format
  30. .clang-format-ignore
  31. .clang-tidy
  32. .git-blame-ignore-revs
  33. .gitattributes
  34. .gitignore
  35. .mailmap
  36. CODE_OF_CONDUCT.md
  37. CONTRIBUTING.md
  38. LICENSE.TXT
  39. pyproject.toml
  40. README.md
  41. SECURITY.md
README.md

The LLVM Compiler Infrastructure

OpenSSF Scorecard OpenSSF Best Practices libc++

Welcome to the LLVM project!

This repository contains the source code for LLVM, a toolkit for the construction of highly optimized compilers, optimizers, and run-time environments.

The LLVM project has multiple components. The core of the project is itself called “LLVM”. This contains all of the tools, libraries, and header files needed to process intermediate representations and convert them into object files. Tools include an assembler, disassembler, bitcode analyzer, and bitcode optimizer.

C-like languages use the Clang frontend. This component compiles C, C++, Objective-C, and Objective-C++ code into LLVM bitcode -- and from there into object files, using LLVM.

Other components include: the libc++ C++ standard library, the LLD linker, and more.

Getting the Source Code and Building LLVM

Consult the Getting Started with LLVM page for information on building and running LLVM.

For information on how to contribute to the LLVM project, please take a look at the Contributing to LLVM guide.

Getting in touch

Join the LLVM Discourse forums, Discord chat, LLVM Office Hours or Regular sync-ups.

The LLVM project has adopted a code of conduct for participants to all modes of communication within the project.