aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn David Anglin <danglin@gcc.gnu.org>2024-07-14 07:22:13 -0400
committerJohn David Anglin <danglin@gcc.gnu.org>2024-07-14 07:25:17 -0400
commit92cc764e58fac1c0c5c9e5c7a7547fbd9e7dcfd4 (patch)
treedfb4cf65fffc1b7b269927239ffe2e4d0af8fe6d
parentfbfdb7bbec1a016c70eab500e0f825fad77b937c (diff)
downloadbinutils-92cc764e58fac1c0c5c9e5c7a7547fbd9e7dcfd4.zip
binutils-92cc764e58fac1c0c5c9e5c7a7547fbd9e7dcfd4.tar.gz
binutils-92cc764e58fac1c0c5c9e5c7a7547fbd9e7dcfd4.tar.bz2
hppa: Fix handling of relocations that apply to data
Commit d125f9675372b1ae01ceb1893c06ccb27bc7bf22 introduced a bug in handling relocations for data. The R_PARISC_DIR32 relocation operates on 32-bit data and not instructions. The HOWTO table needs to be used to determine the format of relocations that apply to data. The R_PARISC_SEGBASE relocation is another special case as it only changes segment base. This was noticed in Debian cmor package build. 2024-07-14 John David Anglin <danglin@gcc.gnu.org> bfd/ChangeLog: * elf32-hppa.c (final_link_relocate): Use HOWTO table to determine reload format for relocations that apply to data.
-rw-r--r--bfd/elf32-hppa.c88
1 files changed, 51 insertions, 37 deletions
diff --git a/bfd/elf32-hppa.c b/bfd/elf32-hppa.c
index 99ec789..c2a7ad9 100644
--- a/bfd/elf32-hppa.c
+++ b/bfd/elf32-hppa.c
@@ -3432,48 +3432,62 @@ final_link_relocate (asection *input_section,
break;
}
- r_format = bfd_hppa_insn2fmt (input_bfd, insn);
- switch (r_format)
+ switch (r_type)
{
- case 10:
- case -10:
- if (val & 7)
- {
- _bfd_error_handler
- /* xgettext:c-format */
- (_("%pB(%pA+%#" PRIx64 "): displacement %#x for insn %#x "
- "is not a multiple of 8 (gp %#x)"),
- input_bfd,
- input_section,
- (uint64_t) offset,
- val,
- insn,
- (unsigned int) elf_gp (input_section->output_section->owner));
- bfd_set_error (bfd_error_bad_value);
- return bfd_reloc_notsupported;
- }
+ case R_PARISC_DIR32:
+ case R_PARISC_SECREL32:
+ case R_PARISC_SEGBASE:
+ case R_PARISC_SEGREL32:
+ case R_PARISC_PLABEL32:
+ /* These relocations apply to data. */
+ r_format = howto->bitsize;
break;
- case -11:
- case -16:
- if (val & 3)
+ default:
+ r_format = bfd_hppa_insn2fmt (input_bfd, insn);
+ switch (r_format)
{
- _bfd_error_handler
- /* xgettext:c-format */
- (_("%pB(%pA+%#" PRIx64 "): displacement %#x for insn %#x "
- "is not a multiple of 4 (gp %#x)"),
- input_bfd,
- input_section,
- (uint64_t) offset,
- val,
- insn,
- (unsigned int) elf_gp (input_section->output_section->owner));
- bfd_set_error (bfd_error_bad_value);
- return bfd_reloc_notsupported;
- }
- break;
+ case 10:
+ case -10:
+ if (val & 7)
+ {
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("%pB(%pA+%#" PRIx64 "): displacement %#x for insn %#x "
+ "is not a multiple of 8 (gp %#x)"),
+ input_bfd,
+ input_section,
+ (uint64_t) offset,
+ val,
+ insn,
+ (unsigned int) elf_gp (input_section->output_section->owner));
+ bfd_set_error (bfd_error_bad_value);
+ return bfd_reloc_notsupported;
+ }
+ break;
- default:
+ case -11:
+ case -16:
+ if (val & 3)
+ {
+ _bfd_error_handler
+ /* xgettext:c-format */
+ (_("%pB(%pA+%#" PRIx64 "): displacement %#x for insn %#x "
+ "is not a multiple of 4 (gp %#x)"),
+ input_bfd,
+ input_section,
+ (uint64_t) offset,
+ val,
+ insn,
+ (unsigned int) elf_gp (input_section->output_section->owner));
+ bfd_set_error (bfd_error_bad_value);
+ return bfd_reloc_notsupported;
+ }
+ break;
+
+ default:
+ break;
+ }
break;
}
insn = hppa_rebuild_insn (insn, val, r_format);