From 28602ebff6fc81337532d280732b52df407b394f Mon Sep 17 00:00:00 2001 From: Kaz Kojima Date: Thu, 3 Oct 2002 04:58:28 +0000 Subject: [PATCH] * contig/tc-sh.c (sh_local_pcrel): New. (sh_force_relocation): Use sh_local_pcrel. (md_pcrel_from_section): Check the relocation type whether it should be resolved locally. Use S_FORCE_RELOC. * testsuite/gas/sh/pcrel2.d: Check code also. --- gas/ChangeLog | 7 +++++++ gas/config/tc-sh.c | 33 +++++++++++++++++++++------------ gas/testsuite/ChangeLog | 4 ++++ gas/testsuite/gas/sh/pcrel2.d | 20 +++++++++++++++++++- 4 files changed, 51 insertions(+), 13 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 155b113e408..ed37bd25ec8 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,10 @@ +2002-10-03 Kaz Kojima + + * contig/tc-sh.c (sh_local_pcrel): New. + (sh_force_relocation): Use sh_local_pcrel. + (md_pcrel_from_section): Check the relocation type whether it + should be resolved locally. Use S_FORCE_RELOC. + 2002-10-01 Alan Modra * config/tc-mips.h (TC_FORCE_RELOCATION_SUB_SAME): Define. diff --git a/gas/config/tc-sh.c b/gas/config/tc-sh.c index be5e8578325..a2e53d50ead 100644 --- a/gas/config/tc-sh.c +++ b/gas/config/tc-sh.c @@ -71,6 +71,7 @@ static void build_relax PARAMS ((sh_opcode_info *, sh_operand_info *)); static char *insert_loop_bounds PARAMS ((char *, sh_operand_info *)); static unsigned int build_Mytes PARAMS ((sh_opcode_info *, sh_operand_info *)); +static boolean sh_local_pcrel PARAMS ((fixS *fix)); #ifdef OBJ_ELF static void sh_elf_cons PARAMS ((int)); @@ -3211,6 +3212,22 @@ sh_handle_align (frag) BFD_RELOC_SH_ALIGN); } +/* See whether the relocation should be resolved locally. */ + +static boolean +sh_local_pcrel (fix) + fixS *fix; +{ + return (! sh_relax && + (fix->fx_r_type == BFD_RELOC_SH_PCDISP8BY2 + || fix->fx_r_type == BFD_RELOC_SH_PCDISP12BY2 + || fix->fx_r_type == BFD_RELOC_SH_PCRELIMM8BY2 + || fix->fx_r_type == BFD_RELOC_SH_PCRELIMM8BY4 + || fix->fx_r_type == BFD_RELOC_8_PCREL + || fix->fx_r_type == BFD_RELOC_SH_SWITCH16 + || fix->fx_r_type == BFD_RELOC_SH_SWITCH32)); +} + /* See whether we need to force a relocation into the output file. This is used to force out switch and PC relative relocations when relaxing. */ @@ -3221,14 +3238,7 @@ sh_force_relocation (fix) { /* These relocations can't make it into a DSO, so no use forcing them for global symbols. */ - if (! sh_relax - && (fix->fx_r_type == BFD_RELOC_SH_PCDISP8BY2 - || fix->fx_r_type == BFD_RELOC_SH_PCDISP12BY2 - || fix->fx_r_type == BFD_RELOC_SH_PCRELIMM8BY2 - || fix->fx_r_type == BFD_RELOC_SH_PCRELIMM8BY4 - || fix->fx_r_type == BFD_RELOC_8_PCREL - || fix->fx_r_type == BFD_RELOC_SH_SWITCH16 - || fix->fx_r_type == BFD_RELOC_SH_SWITCH32)) + if (sh_local_pcrel (fix)) return 0; if (fix->fx_r_type == BFD_RELOC_VTABLE_INHERIT @@ -3684,10 +3694,9 @@ md_pcrel_from_section (fixP, sec) fixS *fixP; segT sec; { - if (fixP->fx_addsy != (symbolS *) NULL - && (! S_IS_DEFINED (fixP->fx_addsy) - || S_IS_EXTERN (fixP->fx_addsy) - || S_IS_WEAK (fixP->fx_addsy) + if (! sh_local_pcrel (fixP) + && fixP->fx_addsy != (symbolS *) NULL + && (S_FORCE_RELOC (fixP->fx_addsy) || S_GET_SEGMENT (fixP->fx_addsy) != sec)) { /* The symbol is undefined (or is defined but not in this section, diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog index 1b625c54164..6ba1a1953ab 100644 --- a/gas/testsuite/ChangeLog +++ b/gas/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2002-10-03 Kaz Kojima + + * testsuite/gas/sh/pcrel2.d: Check code also. + 2002-10-02 Stephen Clarke * gas/sh/sh64/ptc32-noexp-1.d: Adjust for changes to *ABS* diff --git a/gas/testsuite/gas/sh/pcrel2.d b/gas/testsuite/gas/sh/pcrel2.d index 9b363afc3a3..60a01df1cb7 100644 --- a/gas/testsuite/gas/sh/pcrel2.d +++ b/gas/testsuite/gas/sh/pcrel2.d @@ -1,5 +1,23 @@ #as: -big -#objdump: -r +#objdump: -drj.text #name: PC-relative loads .*: file format .*sh.* + +Disassembly of section \.text: + +00000000 : + 0: 8b 01 bf 6 + 2: d0 02 mov\.l c ,r0 ! 0x6 + 4: 90 02 mov\.w c ,r0 ! 0x0 + +00000006 : + 6: af fe bra 6 + 8: 00 09 nop + a: 00 09 nop + +0000000c : + c: 00 00 .*[ ]*.* + e: 00 06 .*[ ]*.* + 10: 00 0a .*[ ]*.* + 12: 0c 00 .*[ ]*.* -- 2.30.2