summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2003-04-30 12:03:58 +0000
committerNick Clifton <nickc@redhat.com>2003-04-30 12:03:58 +0000
commit60df917b23055bf020af8695de7c2ff9b7e16af4 (patch)
tree26bd2e98ed2682df1909a81c25514cc39543759a
parent3d9588a822e9806103498396bcbc87278ffdae6c (diff)
downloadgdb-60df917b23055bf020af8695de7c2ff9b7e16af4.tar.gz
Do not crash when encountering relocs against the *ABS* section.
-rw-r--r--bfd/ChangeLog5
-rw-r--r--bfd/elf32-h8300.c41
2 files changed, 33 insertions, 13 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index 51c0726875c..34883f6f660 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -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>
* elfxx-ia64.c (elfNN_ia64_relax_section): Relax ldxmov during
diff --git a/bfd/elf32-h8300.c b/bfd/elf32-h8300.c
index 6008d5dec2a..e43ed9d2ed3 100644
--- a/bfd/elf32-h8300.c
+++ b/bfd/elf32-h8300.c
@@ -778,9 +778,12 @@ elf32_h8_relax_section (abfd, sec, link_info, again)
isym = isymbuf + ELF32_R_SYM (irel->r_info);
sym_sec = bfd_section_from_elf_index (abfd, isym->st_shndx);
- symval = (isym->st_value
- + sym_sec->output_section->vma
- + sym_sec->output_offset);
+ symval = isym->st_value;
+ /* If the reloc is absolute, it will not have
+ a symbol or section associated with it. */
+ if (sym_sec)
+ symval += sym_sec->output_section->vma
+ + sym_sec->output_offset;
}
else
{
@@ -1082,6 +1085,7 @@ elf32_h8_relax_section (abfd, sec, link_info, again)
&& value >= 0xffff00
&& value <= 0xffffff))
{
+ bfd_boolean skip = FALSE;
unsigned char code;
/* 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);
- if ((code & 0xf0) == 0x00)
- bfd_put_8 (abfd,
- (code & 0xf) | 0x20,
- contents + irel->r_offset - 2);
- else if ((code & 0xf0) == 0x80)
- bfd_put_8 (abfd,
- (code & 0xf) | 0x30,
- contents + irel->r_offset - 2);
- else
- abort ();
+ switch (code & 0xf0)
+ {
+ case 0x00:
+ bfd_put_8 (abfd, (code & 0xf) | 0x20,
+ contents + irel->r_offset - 2);
+ break;
+ case 0x80:
+ bfd_put_8 (abfd, (code & 0xf) | 0x30,
+ contents + irel->r_offset - 2);
+ break;
+ case 0x20:
+ case 0xa0:
+ /* Skip 32bit versions. */
+ skip = TRUE;
+ break;
+ default:
+ abort ();
+ }
+
+ if (skip)
+ break;
/* Fix the relocation's type. */
irel->r_info = ELF32_R_INFO (ELF32_R_SYM (irel->r_info),