diff options
author | Alexandre Oliva <aoliva@redhat.com> | 2001-05-13 23:16:30 +0000 |
---|---|---|
committer | Alexandre Oliva <aoliva@redhat.com> | 2001-05-13 23:16:30 +0000 |
commit | 4e75439ae5c103f6e123a54d5e2bde10382186b8 (patch) | |
tree | 9acaa69b50014fe4888c00482c7e2450cb555e49 /gas | |
parent | fb18ec4a20a034bad4acb16319f213918a9e61f9 (diff) | |
download | gdb-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')
-rw-r--r-- | gas/ChangeLog | 6 | ||||
-rw-r--r-- | gas/config/tc-mn10300.c | 39 |
2 files changed, 45 insertions, 0 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog index f0de913..022709c 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,9 @@ +2001-05-13 Alexandre Oliva <aoliva@redhat.com> + + * 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 <peter.targett@arccores.com> * 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 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) |