Up: Dynamic Linker   [Contents][Index]


36.1 Dynamic Linker Introspection

The GNU C Library provides various functions for querying information from the dynamic linker.

Data Type: struct dl_find_object

This structure contains information about a main program or loaded object. The _dl_find_object function uses it to return result data to the caller.

unsigned long long int dlfo_flags

Currently unused and always 0.

void *dlfo_map_start

The start address of the inspected mapping. This information comes from the program header, so it follows its convention, and the address is not necessarily page-aligned.

void *dlfo_map_end

The end address of the mapping.

struct link_map *dlf_link_map

This member contains a pointer to the link map of the object.

struct link_map *dlf_link_map

This member contains a pointer to the exception handling data of the object. See DLFO_EH_SEGMENT_TYPE below.

This structure is a GNU extension.

Macro: int DLFO_STRUCT_HAS_EH_DBASE

On most targets, this macro is defined as 0. If it is defined to 1, struct dl_find_object contains an additional member dlfo_eh_dbase of type void *. It is the base address for DW_EH_PE_datarel DWARF encodings to this location.

This macro is a GNU extension.

Macro: int DLFO_STRUCT_HAS_EH_COUNT

On most targets, this macro is defined as 0. If it is defined to 1, struct dl_find_object contains an additional member dlfo_eh_count of type int. It is the number of exception handling entries in the EH frame segment identified by the dlfo_eh_frame member.

This macro is a GNU extension.

Macro: int DLFO_EH_SEGMENT_TYPE

On targets using DWARF-based exception unwinding, this macro expands to PT_GNU_EH_FRAME. This indicates that dlfo_eh_frame in struct dl_find_object points to the PT_GNU_EH_FRAME segment of the object. On targets that use other unwinding formats, the macro expands to the program header type for the unwinding data.

This macro is a GNU extension.

Function: int _dl_find_object (void *address, struct dl_find_object *result)

| MT-Safe | AS-Safe | AC-Safe | See POSIX Safety Concepts.

On success, this function returns 0 and writes about the object surrounding the address to *result. On failure, -1 is returned.

The address can be a code address or data address. On architectures using function descriptors, no attempt is made to decode the function descriptor. Depending on how these descriptors are implemented, _dl_find_object may return the object that defines the function descriptor (and not the object that contains the code implementing the function), or fail to find any object at all.

On success address is greater than or equal to result->dlfo_map_start and less than result->dlfo_map_end, that is, the supplied code address is located within the reported mapping.

This function returns a pointer to the unwinding information for the object that contains the program code address in result->dlfo_eh_frame. If the platform uses DWARF unwinding information, this is the in-memory address of the PT_GNU_EH_FRAME segment. See DLFO_EH_SEGMENT_TYPE above. In case address resides in an object that lacks unwinding information, the function still returns 0, but sets result->dlfo_eh_frame to a null pointer.

_dl_find_object itself is thread-safe. However, if the application invokes dlclose for the object that contains address concurrently with _dl_find_object or after the call returns, accessing the unwinding data for that object or the link map (through result->dlfo_link_map) is not safe. Therefore, the application needs to ensure by other means (e.g., by convention) that address remains a valid code address while the unwinding information is processed.

This function is a GNU extension.


Up: Dynamic Linker   [Contents][Index]