wrong loadaddr field for main executable

Carmelo Amoroso carmelo73 at gmail.com
Fri Jul 7 23:50:52 PDT 2006


Hi all,
please discard my previous post, I was needed to have a deeper look  
into the ld.so code.
Now all is clearer to me.

Carmelo

> Hi,
> may someone take a look at this piece of code (taken form
> ldso.c:_dl_get_ready_to_run)?
>
> If the main application is not a PIE, then app_tpnt->loadaddr is 0.
> So, when inserting the main executatle into the _dl_loaded_modules  
> by calling
> the function _dl_add_elf_hash_table, it will be set to 0 into the
> app_tpnt->loadaddr field.
> Is it right? is it a bug?
>
> Thanks,
> Carmelo
>
>
> /* Find the runtime load address of the main executable.  This may be
> 	 * different from what the ELF header says for ET_DYN/PIE  
> executables.
> 	 */
> 	{
> 		unsigned int idx;
> 		ElfW(Phdr) *phdr = (ElfW(Phdr) *) auxvt[AT_PHDR].a_un.a_val;
>
> 		for (idx = 0; idx < auxvt[AT_PHNUM].a_un.a_val; idx++, phdr++)
> 			if (phdr->p_type == PT_PHDR) {
> 				app_tpnt->loadaddr = (ElfW(Addr)) (auxvt[AT_PHDR].a_un.a_val -
> phdr->p_vaddr);
> 				break;
> 			}
>
> 		if (app_tpnt->loadaddr)
> 			_dl_debug_early("Position Independent Executable: "
> 					"app_tpnt->loadaddr=%x\n", app_tpnt->loadaddr);
> 	}
>
>
> /* OK, we have what we need - slip this one into the list. */
> app_tpnt = _dl_add_elf_hash_table(_dl_progname, (char *)app_tpnt- 
> >loadaddr,
>            app_tpnt->dynamic_info, ppnt->p_vaddr +
> app_tpnt->loadaddr, ppnt->p_filesz);



More information about the uClibc mailing list