Scanning Loadable Objects
Information for each object maintained on the runtime linkers link-map can be
obtained from the following structure, defined in
rtld_db.h.
typedef struct rd_loadobj {
psaddr_t rl_nameaddr;
unsigned rl_flags;
psaddr_t rl_base;
psaddr_t rl_data_base;
unsigned rl_lmident;
psaddr_t rl_refnameaddr;
psaddr_t rl_plt_base;
unsigned rl_plt_size;
psaddr_t rl_bend;
psaddr_t rl_padstart;
psaddr_t rl_padend;
psaddt_t rl_dynamic;
unsigned long rl_tlsmodid;
} rd_loadobj_t;All addresses provided in this structure, including string pointers, are addresses in the target process and not in the address space of the controlling process itself.
-
rl_nameaddr -
A pointer to a string that contains the name of the dynamic object.
-
rl_flags -
With revision
RD_VERSION2, dynamically loaded relocatable objects are identified withRD_FLG_MEM_OBJECT. -
rl_base -
The base address of the dynamic object.
-
rl_data_base -
The base address of the data segment of the dynamic object.
-
rl_lmident -
The link-map identifier (see Establishing a Namespace).
-
rl_refnameaddr -
If the dynamic object is a standard filter, then this points to the name of the filtees.
-
rl_plt_base,rl_plt_size -
These elements are present for backward compatibility and are currently unused.
-
rl_bend -
The end address of the object (
text + data + bss). With revisionRD_VERSION2, the end address of a dynamically loaded relocatable object is the end of the created object, including the object section headers. -
rl_padstart -
The base address of the padding before the dynamic object (refer to Dynamic Object Padding).
-
rl_padend -
The base address of the padding after the dynamic object (refer to Dynamic Object Padding).
-
rl_dynamic -
This field, added with
RD_VERSION2, provides the base address of the object's dynamic section, which allows reference to such entries asDT_CHECKSUM(see ELF Dynamic Array Tags). -
rl_tlsmodid -
This field, added with
RD_VERSION4, provides the module identifier for thread local storage,TLS, references. The module identifier is a small integer unique to the object. This identifier can be passed to thelibc_dbfunctiontd_thr_tlsbase() in order to obtain the base address of a thread'sTLSblock for the object in question. Seetd_thr_tlsbase(3C_DB).
The rd_loadobj_iter() routine uses this object data structure to access information from the runtime linker link-map lists.
-
rd_loadobj_iter() -
This function iterates over all dynamic objects currently loaded in the target process.
typedef int rl_iter_f(const rd_loadobj_t *, void *); rd_err_e rd_loadobj_iter(rd_agent_t *rap, rl_iter_f *cb, void *clnt_data);
On each iteration the imported function specified by
cbis called.clnt_datacan be used to pass data to thecbcall. Information about each object is returned by means of a pointer to a volatile (stack allocated)rd_loadobj_tstructure.Return codes from the
cbroutine are examined byrd_loadobj_iter() and have the following meaning.-
1 – continue processing link-maps.
-
0 – stop processing link-maps and return control to the controlling process.
rd_loadobj_iter() returnsRD_OKon success. A return ofRD_NOMAPSindicates the runtime linker has not yet loaded the initial link-maps. -