Fix sanitization problems in the BFD library when running the linker testsuite for the AVR target.

PR 26433
	* elf32-avr.c (avr_final_link_relocate):  Fix undefined shift
	behaviour.
	(avr_elf32_load_records_from_section): Use bfd_get_16 and
	bfd_get_32 to load values from potentially unaligned pointers.
This commit is contained in:
Nick Clifton 2020-08-26 17:43:39 +01:00
parent eae0b5c3b2
commit 8c51f2f291
2 changed files with 13 additions and 7 deletions

View file

@ -1,5 +1,11 @@
2020-08-26 Nick Clifton <nickc@redhat.com>
PR 26433
* elf32-avr.c (avr_final_link_relocate): Fix undefined shift
behaviour.
(avr_elf32_load_records_from_section): Use bfd_get_16 and
bfd_get_32 to load values from potentially unaligned pointers.
PR 26416
* elf64-alpha.c (elf64_alpha_relax_tls_get_addr): Test for and
ignore local symbols.

View file

@ -1052,7 +1052,7 @@ avr_final_link_relocate (reloc_howto_type * howto,
if (srel > ((1 << 7) - 1) || (srel < - (1 << 7)))
return bfd_reloc_overflow;
x = bfd_get_16 (input_bfd, contents);
x = (x & 0xfc07) | (((srel >> 1) << 3) & 0x3f8);
x = (x & 0xfc07) | (((srel >> 1) * 8) & 0x3f8);
bfd_put_16 (input_bfd, x, contents);
break;
@ -4039,7 +4039,7 @@ avr_elf32_load_records_from_section (bfd *abfd, asection *sec)
ptr++;
flags = *((bfd_byte *) ptr);
ptr++;
record_count = *((uint16_t *) ptr);
record_count = bfd_get_16 (abfd, ptr);
ptr+=2;
BFD_ASSERT (ptr - contents == AVR_PROPERTY_SECTION_HEADER_SIZE);
@ -4106,7 +4106,7 @@ avr_elf32_load_records_from_section (bfd *abfd, asection *sec)
}
}
address = *((uint32_t *) ptr);
address = bfd_get_32 (abfd, ptr);
ptr += 4;
size -= 4;
@ -4148,7 +4148,7 @@ avr_elf32_load_records_from_section (bfd *abfd, asection *sec)
/* Just a 4-byte fill to load. */
if (size < 4)
goto load_failed;
r_list->records [i].data.org.fill = *((uint32_t *) ptr);
r_list->records [i].data.org.fill = bfd_get_32 (abfd, ptr);
ptr += 4;
size -= 4;
break;
@ -4156,7 +4156,7 @@ avr_elf32_load_records_from_section (bfd *abfd, asection *sec)
/* Just a 4-byte alignment to load. */
if (size < 4)
goto load_failed;
r_list->records [i].data.align.bytes = *((uint32_t *) ptr);
r_list->records [i].data.align.bytes = bfd_get_32 (abfd, ptr);
ptr += 4;
size -= 4;
/* Just initialise PRECEDING_DELETED field, this field is
@ -4167,9 +4167,9 @@ avr_elf32_load_records_from_section (bfd *abfd, asection *sec)
/* A 4-byte alignment, and a 4-byte fill to load. */
if (size < 8)
goto load_failed;
r_list->records [i].data.align.bytes = *((uint32_t *) ptr);
r_list->records [i].data.align.bytes = bfd_get_32 (abfd, ptr);
ptr += 4;
r_list->records [i].data.align.fill = *((uint32_t *) ptr);
r_list->records [i].data.align.fill = bfd_get_32 (abfd, ptr);
ptr += 4;
size -= 8;
/* Just initialise PRECEDING_DELETED field, this field is