Files
swift-mirror/stdlib/public/runtime/ImageInspectionCommon.h
Jonathan Grynspan 8feba8d584 Use __ehdr_start on ELF instead of calling dladdr(). (#85012)
This PR replaces our use of `__dso_handle` and (indirectly) `dladdr()`
when figuring out the base address of loaded Swift images on ELF-based
platforms. Instead, we use `__ehdr_start` which refers to the start of
the image's ELF header (i.e. the start of the file) and is provided by
the compiler/linker for this purpose.

This pointer is consumed by `swift_addNewDSOImage()` and, later, by
Swift Testing when running tests, but is otherwise unused, so the less
work we do on it at runtime, the better.

A fallback path is present that, for images that do not contain
`__ehdr_start`, derives the address by calling `dladdr()` on the section
structure's address.

Resolves #84997.
2025-10-24 12:01:09 -07:00

3.7 KiB