From 4e75439ae5c103f6e123a54d5e2bde10382186b8 Mon Sep 17 00:00:00 2001 From: Alexandre Oliva Date: Sun, 13 May 2001 23:16:30 +0000 Subject: [PATCH] * 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. --- gas/ChangeLog | 6 ++++++ gas/config/tc-mn10300.c | 39 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) diff --git a/gas/ChangeLog b/gas/ChangeLog index f0de9133427..022709c876f 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2001-05-13 Alexandre Oliva + + * 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. + 2001-05-12 Peter Targett * config/tc-arc.c: Update copyright and tidy source comments. diff --git a/gas/config/tc-mn10300.c b/gas/config/tc-mn10300.c index 5e2ba77b92b..8bda0649e2d 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) -- 2.30.2