15 Commits

Author SHA1 Message Date
Schrodinger ZHU Yifan
b7c7dbd473
Revert "libc: Remove extern "C" from main declarations" (#102827)
Reverts llvm/llvm-project#102825
2024-08-11 13:40:50 -07:00
David Blaikie
1b71c471c7
libc: Remove extern "C" from main declarations (#102825)
This is invalid in C++, and clang recently started warning on it as of
#101853
2024-08-11 13:17:27 -07:00
Schrodinger ZHU Yifan
72c9e24ed9
[libc][startup] fix main thread TLS unmapped with wrong value (#102009)
We have been unmapping a wrong address all the time.
```c
munmap(0x704cffebb000, 41048)           = 0
munmap(0x704cffec6000, 69632)           = 0
munmap(0x704cffe9f000, 41048)           = 0
munmap(0x704cffeaa000, 69632)           = 0
munmap(0x704cffe83000, 41048)           = 0
munmap(0x704cffe8e000, 69632)           = 0
munmap(0x704cffe67000, 41048)           = 0
munmap(0x704cffe72000, 69632)           = 0
munmap(0x704cffe4b000, 41048)           = 0
munmap(0x704cffe56000, 69632)           = 0
munmap(0x704cffe2f000, 41048)           = 0
munmap(0x704cffe3a000, 69632)           = 0
munmap(0x704cfff51028, 41048)           = -1 EINVAL (Invalid argument)
```
2024-08-05 09:25:14 -07:00
Schrodinger ZHU Yifan
3db5c1eeb0
revert all tid changes (#100915) 2024-07-27 22:29:21 -07:00
Schrodinger ZHU Yifan
29be889c2c
reland "[libc] implement cached process/thread identity (#98989)" (#99765) 2024-07-20 10:25:40 -07:00
Schrodinger ZHU Yifan
415ca24f8e
Revert "[libc] implement cached process/thread identity" (#99559)
Reverts llvm/llvm-project#98989
2024-07-18 13:31:04 -07:00
Schrodinger ZHU Yifan
5c9fc3cdd7
[libc] implement cached process/thread identity (#98989)
migrated from https://github.com/llvm/llvm-project/pull/95965 due to
corrupted git history
2024-07-18 13:27:50 -07:00
Petr Hosek
5ff3ff33ff
[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98597)
This is a part of #97655.
2024-07-12 09:28:41 -07:00
Mehdi Amini
ce9035f5bd
Revert "[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration" (#98593)
Reverts llvm/llvm-project#98075

bots are broken
2024-07-12 09:12:13 +02:00
Petr Hosek
3f30effe1b
[libc] Migrate to using LIBC_NAMESPACE_DECL for namespace declaration (#98075)
This is a part of #97655.
2024-07-11 12:35:22 -07:00
Nick Desaulniers (paternity leave)
dca49d739d
[libc][arm32] define argc type and stack alignment (#96367)
https://github.com/ARM-software/abi-aa/blob/main/aapcs32/aapcs32.rst#6212stack-constraints-at-a-public-interface
mentions that the stack on ARM32 is double word aligned.

Remove confused comments around ArgcType. argc is always an int, passed on the
stack, so we need to store a pointer to it (regardless of ILP32 or LP64).
2024-06-25 09:04:19 -07:00
Nick Desaulniers (paternity leave)
bea7f3d873
[libc][startup] create header for ElfW and use in startup (#96510)
This is necessary for 32b platforms such as ARM and i386.

Link: #94128
2024-06-24 14:37:50 -07:00
Schrodinger ZHU Yifan
4a9b5aa116
[libc][NFC] remove TODO about AppProperties (#79356)
```
AppProperties app;
```
is marked as a weak symbol in header now. One can just use `&app !=
nullptr` to check if `app` is defined. There is no need to define it for
overlay mode.
2024-01-24 15:18:11 -05:00
Schrodinger ZHU Yifan
0fe20aa45e
[libc] support PIE relocations (#78993)
For some reasons, we are using `-fpie`
(libc/cmake/modules/LLVMLibCObjectRules.cmake:31) without supporting it.
According to @lntue, some of the hermetic tests are broken without
proper PIE support. This patch implements basic relocations support for
PIE.
2024-01-22 12:45:35 -05:00
Schrodinger ZHU Yifan
2bc994456c
[libc] major refactor of startup library (#76092)
* separate initialization routines into _start and do_start for all
architectures.
* lift do_start as a separate object library to avoid code duplication.
* (addtionally) address the problem of building hermetic libc with
-fstack-pointer-*

The `crt1.o` is now a merged result of three components:

```
___
  |___ x86_64
  |      |_______ start.cpp.o    <- _start (loads process initial stack and aligns stack pointer)
  |      |_______ tls.cpp.o      <- init_tls, cleanup_tls, set_thread_pointer (TLS related routines) 
  |___ do_start.cpp.o            <- do_start (sets up global variables and invokes the main function) 
```
2024-01-04 12:51:14 -08:00