Skip to content

[libc] Add dl_iterate_phdr to Linux x86-64 entrypoints#193601

Open
boomanaiden154 wants to merge 6 commits intousers/boomanaiden154/main.libc-add-dl_iterate_phdr-to-linux-x86-64-entrypointsfrom
users/boomanaiden154/libc-add-dl_iterate_phdr-to-linux-x86-64-entrypoints
Open

[libc] Add dl_iterate_phdr to Linux x86-64 entrypoints#193601
boomanaiden154 wants to merge 6 commits intousers/boomanaiden154/main.libc-add-dl_iterate_phdr-to-linux-x86-64-entrypointsfrom
users/boomanaiden154/libc-add-dl_iterate_phdr-to-linux-x86-64-entrypoints

Conversation

@boomanaiden154
Copy link
Copy Markdown
Contributor

This is needed for building libunwind.

Created using spr 1.3.7
@llvmbot
Copy link
Copy Markdown
Member

llvmbot commented Apr 22, 2026

@llvm/pr-subscribers-libc

Author: Aiden Grossman (boomanaiden154)

Changes

This is needed for building libunwind.


Full diff: https://github.com/llvm/llvm-project/pull/193601.diff

1 Files Affected:

  • (modified) libc/config/linux/x86_64/entrypoints.txt (+3)
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index f67d658d0b176..51da06cec588d 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -1454,6 +1454,9 @@ if(LLVM_LIBC_FULL_BUILD)
     libc.src.nl_types.catopen 
     libc.src.nl_types.catclose
     libc.src.nl_types.catgets
+
+    # link.h entrypoints
+    libc.src.link.dl_iterate_phdr
   )
 endif()
 

@frobtech
Copy link
Copy Markdown
Contributor

This is needed for building libunwind.

AFAICT libunwind when using dl_iterate_phdr will use only dl_iterate_phdr even if statically linked. So it won't find anything at all if dl_iterate_phdr makes no callbacks. Hence I don't think the current no-op stub is sufficient for libunwind to actually function. The simplest implementation would probably be to just fill out one dl_phdr_info once in linux/do_start.cpp and use a copy of that to make a single callback for the executable in dl_iterate_phdr.

Created using spr 1.3.7
Created using spr 1.3.7
@boomanaiden154
Copy link
Copy Markdown
Contributor Author

boomanaiden154 commented Apr 22, 2026

Hence I don't think the current no-op stub is sufficient for libunwind to actually function.

Ah. I was missing that this was only a stub implementation. For some reason I was under the impression that this was a full implementation.

Do we need to fill out a dl_phdr_info on startup and keep that around? I was under the impression that we could implement it by just sending over info for the main executable and vDSO without needing to keep anything around.

Created using spr 1.3.7
Created using spr 1.3.7
Created using spr 1.3.7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants