diff mbox

Fix libbacktrace on prelinked shared libraries

Message ID 20131118131147.GZ892@tucnak.redhat.com
State New
Headers show

Commit Message

Jakub Jelinek Nov. 18, 2013, 1:11 p.m. UTC
Hi!

info->dlpi_addr == 0 is true for executables (but those have also
info->dlpi_name set to ""), but not just for those, it is true also
for successfully prelinked shared libraries or any other libraries that
have been linked at non-zero offset and the dynamic linker managed to mmap
them where they were prelinked resp. linked to.

BTW, I'm surprised you aren't adding base_address (well, in fact it is
actually not base address, but load bias, difference between load address
and link base address) to elf_initialize_syminfo created symbol addresses,
because all of them should be biased by the load address.
And, elf_initialize_syminfo should ignore st_shndx == SHN_UNDEF symbols,
those shouldn't be biased but not even entered into the table.

2013-11-18  Jakub Jelinek  <jakub@redhat.com>

	* elf.c (phdr_callback): Process info->dlpi_addr == 0 normally.


	Jakub

Comments

Ian Lance Taylor Nov. 18, 2013, 4:29 p.m. UTC | #1
On Mon, Nov 18, 2013 at 5:11 AM, Jakub Jelinek <jakub@redhat.com> wrote:
>
> info->dlpi_addr == 0 is true for executables (but those have also
> info->dlpi_name set to ""), but not just for those, it is true also
> for successfully prelinked shared libraries or any other libraries that
> have been linked at non-zero offset and the dynamic linker managed to mmap
> them where they were prelinked resp. linked to.
>
> BTW, I'm surprised you aren't adding base_address (well, in fact it is
> actually not base address, but load bias, difference between load address
> and link base address) to elf_initialize_syminfo created symbol addresses,
> because all of them should be biased by the load address.
> And, elf_initialize_syminfo should ignore st_shndx == SHN_UNDEF symbols,
> those shouldn't be biased but not even entered into the table.

You're right, these are bugs.


> 2013-11-18  Jakub Jelinek  <jakub@redhat.com>
>
>         * elf.c (phdr_callback): Process info->dlpi_addr == 0 normally.

This is OK.

Thanks.

Ian
diff mbox

Patch

--- libbacktrace/elf.c.jj	2013-11-18 09:59:08.000000000 +0100
+++ libbacktrace/elf.c	2013-11-18 12:48:07.780700382 +0100
@@ -863,12 +863,8 @@  phdr_callback (struct dl_phdr_info *info
   fileline elf_fileline_fn;
   int found_dwarf;
 
-  /* There is not much we can do if we don't have the module name.  If
-     the base address is 0, this is probably the executable, which we
-     already loaded.  */
-  if (info->dlpi_name == NULL
-      || info->dlpi_name[0] == '\0'
-      || info->dlpi_addr == 0)
+  /* There is not much we can do if we don't have the module name.  */
+  if (info->dlpi_name == NULL || info->dlpi_name[0] == '\0')
     return 0;
 
   descriptor = backtrace_open (info->dlpi_name, pd->error_callback, pd->data,