Fill phdr and phsize for rtld object. It is needed for

dl_iterate_phdr() reporting the correct values.

PR:	211367
Sponsored by:	The FreeBSD Foundation
MFC after:	1 week
This commit is contained in:
kib 2016-08-12 18:31:44 +00:00
parent 8d800feaf4
commit d5127b8cb7

View File

@ -1916,6 +1916,7 @@ static void
init_rtld(caddr_t mapbase, Elf_Auxinfo **aux_info)
{
Obj_Entry objtmp; /* Temporary rtld object */
const Elf_Ehdr *ehdr;
const Elf_Dyn *dyn_rpath;
const Elf_Dyn *dyn_soname;
const Elf_Dyn *dyn_runpath;
@ -1954,6 +1955,9 @@ init_rtld(caddr_t mapbase, Elf_Auxinfo **aux_info)
relocate_objects(&objtmp, true, &objtmp, 0, NULL);
}
ehdr = (Elf_Ehdr *)mapbase;
objtmp.phdr = (Elf_Phdr *)((char *)mapbase + ehdr->e_phoff);
objtmp.phsize = ehdr->e_phnum * sizeof(objtmp.phdr[0]);
/* Initialize the object list. */
TAILQ_INIT(&obj_list);