Author: marcel
Date: Sat Jul 26 17:07:32 2014
New Revision: 269129
URL: http://svnweb.freebsd.org/changeset/base/269129

Log:
  Fix relocations related to dpcpu and vnet sets. The address is
  rebased to point to the allocated memory, but for architectures
  that have non-zero relocation addends, the address comparison
  happens on the "unfinalized" address.
  After the addend is taken into account, call elf_relocaddr() to
  make sure we rebase properly.

Modified:
  head/sys/powerpc/powerpc/elf32_machdep.c

Modified: head/sys/powerpc/powerpc/elf32_machdep.c
==============================================================================
--- head/sys/powerpc/powerpc/elf32_machdep.c    Sat Jul 26 16:45:11 2014        
(r269128)
+++ head/sys/powerpc/powerpc/elf32_machdep.c    Sat Jul 26 17:07:32 2014        
(r269129)
@@ -190,8 +190,7 @@ elf_reloc_internal(linker_file_t lf, Elf
                        addr = lookup(lf, symidx, 1);
                if (addr == 0)
                        return -1;
-               addr += addend;
-               *where = addr;
+               *where = elf_relocaddr(lf, addr + addend);
                break;
 
                case R_PPC_ADDR16_LO: /* #lo(S) */
@@ -204,9 +203,8 @@ elf_reloc_internal(linker_file_t lf, Elf
                 * are relative to relocbase. Detect this condition.
                 */
                if (addr > relocbase && addr <= (relocbase + addend))
-                       addr = relocbase + addend;
-               else
-                       addr += addend;
+                       addr = relocbase;
+               addr = elf_relocaddr(lf, addr + addend);
                *hwhere = addr & 0xffff;
                break;
 
@@ -220,9 +218,8 @@ elf_reloc_internal(linker_file_t lf, Elf
                 * are relative to relocbase. Detect this condition.
                 */
                if (addr > relocbase && addr <= (relocbase + addend))
-                       addr = relocbase + addend;
-               else
-                       addr += addend;
+                       addr = relocbase;
+               addr = elf_relocaddr(lf, addr + addend);
                *hwhere = ((addr >> 16) + ((addr & 0x8000) ? 1 : 0))
                    & 0xffff;
                break;
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to