Do not crash when encountering relocs against the *ABS* section.

This commit is contained in:
Nick Clifton 2003-04-30 12:03:58 +00:00
parent a9fa03de24
commit 03d14457a6
2 changed files with 33 additions and 13 deletions

View File

@ -1,3 +1,8 @@
2003-04-30 Nick Clifton <nickc@redhat.com>
* elf32-h8300.c (elf32_h8_relax_section): Do not crash when
encountering relocs against the *ABS* section.
2003-04-28 H.J. Lu <hjl@gnu.org> 2003-04-28 H.J. Lu <hjl@gnu.org>
* elfxx-ia64.c (elfNN_ia64_relax_section): Relax ldxmov during * elfxx-ia64.c (elfNN_ia64_relax_section): Relax ldxmov during

View File

@ -778,9 +778,12 @@ elf32_h8_relax_section (abfd, sec, link_info, again)
isym = isymbuf + ELF32_R_SYM (irel->r_info); isym = isymbuf + ELF32_R_SYM (irel->r_info);
sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx); sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
symval = (isym->st_value symval = isym->st_value;
+ sym_sec->output_section->vma /* If the reloc is absolute, it will not have
+ sym_sec->output_offset); a symbol or section associated with it. */
if (sym_sec)
symval += sym_sec->output_section->vma
+ sym_sec->output_offset;
} }
else else
{ {
@ -1082,6 +1085,7 @@ elf32_h8_relax_section (abfd, sec, link_info, again)
&& value >= 0xffff00 && value >= 0xffff00
&& value <= 0xffffff)) && value <= 0xffffff))
{ {
bfd_boolean skip = FALSE;
unsigned char code; unsigned char code;
/* Note that we've changed the relocs, section contents, /* Note that we've changed the relocs, section contents,
@ -1099,16 +1103,27 @@ elf32_h8_relax_section (abfd, sec, link_info, again)
code = bfd_get_8 (abfd, contents + irel->r_offset - 1); code = bfd_get_8 (abfd, contents + irel->r_offset - 1);
if ((code & 0xf0) == 0x00) switch (code & 0xf0)
bfd_put_8 (abfd, {
(code & 0xf) | 0x20, case 0x00:
contents + irel->r_offset - 2); bfd_put_8 (abfd, (code & 0xf) | 0x20,
else if ((code & 0xf0) == 0x80) contents + irel->r_offset - 2);
bfd_put_8 (abfd, break;
(code & 0xf) | 0x30, case 0x80:
contents + irel->r_offset - 2); bfd_put_8 (abfd, (code & 0xf) | 0x30,
else contents + irel->r_offset - 2);
abort (); break;
case 0x20:
case 0xa0:
/* Skip 32bit versions. */
skip = TRUE;
break;
default:
abort ();
}
if (skip)
break;
/* Fix the relocation's type. */ /* Fix the relocation's type. */
irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info), irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),