From 25b1cdd0f302f6fad4482ef1a1a0a5527be7878b Mon Sep 17 00:00:00 2001 From: Michael Meissner Date: Fri, 22 Sep 1995 20:42:38 +0000 Subject: [PATCH] start at handling branch taken/branch not taken hints. --- gas/ChangeLog | 7 +++++ gas/config/tc-ppc.c | 72 +++++++++++++++++++++++++-------------------- 2 files changed, 47 insertions(+), 32 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index ac958583fdd..f26eb85eb4c 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,10 @@ +Fri Sep 22 16:34:46 1995 Michael Meissner + + * config/tc-ppc.c (ppc_elf_suffix): Rewrite to use a table of + strings and relocations they represent. Add @br{,n}taken for + branch taken/not taken support. + (md_apply_fix3): Add BFD_RELOC_PPC_B16_BR{,N}TAKEN support. + Thu Sep 21 21:10:17 1995 Michael Meissner * config/tc-ppc.c (md_parse_option): -mrelocatable-lib now only diff --git a/gas/config/tc-ppc.c b/gas/config/tc-ppc.c index 01f152fc64d..435d0fb0190 100644 --- a/gas/config/tc-ppc.c +++ b/gas/config/tc-ppc.c @@ -554,41 +554,46 @@ static bfd_reloc_code_real_type ppc_elf_suffix (str_p) char **str_p; { - char *str = *str_p; + struct map_bfd { + char *string; + int length; + bfd_reloc_code_real_type reloc; + }; - if (*str != '@') + char *str = *str_p; + int ch; + struct map_bfd *ptr; + + static struct map_bfd mapping[] = { + { "GOT", 3, BFD_RELOC_PPC_TOC16 }, + { "got", 3, BFD_RELOC_PPC_TOC16 }, + { "L", 1, BFD_RELOC_LO16 }, + { "l", 1, BFD_RELOC_LO16 }, + { "HA", 2, BFD_RELOC_HI16_S }, + { "ha", 2, BFD_RELOC_HI16_S }, + { "H", 1, BFD_RELOC_HI16 }, + { "h", 1, BFD_RELOC_HI16 }, + { "SDAREL", 6, BFD_RELOC_GPREL16 }, + { "sdarel", 6, BFD_RELOC_GPREL16 }, + { "FIXUP", 5, BFD_RELOC_CTOR }, /* synonym for BFD_RELOC_32 that doesn't get */ + { "fixup", 5, BFD_RELOC_CTOR }, /* warnings with -mrelocatable */ + { "BRTAKEN", 7, BFD_RELOC_PPC_B16_BRTAKEN }, + { "brtaken", 7, BFD_RELOC_PPC_B16_BRTAKEN }, + { "BRNTAKEN", 8, BFD_RELOC_PPC_B16_BRNTAKEN }, + { "brntaken", 8, BFD_RELOC_PPC_B16_BRNTAKEN }, + { (char *)0, 0, BFD_RELOC_UNUSED } + }; + + if (*str++ != '@') return BFD_RELOC_UNUSED; - if (strncmp (str, "@GOT", 4) == 0 || strncmp (str, "@got", 4) == 0) - { - *str_p += 4; - return BFD_RELOC_PPC_TOC16; - } - else if (strncmp (str, "@L", 2) == 0 || strncmp (str, "@l", 2) == 0) - { - *str_p += 2; - return BFD_RELOC_LO16; - } - else if (strncmp (str, "@HA", 3) == 0 || strncmp (str, "@ha", 3) == 0) - { - *str_p += 3; - return BFD_RELOC_HI16_S; - } - else if (strncmp (str, "@H", 2) == 0 || strncmp (str, "@h", 2) == 0) - { - *str_p += 2; - return BFD_RELOC_HI16; - } - else if (strncmp (str, "@sdarel", 7) == 0 || strncmp (str, "@sdarel", 7) == 0) - { - *str_p += 7; - return BFD_RELOC_GPREL16; - } - else if (strncmp (str, "@FIXUP", 6) == 0 || strncmp (str, "@fixup", 6) == 0) - { - *str_p += 6; - return BFD_RELOC_CTOR; /* synonym for BFD_RELOC_32 that doesn't get */ - } /* warnings with -mrelocatable */ + ch = *str; + for (ptr = &mapping[0]; ptr->length > 0; ptr++) + if (ch == ptr->string[0] && strncmp (str, ptr->string, ptr->length) == 0) + { + *str_p = str + ptr->length; + return ptr->reloc; + } return BFD_RELOC_UNUSED; } @@ -2790,6 +2795,9 @@ md_apply_fix3 (fixp, valuep, seg) if (fixp->fx_pcrel) abort (); + case BFD_RELOC_PPC_B16_BRTAKEN: + case BFD_RELOC_PPC_B16_BRNTAKEN: + value <<= 2; md_number_to_chars (fixp->fx_frag->fr_literal + fixp->fx_where, value, 2); break; -- 2.30.2