From: Janne Ramstedt Date: Sun, 25 May 2025 17:17:20 +0000 (+0300) Subject: alpha, bfd: Fixes for ALPHA_R_OP_STORE X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3e02c4891dcb37a0a12cff53232342f6d160b2c5;p=thirdparty%2Fbinutils-gdb.git alpha, bfd: Fixes for ALPHA_R_OP_STORE ALPHA_R_OP_STORE copies one byte too many and also will cause out of range error when it tries to copy from the end of section. Since "endbyte" is already rounded to next full byte, there is enough bits to copy and the additional "+ 1" is erroneous in bytes count. I also believe size is incorrectly decreased. --- diff --git a/bfd/coff-alpha.c b/bfd/coff-alpha.c index e2f1a4d2808..60d85bbf707 100644 --- a/bfd/coff-alpha.c +++ b/bfd/coff-alpha.c @@ -1007,7 +1007,7 @@ alpha_ecoff_get_relocated_section_contents (bfd *abfd, unsigned int size = rel->addend & 0xff; unsigned int startbyte = offset >> 3; unsigned int endbyte = (offset + size + 7) >> 3; - unsigned int bytes = endbyte + 1 - startbyte; + unsigned int bytes = endbyte - startbyte; if (bytes <= 8 && rel->address + startbyte + bytes >= rel->address @@ -1019,7 +1019,6 @@ alpha_ecoff_get_relocated_section_contents (bfd *abfd, val = (val << 8) | data[rel->address + startbyte + off]; offset -= startbyte << 3; - size -= startbyte << 3; uint64_t mask = (((uint64_t) 1 << size) - 1) << offset; val = (val & ~mask) | ((stack[--tos] << offset) & mask); @@ -1781,7 +1780,7 @@ alpha_relocate_section (bfd *output_bfd, { unsigned int startbyte = r_offset >> 3; unsigned int endbyte = (r_offset + r_size + 7) >> 3; - unsigned int bytes = endbyte + 1 - startbyte; + unsigned int bytes = endbyte - startbyte; if (bytes <= 8 && r_vaddr >= input_section->vma @@ -1795,7 +1794,6 @@ alpha_relocate_section (bfd *output_bfd, val = (val << 8) | p[startbyte + off]; r_offset -= startbyte << 3; - r_size -= startbyte << 3; uint64_t mask = (((uint64_t) 1 << r_size) - 1) << r_offset; val = (val & ~mask) | ((stack[--tos] << r_offset) & mask);