The new code added is still very x86_64 specific. AArch64 support will
be added very soon and refactoring of the loader code will be done as
part of the patches adding it.
Details
- Reviewers
phosek asteinhauser - Commits
- rG5d59385ba67e: [libc] Setup TLS in x86_64 loader.
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
libc/loader/linux/x86_64/start.cpp | ||
---|---|---|
38 | This should be implemented directly in a generic place, instead of adding a TODO and moving all content immediately when implementing aarch64. | |
46 | This formula can be written as: tlsSize = (app.tls.size + app.tls.align) & -app.tls.align | |
51 | The size should be 2 words plus sizeof(pthread) plus p_memsz(PT_TLS) plus (headroom left for padding). Initially dtv[0] = 1 (one module), dtv[1] = DTP offset. The pthread structure is placed at the end of dtv. | |
60 | This can call an internal crash function instead of SYS_exit. mmapRetVal < 0 is sufficient. |
libc/loader/linux/x86_64/start.cpp | ||
---|---|---|
51 | Size of pthread can/will be added once we develop or need an equivalent of that in LLVM-libc. So, without that, and without support for dynamic loading, can you give an example wherein the code as it stands in this patch would fail? [I will add a note in the commit message and also a comment that we don't yet have dynamic loading support.] |
libc/config/linux/app.h | ||
---|---|---|
17 | It would be good to add source-code comments about the semantics of those two structs and their fields. | |
libc/loader/linux/x86_64/start.cpp | ||
25 | There should probably be SYS_mmap2 instead of SYS_mmaps2. | |
46 | The existing comment about tlsSize = (app.tls.size + app.tls.align) & -app.tls.align seems relevant to me. It assumes that app.tls.align is a power of two which is a valid assumption, but might be mentioned in libc/config/linux/app.h comments. | |
59 | Why "if (mmapRetVal == MAP_FAILED)" is not a sufficient check? |
clang-tidy: warning: invalid case style for member 'address' [readability-identifier-naming]
not useful