aboutsummaryrefslogtreecommitdiff
path: root/gas/config/tc-mn10300.c
diff options
context:
space:
mode:
authorAlexandre Oliva <aoliva@redhat.com>2001-05-13 23:16:30 +0000
committerAlexandre Oliva <aoliva@redhat.com>2001-05-13 23:16:30 +0000
commit4e75439ae5c103f6e123a54d5e2bde10382186b8 (patch)
tree9acaa69b50014fe4888c00482c7e2450cb555e49 /gas/config/tc-mn10300.c
parentfb18ec4a20a034bad4acb16319f213918a9e61f9 (diff)
downloadgdb-4e75439ae5c103f6e123a54d5e2bde10382186b8.zip
gdb-4e75439ae5c103f6e123a54d5e2bde10382186b8.tar.gz
gdb-4e75439ae5c103f6e123a54d5e2bde10382186b8.tar.bz2
* config/tc-mn10300.c (tc_gen_reloc): Don't reject differences
between symbols if the base symbol is in the current section; emit a PC-relative relocation instead.
Diffstat (limited to 'gas/config/tc-mn10300.c')
-rw-r--r--gas/config/tc-mn10300.c39
1 files changed, 39 insertions, 0 deletions
diff --git a/gas/config/tc-mn10300.c b/gas/config/tc-mn10300.c
index 5e2ba77..8bda064 100644
--- a/gas/config/tc-mn10300.c
+++ b/gas/config/tc-mn10300.c
@@ -1798,6 +1798,45 @@ tc_gen_reloc (seg, fixp)
if (fixp->fx_addsy && fixp->fx_subsy)
{
+ /* If we got a difference between two symbols, and the
+ subtracted symbol is in the current section, use a
+ PC-relative relocation. If both symbols are in the same
+ section, the difference would have already been simplified
+ to a constant. */
+ if (S_GET_SEGMENT (fixp->fx_subsy) == seg)
+ {
+ reloc->sym_ptr_ptr = (asymbol **) xmalloc (sizeof (asymbol *));
+ *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
+ reloc->addend = (reloc->address - S_GET_VALUE (fixp->fx_subsy)
+ + fixp->fx_offset);
+
+ switch (fixp->fx_r_type)
+ {
+ case BFD_RELOC_8:
+ reloc->howto = bfd_reloc_type_lookup (stdoutput,
+ BFD_RELOC_8_PCREL);
+ return reloc;
+
+ case BFD_RELOC_16:
+ reloc->howto = bfd_reloc_type_lookup (stdoutput,
+ BFD_RELOC_16_PCREL);
+ return reloc;
+
+ case BFD_RELOC_24:
+ reloc->howto = bfd_reloc_type_lookup (stdoutput,
+ BFD_RELOC_24_PCREL);
+ return reloc;
+
+ case BFD_RELOC_32:
+ reloc->howto = bfd_reloc_type_lookup (stdoutput,
+ BFD_RELOC_32_PCREL);
+ return reloc;
+
+ default:
+ /* Try to compute the absolute value below. */
+ break;
+ }
+ }
if ((S_GET_SEGMENT (fixp->fx_addsy) != S_GET_SEGMENT (fixp->fx_subsy))
|| S_GET_SEGMENT (fixp->fx_addsy) == undefined_section)