This is the mail archive of the
elfutils-devel@sourceware.org
mailing list for the elfutils project.
Re: entries in PT_DYNAMIC section refer to the correct address at runtime?
- From: Yubin Ruan <ablacktshirt at gmail dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: binutils at sourceware dot org, elfutils-devel at sourceware dot org
- Date: Fri, 15 Sep 2017 14:57:36 +0800
- Subject: Re: entries in PT_DYNAMIC section refer to the correct address at runtime?
- Authentication-results: sourceware.org; auth=none
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=lxm27pnbhcPIdI8A55kTqixo0UmBwwgDP64JNn5e1i4=; b=ULow8gD7U0ttzD7WvvtBdMXTyyMw19f98ChNIM2Y7r0Ug3cNiN7/njV/W29ZgdfF48 I42ppTjmxqWXXQxIIWgKsyuoT3r429lCS+6KCmohg7iKEqNHqIX51lh2A7sPakhjHFNS O/KqZ1C+SxVX5Rzy7MIEqJgmjRFcgNCGt0QEpDQAfQ0KWF/tzEmusDalktvgbswL1FYX J+W5KIootJxdt6YRXZc/5e0StsY+WXZrxoRDIosw5mE2e5aqPUns6I/Ws86Q3/7uqnYF rt1ZsgxeNCt2MivXMuzvrbbJYkWntDVYuFLoqarhuyMd+1wxa7wJqSpw6/zEVFzw+rBE bQZA==
- References: <CAJYFCiMKh3CwuoPHKBpcqUruJxEm_M4Cr17DD9ou5aMZq1hOZw@mail.gmail.com> <20170914102525.GJ3528@bubble.grove.modra.org>
2017-09-14 18:25 GMT+08:00 Alan Modra <amodra@gmail.com>:
> On Thu, Sep 14, 2017 at 12:09:51PM +0800, Yubin Ruan wrote:
>> Hi,
>>
>> I read the ELF spec and note that, a segment designated by a program
>> header of type PT_DYNAMIC have several entries, many of which contain
>> addresses of other things. For example, an entry of type DT_SYMTAB was
>> described (in the ELF) spec to "holds the address of the symbol
>> table". I wonder whether this address is true at runtime?
>>
>> Normally a program header would have the following structure:
>>
>> typedef struct {
>> Elf32_Word p_type;
>> Elf32_Off p_offset;
>> Elf32_Addr p_vaddr;
>> Elf32_Addr p_paddr;
>> Elf32_Word p_filesz;
>> Elf32_Word p_memsz;
>> Elf32_Word p_flags;
>> Elf32_Word p_align;
>> } Elf32_Phdr;
>>
>> The `p_vaddr` hold the virtual address (runtime address) for a shared
>> object file and a executable file. But, as stated in the ELF spec,
>> `p_vaddr` might not be correct for a shared object (because it is
>> required to be PIC). So, if that `p_vaddr` is not correct, will those
>> entries in PT_DYNAMIC be correct?
>
> DT_ entries that specify addresses will need to be offset by the base
> address.
Will base address be automatically adjusted by the dynamic linker if
it tries to loaded it at a different base address than that specified
in the `p_vaddr'?
Thanks,
Yubin