[Bug libc/26134] New: dladdr() does not set dli_fbase to ELF base address

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Bug libc/26134] New: dladdr() does not set dli_fbase to ELF base address

Sourceware - glibc-bugs mailing list
https://sourceware.org/bugzilla/show_bug.cgi?id=26134

            Bug ID: 26134
           Summary: dladdr() does not set dli_fbase to ELF base address
           Product: glibc
           Version: unspecified
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: libc
          Assignee: unassigned at sourceware dot org
          Reporter: robert.schneider03 at sap dot com
                CC: drepper.fsp at gmail dot com
  Target Milestone: ---

I'm playing around with corner-cases in the ELF format and created a shared
library where the file and program headers are NOT part of any loaded segment.
This causes the ELF base address to be lower than the address of the first
memory mapping.

The man page for dladdr() says that dli_fbase is the "Base address at which
shared object is loaded". I'm not entirely sure if that means _ELF base
address_ or _load address of the lowest segment / memory mapping_. I would
expect dli_fbase to contain the ELF base address.

The code in elf/dl-addr.c, determine_info() sets

    info->dli_fbase = (void *) match->l_map_start;

where l_map_start is documented as

    /* Start and finish of memory map for this object.  l_map_start
       need not be the same as l_addr.  */
    ElfW(Addr) l_map_start, l_map_end;

Indeed, for my strange shared library, dli_fbase is different from the base
address which you can infer from the mappings (lowest mapping, subtract phdr
vaddr) and it's also different from the base address reported via
dl_iterate_phdr dlpi_addr.

Do I simply misunderstand the documentation of dladdr() / dli_fbase? Is there a
particular reason why dli_fbase is set to l_map_start or is this maybe a bug?

--
You are receiving this mail because:
You are on the CC list for the bug.