diff options
-rw-r--r-- | bfd/elf32-ppc.c | 44 | ||||
-rw-r--r-- | bfd/version.h | 2 | ||||
-rw-r--r-- | gas/config/tc-nds32.c | 17 | ||||
-rw-r--r-- | gas/testsuite/gas/nds32/nds32.exp | 22 | ||||
-rw-r--r-- | gas/testsuite/gas/nds32/pr33229.d | 2 | ||||
-rw-r--r-- | gas/testsuite/gas/nds32/pr33229.s | 3 |
6 files changed, 41 insertions, 49 deletions
diff --git a/bfd/elf32-ppc.c b/bfd/elf32-ppc.c index 3fd9f28..1ed995b 100644 --- a/bfd/elf32-ppc.c +++ b/bfd/elf32-ppc.c @@ -53,6 +53,10 @@ static bfd_reloc_status_type ppc_elf_addr16_ha_reloc static bfd_reloc_status_type ppc_elf_unhandled_reloc (bfd *, arelent *, asymbol *, void *, asection *, bfd *, char **); +#ifndef ARRAY_SIZE +#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0])) +#endif + /* Branch prediction bit for branch taken relocs. */ #define BRANCH_PREDICT_BIT 0x200000 /* Mask to set RA in memory instructions. */ @@ -702,13 +706,10 @@ ppc_elf_howto_init (void) { unsigned int i, type; - for (i = 0; - i < sizeof (ppc_elf_howto_raw) / sizeof (ppc_elf_howto_raw[0]); - i++) + for (i = 0; i < ARRAY_SIZE (ppc_elf_howto_raw); i++) { type = ppc_elf_howto_raw[i].type; - if (type >= (sizeof (ppc_elf_howto_table) - / sizeof (ppc_elf_howto_table[0]))) + if (type >= ARRAY_SIZE (ppc_elf_howto_table)) abort (); ppc_elf_howto_table[type] = &ppc_elf_howto_raw[i]; } @@ -870,9 +871,7 @@ ppc_elf_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED, { unsigned int i; - for (i = 0; - i < sizeof (ppc_elf_howto_raw) / sizeof (ppc_elf_howto_raw[0]); - i++) + for (i = 0; i < ARRAY_SIZE (ppc_elf_howto_raw); i++) if (ppc_elf_howto_raw[i].name != NULL && strcasecmp (ppc_elf_howto_raw[i].name, r_name) == 0) return &ppc_elf_howto_raw[i]; @@ -894,7 +893,8 @@ ppc_elf_info_to_howto (bfd *abfd, ppc_elf_howto_init (); r_type = ELF32_R_TYPE (dst->r_info); - if (r_type >= R_PPC_max) + if (r_type >= ARRAY_SIZE (ppc_elf_howto_table) + || ppc_elf_howto_table[r_type] == NULL) { /* xgettext:c-format */ _bfd_error_handler (_("%pB: unsupported relocation type %#x"), @@ -904,19 +904,6 @@ ppc_elf_info_to_howto (bfd *abfd, } cache_ptr->howto = ppc_elf_howto_table[r_type]; - - /* Just because the above assert didn't trigger doesn't mean that - ELF32_R_TYPE (dst->r_info) is necessarily a valid relocation. */ - if (cache_ptr->howto == NULL) - { - /* xgettext:c-format */ - _bfd_error_handler (_("%pB: unsupported relocation type %#x"), - abfd, r_type); - bfd_set_error (bfd_error_bad_value); - - return false; - } - return true; } @@ -7088,12 +7075,11 @@ ppc_elf_relocate_section (bfd *output_bfd, /* For relocs against symbols from removed linkonce sections, or sections discarded by a linker script, we just want the section contents zeroed. Avoid any special processing. */ - howto = NULL; - if (r_type < R_PPC_max) - howto = ppc_elf_howto_table[r_type]; - - _bfd_clear_contents (howto, input_bfd, input_section, - contents, rel->r_offset); + if (r_type < ARRAY_SIZE (ppc_elf_howto_table) + && ppc_elf_howto_table[r_type] != NULL) + _bfd_clear_contents (ppc_elf_howto_table[r_type], + input_bfd, input_section, + contents, rel->r_offset); wrel->r_offset = rel->r_offset; wrel->r_info = 0; wrel->r_addend = 0; @@ -7653,7 +7639,7 @@ ppc_elf_relocate_section (bfd *output_bfd, addend = rel->r_addend; save_unresolved_reloc = unresolved_reloc; howto = NULL; - if (r_type < R_PPC_max) + if (r_type < ARRAY_SIZE (ppc_elf_howto_table)) howto = ppc_elf_howto_table[r_type]; tls_type = 0; diff --git a/bfd/version.h b/bfd/version.h index c4f5e1b..33e2b9c 100644 --- a/bfd/version.h +++ b/bfd/version.h @@ -16,7 +16,7 @@ In releases, the date is not included in either version strings or sonames. */ -#define BFD_VERSION_DATE 20250729 +#define BFD_VERSION_DATE 20250731 #define BFD_VERSION @bfd_version@ #define BFD_VERSION_STRING @bfd_version_package@ @bfd_version_string@ #define REPORT_BUGS_TO @report_bugs_to@ diff --git a/gas/config/tc-nds32.c b/gas/config/tc-nds32.c index 647744f..d107555 100644 --- a/gas/config/tc-nds32.c +++ b/gas/config/tc-nds32.c @@ -3452,8 +3452,9 @@ nds32_lookup_pseudo_opcode (const char *str) for (i = 0; i < maxlen; i++) { - if (is_whitespace (op[i] = str[i])) + if (is_end_of_stmt (str[i]) || is_whitespace (str[i])) break; + op[i] = str[i]; } op[i] = '\0'; @@ -4093,7 +4094,8 @@ nds32_relax_relocs (int relax) {"", "",}; name = input_line_pointer; - while (*input_line_pointer && !is_whitespace (*input_line_pointer)) + while (!is_end_of_stmt (*input_line_pointer) + && !is_whitespace (*input_line_pointer)) input_line_pointer++; saved_char = *input_line_pointer; *input_line_pointer = 0; @@ -4228,7 +4230,8 @@ nds32_relax_hint (int mode ATTRIBUTE_UNUSED) struct relax_hint_id *record_id; name = input_line_pointer; - while (*input_line_pointer && !is_whitespace (*input_line_pointer)) + while (!is_end_of_stmt (*input_line_pointer) + && !is_whitespace (*input_line_pointer)) input_line_pointer++; saved_char = *input_line_pointer; *input_line_pointer = 0; @@ -4361,7 +4364,8 @@ nds32_flag (int ignore ATTRIBUTE_UNUSED) /* Skip whitespaces. */ name = input_line_pointer; - while (*input_line_pointer && !is_whitespace (*input_line_pointer)) + while (!is_end_of_stmt (*input_line_pointer) + && !is_whitespace (*input_line_pointer)) input_line_pointer++; saved_char = *input_line_pointer; *input_line_pointer = 0; @@ -4398,7 +4402,8 @@ ict_model (int ignore ATTRIBUTE_UNUSED) /* Skip whitespaces. */ name = input_line_pointer; - while (*input_line_pointer && !is_whitespace (*input_line_pointer)) + while (!is_end_of_stmt (*input_line_pointer) + && !is_whitespace (*input_line_pointer)) input_line_pointer++; saved_char = *input_line_pointer; *input_line_pointer = 0; @@ -5944,7 +5949,7 @@ nds32_elf_append_relax_relocs (const char *key, const void *value) char *where; int pcrel; - if (!relocs_pattern) + if (!relocs_pattern || !relocs_pattern->opcode) return; if (!nds32_find_reloc_table (relocs_pattern, &hint_info)) diff --git a/gas/testsuite/gas/nds32/nds32.exp b/gas/testsuite/gas/nds32/nds32.exp index 82934ce..216fcf1 100644 --- a/gas/testsuite/gas/nds32/nds32.exp +++ b/gas/testsuite/gas/nds32/nds32.exp @@ -16,17 +16,13 @@ # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, # MA 02110-1301, USA. -if { [istarget nds32*] } { - run_dump_test "alu-1" - run_dump_test "alu-2" - run_dump_test "lsi" - run_dump_test "ls" - run_dump_test "br-1" - run_dump_test "br-2" - run_dump_test "ji-jr" - run_dump_test "to-16bit-v1" - run_dump_test "to-16bit-v2" - run_dump_test "to-16bit-v3" - run_dump_test "usr-spe-reg" - run_dump_test "sys-reg" +if { ![istarget nds32*] } { + return +} + +set test_list [lsort [glob -nocomplain $srcdir/$subdir/*.d]] +foreach t $test_list { + # We need to strip the ".d", but can leave the dirname. + verbose [file rootname $t] + run_dump_test [file rootname $t] } diff --git a/gas/testsuite/gas/nds32/pr33229.d b/gas/testsuite/gas/nds32/pr33229.d new file mode 100644 index 0000000..e65ca41 --- /dev/null +++ b/gas/testsuite/gas/nds32/pr33229.d @@ -0,0 +1,2 @@ +#as: --fatal-warnings +#error: .*relax hint.* diff --git a/gas/testsuite/gas/nds32/pr33229.s b/gas/testsuite/gas/nds32/pr33229.s new file mode 100644 index 0000000..3127d6d --- /dev/null +++ b/gas/testsuite/gas/nds32/pr33229.s @@ -0,0 +1,3 @@ + .relax_hint 0 + ret5 + .relax_hint 1 |