More fixes related to NONE relocs
authorAlan Modra <amodra@gmail.com>
Mon, 19 Jan 2015 07:45:30 +0000 (18:15 +1030)
committerAlan Modra <amodra@gmail.com>
Mon, 19 Jan 2015 09:07:45 +0000 (19:37 +1030)
* elf32-bfin.c (bfin_bfd_reloc_type_lookup): Correct loop iteration
to allow return of first howto.
* elf32-fr30.c (fr30_reloc_type_lookup): Likewise.
* elf32-m32c.c (m32c_reloc_type_lookup): Likewise.
* elf32-moxie.c (moxie_reloc_type_lookup): Likewise.
* elf32-or1k.c (or1k_reloc_type_lookup): Likewise.
* elf32-rl78.c (rl78_reloc_type_lookup): Likewise.
* elf32-rx.c (rx_reloc_type_lookup): Likewise.
* elf32-tilepro.c (tilepro_reloc_type_lookup): Likewise.
* elf32-xstormy16.c (xstormy16_reloc_type_lookup): Likewise.
* elfxx-tilegx.c (tilegx_reloc_type_lookup): Likewise.
* elf32-nios2.c (nios2_reloc_map): Add mapping for R_NIOS2_NONE.
* elf32-spu.c (spu_elf_bfd_to_reloc_type): Allow return of R_SPU_NONE.
(spu_elf_reloc_type_lookup): Adjust to suit.

13 files changed:
bfd/ChangeLog
bfd/elf32-bfin.c
bfd/elf32-fr30.c
bfd/elf32-m32c.c
bfd/elf32-moxie.c
bfd/elf32-nios2.c
bfd/elf32-or1k.c
bfd/elf32-rl78.c
bfd/elf32-rx.c
bfd/elf32-spu.c
bfd/elf32-tilepro.c
bfd/elf32-xstormy16.c
bfd/elfxx-tilegx.c

index b9c6c38..5b03d1c 100644 (file)
@@ -1,5 +1,22 @@
 2015-01-19  Alan Modra  <amodra@gmail.com>
 
+       * elf32-bfin.c (bfin_bfd_reloc_type_lookup): Correct loop iteration
+       to allow return of first howto.
+       * elf32-fr30.c (fr30_reloc_type_lookup): Likewise.
+       * elf32-m32c.c (m32c_reloc_type_lookup): Likewise.
+       * elf32-moxie.c (moxie_reloc_type_lookup): Likewise.
+       * elf32-or1k.c (or1k_reloc_type_lookup): Likewise.
+       * elf32-rl78.c (rl78_reloc_type_lookup): Likewise.
+       * elf32-rx.c (rx_reloc_type_lookup): Likewise.
+       * elf32-tilepro.c (tilepro_reloc_type_lookup): Likewise.
+       * elf32-xstormy16.c (xstormy16_reloc_type_lookup): Likewise.
+       * elfxx-tilegx.c (tilegx_reloc_type_lookup): Likewise.
+       * elf32-nios2.c (nios2_reloc_map): Add mapping for R_NIOS2_NONE.
+       * elf32-spu.c (spu_elf_bfd_to_reloc_type): Allow return of R_SPU_NONE.
+       (spu_elf_reloc_type_lookup): Adjust to suit.
+
+2015-01-19  Alan Modra  <amodra@gmail.com>
+
        * bfd-in.h (bfd_get_section_limit_octets): New define, extracted from..
        (bfd_get_section_limit): ..here.
        * reloc.c (bfd_perform_relocation): Correct bfd_reloc_outofrange check.
index 898010f..80d20ca 100644 (file)
@@ -1065,13 +1065,13 @@ bfin_bfd_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
                            bfd_reloc_code_real_type code)
 {
   unsigned int i;
-  unsigned int r_type = BFIN_RELOC_MIN;
+  unsigned int r_type = (unsigned int) -1;
 
-  for (i = sizeof (bfin_reloc_map) / sizeof (bfin_reloc_map[0]); --i;)
+  for (i = sizeof (bfin_reloc_map) / sizeof (bfin_reloc_map[0]); i--;)
     if (bfin_reloc_map[i].bfd_reloc_val == code)
       r_type = bfin_reloc_map[i].bfin_reloc_val;
 
-  if (r_type <= BFIN_RELOC_MAX && r_type > BFIN_RELOC_MIN)
+  if (r_type <= BFIN_RELOC_MAX)
     return &bfin_howto_table [r_type];
 
   else if (r_type >= BFIN_GNUEXT_RELOC_MIN && r_type <= BFIN_GNUEXT_RELOC_MAX)
index d7c326d..ba47a3d 100644 (file)
@@ -343,7 +343,7 @@ fr30_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
   unsigned int i;
 
   for (i = sizeof (fr30_reloc_map) / sizeof (fr30_reloc_map[0]);
-       --i;)
+       i--;)
     if (fr30_reloc_map [i].bfd_reloc_val == code)
       return & fr30_elf_howto_table [fr30_reloc_map[i].fr30_reloc_val];
 
index 988aa2a..cbc1765 100644 (file)
@@ -264,7 +264,7 @@ m32c_reloc_type_lookup
 {
   unsigned int i;
 
-  for (i = ARRAY_SIZE (m32c_reloc_map); --i;)
+  for (i = ARRAY_SIZE (m32c_reloc_map); i--;)
     if (m32c_reloc_map [i].bfd_reloc_val == code)
       return & m32c_elf_howto_table [m32c_reloc_map[i].m32c_reloc_val];
 
index a858423..7123ac1 100644 (file)
@@ -99,7 +99,7 @@ moxie_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
   unsigned int i;
 
   for (i = sizeof (moxie_reloc_map) / sizeof (moxie_reloc_map[0]);
-       --i;)
+       i--;)
     if (moxie_reloc_map [i].bfd_reloc_val == code)
       return & moxie_elf_howto_table [moxie_reloc_map[i].moxie_reloc_val];
 
index 55a3f60..c72c460 100644 (file)
@@ -764,6 +764,7 @@ struct elf_reloc_map
 };
 
 static const struct elf_reloc_map nios2_reloc_map[] = {
+  {BFD_RELOC_NONE, R_NIOS2_NONE},
   {BFD_RELOC_NIOS2_S16, R_NIOS2_S16},
   {BFD_RELOC_NIOS2_U16, R_NIOS2_U16},
   {BFD_RELOC_16_PCREL, R_NIOS2_PCREL16},
index 0d2ebf0..fa2e985 100644 (file)
@@ -704,7 +704,7 @@ or1k_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
 {
   unsigned int i;
 
-  for (i = ARRAY_SIZE (or1k_reloc_map); --i;)
+  for (i = ARRAY_SIZE (or1k_reloc_map); i--;)
     if (or1k_reloc_map[i].bfd_reloc_val == code)
       return & or1k_elf_howto_table[or1k_reloc_map[i].or1k_reloc_val];
 
index 5901ed8..3230c8c 100644 (file)
@@ -246,7 +246,7 @@ rl78_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
   if (code == BFD_RELOC_RL78_32_OP)
     return rl78_elf_howto_table + R_RL78_DIR32;
 
-  for (i = ARRAY_SIZE (rl78_reloc_map); --i;)
+  for (i = ARRAY_SIZE (rl78_reloc_map); i--;)
     if (rl78_reloc_map [i].bfd_reloc_val == code)
       return rl78_elf_howto_table + rl78_reloc_map[i].rl78_reloc_val;
 
index 058e086..beb4e09 100644 (file)
@@ -277,7 +277,7 @@ rx_reloc_type_lookup (bfd *                    abfd ATTRIBUTE_UNUSED,
   if (code == BFD_RELOC_RX_32_OP)
     return rx_elf_howto_table + R_RX_DIR32;
 
-  for (i = ARRAY_SIZE (rx_reloc_map); --i;)
+  for (i = ARRAY_SIZE (rx_reloc_map); i--;)
     if (rx_reloc_map [i].bfd_reloc_val == code)
       return rx_elf_howto_table + rx_reloc_map[i].rx_reloc_val;
 
index a806c5d..8203286 100644 (file)
@@ -105,6 +105,8 @@ spu_elf_bfd_to_reloc_type (bfd_reloc_code_real_type code)
   switch (code)
     {
     default:
+      return (enum elf_spu_reloc_type) -1;
+    case BFD_RELOC_NONE:
       return R_SPU_NONE;
     case BFD_RELOC_SPU_IMM10W:
       return R_SPU_ADDR10;
@@ -168,7 +170,7 @@ spu_elf_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED,
 {
   enum elf_spu_reloc_type r_type = spu_elf_bfd_to_reloc_type (code);
 
-  if (r_type == R_SPU_NONE)
+  if (r_type == (enum elf_spu_reloc_type) -1)
     return NULL;
 
   return elf_howto_table + r_type;
index b8c9586..f573978 100644 (file)
@@ -774,7 +774,7 @@ tilepro_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
 {
   unsigned int i;
 
-  for (i = ARRAY_SIZE (tilepro_reloc_map); --i;)
+  for (i = ARRAY_SIZE (tilepro_reloc_map); i--;)
     {
       const reloc_map * entry;
 
index 8f47df5..6bf277c 100644 (file)
@@ -334,7 +334,7 @@ xstormy16_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
 {
   unsigned int i;
 
-  for (i = ARRAY_SIZE (xstormy16_reloc_map); --i;)
+  for (i = ARRAY_SIZE (xstormy16_reloc_map); i--;)
     {
       const reloc_map * entry;
 
index e747fad..df1fe41 100644 (file)
@@ -921,7 +921,7 @@ tilegx_reloc_type_lookup (bfd * abfd ATTRIBUTE_UNUSED,
 {
   unsigned int i;
 
-  for (i = ARRAY_SIZE (tilegx_reloc_map); --i;)
+  for (i = ARRAY_SIZE (tilegx_reloc_map); i--;)
     {
       const reloc_map * entry;