Procedure Linkage Table Skipping
The rtld-debugger interface enables a controlling process to skip over procedure linkage table entries. When a controlling process, such as a debugger, is asked to step into a function for the first time, the procedure linkage table processing, causes control to be passed to the runtime linker to search for the function definition.
The following interface enables a controlling process to step over the runtime linker procedure linkage table processing. The controlling process can determine when a procedure linkage table entry is encountered based on external information provided in the ELF file.
Once a target process has stepped into a procedure linkage table entry, the
process calls the rd_plt_resolution
() interface.
-
rd_plt_resolution
() -
This function returns the resolution state of the current procedure linkage table entry and information on how to skip it.
rd_err_e rd_plt_resolution(rd_agent_t *rdap, paddr_t pc, lwpid_t lwpid, paddr_t plt_base, rd_plt_info_t *rpi);
pc
represents the first instruction of the procedure linkage table entry.lwpid
provides thelwp
identifier andplt_base
provides the base address of the procedure linkage table. These three variables provide information sufficient for various architectures to process the procedure linkage table.rpi
provides detailed information regarding the procedure linkage table entry as defined in the following data structure, defined inrtld_db.h
.
typedef enum { RD_RESOLVE_NONE, RD_RESOLVE_STEP, RD_RESOLVE_TARGET, RD_RESOLVE_TARGET_STEP } rd_skip_e; typedef struct rd_plt_info { rd_skip_e pi_skip_method; long pi_nstep; psaddr_t pi_target; psaddr_t pi_baddr; unsigned int pi_flags; } rd_plt_info_t; #define RD_FLG_PI_PLTBOUND 0x0001
The elements of the rd_plt_info_t
structure
are:
-
pi_skip_method
-
Identifies how the procedure linkage table entry can be traversed. This method is set to one of the
rd_skip_e
values. -
pi_nstep
-
Identifies how many instructions to step over when
RD_RESOLVE_STEP
orRD_RESOLVE_TARGET_STEP
are returned. -
pi_target
-
Specifies the address at which to set a breakpoint when
RD_RESOLVE_TARGET_STEP
orRD_RESOLVE_TARGET
are returned. -
pi_baddr
-
The procedure linkage table destination address, added with
RD_VERSION3
. When theRD_FLG_PI_PLTBOUND
flag of thepi_flags
field is set, this element identifies the resolved (bound) destination address. -
pi_flags
-
A flags field, added with
RD_VERSION3
. The flagRD_FLG_PI_PLTBOUND
identifies the procedure linkage entry as having been resolved (bound) to its destination address, which is available in thepi_baddr
field.
The following scenarios are possible from the
rd_plt_info_t
return values.
-
The first call through this procedure linkage table must be resolved by the runtime linker. In this case, the
rd_plt_info_t
contains:{RD_RESOLVE_TARGET_STEP, M, <BREAK>, 0, 0}
The controlling process sets a breakpoint at
BREAK
and continues the target process. When the breakpoint is reached, the procedure linkage table entry processing has finished. The controlling process can then stepM
instructions to the destination function. Notice that the bound address (pi_baddr
) has not been set since this is the first call through a procedure linkage table entry. -
On the
Nth
time through this procedure linkage table,rd_plt_info_t
contains:{RD_RESOLVE_STEP, M, 0, <BoundAddr>, RD_FLG_PI_PLTBOUND}
The procedure linkage table entry has already been resolved and the controlling process can step
M
instructions to the destination function. The address that the procedure linkage table entry is bound to is<BoundAddr>
and theRD_FLG_PI_PLTBOUND
bit has been set in the flags field.