]> git.ipfire.org Git - thirdparty/binutils-gdb.git/commitdiff
Fix overflow handling of VLE_SDA21
authorAlan Modra <amodra@gmail.com>
Fri, 14 Mar 2014 04:31:53 +0000 (15:01 +1030)
committerAlan Modra <amodra@gmail.com>
Thu, 12 Jun 2014 15:29:04 +0000 (00:59 +0930)
bfd/
* elf32-ppc.c (ppc_elf_relocate_section): Correct overflow
handling for VLE_SDA21 relocs.
ld/testsuite/
* ld-powerpc/vle.ld: Place .PPC.EMB.sdata0 within 32k of 0.
* ld-powerpc/vle-reloc-3.d: Update.

bfd/ChangeLog
bfd/elf32-ppc.c
ld/testsuite/ChangeLog
ld/testsuite/ld-powerpc/vle-reloc-3.d
ld/testsuite/ld-powerpc/vle.ld

index f6ccd396c4e6fbfa65b4d585f402fdd4130d1317..01566292d1e42b4b98aa73968058f46218a4e55e 100644 (file)
@@ -1,6 +1,10 @@
 2014-06-12  Alan Modra  <amodra@gmail.com>
 
        Backport mainline patches
+       2014-03-14  Alan Modra  <amodra@gmail.com>
+       * elf32-ppc.c (ppc_elf_relocate_section): Correct overflow
+       handling for VLE_SDA21 relocs.
+
        2014-03-08  Alan Modra  <amodra@gmail.com>
        * elf32-ppc.c (ppc_elf_howto_raw): Correct overflow check for
        many relocations.  Correct bitsize and rightshift too for a number
index 8fd437b3108f4d9dcd06361807f9276815ec38df..14083b9da9ebce7ff56121049d6cbe453c38bf4d 100644 (file)
@@ -8855,11 +8855,12 @@ ppc_elf_relocate_section (bfd *output_bfd,
                /* And the final 11 bits of the value to bits 21 to 31.  */
                insn |= relocation & 0x7ff;
 
-               /* Use _bfd_final_link_relocate to report overflow,
-                  but do so with a value that won't modify the insn.  */
-               if (relocation + 0x80000 > 0x100000)
-                 addend = 0x100000;
-               relocation = 0;
+               bfd_put_32 (output_bfd, insn, contents + rel->r_offset);
+
+               if (r_type == R_PPC_VLE_SDA21
+                   && ((relocation + 0x80000) & 0xffffffff) > 0x100000)
+                 goto overflow;
+               continue;
              }
            else if (r_type == R_PPC_EMB_SDA21
                     || r_type == R_PPC_VLE_SDA21
@@ -9156,6 +9157,7 @@ ppc_elf_relocate_section (bfd *output_bfd,
        {
          if (r == bfd_reloc_overflow)
            {
+           overflow:
              if (warned)
                continue;
              if (h != NULL
index e92ffe2d5eba18f746c7660ea511ef06f5f9f979..f3d5c328e415922ed49c79081780acaf63e8f0f9 100644 (file)
@@ -1,6 +1,10 @@
 2014-06-12  Alan Modra  <amodra@gmail.com>
 
        Apply mainline patches
+       2014-03-14  Alan Modra  <amodra@gmail.com>
+       * ld-powerpc/vle.ld: Place .PPC.EMB.sdata0 within 32k of 0.
+       * ld-powerpc/vle-reloc-3.d: Update.
+
        2014-02-10  H.J. Lu  <hongjiu.lu@intel.com>
        PR gold/16530
        * ld-elf/dynamic-1.c: New file.
index e29f4f07864b287712fe5ae4512df1beb233ddb3..584c4833d1f336ca58e35773b708c2c4a5bdbdb2 100644 (file)
@@ -5,4 +5,4 @@ Disassembly of section .text:
 01800094 <sda21_test>:
  1800094:      1c ad 80 08     e_add16i r5,r13,-32760
  1800098:      1c a2 80 04     e_add16i r5,r2,-32764
- 180009c:      70 00 00 ac     e_li    r0,172
+ 180009c:      70 b0 78 04     e_li    r5,-32764
index 01b659857b273c8b03e871a9ca7d566274831340..ff92a05e0789524240988b4d8e59ad47c121c0a6 100644 (file)
@@ -2,10 +2,11 @@ SECTIONS
 {
   . = 0x01800000 + SIZEOF_HEADERS;
   .text : { *(.text) }
-  .PPC.EMB.sdata0 : { *(.PPC.EMB.sdata0) }
   .sdata2 : { PROVIDE (_SDA2_BASE_ = 32768); *(.sdata2) }
   . = ALIGN (0x10000) + (. & (0x10000 - 1));
   .data : { *(.data) }
   .sdata : { PROVIDE (_SDA_BASE_ = 32768); *(.sdata) }
+  . = 0xffff8000;
+  .PPC.EMB.sdata0 : { *(.PPC.EMB.sdata0) }
   /DISCARD/ : { *(*) }
 }