Skip to content

Commit

Permalink
static-PIE: Update DT_DEBUG for debugger [BZ #23206]
Browse files Browse the repository at this point in the history
	[BZ #23206]
	* elf/dl-reloc-static-pie.c (_dl_relocate_static_pie): Initialize
	_r_debug and update DT_DEBUG for debugger.
  • Loading branch information
hjl-tools committed May 22, 2018
1 parent e28e9b1 commit d82c7e2
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions elf/dl-reloc-static-pie.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,5 +48,21 @@ _dl_relocate_static_pie (void)
data access using the global offset table. */
ELF_DYNAMIC_RELOCATE (main_map, 0, 0, 0);
main_map->l_relocated = 1;

/* Initialize _r_debug. */
struct r_debug *r = _dl_debug_initialize (0, LM_ID_BASE);
r->r_state = RT_CONSISTENT;

/* Set up debugging before the debugger is notified for the first
time. */
# ifdef ELF_MACHINE_DEBUG_SETUP
/* Some machines (e.g. MIPS) don't use DT_DEBUG in this way. */
ELF_MACHINE_DEBUG_SETUP (main_map, r);
# else
if (main_map->l_info[DT_DEBUG] != NULL)
/* There is a DT_DEBUG entry in the dynamic section. Fill it in
with the run-time address of the r_debug structure */
main_map->l_info[DT_DEBUG]->d_un.d_ptr = (ElfW(Addr)) r;
# endif
}
#endif

0 comments on commit d82c7e2

Please sign in to comment.