aboutsummaryrefslogtreecommitdiff
path: root/bfd/xcofflink.c
diff options
context:
space:
mode:
authorCl?ment Chigot <clement.chigot@atos.net>2021-04-20 14:40:43 +0100
committerNick Clifton <nickc@redhat.com>2021-04-20 14:40:43 +0100
commitc5df7e442e6cdc9303b7373842370d6ee8f67ea5 (patch)
tree28e1442062fdbb13b5c46d98ceeba9c556e6f3b0 /bfd/xcofflink.c
parentd549b029d6d622af531211ef4c7bc48cb5011d93 (diff)
downloadgdb-c5df7e442e6cdc9303b7373842370d6ee8f67ea5.zip
gdb-c5df7e442e6cdc9303b7373842370d6ee8f67ea5.tar.gz
gdb-c5df7e442e6cdc9303b7373842370d6ee8f67ea5.tar.bz2
Rework the R_NEG support on both gas and ld for the PowerPC AIX targets, in order to manage C++ exceptions built with GCC.
bfd PR binutils/21700 * reloc.c (BFD_RELOC_PPC_NEG): New relocation. * bfd-in2.h: Regenerate. * libbfd.h: Regenerate. * coff-rs6000.c (_bfd_xcoff_reloc_type_lookup): Add BFD_RELOC_PPC_NEG handler. (xcoff_reloc_type_neg): Correctly substract addend. * coff64-rs6000.c (xcoff64_howto_table): Add R_NEG_32 howto. (xcoff64_rtype2howto): Add handler for R_NEG_32. (xcoff64_reloc_type_lookup): Add BFD_RELOC_PPC_NEG handler. * xcofflink.c (xcoff_need_ldrel_p): Check output section for R_POS-like relocations. New argument added. (xcoff_mark): Adapt to new xcoff_need_ldrel_p argument. (xcoff_link_input_bfd): Likewise. gas * config/tc-ppc.c (ppc_get_csect_to_adjust): New function. (ppc_fix_adjustable): Manage fx_subsy part. (tc_gen_reloc): Create second relocation when both fx_addsy and fx_subsy are provided. * config/tc-ppc.h (RELOC_EXPANSION_POSSIBLE): New define. (MAX_RELOC_EXPANSION): Likewise. (TC_FORCE_RELOCATION_SUB_SAME): Likewise (UNDEFINED_DIFFERENCE_OK): Likewise * testsuite/gas/all/gas.exp: Skip difference between two undefined symbols test. ld * testsuite/ld-powerpc/aix52.exp: Add new test. * testsuite/ld-powerpc/aix-neg-reloc-32.d: New test. * testsuite/ld-powerpc/aix-neg-reloc-64.d: New test. * testsuite/ld-powerpc/aix-neg-reloc.ex: New test. * testsuite/ld-powerpc/aix-neg-reloc.s: New test.
Diffstat (limited to 'bfd/xcofflink.c')
-rw-r--r--bfd/xcofflink.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/bfd/xcofflink.c b/bfd/xcofflink.c
index f0e0fe7..1607cd5 100644
--- a/bfd/xcofflink.c
+++ b/bfd/xcofflink.c
@@ -2653,7 +2653,7 @@ xcoff_auto_export_p (struct bfd_link_info *info,
static bool
xcoff_need_ldrel_p (struct bfd_link_info *info, struct internal_reloc *rel,
- struct xcoff_link_hash_entry *h)
+ struct xcoff_link_hash_entry *h, asection *ssec)
{
if (!xcoff_hash_table (info)->loader_section)
return false;
@@ -2701,6 +2701,14 @@ xcoff_need_ldrel_p (struct bfd_link_info *info, struct internal_reloc *rel,
&& bfd_is_abs_section (sec->output_section)))
return false;
}
+
+ /* Absolute relocations from read-only sections are forbidden
+ by AIX loader. However, they can appear in their section's
+ relocations. */
+ if (ssec != NULL
+ && (ssec->output_section->flags & SEC_READONLY) != 0)
+ return false;
+
return true;
case R_TLS:
@@ -2989,7 +2997,7 @@ xcoff_mark (struct bfd_link_info *info, asection *sec)
/* See if this reloc needs to be copied into the .loader
section. */
- if (xcoff_need_ldrel_p (info, rel, h))
+ if (xcoff_need_ldrel_p (info, rel, h, sec))
{
++xcoff_hash_table (info)->ldrel_count;
if (h != NULL)
@@ -4982,7 +4990,7 @@ xcoff_link_input_bfd (struct xcoff_final_link_info *flinfo,
}
if ((o->flags & SEC_DEBUGGING) == 0
- && xcoff_need_ldrel_p (flinfo->info, irel, h))
+ && xcoff_need_ldrel_p (flinfo->info, irel, h, o))
{
asection *sec;