From: Alan Modra Date: Mon, 19 Jan 2015 07:45:30 +0000 (+1030) Subject: More fixes related to NONE relocs X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=0ba38529f27a815a576bc07c85ceb65f6498ef5a;p=binutils-gdb.git More fixes related to NONE relocs * 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. --- diff --git a/bfd/ChangeLog b/bfd/ChangeLog index b9c6c389e7f..5b03d1c3678 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,20 @@ +2015-01-19 Alan Modra + + * 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 * bfd-in.h (bfd_get_section_limit_octets): New define, extracted from.. diff --git a/bfd/elf32-bfin.c b/bfd/elf32-bfin.c index 898010fbfd3..80d20ca224f 100644 --- a/bfd/elf32-bfin.c +++ b/bfd/elf32-bfin.c @@ -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) diff --git a/bfd/elf32-fr30.c b/bfd/elf32-fr30.c index d7c326d3648..ba47a3d3f8a 100644 --- a/bfd/elf32-fr30.c +++ b/bfd/elf32-fr30.c @@ -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]; diff --git a/bfd/elf32-m32c.c b/bfd/elf32-m32c.c index 988aa2a7fde..cbc17659e85 100644 --- a/bfd/elf32-m32c.c +++ b/bfd/elf32-m32c.c @@ -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]; diff --git a/bfd/elf32-moxie.c b/bfd/elf32-moxie.c index a8584230a42..7123ac10411 100644 --- a/bfd/elf32-moxie.c +++ b/bfd/elf32-moxie.c @@ -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]; diff --git a/bfd/elf32-nios2.c b/bfd/elf32-nios2.c index 55a3f60da7b..c72c460770b 100644 --- a/bfd/elf32-nios2.c +++ b/bfd/elf32-nios2.c @@ -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}, diff --git a/bfd/elf32-or1k.c b/bfd/elf32-or1k.c index 0d2ebf0cb2f..fa2e9859bab 100644 --- a/bfd/elf32-or1k.c +++ b/bfd/elf32-or1k.c @@ -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]; diff --git a/bfd/elf32-rl78.c b/bfd/elf32-rl78.c index 5901ed873f4..3230c8c059a 100644 --- a/bfd/elf32-rl78.c +++ b/bfd/elf32-rl78.c @@ -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; diff --git a/bfd/elf32-rx.c b/bfd/elf32-rx.c index 058e086008f..beb4e09d7c1 100644 --- a/bfd/elf32-rx.c +++ b/bfd/elf32-rx.c @@ -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; diff --git a/bfd/elf32-spu.c b/bfd/elf32-spu.c index a806c5de1dc..82032864157 100644 --- a/bfd/elf32-spu.c +++ b/bfd/elf32-spu.c @@ -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; diff --git a/bfd/elf32-tilepro.c b/bfd/elf32-tilepro.c index b8c9586de32..f5739781abb 100644 --- a/bfd/elf32-tilepro.c +++ b/bfd/elf32-tilepro.c @@ -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; diff --git a/bfd/elf32-xstormy16.c b/bfd/elf32-xstormy16.c index 8f47df5d571..6bf277cb120 100644 --- a/bfd/elf32-xstormy16.c +++ b/bfd/elf32-xstormy16.c @@ -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; diff --git a/bfd/elfxx-tilegx.c b/bfd/elfxx-tilegx.c index e747fad18c6..df1fe418d57 100644 --- a/bfd/elfxx-tilegx.c +++ b/bfd/elfxx-tilegx.c @@ -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;