bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/24896] [powerpc] ld can probably drop R_PPC64_UADDR64 conversion


From: maskray at google dot com
Subject: [Bug ld/24896] [powerpc] ld can probably drop R_PPC64_UADDR64 conversion
Date: Wed, 14 Aug 2019 10:28:09 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=24896

--- Comment #3 from Fangrui Song <maskray at google dot com> ---
Thanks for the information.

* Aligned R_PPC64_UADDR64 -> R_PPC64_ADDR64  => the code is there and it
doesn't hurt anyone, so let's keep it
* Misaligned R_PPC64_ADDR64 -> R_PPC64_UADDR64 => this matters on power7 and
previous processors (assumably they may trap for a misaligned 64-bit access)

Am I correct? There is probably a bug in glibc powerpc32. For a dynamic
relocation R_PPC_UADDR32 to a STB_LOCAL STT_SECTION symbol, the relocated value
is wrong.
The offending code was added in 2003 but there seems no way for gas to emit
UADDR32, so ld won't emit dynamic UADDR32, and this bug gets unnoticed for
years...


// glibc/sysdeps/power/powerpc32/dl-machine.h
auto inline void __attribute__ ((always_inline))
elf_machine_rela (struct link_map *map, const Elf32_Rela *reloc,
                  const Elf32_Sym *sym, const struct r_found_version *version,
                  void *const reloc_addr_arg, int skip_ifunc)
{
  ...
  /* binutils on ppc32 includes st_value in r_addend for relocations
     against local symbols.  */
  if (__builtin_expect (ELF32_ST_BIND (sym->st_info) == STB_LOCAL, 0)
      && sym->st_shndx != SHN_UNDEF)
    {
      sym_map = map;
      value = map->l_addr; /////// st_value is not considered
    }
  else
    {
      sym_map = RESOLVE_MAP (&sym, version, r_type);
      value = SYMBOL_ADDRESS (sym_map, sym, true);
    }
  value += reloc->r_addend;

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


reply via email to

[Prev in Thread] Current Thread [Next in Thread]