GNU Binutils with patches for OS216
Revisión | 1b7e3d2fb7036ce6f9d74e32dc052518f5cd45b6 (tree) |
---|---|
Tiempo | 2017-02-03 18:04:21 |
Autor | Nick Clifton <nickc@redh...> |
Commiter | Nick Clifton |
Fix compile time warning messages when compiling binutils with gcc 7.0.1.
PR 21096
bfd * coffcode.h (coff_write_object_contents): Enlarge size of
s_name_buf in order to avoid compile time warning about possible
integer truncation.
* elf32-nds32.c (nds32_elf_ex9_import_table): Mask off lower
32-bits of insn value before printing into buffer.
opcodes * aarch64-opc.c (print_register_list): Ensure that the register
list index will fir into the tb buffer.
(print_register_offset_address): Likewise.
* tic6x-dis.c (print_insn_tic6x): Increase size of func_unit_buf.
@@ -1,3 +1,12 @@ | ||
1 | +2017-02-03 Nick Clifton <nickc@redhat.com> | |
2 | + | |
3 | + PR 21096 | |
4 | + * coffcode.h (coff_write_object_contents): Enlarge size of | |
5 | + s_name_buf in order to avoid compile time warning about possible | |
6 | + integer truncation. | |
7 | + * elf32-nds32.c (nds32_elf_ex9_import_table): Mask off lower | |
8 | + 32-bits of insn value before printing into buffer. | |
9 | + | |
1 | 10 | 2017-02-02 Maciej W. Rozycki <macro@imgtec.com> |
2 | 11 | |
3 | 12 | * elfxx-mips.c (mips_elf_hash_sort_data): Add |
@@ -3755,7 +3755,9 @@ coff_write_object_contents (bfd * abfd) | ||
3755 | 3755 | NUL-terminated. We use a temporary buffer so that we can still |
3756 | 3756 | sprintf all eight chars without splatting a terminating NUL |
3757 | 3757 | over the first byte of the following member (s_paddr). */ |
3758 | - char s_name_buf[SCNNMLEN + 1]; | |
3758 | + /* PR 21096: The +20 is to stop a bogus warning from gcc7 about | |
3759 | + a possible buffer overflow. */ | |
3760 | + char s_name_buf[SCNNMLEN + 1 + 20]; | |
3759 | 3761 | |
3760 | 3762 | /* An inherent limitation of the /nnnnnnn notation used to indicate |
3761 | 3763 | the offset of the long name in the string table is that we |
@@ -3770,9 +3772,10 @@ coff_write_object_contents (bfd * abfd) | ||
3770 | 3772 | return FALSE; |
3771 | 3773 | } |
3772 | 3774 | |
3773 | - /* snprintf not strictly necessary now we've verified the value | |
3774 | - has less than eight ASCII digits, but never mind. */ | |
3775 | - snprintf (s_name_buf, SCNNMLEN + 1, "/%lu", (unsigned long) string_size); | |
3775 | + /* We do not need to use snprintf here as we have already verfied | |
3776 | + that string_size is not too big, plus we have an overlarge | |
3777 | + buffer, just in case. */ | |
3778 | + sprintf (s_name_buf, "/%lu", (unsigned long) string_size); | |
3776 | 3779 | /* Then strncpy takes care of any padding for us. */ |
3777 | 3780 | strncpy (section.s_name, s_name_buf, SCNNMLEN); |
3778 | 3781 | string_size += len + 1; |
@@ -14949,7 +14949,6 @@ nds32_elf_ex9_import_table (struct bfd_link_info *info) | ||
14949 | 14949 | { |
14950 | 14950 | int num = 0; |
14951 | 14951 | bfd_byte *contents; |
14952 | - unsigned long insn; | |
14953 | 14952 | FILE *ex9_import_file; |
14954 | 14953 | int update_ex9_table; |
14955 | 14954 | struct elf_nds32_link_hash_table *table; |
@@ -14963,6 +14962,7 @@ nds32_elf_ex9_import_table (struct bfd_link_info *info) | ||
14963 | 14962 | /* Read instructions from the input file and build the list. */ |
14964 | 14963 | while (!feof (ex9_import_file)) |
14965 | 14964 | { |
14965 | + unsigned long insn; | |
14966 | 14966 | char *code; |
14967 | 14967 | struct elf_nds32_insn_times_entry *ptr; |
14968 | 14968 | size_t nread; |
@@ -14973,7 +14973,7 @@ nds32_elf_ex9_import_table (struct bfd_link_info *info) | ||
14973 | 14973 | break; |
14974 | 14974 | insn = bfd_getb32 (contents); |
14975 | 14975 | code = bfd_malloc (sizeof (char) * 9); |
14976 | - snprintf (code, 9, "%08lx", insn); | |
14976 | + snprintf (code, 9, "%08lx", (insn & 0xffffffff)); | |
14977 | 14977 | ptr = bfd_malloc (sizeof (struct elf_nds32_insn_times_entry)); |
14978 | 14978 | ptr->string = code; |
14979 | 14979 | ptr->order = num; |
@@ -1,3 +1,11 @@ | ||
1 | +2017-02-03 Nick Clifton <nickc@redhat.com> | |
2 | + | |
3 | + PR 21096 | |
4 | + * aarch64-opc.c (print_register_list): Ensure that the register | |
5 | + list index will fir into the tb buffer. | |
6 | + (print_register_offset_address): Likewise. | |
7 | + * tic6x-dis.c (print_insn_tic6x): Increase size of func_unit_buf. | |
8 | + | |
1 | 9 | 2017-01-27 Alexis Deruell <alexis.deruelle@gmail.com> |
2 | 10 | |
3 | 11 | PR 21056 |
@@ -2865,7 +2865,8 @@ print_register_list (char *buf, size_t size, const aarch64_opnd_info *opnd, | ||
2865 | 2865 | |
2866 | 2866 | /* Prepare the index if any. */ |
2867 | 2867 | if (opnd->reglist.has_index) |
2868 | - snprintf (tb, 8, "[%" PRIi64 "]", opnd->reglist.index); | |
2868 | + /* PR 21096: The %100 is to silence a warning about possible truncation. */ | |
2869 | + snprintf (tb, 8, "[%" PRIi64 "]", (opnd->reglist.index % 100)); | |
2869 | 2870 | else |
2870 | 2871 | tb[0] = '\0'; |
2871 | 2872 |
@@ -2965,7 +2966,8 @@ print_register_offset_address (char *buf, size_t size, | ||
2965 | 2966 | { |
2966 | 2967 | if (print_amount_p) |
2967 | 2968 | snprintf (tb, sizeof (tb), ", %s #%" PRIi64, shift_name, |
2968 | - opnd->shifter.amount); | |
2969 | + /* PR 21096: The %100 is to silence a warning about possible truncation. */ | |
2970 | + (opnd->shifter.amount % 100)); | |
2969 | 2971 | else |
2970 | 2972 | snprintf (tb, sizeof (tb), ", %s", shift_name); |
2971 | 2973 | } |
@@ -316,7 +316,7 @@ print_insn_tic6x (bfd_vma addr, struct disassemble_info *info) | ||
316 | 316 | const char *parallel; |
317 | 317 | const char *cond = ""; |
318 | 318 | const char *func_unit; |
319 | - char func_unit_buf[7]; | |
319 | + char func_unit_buf[8]; | |
320 | 320 | unsigned int func_unit_side = 0; |
321 | 321 | unsigned int func_unit_data_side = 0; |
322 | 322 | unsigned int func_unit_cross = 0; |
@@ -703,8 +703,9 @@ print_insn_tic6x (bfd_vma addr, struct disassemble_info *info) | ||
703 | 703 | if (opc->flags & TIC6X_FLAG_INSN16_BSIDE && func_unit_side == 1) |
704 | 704 | func_unit_cross = 1; |
705 | 705 | |
706 | - snprintf (func_unit_buf, 7, " .%c%u%s%s", func_unit_char, | |
707 | - func_unit_side, (func_unit_cross ? "X" : ""), data_str); | |
706 | + snprintf (func_unit_buf, sizeof func_unit_buf, " .%c%u%s%s", | |
707 | + func_unit_char, func_unit_side, | |
708 | + (func_unit_cross ? "X" : ""), data_str); | |
708 | 709 | func_unit = func_unit_buf; |
709 | 710 | } |
710 | 711 |