summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNick Clifton <nickc@redhat.com>2009-03-02 10:33:05 +0000
committerNick Clifton <nickc@redhat.com>2009-03-02 10:33:05 +0000
commit67ce5c51fad3b8bdc866d181e58293e87dc265a3 (patch)
treebe2a61c243b9bbfc4e7d702889c852b8fe661eb2
parent9c0fd74003677eef751f51629c403a03f2241c06 (diff)
downloadgdb-67ce5c51fad3b8bdc866d181e58293e87dc265a3.tar.gz
Add support for Score7 architecture.
-rw-r--r--bfd/ChangeLog17
-rw-r--r--bfd/Makefile.am9
-rw-r--r--bfd/Makefile.in8
-rw-r--r--bfd/archures.c4
-rw-r--r--bfd/bfd-in2.h17
-rwxr-xr-xbfd/configure4
-rw-r--r--bfd/configure.in4
-rw-r--r--bfd/cpu-score.c68
-rw-r--r--bfd/elf32-score.c2250
-rw-r--r--bfd/elf32-score.h152
-rw-r--r--bfd/elf32-score7.c3947
-rw-r--r--bfd/libbfd.h4
-rw-r--r--bfd/reloc.c17
-rw-r--r--include/elf/ChangeLog5
-rw-r--r--include/elf/common.h3
-rw-r--r--include/elf/score.h13
-rw-r--r--include/opcode/ChangeLog6
-rw-r--r--include/opcode/score-datadep.h227
-rw-r--r--include/opcode/score-inst.h313
-rw-r--r--opcodes/ChangeLog10
-rw-r--r--opcodes/Makefile.am7
-rw-r--r--opcodes/Makefile.in7
-rwxr-xr-xopcodes/configure2
-rw-r--r--opcodes/configure.in2
-rw-r--r--opcodes/score-dis.c880
-rw-r--r--opcodes/score-opc.h460
-rw-r--r--opcodes/score7-dis.c972
27 files changed, 7706 insertions, 1702 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index ff99690bcda..d431c0d5f90 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,20 @@
+2009-03-02 Qinwei <qinwei@sunnorth.com.cn>
+
+ * elf32-score7.c: New file.
+ * elf32-score.h: New file.
+ * elf32-score.c: Add code to support score 7. Set score7 as the
+ default.
+ * cpu-score.c: Add score7 architecure.
+ (compatibile): New function.
+ * Makefile.am: Add rules for building elf32-score7 object.
+ * Makefile.in: Regenerate.
+ * configure.in: Add elf32-score7 object to score vectors.
+ * configure: Regenerate.
+ * reloc.c: Add score7 relocs.
+ * archures.c: Add score3 and score7 machine numbers.
+ * bfd-in2.h: Regenerate.
+ * libbfd.h: Regenerate.
+
2009-03-01 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
* configure: Regenerate.
diff --git a/bfd/Makefile.am b/bfd/Makefile.am
index 8d67cb8ef75..08f0c2a8318 100644
--- a/bfd/Makefile.am
+++ b/bfd/Makefile.am
@@ -289,6 +289,7 @@ BFD32_BACKENDS = \
elf32-ppc.lo \
elf32-s390.lo \
elf32-score.lo \
+ elf32-score7.lo \
elf32-sh.lo \
elf32-sh-symbian.lo \
elf32-sh64.lo \
@@ -474,6 +475,7 @@ BFD32_BACKENDS_CFILES = \
elf32-sh64-com.c \
elf32-s390.c \
elf32-score.c \
+ elf32-score7.c \
elf32-sh.c \
elf32-sh-symbian.c \
elfxx-sparc.c \
@@ -1570,7 +1572,12 @@ elf32-s390.lo: elf32-s390.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
elf32-score.lo: elf32-score.c $(INCDIR)/filenames.h \
$(INCDIR)/hashtab.h $(INCDIR)/libiberty.h elf-bfd.h \
$(INCDIR)/elf/common.h $(INCDIR)/elf/external.h $(INCDIR)/elf/internal.h \
- $(INCDIR)/bfdlink.h $(INCDIR)/elf/score.h $(INCDIR)/elf/reloc-macros.h \
+ $(INCDIR)/bfdlink.h elf32-score.h $(INCDIR)/elf/score.h $(INCDIR)/elf/reloc-macros.h \
+ elf32-target.h
+elf32-score7.lo: elf32-score7.c $(INCDIR)/filenames.h \
+ $(INCDIR)/hashtab.h $(INCDIR)/libiberty.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/external.h $(INCDIR)/elf/internal.h \
+ $(INCDIR)/bfdlink.h elf32-score.h $(INCDIR)/elf/score.h $(INCDIR)/elf/reloc-macros.h \
elf32-target.h
elf32-sh.lo: elf32-sh.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
$(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
diff --git a/bfd/Makefile.in b/bfd/Makefile.in
index 9932dea1324..1eb588789d8 100644
--- a/bfd/Makefile.in
+++ b/bfd/Makefile.in
@@ -555,6 +555,7 @@ BFD32_BACKENDS = \
elf32-ppc.lo \
elf32-s390.lo \
elf32-score.lo \
+ elf32-score7.lo \
elf32-sh.lo \
elf32-sh-symbian.lo \
elf32-sh64.lo \
@@ -739,6 +740,7 @@ BFD32_BACKENDS_CFILES = \
elf32-sh64.c \
elf32-sh64-com.c \
elf32-s390.c \
+ elf32-score7.c \
elf32-score.c \
elf32-sh.c \
elf32-sh-symbian.c \
@@ -2167,6 +2169,12 @@ elf32-score.lo: elf32-score.c $(INCDIR)/filenames.h \
$(INCDIR)/hashtab.h $(INCDIR)/libiberty.h elf-bfd.h \
$(INCDIR)/elf/common.h $(INCDIR)/elf/external.h $(INCDIR)/elf/internal.h \
$(INCDIR)/bfdlink.h $(INCDIR)/elf/score.h $(INCDIR)/elf/reloc-macros.h \
+ $(INCDIR)/bfdlink.h elf32-score.h $(INCDIR)/elf/score.h $(INCDIR)/elf/reloc-macros.h \
+ elf32-target.h
+elf32-score7.lo: elf32-score7.c $(INCDIR)/filenames.h \
+ $(INCDIR)/hashtab.h $(INCDIR)/libiberty.h elf-bfd.h \
+ $(INCDIR)/elf/common.h $(INCDIR)/elf/external.h $(INCDIR)/elf/internal.h \
+ $(INCDIR)/bfdlink.h elf32-score.h $(INCDIR)/elf/score.h $(INCDIR)/elf/reloc-macros.h \
elf32-target.h
elf32-sh.lo: elf32-sh.c $(INCDIR)/filenames.h $(INCDIR)/bfdlink.h \
$(INCDIR)/hashtab.h elf-bfd.h $(INCDIR)/elf/common.h \
diff --git a/bfd/archures.c b/bfd/archures.c
index f548ea21d45..fa03d81a698 100644
--- a/bfd/archures.c
+++ b/bfd/archures.c
@@ -1,6 +1,6 @@
/* BFD library support routines for architectures.
Copyright 1990, 1991, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
- 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008
+ 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
Free Software Foundation, Inc.
Hacked by John Gilmore and Steve Chamberlain of Cygnus Support.
@@ -376,6 +376,8 @@ DESCRIPTION
.#define bfd_mach_s390_31 31
.#define bfd_mach_s390_64 64
. bfd_arch_score, {* Sunplus score *}
+.#define bfd_mach_score3 3
+.#define bfd_mach_score7 7
. bfd_arch_openrisc, {* OpenRISC *}
. bfd_arch_mmix, {* Donald Knuth's educational processor. *}
. bfd_arch_xstormy16,
diff --git a/bfd/bfd-in2.h b/bfd/bfd-in2.h
index 7870962f1af..be35ac4db63 100644
--- a/bfd/bfd-in2.h
+++ b/bfd/bfd-in2.h
@@ -2002,6 +2002,8 @@ enum bfd_architecture
#define bfd_mach_s390_31 31
#define bfd_mach_s390_64 64
bfd_arch_score, /* Sunplus score */
+#define bfd_mach_score3 3
+#define bfd_mach_score7 7
bfd_arch_openrisc, /* OpenRISC */
bfd_arch_mmix, /* Donald Knuth's educational processor. */
bfd_arch_xstormy16,
@@ -3889,10 +3891,8 @@ instructions */
BFD_RELOC_390_GOTPLT20,
BFD_RELOC_390_TLS_GOTIE20,
-/* Score relocations */
- BFD_RELOC_SCORE_DUMMY1,
-
-/* Low 16 bit for load/store */
+/* Score relocations
+Low 16 bit for load/store */
BFD_RELOC_SCORE_GPREL15,
/* This is a 24-bit reloc with the right 1 bit assumed to be 0 */
@@ -3902,12 +3902,21 @@ instructions */
/* This is a 19-bit reloc with the right 1 bit assumed to be 0 */
BFD_RELOC_SCORE_BRANCH,
+/* This is a 32-bit reloc for 48-bit instructions. */
+ BFD_RELOC_SCORE_IMM30,
+
+/* This is a 32-bit reloc for 48-bit instructions. */
+ BFD_RELOC_SCORE_IMM32,
+
/* This is a 11-bit reloc with the right 1 bit assumed to be 0 */
BFD_RELOC_SCORE16_JMP,
/* This is a 8-bit reloc with the right 1 bit assumed to be 0 */
BFD_RELOC_SCORE16_BRANCH,
+/* This is a 9-bit reloc with the right 1 bit assumed to be 0 */
+ BFD_RELOC_SCORE_BCMP,
+
/* Undocumented Score relocs */
BFD_RELOC_SCORE_GOT15,
BFD_RELOC_SCORE_GOT_LO16,
diff --git a/bfd/configure b/bfd/configure
index edfb2f20f35..6c21291fea3 100755
--- a/bfd/configure
+++ b/bfd/configure
@@ -20783,8 +20783,8 @@ do
bfd_elf32_powerpcle_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;;
bfd_elf32_powerpc_vxworks_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;;
bfd_elf32_s390_vec) tb="$tb elf32-s390.lo elf32.lo $elf" ;;
- bfd_elf32_bigscore_vec) tb="$tb elf32-score.lo elf32.lo $elf" ;;
- bfd_elf32_littlescore_vec) tb="$tb elf32-score.lo elf32.lo $elf" ;;
+ bfd_elf32_bigscore_vec) tb="$tb elf32-score.lo elf32-score7.lo elf32.lo $elf"; want64=true;;
+ bfd_elf32_littlescore_vec) tb="$tb elf32-score.lo elf32-score7.lo elf32.lo $elf"; want64=true;;
# FIXME: We include cofflink.lo not because it's needed for
# bfd_elf32_sh64[l]_vec, but because we include bfd_elf32_sh[l]_vec
# which needs it but does not list it. Should be fixed in right place.
diff --git a/bfd/configure.in b/bfd/configure.in
index a4444185fd3..a56004d4acd 100644
--- a/bfd/configure.in
+++ b/bfd/configure.in
@@ -724,8 +724,8 @@ do
bfd_elf32_powerpcle_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;;
bfd_elf32_powerpc_vxworks_vec) tb="$tb elf32-ppc.lo elf-vxworks.lo elf32.lo $elf" ;;
bfd_elf32_s390_vec) tb="$tb elf32-s390.lo elf32.lo $elf" ;;
- bfd_elf32_bigscore_vec) tb="$tb elf32-score.lo elf32.lo $elf" ;;
- bfd_elf32_littlescore_vec) tb="$tb elf32-score.lo elf32.lo $elf" ;;
+ bfd_elf32_bigscore_vec) tb="$tb elf32-score.lo elf32-score7.lo elf32.lo $elf"; want64=true;;
+ bfd_elf32_littlescore_vec) tb="$tb elf32-score.lo elf32-score7.lo elf32.lo $elf"; want64=true;;
# FIXME: We include cofflink.lo not because it's needed for
# bfd_elf32_sh64[l]_vec, but because we include bfd_elf32_sh[l]_vec
# which needs it but does not list it. Should be fixed in right place.
diff --git a/bfd/cpu-score.c b/bfd/cpu-score.c
index 0ccc371cabf..0ed4095c1a0 100644
--- a/bfd/cpu-score.c
+++ b/bfd/cpu-score.c
@@ -1,8 +1,9 @@
/* BFD support for the score processor
- Copyright 2006, 2007 Free Software Foundation, Inc.
+ Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
Contributed by
+ Brain.lin (brain.lin@sunplusct.com)
Mei Ligang (ligang@sunnorth.com.cn)
- Pei-Lin Tsai (pltsai@sunplus.com)
+ Pei-Lin Tsai (pltsai@sunplus.com)
This file is part of BFD, the Binary File Descriptor library.
@@ -21,32 +22,47 @@
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
MA 02110-1301, USA. */
-#include "sysdep.h"
#include "bfd.h"
+#include "sysdep.h"
#include "libbfd.h"
-const bfd_arch_info_type
-bfd_score_arch =
+/* This routine is provided two arch_infos and works out which Score
+ machine which would be compatible with both and returns a pointer
+ to its info structure. */
+
+static const bfd_arch_info_type *
+compatible (const bfd_arch_info_type * a, const bfd_arch_info_type * b)
{
- 32, /* There's 32 bits_per_word. */
- 32, /* There's 32 bits_per_address. */
- 8, /* There's 8 bits_per_byte. */
- bfd_arch_score, /* One of enum bfd_architecture, defined
- in archures.c and provided in
- generated header files. */
- 0, /* Only 1 machine, but #255 for
- historical reasons. */
- "score", /* The arch_name. */
- "score", /* The printable name is the same. */
- 4, /* Section alignment power; each section
- is aligned to (only) 2^4 bytes. */
- TRUE, /* This is the default "machine", since
- there's only one. */
- bfd_default_compatible, /* A default function for testing
- "machine" compatibility of two
- bfd_arch_info_type. */
- bfd_default_scan, /* Check if an bfd_arch_info_type is a
- match. */
- NULL /* Pointer to next bfd_arch_info_type in
- the same family. */
+ /* If a & b are for different architectures we can do nothing. */
+ if (a->arch != b->arch)
+ return NULL;
+
+ if (a->mach != b->mach)
+ return NULL;
+
+ return a;
+}
+
+#define N(addr_bits, machine, print, default, next) \
+{ \
+ 32, /* 16 bits in a word. */ \
+ 32, /* Bits in an address. */ \
+ 8, /* 8 bits in a byte. */ \
+ bfd_arch_score, \
+ machine, /* Machine number. */ \
+ "score", /* Architecture name. */ \
+ print, /* Printable name. */ \
+ 4, /* Section align power. */ \
+ default, /* The default machine. */ \
+ compatible, \
+ bfd_default_scan, \
+ next \
+}
+
+static const bfd_arch_info_type arch_info_struct[] =
+{
+ N (16, bfd_mach_score3, "score3", FALSE, NULL),
};
+
+const bfd_arch_info_type bfd_score_arch =
+ N (16, bfd_mach_score7, "score7", TRUE, & arch_info_struct[0]);
diff --git a/bfd/elf32-score.c b/bfd/elf32-score.c
index 813f21ead97..d5e21b5383d 100644
--- a/bfd/elf32-score.c
+++ b/bfd/elf32-score.c
@@ -1,6 +1,7 @@
/* 32-bit ELF support for S+core.
- Copyright 2006, 2007 Free Software Foundation, Inc.
+ Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
Contributed by
+ Brain.lin (brain.lin@sunplusct.com)
Mei Ligang (ligang@sunnorth.com.cn)
Pei-Lin Tsai (pltsai@sunplus.com)
@@ -30,10 +31,13 @@
#include "elf/common.h"
#include "elf/internal.h"
#include "hashtab.h"
+#include "elf32-score.h"
-/* Score ELF linker hash table. */
+int score3 = 0;
+int score7 = 1;
+/* Score ELF linker hash table. */
struct score_elf_link_hash_table
{
/* The main hash table. */
@@ -42,7 +46,6 @@ struct score_elf_link_hash_table
/* The SCORE ELF linker needs additional information for each symbol in
the global hash table. */
-
struct score_elf_link_hash_entry
{
struct elf_link_hash_entry root;
@@ -175,7 +178,7 @@ struct _score_elf_section_data
#define SCORE_ELF_STUB_SECTION_NAME (".SCORE.stub")
#define SCORE_FUNCTION_STUB_SIZE (16)
-#define STUB_LW 0xc3bcc010 /* lw r29, [r28, -0x3ff0] */
+#define STUB_LW 0xc3bcc010 /* lw r29, [r28, -0x3ff0] */
#define STUB_MOVE 0x8363bc56 /* mv r27, r3 */
#define STUB_LI16 0x87548000 /* ori r26, .dynsym_index */
#define STUB_BRL 0x801dbc09 /* brl r29 */
@@ -198,10 +201,6 @@ struct _score_elf_section_data
#define SCORE_ELF_LOG_FILE_ALIGN(abfd)\
(get_elf_backend_data (abfd)->s->log_file_align)
-#ifndef NUM_ELEM
-#define NUM_ELEM(a) (sizeof (a) / (sizeof (a)[0]))
-#endif
-
static bfd_byte *hi16_rel_addr;
/* This will be used when we sort the dynamic relocation records. */
@@ -216,14 +215,112 @@ static asection score_elf_scom_section;
static asymbol score_elf_scom_symbol;
static asymbol *score_elf_scom_symbol_ptr;
+static bfd_vma
+score_bfd_get_16 (bfd *abfd, const void *data)
+{
+ return bfd_get_16 (abfd, data);
+}
+
+static bfd_vma
+score3_bfd_getl32 (const void *p)
+{
+ const bfd_byte *addr = p;
+ unsigned long v;
+
+ v = (unsigned long) addr[2];
+ v |= (unsigned long) addr[3] << 8;
+ v |= (unsigned long) addr[0] << 16;
+ v |= (unsigned long) addr[1] << 24;
+ return v;
+}
+
+static bfd_vma
+score3_bfd_getl48 (const void *p)
+{
+ const bfd_byte *addr = p;
+ unsigned long long v;
+
+ v = (unsigned long long) addr[4];
+ v |= (unsigned long long) addr[5] << 8;
+ v |= (unsigned long long) addr[2] << 16;
+ v |= (unsigned long long) addr[3] << 24;
+ v |= (unsigned long long) addr[0] << 32;
+ v |= (unsigned long long) addr[1] << 40;
+ return v;
+}
+
+static bfd_vma
+score_bfd_get_32 (bfd *abfd, const void *data)
+{
+ if (/* score3 && */ abfd->xvec->byteorder == BFD_ENDIAN_LITTLE)
+ return score3_bfd_getl32 (data);
+ else
+ return bfd_get_32 (abfd, data);
+}
+
+static bfd_vma
+score_bfd_get_48 (bfd *abfd, const void *p)
+{
+ if (/* score3 && */ abfd->xvec->byteorder == BFD_ENDIAN_LITTLE)
+ return score3_bfd_getl48 (p);
+ else
+ return bfd_get_bits (p, 48, 1);
+}
+
+static void
+score_bfd_put_16 (bfd *abfd, bfd_vma addr, void *data)
+{
+ return bfd_put_16 (abfd, addr, data);
+}
+
+static void
+score3_bfd_putl32 (bfd_vma data, void *p)
+{
+ bfd_byte *addr = p;
+ addr[0] = (data >> 16) & 0xff;
+ addr[1] = (data >> 24) & 0xff;
+ addr[2] = data & 0xff;
+ addr[3] = (data >> 8) & 0xff;
+}
+
+static void
+score3_bfd_putl48 (bfd_vma data, void *p)
+{
+ bfd_byte *addr = p;
+ addr[0] = (data >> 32) & 0xff;
+ addr[1] = (data >> 40) & 0xff;
+ addr[2] = (data >> 16) & 0xff;
+ addr[3] = (data >> 24) & 0xff;
+ addr[4] = data & 0xff;
+ addr[5] = (data >> 8) & 0xff;
+}
+
+static void
+score_bfd_put_32 (bfd *abfd, bfd_vma addr, void *data)
+{
+ if (/* score3 && */ abfd->xvec->byteorder == BFD_ENDIAN_LITTLE)
+ return score3_bfd_putl32 (addr, data);
+ else
+ return bfd_put_32 (abfd, addr, data);
+}
+
+static void
+score_bfd_put_48 (bfd *abfd, bfd_vma val, void *p)
+{
+ if (/* score3 && */ abfd->xvec->byteorder == BFD_ENDIAN_LITTLE)
+ return score3_bfd_putl48 (val, p);
+ else
+ return bfd_put_bits (val, p, 48, 1);
+}
+
static bfd_reloc_status_type
score_elf_hi16_reloc (bfd *abfd ATTRIBUTE_UNUSED,
- arelent *reloc_entry,
- asymbol *symbol ATTRIBUTE_UNUSED,
- void * data,
- asection *input_section ATTRIBUTE_UNUSED,
- bfd *output_bfd ATTRIBUTE_UNUSED,
- char **error_message ATTRIBUTE_UNUSED)
+ arelent *reloc_entry,
+ asymbol *symbol ATTRIBUTE_UNUSED,
+ void * data,
+ asection *input_section ATTRIBUTE_UNUSED,
+ bfd *output_bfd ATTRIBUTE_UNUSED,
+ char **error_message ATTRIBUTE_UNUSED)
{
hi16_rel_addr = (bfd_byte *) data + reloc_entry->address;
return bfd_reloc_ok;
@@ -231,20 +328,20 @@ score_elf_hi16_reloc (bfd *abfd ATTRIBUTE_UNUSED,
static bfd_reloc_status_type
score_elf_lo16_reloc (bfd *abfd,
- arelent *reloc_entry,
- asymbol *symbol ATTRIBUTE_UNUSED,
- void * data,
- asection *input_section,
- bfd *output_bfd ATTRIBUTE_UNUSED,
- char **error_message ATTRIBUTE_UNUSED)
+ arelent *reloc_entry,
+ asymbol *symbol ATTRIBUTE_UNUSED,
+ void * data,
+ asection *input_section,
+ bfd *output_bfd ATTRIBUTE_UNUSED,
+ char **error_message ATTRIBUTE_UNUSED)
{
bfd_vma addend = 0, offset = 0;
unsigned long val;
unsigned long hi16_offset, hi16_value, uvalue;
- hi16_value = bfd_get_32 (abfd, hi16_rel_addr);
+ hi16_value = score_bfd_get_32 (abfd, hi16_rel_addr);
hi16_offset = ((((hi16_value >> 16) & 0x3) << 15) | (hi16_value & 0x7fff)) >> 1;
- addend = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
+ addend = score_bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
offset = ((((addend >> 16) & 0x3) << 15) | (addend & 0x7fff)) >> 1;
val = reloc_entry->addend;
if (reloc_entry->address > input_section->size)
@@ -252,10 +349,10 @@ score_elf_lo16_reloc (bfd *abfd,
uvalue = ((hi16_offset << 16) | (offset & 0xffff)) + val;
hi16_offset = (uvalue >> 16) << 1;
hi16_value = (hi16_value & ~0x37fff) | (hi16_offset & 0x7fff) | ((hi16_offset << 1) & 0x30000);
- bfd_put_32 (abfd, hi16_value, hi16_rel_addr);
+ score_bfd_put_32 (abfd, hi16_value, hi16_rel_addr);
offset = (uvalue & 0xffff) << 1;
addend = (addend & ~0x37fff) | (offset & 0x7fff) | ((offset << 1) & 0x30000);
- bfd_put_32 (abfd, addend, (bfd_byte *) data + reloc_entry->address);
+ score_bfd_put_32 (abfd, addend, (bfd_byte *) data + reloc_entry->address);
return bfd_reloc_ok;
}
@@ -284,17 +381,17 @@ score_elf_assign_gp (bfd *output_bfd, bfd_vma *pgp)
else
{
for (i = 0; i < count; i++, sym++)
- {
- const char *name;
+ {
+ const char *name;
- name = bfd_asymbol_name (*sym);
- if (*name == '_' && strcmp (name, "_gp") == 0)
- {
- *pgp = bfd_asymbol_value (*sym);
- _bfd_set_gp_value (output_bfd, *pgp);
- break;
- }
- }
+ name = bfd_asymbol_name (*sym);
+ if (*name == '_' && strcmp (name, "_gp") == 0)
+ {
+ *pgp = bfd_asymbol_value (*sym);
+ _bfd_set_gp_value (output_bfd, *pgp);
+ break;
+ }
+ }
}
if (i >= count)
@@ -313,13 +410,12 @@ score_elf_assign_gp (bfd *output_bfd, bfd_vma *pgp)
BFD. If we can't find it, we're stuck. We cache it in the ELF
target data. We don't need to adjust the symbol value for an
external symbol if we are producing relocatable output. */
-
static bfd_reloc_status_type
score_elf_final_gp (bfd *output_bfd,
- asymbol *symbol,
- bfd_boolean relocatable,
- char **error_message,
- bfd_vma *pgp)
+ asymbol *symbol,
+ bfd_boolean relocatable,
+ char **error_message,
+ bfd_vma *pgp)
{
if (bfd_is_und_section (symbol->section)
&& ! relocatable)
@@ -331,20 +427,20 @@ score_elf_final_gp (bfd *output_bfd,
*pgp = _bfd_get_gp_value (output_bfd);
if (*pgp == 0
&& (! relocatable
- || (symbol->flags & BSF_SECTION_SYM) != 0))
+ || (symbol->flags & BSF_SECTION_SYM) != 0))
{
if (relocatable)
- {
- /* Make up a value. */
- *pgp = symbol->section->output_section->vma + 0x4000;
- _bfd_set_gp_value (output_bfd, *pgp);
- }
+ {
+ /* Make up a value. */
+ *pgp = symbol->section->output_section->vma + 0x4000;
+ _bfd_set_gp_value (output_bfd, *pgp);
+ }
else if (!score_elf_assign_gp (output_bfd, pgp))
- {
- *error_message =
- (char *) _("GP relative relocation when _gp not defined");
- return bfd_reloc_dangerous;
- }
+ {
+ *error_message =
+ (char *) _("GP relative relocation when _gp not defined");
+ return bfd_reloc_dangerous;
+ }
}
return bfd_reloc_ok;
@@ -352,12 +448,12 @@ score_elf_final_gp (bfd *output_bfd,
static bfd_reloc_status_type
score_elf_gprel15_with_gp (bfd *abfd,
- asymbol *symbol,
- arelent *reloc_entry,
- asection *input_section,
- bfd_boolean relocateable,
- void * data,
- bfd_vma gp ATTRIBUTE_UNUSED)
+ asymbol *symbol,
+ arelent *reloc_entry,
+ asection *input_section,
+ bfd_boolean relocateable,
+ void * data,
+ bfd_vma gp ATTRIBUTE_UNUSED)
{
bfd_vma relocation;
unsigned long insn;
@@ -372,13 +468,13 @@ score_elf_gprel15_with_gp (bfd *abfd,
if (reloc_entry->address > input_section->size)
return bfd_reloc_outofrange;
- insn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
+ insn = score_bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
if (((reloc_entry->addend & 0xffffc000) != 0)
&& ((reloc_entry->addend & 0xffffc000) != 0xffffc000))
return bfd_reloc_overflow;
insn = (insn & ~0x7fff) | (reloc_entry->addend & 0x7fff);
- bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
+ score_bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
if (relocateable)
reloc_entry->address += input_section->output_offset;
@@ -387,8 +483,8 @@ score_elf_gprel15_with_gp (bfd *abfd,
static bfd_reloc_status_type
gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
- asection *input_section, bfd_boolean relocatable,
- void *data, bfd_vma gp)
+ asection *input_section, bfd_boolean relocatable,
+ void *data, bfd_vma gp)
{
bfd_vma relocation;
bfd_vma val;
@@ -408,7 +504,7 @@ gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
val = reloc_entry->addend;
if (reloc_entry->howto->partial_inplace)
- val += bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
+ val += score_bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
/* Adjust val for the final section location and GP value. If we
are producing relocatable output, we don't want to do this for
@@ -418,7 +514,7 @@ gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
val += relocation - gp;
if (reloc_entry->howto->partial_inplace)
- bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
+ score_bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
else
reloc_entry->addend = val;
@@ -430,24 +526,24 @@ gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
static bfd_reloc_status_type
score_elf_gprel15_reloc (bfd *abfd,
- arelent *reloc_entry,
- asymbol *symbol,
- void * data,
- asection *input_section,
- bfd *output_bfd,
- char **error_message)
+ arelent *reloc_entry,
+ asymbol *symbol,
+ void * data,
+ asection *input_section,
+ bfd *output_bfd,
+ char **error_message)
{
bfd_boolean relocateable;
bfd_reloc_status_type ret;
bfd_vma gp;
- if (output_bfd != (bfd *) NULL
+ if (output_bfd != NULL
&& (symbol->flags & BSF_SECTION_SYM) == 0 && reloc_entry->addend == 0)
{
reloc_entry->address += input_section->output_offset;
return bfd_reloc_ok;
}
- if (output_bfd != (bfd *) NULL)
+ if (output_bfd != NULL)
relocateable = TRUE;
else
{
@@ -468,8 +564,8 @@ score_elf_gprel15_reloc (bfd *abfd,
static bfd_reloc_status_type
score_elf_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
- void *data, asection *input_section, bfd *output_bfd,
- char **error_message)
+ void *data, asection *input_section, bfd *output_bfd,
+ char **error_message)
{
bfd_boolean relocatable;
bfd_reloc_status_type ret;
@@ -481,7 +577,7 @@ score_elf_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
&& (symbol->flags & BSF_LOCAL) != 0)
{
*error_message = (char *)
- _("32bits gp relative relocation occurs for an external symbol");
+ _("32bits gp relative relocation occurs for an external symbol");
return bfd_reloc_outofrange;
}
@@ -497,48 +593,47 @@ score_elf_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
if (ret != bfd_reloc_ok)
return ret;
- gp = 0; /* FIXME. */
+ gp = 0;
return gprel32_with_gp (abfd, symbol, reloc_entry, input_section,
- relocatable, data, gp);
+ relocatable, data, gp);
}
/* A howto special_function for R_SCORE_GOT15 relocations. This is just
like any other 16-bit relocation when applied to global symbols, but is
treated in the same as R_SCORE_HI16 when applied to local symbols. */
-
static bfd_reloc_status_type
score_elf_got15_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
- void *data, asection *input_section,
- bfd *output_bfd, char **error_message)
+ void *data, asection *input_section,
+ bfd *output_bfd, char **error_message)
{
if ((symbol->flags & (BSF_GLOBAL | BSF_WEAK)) != 0
|| bfd_is_und_section (bfd_get_section (symbol))
|| bfd_is_com_section (bfd_get_section (symbol)))
/* The relocation is against a global symbol. */
return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
- input_section, output_bfd,
- error_message);
+ input_section, output_bfd,
+ error_message);
return score_elf_hi16_reloc (abfd, reloc_entry, symbol, data,
- input_section, output_bfd, error_message);
+ input_section, output_bfd, error_message);
}
static bfd_reloc_status_type
score_elf_got_lo16_reloc (bfd *abfd,
- arelent *reloc_entry,
- asymbol *symbol ATTRIBUTE_UNUSED,
- void * data,
- asection *input_section,
- bfd *output_bfd ATTRIBUTE_UNUSED,
- char **error_message ATTRIBUTE_UNUSED)
+ arelent *reloc_entry,
+ asymbol *symbol ATTRIBUTE_UNUSED,
+ void * data,
+ asection *input_section,
+ bfd *output_bfd ATTRIBUTE_UNUSED,
+ char **error_message ATTRIBUTE_UNUSED)
{
bfd_vma addend = 0, offset = 0;
signed long val;
signed long hi16_offset, hi16_value, uvalue;
- hi16_value = bfd_get_32 (abfd, hi16_rel_addr);
+ hi16_value = score_bfd_get_32 (abfd, hi16_rel_addr);
hi16_offset = ((((hi16_value >> 16) & 0x3) << 15) | (hi16_value & 0x7fff)) >> 1;
- addend = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
+ addend = score_bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
offset = ((((addend >> 16) & 0x3) << 15) | (addend & 0x7fff)) >> 1;
val = reloc_entry->addend;
if (reloc_entry->address > input_section->size)
@@ -549,10 +644,10 @@ score_elf_got_lo16_reloc (bfd *abfd,
else
hi16_offset = (uvalue >> 16) & 0x7fff;
hi16_value = (hi16_value & ~0x37fff) | (hi16_offset & 0x7fff) | ((hi16_offset << 1) & 0x30000);
- bfd_put_32 (abfd, hi16_value, hi16_rel_addr);
+ score_bfd_put_32 (abfd, hi16_value, hi16_rel_addr);
offset = (uvalue & 0xffff) << 1;
addend = (addend & ~0x37fff) | (offset & 0x7fff) | ((offset << 1) & 0x30000);
- bfd_put_32 (abfd, addend, (bfd_byte *) data + reloc_entry->address);
+ score_bfd_put_32 (abfd, addend, (bfd_byte *) data + reloc_entry->address);
return bfd_reloc_ok;
}
@@ -581,7 +676,7 @@ static reloc_howto_type elf32_score_howto_table[] =
FALSE, /* pc_relative */
1, /* bitpos */
complain_overflow_dont,/* complain_on_overflow */
- score_elf_hi16_reloc, /* special_function */
+ score_elf_hi16_reloc, /* special_function */
"R_SCORE_HI16", /* name */
TRUE, /* partial_inplace */
0x37fff, /* src_mask */
@@ -603,19 +698,19 @@ static reloc_howto_type elf32_score_howto_table[] =
0x37fff, /* dst_mask */
FALSE), /* pcrel_offset */
- /* R_SCORE_DUMMY1 */
- HOWTO (R_SCORE_DUMMY1, /* type */
- 0, /* rightshift */
+ /* R_SCORE_BCMP */
+ HOWTO (R_SCORE_BCMP, /* type */
+ 1, /* rightshift */
2, /* size (0 = byte, 1 = short, 2 = long) */
16, /* bitsize */
- FALSE, /* pc_relative */
+ TRUE, /* pc_relative */
1, /* bitpos */
complain_overflow_dont,/* complain_on_overflow */
bfd_elf_generic_reloc, /* special_function */
- "R_SCORE_DUMMY1", /* name */
- TRUE, /* partial_inplace */
- 0x0000ffff, /* src_mask */
- 0x0000ffff, /* dst_mask */
+ "R_SCORE_BCMP", /* name */
+ FALSE, /* partial_inplace */
+ 0x03e00381, /* src_mask */
+ 0x03e00381, /* dst_mask */
FALSE), /* pcrel_offset */
/*R_SCORE_24 */
@@ -667,15 +762,15 @@ static reloc_howto_type elf32_score_howto_table[] =
HOWTO (R_SCORE16_PC8, /* type */
1, /* rightshift */
1, /* size (0 = byte, 1 = short, 2 = long) */
- 8, /* bitsize */
+ 9, /* bitsize */
TRUE, /* pc_relative */
0, /* bitpos */
complain_overflow_dont,/* complain_on_overflow */
bfd_elf_generic_reloc, /* special_function */
"R_SCORE16_PC8", /* name */
FALSE, /* partial_inplace */
- 0x000000ff, /* src_mask */
- 0x000000ff, /* dst_mask */
+ 0x000001ff, /* src_mask */
+ 0x000001ff, /* dst_mask */
FALSE), /* pcrel_offset */
/* 32 bit absolute */
@@ -830,18 +925,18 @@ static reloc_howto_type elf32_score_howto_table[] =
/* 32 bit symbol relative relocation. */
HOWTO (R_SCORE_REL32, /* type */
- 0, /* rightshift */
- 2, /* size (0 = byte, 1 = short, 2 = long) */
- 32, /* bitsize */
- FALSE, /* pc_relative */
- 0, /* bitpos */
- complain_overflow_dont,/* complain_on_overflow */
- bfd_elf_generic_reloc, /* special_function */
- "R_SCORE_REL32", /* name */
- TRUE, /* partial_inplace */
- 0xffffffff, /* src_mask */
- 0xffffffff, /* dst_mask */
- FALSE), /* pcrel_offset */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_SCORE_REL32", /* name */
+ TRUE, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ FALSE), /* pcrel_offset */
/* R_SCORE_DUMMY_HI16 */
HOWTO (R_SCORE_DUMMY_HI16, /* type */
@@ -851,12 +946,42 @@ static reloc_howto_type elf32_score_howto_table[] =
FALSE, /* pc_relative */
1, /* bitpos */
complain_overflow_dont,/* complain_on_overflow */
- score_elf_hi16_reloc, /* special_function */
+ score_elf_hi16_reloc, /* special_function */
"R_SCORE_DUMMY_HI16", /* name */
TRUE, /* partial_inplace */
0x37fff, /* src_mask */
0x37fff, /* dst_mask */
FALSE), /* pcrel_offset */
+
+ /* R_SCORE_IMM30 */
+ HOWTO (R_SCORE_IMM30, /* type */
+ 2, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 30, /* bitsize */
+ FALSE, /* pc_relative */
+ 7, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_SCORE_IMM30", /* name */
+ FALSE, /* partial_inplace */
+ 0x7f7fff7f80LL, /* src_mask */
+ 0x7f7fff7f80LL, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ /* R_SCORE_IMM32 */
+ HOWTO (R_SCORE_IMM32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ FALSE, /* pc_relative */
+ 5, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_SCORE_IMM32", /* name */
+ FALSE, /* partial_inplace */
+ 0x7f7fff7fe0LL, /* src_mask */
+ 0x7f7fff7fe0LL, /* dst_mask */
+ FALSE), /* pcrel_offset */
};
struct score_reloc_map
@@ -870,7 +995,7 @@ static const struct score_reloc_map elf32_score_reloc_map[] =
{BFD_RELOC_NONE, R_SCORE_NONE},
{BFD_RELOC_HI16_S, R_SCORE_HI16},
{BFD_RELOC_LO16, R_SCORE_LO16},
- {BFD_RELOC_SCORE_DUMMY1, R_SCORE_DUMMY1},
+ {BFD_RELOC_SCORE_BCMP, R_SCORE_BCMP},
{BFD_RELOC_SCORE_JMP, R_SCORE_24},
{BFD_RELOC_SCORE_BRANCH, R_SCORE_PC19},
{BFD_RELOC_SCORE16_JMP, R_SCORE16_11},
@@ -887,12 +1012,13 @@ static const struct score_reloc_map elf32_score_reloc_map[] =
{BFD_RELOC_GPREL32, R_SCORE_GPREL32},
{BFD_RELOC_32_PCREL, R_SCORE_REL32},
{BFD_RELOC_SCORE_DUMMY_HI16, R_SCORE_DUMMY_HI16},
+ {BFD_RELOC_SCORE_IMM30, R_SCORE_IMM30},
+ {BFD_RELOC_SCORE_IMM32, R_SCORE_IMM32},
};
/* got_entries only match if they're identical, except for gotidx, so
use all fields to compute the hash, and compare the appropriate
union members. */
-
static hashval_t
score_elf_got_entry_hash (const void *entry_)
{
@@ -910,14 +1036,13 @@ score_elf_got_entry_eq (const void *entry1, const void *entry2)
return e1->abfd == e2->abfd && e1->symndx == e2->symndx
&& (! e1->abfd ? e1->d.address == e2->d.address
- : e1->symndx >= 0 ? e1->d.addend == e2->d.addend
- : e1->d.h == e2->d.h);
+ : e1->symndx >= 0 ? e1->d.addend == e2->d.addend
+ : e1->d.h == e2->d.h);
}
/* If H needs a GOT entry, assign it the highest available dynamic
index. Otherwise, assign it the lowest available dynamic
index. */
-
static bfd_boolean
score_elf_sort_hash_table_f (struct score_elf_link_hash_entry *h, void *data)
{
@@ -937,7 +1062,7 @@ score_elf_sort_hash_table_f (struct score_elf_link_hash_entry *h, void *data)
if (h->root.got.offset == 2)
{
if (hsd->max_unref_got_dynindx == hsd->min_got_dynindx)
- hsd->low = (struct elf_link_hash_entry *) h;
+ hsd->low = (struct elf_link_hash_entry *) h;
h->root.dynindx = hsd->max_unref_got_dynindx++;
}
else if (h->root.got.offset != 1)
@@ -963,7 +1088,6 @@ score_elf_got_section (bfd *abfd, bfd_boolean maybe_excluded)
/* Returns the GOT information associated with the link indicated by
INFO. If SGOTP is non-NULL, it is filled in with the GOT section. */
-
static struct score_got_info *
score_elf_got_info (bfd *abfd, asection **sgotp)
{
@@ -985,12 +1109,11 @@ score_elf_got_info (bfd *abfd, asection **sgotp)
appear towards the end. This reduces the amount of GOT space
required. MAX_LOCAL is used to set the number of local symbols
known to be in the dynamic symbol table. During
- _bfd_score_elf_size_dynamic_sections, this value is 1. Afterward, the
+ s3_bfd_score_elf_size_dynamic_sections, this value is 1. Afterward, the
section symbols are added and the count is higher. */
-
static bfd_boolean
score_elf_sort_hash_table (struct bfd_link_info *info,
- unsigned long max_local)
+ unsigned long max_local)
{
struct score_elf_hash_sort_data hsd;
struct score_got_info *g;
@@ -1013,15 +1136,15 @@ score_elf_sort_hash_table (struct bfd_link_info *info,
- (g->next ? g->assigned_gotno : 0);
hsd.max_non_got_dynindx = max_local;
score_elf_link_hash_traverse (((struct score_elf_link_hash_table *)
- elf_hash_table (info)),
- score_elf_sort_hash_table_f,
- &hsd);
+ elf_hash_table (info)),
+ score_elf_sort_hash_table_f,
+ &hsd);
/* There should have been enough room in the symbol table to
accommodate both the GOT and non-GOT symbols. */
BFD_ASSERT (hsd.max_non_got_dynindx <= hsd.min_got_dynindx);
BFD_ASSERT ((unsigned long)hsd.max_unref_got_dynindx
- <= elf_hash_table (info)->dynsymcount);
+ <= elf_hash_table (info)->dynsymcount);
/* Now we know which dynamic symbol has the lowest dynamic symbol
table index in the GOT. */
@@ -1031,11 +1154,10 @@ score_elf_sort_hash_table (struct bfd_link_info *info,
}
/* Create an entry in an score ELF linker hash table. */
-
static struct bfd_hash_entry *
score_elf_link_hash_newfunc (struct bfd_hash_entry *entry,
- struct bfd_hash_table *table,
- const char *string)
+ struct bfd_hash_table *table,
+ const char *string)
{
struct score_elf_link_hash_entry *ret = (struct score_elf_link_hash_entry *)entry;
@@ -1062,16 +1184,15 @@ score_elf_link_hash_newfunc (struct bfd_hash_entry *entry,
/* Returns the first relocation of type r_type found, beginning with
RELOCATION. RELEND is one-past-the-end of the relocation table. */
-
static const Elf_Internal_Rela *
score_elf_next_relocation (bfd *abfd ATTRIBUTE_UNUSED, unsigned int r_type,
- const Elf_Internal_Rela *relocation,
- const Elf_Internal_Rela *relend)
+ const Elf_Internal_Rela *relocation,
+ const Elf_Internal_Rela *relend)
{
while (relocation < relend)
{
if (ELF32_R_TYPE (relocation->r_info) == r_type)
- return relocation;
+ return relocation;
++relocation;
}
@@ -1083,7 +1204,6 @@ score_elf_next_relocation (bfd *abfd ATTRIBUTE_UNUSED, unsigned int r_type,
/* This function is called via qsort() to sort the dynamic relocation
entries by increasing r_symndx value. */
-
static int
score_elf_sort_dynamic_relocs (const void *arg1, const void *arg2)
{
@@ -1097,11 +1217,11 @@ score_elf_sort_dynamic_relocs (const void *arg1, const void *arg2)
}
/* Return whether a relocation is against a local symbol. */
-
static bfd_boolean
score_elf_local_relocation_p (bfd *input_bfd,
- const Elf_Internal_Rela *relocation,
- bfd_boolean check_forced)
+ const Elf_Internal_Rela *relocation,
+ asection **local_sections,
+ bfd_boolean check_forced)
{
unsigned long r_symndx;
Elf_Internal_Shdr *symtab_hdr;
@@ -1110,29 +1230,30 @@ score_elf_local_relocation_p (bfd *input_bfd,
r_symndx = ELF32_R_SYM (relocation->r_info);
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
- extsymoff = symtab_hdr->sh_info;
+ extsymoff = (elf_bad_symtab (input_bfd)) ? 0 : symtab_hdr->sh_info;
if (r_symndx < extsymoff)
return TRUE;
+ if (elf_bad_symtab (input_bfd) && local_sections[r_symndx] != NULL)
+ return TRUE;
if (check_forced)
{
/* Look up the hash table to check whether the symbol was forced local. */
h = (struct score_elf_link_hash_entry *)
- elf_sym_hashes (input_bfd) [r_symndx - extsymoff];
+ elf_sym_hashes (input_bfd) [r_symndx - extsymoff];
/* Find the real hash-table entry for this symbol. */
while (h->root.root.type == bfd_link_hash_indirect
- || h->root.root.type == bfd_link_hash_warning)
- h = (struct score_elf_link_hash_entry *) h->root.root.u.i.link;
+ || h->root.root.type == bfd_link_hash_warning)
+ h = (struct score_elf_link_hash_entry *) h->root.root.u.i.link;
if (h->root.forced_local)
- return TRUE;
+ return TRUE;
}
return FALSE;
}
/* Returns the dynamic relocation section for DYNOBJ. */
-
static asection *
score_elf_rel_dyn_section (bfd *dynobj, bfd_boolean create_p)
{
@@ -1150,11 +1271,11 @@ score_elf_rel_dyn_section (bfd *dynobj, bfd_boolean create_p)
| SEC_LINKER_CREATED
| SEC_READONLY));
if (sreloc == NULL
- || ! bfd_set_section_alignment (dynobj, sreloc,
- SCORE_ELF_LOG_FILE_ALIGN (dynobj)))
- return NULL;
+ || ! bfd_set_section_alignment (dynobj, sreloc,
+ SCORE_ELF_LOG_FILE_ALIGN (dynobj)))
+ return NULL;
}
- return sreloc;
+ return sreloc;
}
static void
@@ -1178,14 +1299,13 @@ score_elf_allocate_dynamic_relocations (bfd *abfd, unsigned int n)
is the original relocation, which is now being transformed into a
dynamic relocation. The ADDENDP is adjusted if necessary; the
caller should store the result in place of the original addend. */
-
static bfd_boolean
score_elf_create_dynamic_relocation (bfd *output_bfd,
- struct bfd_link_info *info,
- const Elf_Internal_Rela *rel,
- struct score_elf_link_hash_entry *h,
- bfd_vma symbol,
- bfd_vma *addendp, asection *input_section)
+ struct bfd_link_info *info,
+ const Elf_Internal_Rela *rel,
+ struct score_elf_link_hash_entry *h,
+ bfd_vma symbol,
+ bfd_vma *addendp, asection *input_section)
{
Elf_Internal_Rela outrel[3];
asection *sreloc;
@@ -1215,8 +1335,8 @@ score_elf_create_dynamic_relocation (bfd *output_bfd,
if (outrel[0].r_offset == MINUS_TWO)
{
/* The relocation field has been converted into a relative value of
- some sort. Functions like _bfd_elf_write_section_eh_frame expect
- the field to be fully relocated, so add in the symbol's value. */
+ some sort. Functions like _bfd_elf_write_section_eh_frame expect
+ the field to be fully relocated, so add in the symbol's value. */
*addendp += symbol;
return TRUE;
}
@@ -1226,14 +1346,14 @@ score_elf_create_dynamic_relocation (bfd *output_bfd,
if (h != NULL
&& (! info->symbolic || !h->root.def_regular)
/* h->root.dynindx may be -1 if this symbol was marked to
- become local. */
+ become local. */
&& h->root.dynindx != -1)
{
indx = h->root.dynindx;
- /* ??? glibc's ld.so just adds the final GOT entry to the
- relocation field. It therefore treats relocs against
- defined symbols in the same way as relocs against
- undefined symbols. */
+ /* ??? glibc's ld.so just adds the final GOT entry to the
+ relocation field. It therefore treats relocs against
+ defined symbols in the same way as relocs against
+ undefined symbols. */
defined_p = FALSE;
}
else
@@ -1271,11 +1391,11 @@ score_elf_create_dynamic_relocation (bfd *output_bfd,
/* Adjust the output offset of the relocation to reference the
correct location in the output file. */
outrel[0].r_offset += (input_section->output_section->vma
- + input_section->output_offset);
+ + input_section->output_offset);
outrel[1].r_offset += (input_section->output_section->vma
- + input_section->output_offset);
+ + input_section->output_offset);
outrel[2].r_offset += (input_section->output_section->vma
- + input_section->output_offset);
+ + input_section->output_offset);
/* Put the relocation back out. We have to use the special
relocation outputter in the 64-bit case since the 64-bit
@@ -1297,7 +1417,7 @@ score_elf_create_dynamic_relocation (bfd *output_bfd,
static bfd_boolean
score_elf_create_got_section (bfd *abfd,
struct bfd_link_info *info,
- bfd_boolean maybe_exclude)
+ bfd_boolean maybe_exclude)
{
flagword flags;
asection *s;
@@ -1311,7 +1431,7 @@ score_elf_create_got_section (bfd *abfd,
if (s)
{
if (! maybe_exclude)
- s->flags &= ~SEC_EXCLUDE;
+ s->flags &= ~SEC_EXCLUDE;
return TRUE;
}
@@ -1332,8 +1452,8 @@ score_elf_create_got_section (bfd *abfd,
are not creating a global offset table. */
bh = NULL;
if (! (_bfd_generic_link_add_one_symbol
- (info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s,
- 0, NULL, FALSE, get_elf_backend_data (abfd)->collect, &bh)))
+ (info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s,
+ 0, NULL, FALSE, get_elf_backend_data (abfd)->collect, &bh)))
return FALSE;
h = (struct elf_link_hash_entry *) bh;
@@ -1357,7 +1477,7 @@ score_elf_create_got_section (bfd *abfd,
g->next = NULL;
g->got_entries = htab_try_create (1, score_elf_got_entry_hash,
- score_elf_got_entry_eq, NULL);
+ score_elf_got_entry_eq, NULL);
if (g->got_entries == NULL)
return FALSE;
score_elf_section_data (s)->u.got_info = g;
@@ -1367,7 +1487,6 @@ score_elf_create_got_section (bfd *abfd,
}
/* Calculate the %high function. */
-
static bfd_vma
score_elf_high (bfd_vma value)
{
@@ -1376,15 +1495,14 @@ score_elf_high (bfd_vma value)
/* Create a local GOT entry for VALUE. Return the index of the entry,
or -1 if it could not be created. */
-
static struct score_got_entry *
score_elf_create_local_got_entry (bfd *abfd,
bfd *ibfd ATTRIBUTE_UNUSED,
- struct score_got_info *gg,
- asection *sgot, bfd_vma value,
- unsigned long r_symndx ATTRIBUTE_UNUSED,
- struct score_elf_link_hash_entry *h ATTRIBUTE_UNUSED,
- int r_type ATTRIBUTE_UNUSED)
+ struct score_got_info *gg,
+ asection *sgot, bfd_vma value,
+ unsigned long r_symndx ATTRIBUTE_UNUSED,
+ struct score_elf_link_hash_entry *h ATTRIBUTE_UNUSED,
+ int r_type ATTRIBUTE_UNUSED)
{
struct score_got_entry entry, **loc;
struct score_got_info *g;
@@ -1412,22 +1530,21 @@ score_elf_create_local_got_entry (bfd *abfd,
(*loc)->gotidx = -1;
/* We didn't allocate enough space in the GOT. */
(*_bfd_error_handler)
- (_("not enough GOT space for local GOT entries"));
+ (_("not enough GOT space for local GOT entries"));
bfd_set_error (bfd_error_bad_value);
return NULL;
}
- bfd_put_32 (abfd, value, (sgot->contents + entry.gotidx));
+ score_bfd_put_32 (abfd, value, (sgot->contents + entry.gotidx));
return *loc;
}
/* Find a GOT entry whose higher-order 16 bits are the same as those
for value. Return the index into the GOT for this entry. */
-
static bfd_vma
score_elf_got16_entry (bfd *abfd, bfd *ibfd, struct bfd_link_info *info,
- bfd_vma value, bfd_boolean external)
+ bfd_vma value, bfd_boolean external)
{
asection *sgot;
struct score_got_info *g;
@@ -1436,16 +1553,16 @@ score_elf_got16_entry (bfd *abfd, bfd *ibfd, struct bfd_link_info *info,
if (!external)
{
/* Although the ABI says that it is "the high-order 16 bits" that we
- want, it is really the %high value. The complete value is
- calculated with a `addiu' of a LO16 relocation, just as with a
- HI16/LO16 pair. */
+ want, it is really the %high value. The complete value is
+ calculated with a `addiu' of a LO16 relocation, just as with a
+ HI16/LO16 pair. */
value = score_elf_high (value) << 16;
}
g = score_elf_got_info (elf_hash_table (info)->dynobj, &sgot);
entry = score_elf_create_local_got_entry (abfd, ibfd, g, sgot, value, 0, NULL,
- R_SCORE_GOT15);
+ R_SCORE_GOT15);
if (entry)
return entry->gotidx;
else
@@ -1453,9 +1570,9 @@ score_elf_got16_entry (bfd *abfd, bfd *ibfd, struct bfd_link_info *info,
}
static void
-_bfd_score_elf_hide_symbol (struct bfd_link_info *info,
- struct elf_link_hash_entry *entry,
- bfd_boolean force_local)
+s3_bfd_score_elf_hide_symbol (struct bfd_link_info *info,
+ struct elf_link_hash_entry *entry,
+ bfd_boolean force_local)
{
bfd *dynobj;
asection *got;
@@ -1472,55 +1589,55 @@ _bfd_score_elf_hide_symbol (struct bfd_link_info *info,
{
got = score_elf_got_section (dynobj, FALSE);
if (got == NULL)
- return;
+ return;
g = score_elf_section_data (got)->u.got_info;
if (g->next)
- {
- struct score_got_entry e;
- struct score_got_info *gg = g;
-
- /* Since we're turning what used to be a global symbol into a
- local one, bump up the number of local entries of each GOT
- that had an entry for it. This will automatically decrease
- the number of global entries, since global_gotno is actually
- the upper limit of global entries. */
- e.abfd = dynobj;
- e.symndx = -1;
- e.d.h = h;
-
- for (g = g->next; g != gg; g = g->next)
- if (htab_find (g->got_entries, &e))
- {
- BFD_ASSERT (g->global_gotno > 0);
- g->local_gotno++;
- g->global_gotno--;
- }
-
- /* If this was a global symbol forced into the primary GOT, we
- no longer need an entry for it. We can't release the entry
- at this point, but we must at least stop counting it as one
- of the symbols that required a forced got entry. */
- if (h->root.got.offset == 2)
- {
- BFD_ASSERT (gg->assigned_gotno > 0);
- gg->assigned_gotno--;
- }
- }
+ {
+ struct score_got_entry e;
+ struct score_got_info *gg = g;
+
+ /* Since we're turning what used to be a global symbol into a
+ local one, bump up the number of local entries of each GOT
+ that had an entry for it. This will automatically decrease
+ the number of global entries, since global_gotno is actually
+ the upper limit of global entries. */
+ e.abfd = dynobj;
+ e.symndx = -1;
+ e.d.h = h;
+
+ for (g = g->next; g != gg; g = g->next)
+ if (htab_find (g->got_entries, &e))
+ {
+ BFD_ASSERT (g->global_gotno > 0);
+ g->local_gotno++;
+ g->global_gotno--;
+ }
+
+ /* If this was a global symbol forced into the primary GOT, we
+ no longer need an entry for it. We can't release the entry
+ at this point, but we must at least stop counting it as one
+ of the symbols that required a forced got entry. */
+ if (h->root.got.offset == 2)
+ {
+ BFD_ASSERT (gg->assigned_gotno > 0);
+ gg->assigned_gotno--;
+ }
+ }
else if (g->global_gotno == 0 && g->global_gotsym == NULL)
- /* If we haven't got through GOT allocation yet, just bump up the
- number of local entries, as this symbol won't be counted as
- global. */
- g->local_gotno++;
+ /* If we haven't got through GOT allocation yet, just bump up the
+ number of local entries, as this symbol won't be counted as
+ global. */
+ g->local_gotno++;
else if (h->root.got.offset == 1)
- {
- /* If we're past non-multi-GOT allocation and this symbol had
- been marked for a global got entry, give it a local entry
- instead. */
- BFD_ASSERT (g->global_gotno > 0);
- g->local_gotno++;
- g->global_gotno--;
- }
+ {
+ /* If we're past non-multi-GOT allocation and this symbol had
+ been marked for a global got entry, give it a local entry
+ instead. */
+ BFD_ASSERT (g->global_gotno > 0);
+ g->local_gotno++;
+ g->global_gotno--;
+ }
}
_bfd_elf_link_hash_hide_symbol (info, &h->root, force_local);
@@ -1529,12 +1646,11 @@ _bfd_score_elf_hide_symbol (struct bfd_link_info *info,
/* If H is a symbol that needs a global GOT entry, but has a dynamic
symbol table index lower than any we've seen to date, record it for
posterity. */
-
static bfd_boolean
score_elf_record_global_got_symbol (struct elf_link_hash_entry *h,
- bfd *abfd,
+ bfd *abfd,
struct bfd_link_info *info,
- struct score_got_info *g)
+ struct score_got_info *g)
{
struct score_got_entry entry, **loc;
@@ -1542,14 +1658,14 @@ score_elf_record_global_got_symbol (struct elf_link_hash_entry *h,
if (h->dynindx == -1)
{
switch (ELF_ST_VISIBILITY (h->other))
- {
- case STV_INTERNAL:
- case STV_HIDDEN:
- _bfd_score_elf_hide_symbol (info, h, TRUE);
- break;
- }
+ {
+ case STV_INTERNAL:
+ case STV_HIDDEN:
+ s3_bfd_score_elf_hide_symbol (info, h, TRUE);
+ break;
+ }
if (!bfd_elf_link_record_dynamic_symbol (info, h))
- return FALSE;
+ return FALSE;
}
entry.abfd = abfd;
@@ -1584,12 +1700,11 @@ score_elf_record_global_got_symbol (struct elf_link_hash_entry *h,
/* Reserve space in G for a GOT entry containing the value of symbol
SYMNDX in input bfd ABDF, plus ADDEND. */
-
static bfd_boolean
score_elf_record_local_got_symbol (bfd *abfd,
long symndx,
bfd_vma addend,
- struct score_got_info *g)
+ struct score_got_info *g)
{
struct score_got_entry entry, **loc;
@@ -1615,11 +1730,10 @@ score_elf_record_local_got_symbol (bfd *abfd,
/* Returns the GOT offset at which the indicated address can be found.
If there is not yet a GOT entry for this value, create one.
Returns -1 if no satisfactory GOT offset can be found. */
-
static bfd_vma
score_elf_local_got_index (bfd *abfd, bfd *ibfd, struct bfd_link_info *info,
- bfd_vma value, unsigned long r_symndx,
- struct score_elf_link_hash_entry *h, int r_type)
+ bfd_vma value, unsigned long r_symndx,
+ struct score_elf_link_hash_entry *h, int r_type)
{
asection *sgot;
struct score_got_info *g;
@@ -1628,7 +1742,7 @@ score_elf_local_got_index (bfd *abfd, bfd *ibfd, struct bfd_link_info *info,
g = score_elf_got_info (elf_hash_table (info)->dynobj, &sgot);
entry = score_elf_create_local_got_entry (abfd, ibfd, g, sgot, value,
- r_symndx, h, r_type);
+ r_symndx, h, r_type);
if (!entry)
return MINUS_ONE;
@@ -1662,10 +1776,9 @@ score_elf_global_got_index (bfd *abfd, struct elf_link_hash_entry *h)
}
/* Returns the offset for the entry at the INDEXth position in the GOT. */
-
static bfd_vma
score_elf_got_offset_from_index (bfd *dynobj, bfd *output_bfd,
- bfd *input_bfd ATTRIBUTE_UNUSED, bfd_vma index)
+ bfd *input_bfd ATTRIBUTE_UNUSED, bfd_vma index)
{
asection *sgot;
bfd_vma gp;
@@ -1694,30 +1807,30 @@ score_elf_resolve_final_got_entry (void **entryp, void *p)
struct score_elf_link_hash_entry *h = entry->d.h;
while (h->root.root.type == bfd_link_hash_indirect
- || h->root.root.type == bfd_link_hash_warning)
- h = (struct score_elf_link_hash_entry *) h->root.root.u.i.link;
+ || h->root.root.type == bfd_link_hash_warning)
+ h = (struct score_elf_link_hash_entry *) h->root.root.u.i.link;
if (entry->d.h == h)
- return 1;
+ return 1;
entry->d.h = h;
/* If we can't find this entry with the new bfd hash, re-insert
- it, and get the traversal restarted. */
+ it, and get the traversal restarted. */
if (! htab_find (got_entries, entry))
- {
- htab_clear_slot (got_entries, entryp);
- entryp = htab_find_slot (got_entries, entry, INSERT);
- if (! *entryp)
- *entryp = entry;
- /* Abort the traversal, since the whole table may have
- moved, and leave it up to the parent to restart the
- process. */
- *(htab_t *)p = NULL;
- return 0;
- }
+ {
+ htab_clear_slot (got_entries, entryp);
+ entryp = htab_find_slot (got_entries, entry, INSERT);
+ if (! *entryp)
+ *entryp = entry;
+ /* Abort the traversal, since the whole table may have
+ moved, and leave it up to the parent to restart the
+ process. */
+ *(htab_t *)p = NULL;
+ return 0;
+ }
/* We might want to decrement the global_gotno count, but it's
- either too early or too late for that at this point. */
+ either too early or too late for that at this point. */
}
return 1;
@@ -1734,19 +1847,18 @@ score_elf_resolve_final_got_entries (struct score_got_info *g)
got_entries = g->got_entries;
htab_traverse (got_entries,
- score_elf_resolve_final_got_entry,
- &got_entries);
+ score_elf_resolve_final_got_entry,
+ &got_entries);
}
while (got_entries == NULL);
}
/* Add INCREMENT to the reloc (of type HOWTO) at ADDRESS. for -r */
-
static void
score_elf_add_to_rel (bfd *abfd,
- bfd_byte *address,
- reloc_howto_type *howto,
- bfd_signed_vma increment)
+ bfd_byte *address,
+ reloc_howto_type *howto,
+ bfd_signed_vma increment)
{
bfd_signed_vma addend;
bfd_vma contents;
@@ -1754,7 +1866,7 @@ score_elf_add_to_rel (bfd *abfd,
unsigned long r_type = howto->type;
unsigned long hi16_addend, hi16_offset, hi16_value, uvalue;
- contents = bfd_get_32 (abfd, address);
+ contents = score_bfd_get_32 (abfd, address);
/* Get the (signed) value from the instruction. */
addend = contents & howto->src_mask;
if (addend & ((howto->src_mask + 1) >> 1))
@@ -1775,12 +1887,12 @@ score_elf_add_to_rel (bfd *abfd,
contents =
(contents & ~howto->
src_mask) | (((offset << 6) & howto->src_mask) & 0x3ff0000) | (offset & 0x3ff);
- bfd_put_32 (abfd, contents, address);
+ score_bfd_put_32 (abfd, contents, address);
break;
case R_SCORE_HI16:
break;
case R_SCORE_LO16:
- hi16_addend = bfd_get_32 (abfd, address - 4);
+ hi16_addend = score_bfd_get_32 (abfd, address - 4);
hi16_offset = ((((hi16_addend >> 16) & 0x3) << 15) | (hi16_addend & 0x7fff)) >> 1;
offset = ((((contents >> 16) & 0x3) << 15) | (contents & 0x7fff)) >> 1;
offset = (hi16_offset << 16) | (offset & 0xffff);
@@ -1788,10 +1900,10 @@ score_elf_add_to_rel (bfd *abfd,
hi16_offset = (uvalue >> 16) << 1;
hi16_value = (hi16_addend & (~(howto->dst_mask)))
| (hi16_offset & 0x7fff) | ((hi16_offset << 1) & 0x30000);
- bfd_put_32 (abfd, hi16_value, address - 4);
+ score_bfd_put_32 (abfd, hi16_value, address - 4);
offset = (uvalue & 0xffff) << 1;
contents = (contents & (~(howto->dst_mask))) | (offset & 0x7fff) | ((offset << 1) & 0x30000);
- bfd_put_32 (abfd, contents, address);
+ score_bfd_put_32 (abfd, contents, address);
break;
case R_SCORE_24:
offset =
@@ -1800,48 +1912,78 @@ score_elf_add_to_rel (bfd *abfd,
contents =
(contents & ~howto->
src_mask) | (((offset << 1) & howto->src_mask) & 0x3ff0000) | (offset & 0x7fff);
- bfd_put_32 (abfd, contents, address);
+ score_bfd_put_32 (abfd, contents, address);
break;
+
case R_SCORE16_11:
- contents = bfd_get_16 (abfd, address);
+ contents = score_bfd_get_16 (abfd, address);
offset = contents & howto->src_mask;
offset += increment;
contents = (contents & ~howto->src_mask) | (offset & howto->src_mask);
- bfd_put_16 (abfd, contents, address);
+ score_bfd_put_16 (abfd, contents, address);
break;
case R_SCORE16_PC8:
- contents = bfd_get_16 (abfd, address);
- offset = (contents & howto->src_mask) + ((increment >> 1) & 0xff);
+ contents = score_bfd_get_16 (abfd, address);
+ offset = (contents & howto->src_mask) + ((increment >> 1) & 0x1ff);
contents = (contents & (~howto->src_mask)) | (offset & howto->src_mask);
- bfd_put_16 (abfd, contents, address);
+ score_bfd_put_16 (abfd, contents, address);
break;
+
+ case R_SCORE_BCMP:
+ contents = score_bfd_get_32 (abfd, address);
+ offset = (contents & howto->src_mask);
+ offset <<= howto->rightshift;
+ offset += increment;
+ offset >>= howto->rightshift;
+ contents = (contents & (~howto->src_mask)) | (offset & howto->src_mask);
+ score_bfd_put_32 (abfd, contents, address);
+ break;
+
+ case R_SCORE_IMM30:
+ contents = score_bfd_get_48 (abfd, address);
+ offset = (contents & howto->src_mask);
+ offset <<= howto->rightshift;
+ offset += increment;
+ offset >>= howto->rightshift;
+ contents = (contents & (~howto->src_mask)) | (offset & howto->src_mask);
+ score_bfd_put_48 (abfd, contents, address);
+ break;
+
+ case R_SCORE_IMM32:
+ contents = score_bfd_get_48 (abfd, address);
+ offset = (contents & howto->src_mask);
+ offset += increment;
+ contents = (contents & (~howto->src_mask)) | (offset & howto->src_mask);
+ score_bfd_put_48 (abfd, contents, address);
+ break;
+
default:
addend += increment;
contents = (contents & ~howto->dst_mask) | (addend & howto->dst_mask);
- bfd_put_32 (abfd, contents, address);
+ score_bfd_put_32 (abfd, contents, address);
break;
}
}
/* Perform a relocation as part of a final link. */
-
static bfd_reloc_status_type
score_elf_final_link_relocate (reloc_howto_type *howto,
- bfd *input_bfd,
- bfd *output_bfd,
- asection *input_section,
- bfd_byte *contents,
- Elf_Internal_Rela *rel,
- Elf_Internal_Rela *relocs,
- bfd_vma symbol,
- struct bfd_link_info *info,
- const char *sym_name ATTRIBUTE_UNUSED,
- int sym_flags ATTRIBUTE_UNUSED,
- struct score_elf_link_hash_entry *h,
+ bfd *input_bfd,
+ bfd *output_bfd,
+ asection *input_section,
+ bfd_byte *contents,
+ Elf_Internal_Rela *rel,
+ Elf_Internal_Rela *relocs,
+ bfd_vma symbol,
+ struct bfd_link_info *info,
+ const char *sym_name ATTRIBUTE_UNUSED,
+ int sym_flags ATTRIBUTE_UNUSED,
+ struct score_elf_link_hash_entry *h,
+ asection **local_sections,
bfd_boolean gp_disp_p)
{
unsigned long r_type;
@@ -1864,13 +2006,14 @@ score_elf_final_link_relocate (reloc_howto_type *howto,
bfd_vma value = symbol;
unsigned long hi16_addend, hi16_offset, hi16_value, uvalue, offset, abs_value = 0;
+
if (elf_gp (output_bfd) == 0)
{
struct bfd_link_hash_entry *bh;
asection *o;
bh = bfd_link_hash_lookup (info->hash, "_gp", 0, 0, 1);
- if (bh != (struct bfd_link_hash_entry *)NULL && bh->type == bfd_link_hash_defined)
+ if (bh != NULL && bh->type == bfd_link_hash_defined)
elf_gp (output_bfd) = (bh->u.def.value
+ bh->u.def.section->output_section->vma
+ bh->u.def.section->output_offset);
@@ -1879,7 +2022,7 @@ score_elf_final_link_relocate (reloc_howto_type *howto,
bfd_vma lo = -1;
/* Find the GP-relative section with the lowest offset. */
- for (o = output_bfd->sections; o != (asection *) NULL; o = o->next)
+ for (o = output_bfd->sections; o != NULL; o = o->next)
if (o->vma < lo)
lo = o->vma;
/* And calculate GP relative to that. */
@@ -1897,7 +2040,7 @@ score_elf_final_link_relocate (reloc_howto_type *howto,
r_symndx = ELF32_R_SYM (rel->r_info);
r_type = ELF32_R_TYPE (rel->r_info);
rel_addr = (input_section->output_section->vma + input_section->output_offset + rel->r_offset);
- local_p = score_elf_local_relocation_p (input_bfd, rel, TRUE);
+ local_p = score_elf_local_relocation_p (input_bfd, rel, local_sections, TRUE);
if (r_type == R_SCORE_GOT15)
{
@@ -1910,17 +2053,22 @@ score_elf_final_link_relocate (reloc_howto_type *howto,
relend = relocs + input_section->reloc_count * bed->s->int_rels_per_ext_rel;
lo16_rel = score_elf_next_relocation (input_bfd, R_SCORE_GOT_LO16, rel, relend);
if ((local_p) && (lo16_rel != NULL))
- {
- bfd_vma tmp = 0;
- tmp = bfd_get_32 (input_bfd, contents + lo16_rel->r_offset);
- lo_value = (((tmp >> 16) & 0x3) << 14) | ((tmp & 0x7fff) >> 1);
- }
+ {
+ bfd_vma tmp = 0;
+ tmp = score_bfd_get_32 (input_bfd, contents + lo16_rel->r_offset);
+ lo_value = (((tmp >> 16) & 0x3) << 14) | ((tmp & 0x7fff) >> 1);
+ }
addend = lo_value;
}
- else
+ /* For score3 R_SCORE_ABS32. */
+ else if (r_type == R_SCORE_ABS32 || r_type == R_SCORE_REL32)
{
addend = (bfd_get_32 (input_bfd, hit_data) >> howto->bitpos) & howto->src_mask;
}
+ else
+ {
+ addend = (score_bfd_get_32 (input_bfd, hit_data) >> howto->bitpos) & howto->src_mask;
+ }
/* If we haven't already determined the GOT offset, or the GP value,
and we're going to need it, get it now. */
@@ -1942,26 +2090,26 @@ score_elf_final_link_relocate (reloc_howto_type *howto,
We must initialize this entry in the GOT. */
bfd *tmpbfd = elf_hash_table (info)->dynobj;
asection *sgot = score_elf_got_section (tmpbfd, FALSE);
- bfd_put_32 (tmpbfd, value, sgot->contents + g);
+ score_bfd_put_32 (tmpbfd, value, sgot->contents + g);
}
}
else if (r_type == R_SCORE_GOT15 || r_type == R_SCORE_CALL15)
{
- /* There's no need to create a local GOT entry here; the
- calculation for a local GOT15 entry does not involve G. */
- ;
- }
+ /* There's no need to create a local GOT entry here; the
+ calculation for a local GOT15 entry does not involve G. */
+ ;
+ }
else
{
- g = score_elf_local_got_index (output_bfd, input_bfd, info,
+ g = score_elf_local_got_index (output_bfd, input_bfd, info,
symbol + addend, r_symndx, h, r_type);
- if (g == MINUS_ONE)
- return bfd_reloc_outofrange;
+ if (g == MINUS_ONE)
+ return bfd_reloc_outofrange;
}
/* Convert GOT indices to actual offsets. */
g = score_elf_got_offset_from_index (elf_hash_table (info)->dynobj,
- output_bfd, input_bfd, g);
+ output_bfd, input_bfd, g);
break;
case R_SCORE_HI16:
@@ -1986,30 +2134,35 @@ score_elf_final_link_relocate (reloc_howto_type *howto,
case R_SCORE_ABS32:
case R_SCORE_REL32:
if ((info->shared
- || (elf_hash_table (info)->dynamic_sections_created
- && h != NULL
- && h->root.def_dynamic
- && !h->root.def_regular))
- && r_symndx != 0
- && (input_section->flags & SEC_ALLOC) != 0)
- {
- /* If we're creating a shared library, or this relocation is against a symbol
+ || (elf_hash_table (info)->dynamic_sections_created
+ && h != NULL
+ && h->root.def_dynamic
+ && !h->root.def_regular))
+ && r_symndx != 0
+ && (input_section->flags & SEC_ALLOC) != 0)
+ {
+ /* If we're creating a shared library, or this relocation is against a symbol
in a shared library, then we can't know where the symbol will end up.
So, we create a relocation record in the output, and leave the job up
to the dynamic linker. */
- value = addend;
- if (!score_elf_create_dynamic_relocation (output_bfd, info, rel, h,
- symbol, &value,
- input_section))
- return bfd_reloc_undefined;
- }
+ value = addend;
+ if (!score_elf_create_dynamic_relocation (output_bfd, info, rel, h,
+ symbol, &value,
+ input_section))
+ return bfd_reloc_undefined;
+ }
+ else if (r_symndx == 0)
+ /* r_symndx will be zero only for relocs against symbols
+ from removed linkonce sections, or sections discarded by
+ a linker script. */
+ value = 0;
else
- {
- if (r_type != R_SCORE_REL32)
- value = symbol + addend;
- else
- value = addend;
- }
+ {
+ if (r_type != R_SCORE_REL32)
+ value = symbol + addend;
+ else
+ value = addend;
+ }
value &= howto->dst_mask;
bfd_put_32 (input_bfd, value, hit_data);
return bfd_reloc_ok;
@@ -2018,22 +2171,71 @@ score_elf_final_link_relocate (reloc_howto_type *howto,
value += addend;
if ((long)value > 0x7fff || (long)value < -0x8000)
return bfd_reloc_overflow;
- bfd_put_16 (input_bfd, value, hit_data);
+ score_bfd_put_16 (input_bfd, value, hit_data);
return bfd_reloc_ok;
case R_SCORE_24:
- addend = bfd_get_32 (input_bfd, hit_data);
+ addend = score_bfd_get_32 (input_bfd, hit_data);
offset = (((addend & howto->src_mask) >> 1) & 0x1ff8000) | ((addend & howto->src_mask) & 0x7fff);
if ((offset & 0x1000000) != 0)
offset |= 0xfe000000;
value += offset;
+ abs_value = abs (value - rel_addr);
+ if ((abs_value & 0xfe000000) != 0)
+ return bfd_reloc_overflow;
addend = (addend & ~howto->src_mask)
| (((value << 1) & howto->src_mask) & 0x3ff0000) | (value & 0x7fff);
- bfd_put_32 (input_bfd, addend, hit_data);
+ score_bfd_put_32 (input_bfd, addend, hit_data);
return bfd_reloc_ok;
+ /* signed imm32. */
+ case R_SCORE_IMM30:
+ {
+ int not_word_align_p = 0;
+ bfd_vma imm_offset = 0;
+ addend = score_bfd_get_48 (input_bfd, hit_data);
+ imm_offset = ((addend >> 7) & 0xff)
+ | (((addend >> 16) & 0x7fff) << 8)
+ | (((addend >> 32) & 0x7f) << 23);
+ imm_offset <<= howto->rightshift;
+ value += imm_offset;
+ value &= 0xffffffff;
+
+ /* Check lw48/sw48 rd, value/label word align. */
+ if ((value & 0x3) != 0)
+ not_word_align_p = 1;
+
+ value >>= howto->rightshift;
+ addend = (addend & ~howto->src_mask)
+ | (((value & 0xff) >> 0) << 7)
+ | (((value & 0x7fff00) >> 8) << 16)
+ | (((value & 0x3f800000) >> 23) << 32);
+ score_bfd_put_48 (input_bfd, addend, hit_data);
+ if (not_word_align_p)
+ return bfd_reloc_other;
+ else
+ return bfd_reloc_ok;
+ }
+
+ case R_SCORE_IMM32:
+ {
+ bfd_vma imm_offset = 0;
+ addend = score_bfd_get_48 (input_bfd, hit_data);
+ imm_offset = ((addend >> 5) & 0x3ff)
+ | (((addend >> 16) & 0x7fff) << 10)
+ | (((addend >> 32) & 0x7f) << 25);
+ value += imm_offset;
+ value &= 0xffffffff;
+ addend = (addend & ~howto->src_mask)
+ | ((value & 0x3ff) << 5)
+ | (((value >> 10) & 0x7fff) << 16)
+ | (((value >> 25) & 0x7f) << 32);
+ score_bfd_put_48 (input_bfd, addend, hit_data);
+ return bfd_reloc_ok;
+ }
+
case R_SCORE_PC19:
- addend = bfd_get_32 (input_bfd, hit_data);
+ addend = score_bfd_get_32 (input_bfd, hit_data);
offset = (((addend & howto->src_mask) & 0x3ff0000) >> 6) | ((addend & howto->src_mask) & 0x3ff);
if ((offset & 0x80000) != 0)
offset |= 0xfff00000;
@@ -2045,59 +2247,79 @@ score_elf_final_link_relocate (reloc_howto_type *howto,
return bfd_reloc_overflow;
addend = (addend & ~howto->src_mask)
| (((value << 6) & howto->src_mask) & 0x3ff0000) | (value & 0x3ff);
- bfd_put_32 (input_bfd, addend, hit_data);
+ score_bfd_put_32 (input_bfd, addend, hit_data);
return bfd_reloc_ok;
case R_SCORE16_11:
- addend = bfd_get_16 (input_bfd, hit_data);
+ addend = score_bfd_get_16 (input_bfd, hit_data);
offset = addend & howto->src_mask;
if ((offset & 0x800) != 0) /* Offset is negative. */
offset |= 0xfffff000;
value += offset;
+ abs_value = abs (value - rel_addr);
+ if ((abs_value & 0xfffff000) != 0)
+ return bfd_reloc_overflow;
addend = (addend & ~howto->src_mask) | (value & howto->src_mask);
- bfd_put_16 (input_bfd, addend, hit_data);
+ score_bfd_put_16 (input_bfd, addend, hit_data);
return bfd_reloc_ok;
case R_SCORE16_PC8:
- addend = bfd_get_16 (input_bfd, hit_data);
+ addend = score_bfd_get_16 (input_bfd, hit_data);
offset = (addend & howto->src_mask) << 1;
- if ((offset & 0x100) != 0) /* Offset is negative. */
+ if ((offset & 0x200) != 0) /* Offset is negative. */
offset |= 0xfffffe00;
abs_value = value = value - rel_addr + offset;
/* Sign bit + exceed 9 bit. */
- if (((value & 0xffffff00) != 0) && ((value & 0xffffff00) != 0xffffff00))
+ if (((value & 0xfffffe00) != 0) && ((value & 0xfffffe00) != 0xfffffe00))
return bfd_reloc_overflow;
value >>= 1;
addend = (addend & ~howto->src_mask) | (value & howto->src_mask);
- bfd_put_16 (input_bfd, addend, hit_data);
+ score_bfd_put_16 (input_bfd, addend, hit_data);
+ return bfd_reloc_ok;
+
+ case R_SCORE_BCMP:
+ addend = score_bfd_get_32 (input_bfd, hit_data);
+ offset = (addend & howto->src_mask) << howto->rightshift;
+ if ((offset & 0x200) != 0) /* Offset is negative. */
+ offset |= 0xfffffe00;
+ value = value - rel_addr + offset;
+ /* Sign bit + exceed 9 bit. */
+ if (((value & 0xfffffe00) != 0) && ((value & 0xfffffe00) != 0xfffffe00))
+ return bfd_reloc_overflow;
+ value >>= howto->rightshift;
+ addend = (addend & ~howto->src_mask)
+ | (value & 0x1)
+ | (((value >> 1) & 0x7) << 7)
+ | (((value >> 4) & 0x1f) << 21);
+ score_bfd_put_32 (input_bfd, addend, hit_data);
return bfd_reloc_ok;
case R_SCORE_HI16:
return bfd_reloc_ok;
case R_SCORE_LO16:
- hi16_addend = bfd_get_32 (input_bfd, hit_data - 4);
+ hi16_addend = score_bfd_get_32 (input_bfd, hit_data - 4);
hi16_offset = ((((hi16_addend >> 16) & 0x3) << 15) | (hi16_addend & 0x7fff)) >> 1;
- addend = bfd_get_32 (input_bfd, hit_data);
+ addend = score_bfd_get_32 (input_bfd, hit_data);
offset = ((((addend >> 16) & 0x3) << 15) | (addend & 0x7fff)) >> 1;
offset = (hi16_offset << 16) | (offset & 0xffff);
if (!gp_disp_p)
- uvalue = value + offset;
+ uvalue = value + offset;
else
- uvalue = offset + gp - rel_addr + 4;
+ uvalue = offset + gp - rel_addr + 4;
hi16_offset = (uvalue >> 16) << 1;
hi16_value = (hi16_addend & (~(howto->dst_mask)))
| (hi16_offset & 0x7fff) | ((hi16_offset << 1) & 0x30000);
- bfd_put_32 (input_bfd, hi16_value, hit_data - 4);
+ score_bfd_put_32 (input_bfd, hi16_value, hit_data - 4);
offset = (uvalue & 0xffff) << 1;
value = (addend & (~(howto->dst_mask))) | (offset & 0x7fff) | ((offset << 1) & 0x30000);
- bfd_put_32 (input_bfd, value, hit_data);
+ score_bfd_put_32 (input_bfd, value, hit_data);
return bfd_reloc_ok;
case R_SCORE_GP15:
- addend = bfd_get_32 (input_bfd, hit_data);
+ addend = score_bfd_get_32 (input_bfd, hit_data);
offset = addend & 0x7fff;
if ((offset & 0x4000) == 0x4000)
offset |= 0xffffc000;
@@ -2105,52 +2327,53 @@ score_elf_final_link_relocate (reloc_howto_type *howto,
if (((value & 0xffffc000) != 0) && ((value & 0xffffc000) != 0xffffc000))
return bfd_reloc_overflow;
value = (addend & ~howto->src_mask) | (value & howto->src_mask);
- bfd_put_32 (input_bfd, value, hit_data);
+ score_bfd_put_32 (input_bfd, value, hit_data);
return bfd_reloc_ok;
case R_SCORE_GOT15:
case R_SCORE_CALL15:
if (local_p)
- {
- bfd_boolean forced;
+ {
+ bfd_boolean forced;
- /* The special case is when the symbol is forced to be local. We need the
+ /* The special case is when the symbol is forced to be local. We need the
full address in the GOT since no R_SCORE_GOT_LO16 relocation follows. */
- forced = ! score_elf_local_relocation_p (input_bfd, rel, FALSE);
- value = score_elf_got16_entry (output_bfd, input_bfd, info,
- symbol + addend, forced);
- if (value == MINUS_ONE)
- return bfd_reloc_outofrange;
- value = score_elf_got_offset_from_index (elf_hash_table (info)->dynobj,
- output_bfd, input_bfd, value);
- }
+ forced = ! score_elf_local_relocation_p (input_bfd, rel,
+ local_sections, FALSE);
+ value = score_elf_got16_entry (output_bfd, input_bfd, info,
+ symbol + addend, forced);
+ if (value == MINUS_ONE)
+ return bfd_reloc_outofrange;
+ value = score_elf_got_offset_from_index (elf_hash_table (info)->dynobj,
+ output_bfd, input_bfd, value);
+ }
else
- {
- value = g;
- }
+ {
+ value = g;
+ }
if ((long) value > 0x3fff || (long) value < -0x4000)
return bfd_reloc_overflow;
- addend = bfd_get_32 (input_bfd, hit_data);
+ addend = score_bfd_get_32 (input_bfd, hit_data);
value = (addend & ~howto->dst_mask) | (value & howto->dst_mask);
- bfd_put_32 (input_bfd, value, hit_data);
+ score_bfd_put_32 (input_bfd, value, hit_data);
return bfd_reloc_ok;
case R_SCORE_GPREL32:
value = (addend + symbol - gp);
value &= howto->dst_mask;
- bfd_put_32 (input_bfd, value, hit_data);
+ score_bfd_put_32 (input_bfd, value, hit_data);
return bfd_reloc_ok;
case R_SCORE_GOT_LO16:
- addend = bfd_get_32 (input_bfd, hit_data);
+ addend = score_bfd_get_32 (input_bfd, hit_data);
value = (((addend >> 16) & 0x3) << 14) | ((addend & 0x7fff) >> 1);
value += symbol;
- value = (addend & (~(howto->dst_mask))) | ((value & 0x3fff) << 1)
+ value = (addend & (~(howto->dst_mask))) | ((value & 0x3fff) << 1)
| (((value >> 14) & 0x3) << 16);
- bfd_put_32 (input_bfd, value, hit_data);
+ score_bfd_put_32 (input_bfd, value, hit_data);
return bfd_reloc_ok;
case R_SCORE_DUMMY_HI16:
@@ -2167,32 +2390,30 @@ score_elf_final_link_relocate (reloc_howto_type *howto,
}
/* Score backend functions. */
-
static void
-_bfd_score_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
- arelent *bfd_reloc,
- Elf_Internal_Rela *elf_reloc)
+s3_bfd_score_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+ arelent *bfd_reloc,
+ Elf_Internal_Rela *elf_reloc)
{
unsigned int r_type;
r_type = ELF32_R_TYPE (elf_reloc->r_info);
- if (r_type >= NUM_ELEM (elf32_score_howto_table))
+ if (r_type >= ARRAY_SIZE (elf32_score_howto_table))
bfd_reloc->howto = NULL;
else
bfd_reloc->howto = &elf32_score_howto_table[r_type];
}
/* Relocate an score ELF section. */
-
static bfd_boolean
-_bfd_score_elf_relocate_section (bfd *output_bfd,
- struct bfd_link_info *info,
- bfd *input_bfd,
- asection *input_section,
- bfd_byte *contents,
- Elf_Internal_Rela *relocs,
- Elf_Internal_Sym *local_syms,
- asection **local_sections)
+s3_bfd_score_elf_relocate_section (bfd *output_bfd,
+ struct bfd_link_info *info,
+ bfd *input_bfd,
+ asection *input_section,
+ bfd_byte *contents,
+ Elf_Internal_Rela *relocs,
+ Elf_Internal_Sym *local_syms,
+ asection **local_sections)
{
Elf_Internal_Shdr *symtab_hdr;
struct elf_link_hash_entry **sym_hashes;
@@ -2209,23 +2430,23 @@ _bfd_score_elf_relocate_section (bfd *output_bfd,
{
bfd_size_type dynsecsymcount = 0;
if (info->shared)
- {
- asection * p;
- const struct elf_backend_data *bed = get_elf_backend_data (output_bfd);
-
- for (p = output_bfd->sections; p ; p = p->next)
- if ((p->flags & SEC_EXCLUDE) == 0
- && (p->flags & SEC_ALLOC) != 0
- && !(*bed->elf_backend_omit_section_dynsym) (output_bfd, info, p))
- ++ dynsecsymcount;
- }
+ {
+ asection * p;
+ const struct elf_backend_data *bed = get_elf_backend_data (output_bfd);
+
+ for (p = output_bfd->sections; p ; p = p->next)
+ if ((p->flags & SEC_EXCLUDE) == 0
+ && (p->flags & SEC_ALLOC) != 0
+ && !(*bed->elf_backend_omit_section_dynsym) (output_bfd, info, p))
+ ++ dynsecsymcount;
+ }
if (!score_elf_sort_hash_table (info, dynsecsymcount + 1))
- return FALSE;
+ return FALSE;
}
symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
- extsymoff = symtab_hdr->sh_info;
+ extsymoff = (elf_bad_symtab (input_bfd)) ? 0 : symtab_hdr->sh_info;
sym_hashes = elf_sym_hashes (input_bfd);
rel = relocs;
relend = relocs + input_section->reloc_count;
@@ -2244,7 +2465,7 @@ _bfd_score_elf_relocate_section (bfd *output_bfd,
r_symndx = ELF32_R_SYM (rel->r_info);
r_type = ELF32_R_TYPE (rel->r_info);
- _bfd_score_info_to_howto (input_bfd, &bfd_reloc, (Elf_Internal_Rela *) rel);
+ s3_bfd_score_info_to_howto (input_bfd, &bfd_reloc, (Elf_Internal_Rela *) rel);
howto = bfd_reloc.howto;
h = NULL;
@@ -2256,13 +2477,13 @@ _bfd_score_elf_relocate_section (bfd *output_bfd,
sym = local_syms + r_symndx;
sec = local_sections[r_symndx];
relocation = (sec->output_section->vma
- + sec->output_offset
- + sym->st_value);
+ + sec->output_offset
+ + sym->st_value);
name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym, sec);
if (!info->relocatable
- && (sec->flags & SEC_MERGE) != 0
- && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ && (sec->flags & SEC_MERGE)
+ && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
{
asection *msec;
bfd_vma addend, value;
@@ -2272,9 +2493,9 @@ _bfd_score_elf_relocate_section (bfd *output_bfd,
case R_SCORE_HI16:
break;
case R_SCORE_LO16:
- hi16_addend = bfd_get_32 (input_bfd, contents + rel->r_offset - 4);
+ hi16_addend = score_bfd_get_32 (input_bfd, contents + rel->r_offset - 4);
hi16_offset = ((((hi16_addend >> 16) & 0x3) << 15) | (hi16_addend & 0x7fff)) >> 1;
- value = bfd_get_32 (input_bfd, contents + rel->r_offset);
+ value = score_bfd_get_32 (input_bfd, contents + rel->r_offset);
offset = ((((value >> 16) & 0x3) << 15) | (value & 0x7fff)) >> 1;
addend = (hi16_offset << 16) | (offset & 0xffff);
msec = sec;
@@ -2285,14 +2506,65 @@ _bfd_score_elf_relocate_section (bfd *output_bfd,
hi16_offset = (uvalue >> 16) << 1;
hi16_value = (hi16_addend & (~(howto->dst_mask)))
| (hi16_offset & 0x7fff) | ((hi16_offset << 1) & 0x30000);
- bfd_put_32 (input_bfd, hi16_value, contents + rel->r_offset - 4);
+ score_bfd_put_32 (input_bfd, hi16_value, contents + rel->r_offset - 4);
offset = (uvalue & 0xffff) << 1;
value = (value & (~(howto->dst_mask)))
| (offset & 0x7fff) | ((offset << 1) & 0x30000);
- bfd_put_32 (input_bfd, value, contents + rel->r_offset);
+ score_bfd_put_32 (input_bfd, value, contents + rel->r_offset);
break;
+
+ case R_SCORE_IMM32:
+ {
+ value = score_bfd_get_48 (input_bfd, contents + rel->r_offset);
+ addend = ((value >> 5) & 0x3ff)
+ | (((value >> 16) & 0x7fff) << 10)
+ | (((value >> 32) & 0x7f) << 25);
+ msec = sec;
+ addend = _bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend);
+ addend -= relocation;
+ addend += msec->output_section->vma + msec->output_offset;
+ addend &= 0xffffffff;
+ value = (value & ~howto->src_mask)
+ | ((addend & 0x3ff) << 5)
+ | (((addend >> 10) & 0x7fff) << 16)
+ | (((addend >> 25) & 0x7f) << 32);
+ score_bfd_put_48 (input_bfd, value, contents + rel->r_offset);
+ break;
+ }
+
+ case R_SCORE_IMM30:
+ {
+ int not_word_align_p = 0;
+ value = score_bfd_get_48 (input_bfd, contents + rel->r_offset);
+ addend = ((value >> 7) & 0xff)
+ | (((value >> 16) & 0x7fff) << 8)
+ | (((value >> 32) & 0x7f) << 23);
+ addend <<= howto->rightshift;
+ msec = sec;
+ addend = _bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend);
+ addend -= relocation;
+ addend += msec->output_section->vma + msec->output_offset;
+ addend &= 0xffffffff;
+
+ /* Check lw48/sw48 rd, value/label word align. */
+ if ((addend & 0x3) != 0)
+ not_word_align_p = 1;
+
+ addend >>= howto->rightshift;
+ value = (value & ~howto->src_mask)
+ | (((addend & 0xff) >> 0) << 7)
+ | (((addend & 0x7fff00) >> 8) << 16)
+ | (((addend & 0x3f800000) >> 23) << 32);
+ score_bfd_put_48 (input_bfd, value, contents + rel->r_offset);
+
+ if (not_word_align_p)
+ return bfd_reloc_other;
+ else
+ break;
+ }
+
case R_SCORE_GOT_LO16:
- value = bfd_get_32 (input_bfd, contents + rel->r_offset);
+ value = score_bfd_get_32 (input_bfd, contents + rel->r_offset);
addend = (((value >> 16) & 0x3) << 14) | ((value & 0x7fff) >> 1);
msec = sec;
addend = _bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend) - relocation;
@@ -2300,9 +2572,11 @@ _bfd_score_elf_relocate_section (bfd *output_bfd,
value = (value & (~(howto->dst_mask))) | ((addend & 0x3fff) << 1)
| (((addend >> 14) & 0x3) << 16);
- bfd_put_32 (input_bfd, value, contents + rel->r_offset);
+ score_bfd_put_32 (input_bfd, value, contents + rel->r_offset);
break;
- default:
+
+ case R_SCORE_ABS32:
+ case R_SCORE_REL32:
value = bfd_get_32 (input_bfd, contents + rel->r_offset);
/* Get the (signed) value from the instruction. */
addend = value & howto->src_mask;
@@ -2320,91 +2594,110 @@ _bfd_score_elf_relocate_section (bfd *output_bfd,
value = (value & ~howto->dst_mask) | (addend & howto->dst_mask);
bfd_put_32 (input_bfd, value, contents + rel->r_offset);
break;
+
+ default:
+ value = score_bfd_get_32 (input_bfd, contents + rel->r_offset);
+ /* Get the (signed) value from the instruction. */
+ addend = value & howto->src_mask;
+ if (addend & ((howto->src_mask + 1) >> 1))
+ {
+ bfd_signed_vma mask;
+
+ mask = -1;
+ mask &= ~howto->src_mask;
+ addend |= mask;
+ }
+ msec = sec;
+ addend = _bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend) - relocation;
+ addend += msec->output_section->vma + msec->output_offset;
+ value = (value & ~howto->dst_mask) | (addend & howto->dst_mask);
+ score_bfd_put_32 (input_bfd, value, contents + rel->r_offset);
+ break;
}
}
}
else
{
- /* For global symbols we look up the symbol in the hash-table. */
- h = ((struct score_elf_link_hash_entry *)
- elf_sym_hashes (input_bfd) [r_symndx - extsymoff]);
- /* Find the real hash-table entry for this symbol. */
- while (h->root.root.type == bfd_link_hash_indirect
- || h->root.root.type == bfd_link_hash_warning)
- h = (struct score_elf_link_hash_entry *) h->root.root.u.i.link;
-
- /* Record the name of this symbol, for our caller. */
- name = h->root.root.root.string;
-
- /* See if this is the special GP_DISP_LABEL symbol. Note that such a
- symbol must always be a global symbol. */
- if (strcmp (name, GP_DISP_LABEL) == 0)
- {
- /* Relocations against GP_DISP_LABEL are permitted only with
- R_SCORE_HI16 and R_SCORE_LO16 relocations. */
- if (r_type != R_SCORE_HI16 && r_type != R_SCORE_LO16)
- return bfd_reloc_notsupported;
-
- gp_disp_p = TRUE;
- }
-
- /* If this symbol is defined, calculate its address. Note that
- GP_DISP_LABEL is a magic symbol, always implicitly defined by the
- linker, so it's inappropriate to check to see whether or not
- its defined. */
- else if ((h->root.root.type == bfd_link_hash_defined
- || h->root.root.type == bfd_link_hash_defweak)
- && h->root.root.u.def.section)
- {
- sec = h->root.root.u.def.section;
- if (sec->output_section)
- relocation = (h->root.root.u.def.value
- + sec->output_section->vma
- + sec->output_offset);
- else
- {
- relocation = h->root.root.u.def.value;
- }
- }
- else if (h->root.root.type == bfd_link_hash_undefweak)
- /* We allow relocations against undefined weak symbols, giving
- it the value zero, so that you can undefined weak functions
- and check to see if they exist by looking at their addresses. */
- relocation = 0;
- else if (info->unresolved_syms_in_objects == RM_IGNORE
- && ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT)
- relocation = 0;
- else if (strcmp (name, "_DYNAMIC_LINK") == 0)
- {
- /* If this is a dynamic link, we should have created a _DYNAMIC_LINK symbol
- in _bfd_score_elf_create_dynamic_sections. Otherwise, we should define
+ /* For global symbols we look up the symbol in the hash-table. */
+ h = ((struct score_elf_link_hash_entry *)
+ elf_sym_hashes (input_bfd) [r_symndx - extsymoff]);
+ /* Find the real hash-table entry for this symbol. */
+ while (h->root.root.type == bfd_link_hash_indirect
+ || h->root.root.type == bfd_link_hash_warning)
+ h = (struct score_elf_link_hash_entry *) h->root.root.u.i.link;
+
+ /* Record the name of this symbol, for our caller. */
+ name = h->root.root.root.string;
+
+ /* See if this is the special GP_DISP_LABEL symbol. Note that such a
+ symbol must always be a global symbol. */
+ if (strcmp (name, GP_DISP_LABEL) == 0)
+ {
+ /* Relocations against GP_DISP_LABEL are permitted only with
+ R_SCORE_HI16 and R_SCORE_LO16 relocations. */
+ if (r_type != R_SCORE_HI16 && r_type != R_SCORE_LO16)
+ return bfd_reloc_notsupported;
+
+ gp_disp_p = TRUE;
+ }
+
+ /* If this symbol is defined, calculate its address. Note that
+ GP_DISP_LABEL is a magic symbol, always implicitly defined by the
+ linker, so it's inappropriate to check to see whether or not
+ its defined. */
+ else if ((h->root.root.type == bfd_link_hash_defined
+ || h->root.root.type == bfd_link_hash_defweak)
+ && h->root.root.u.def.section)
+ {
+ sec = h->root.root.u.def.section;
+ if (sec->output_section)
+ relocation = (h->root.root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ else
+ {
+ relocation = h->root.root.u.def.value;
+ }
+ }
+ else if (h->root.root.type == bfd_link_hash_undefweak)
+ /* We allow relocations against undefined weak symbols, giving
+ it the value zero, so that you can undefined weak functions
+ and check to see if they exist by looking at their addresses. */
+ relocation = 0;
+ else if (info->unresolved_syms_in_objects == RM_IGNORE
+ && ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT)
+ relocation = 0;
+ else if (strcmp (name, "_DYNAMIC_LINK") == 0)
+ {
+ /* If this is a dynamic link, we should have created a _DYNAMIC_LINK symbol
+ in s3_bfd_score_elf_create_dynamic_sections. Otherwise, we should define
the symbol with a value of 0. */
- BFD_ASSERT (! info->shared);
- BFD_ASSERT (bfd_get_section_by_name (output_bfd, ".dynamic") == NULL);
- relocation = 0;
- }
- else if (!info->relocatable)
- {
- if (! ((*info->callbacks->undefined_symbol)
- (info, h->root.root.root.string, input_bfd,
- input_section, rel->r_offset,
- (info->unresolved_syms_in_objects == RM_GENERATE_ERROR)
- || ELF_ST_VISIBILITY (h->root.other))))
- return bfd_reloc_undefined;
- relocation = 0;
- }
+ BFD_ASSERT (! info->shared);
+ BFD_ASSERT (bfd_get_section_by_name (output_bfd, ".dynamic") == NULL);
+ relocation = 0;
+ }
+ else if (!info->relocatable)
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.root.string, input_bfd,
+ input_section, rel->r_offset,
+ (info->unresolved_syms_in_objects == RM_GENERATE_ERROR)
+ || ELF_ST_VISIBILITY (h->root.other))))
+ return bfd_reloc_undefined;
+ relocation = 0;
+ }
}
if (sec != NULL && elf_discarded_section (sec))
- {
- /* For relocs against symbols from removed linkonce sections,
- or sections discarded by a linker script, we just want the
- section contents zeroed. Avoid any special processing. */
- _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
- rel->r_info = 0;
- rel->r_addend = 0;
- continue;
- }
+ {
+ /* For relocs against symbols from removed linkonce sections,
+ or sections discarded by a linker script, we just want the
+ section contents zeroed. Avoid any special processing. */
+ _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
+ rel->r_info = 0;
+ rel->r_addend = 0;
+ continue;
+ }
if (info->relocatable)
{
@@ -2412,17 +2705,25 @@ _bfd_score_elf_relocate_section (bfd *output_bfd,
anything, unless the reloc is against a section symbol,
in which case we have to adjust according to where the
section symbol winds up in the output section. */
- if (sym != NULL && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
- score_elf_add_to_rel (input_bfd, contents + rel->r_offset,
- howto, (bfd_signed_vma) sec->output_offset);
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+ if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ {
+ sec = local_sections[r_symndx];
+ score_elf_add_to_rel (input_bfd, contents + rel->r_offset,
+ howto, (bfd_signed_vma) (sec->output_offset + sym->st_value));
+ }
+ }
continue;
}
+ /* This is a final link. */
r = score_elf_final_link_relocate (howto, input_bfd, output_bfd,
input_section, contents, rel, relocs,
relocation, info, name,
(h ? ELF_ST_TYPE ((unsigned int)h->root.root.type) :
- ELF_ST_TYPE ((unsigned int)sym->st_info)), h,
+ ELF_ST_TYPE ((unsigned int)sym->st_info)), h, local_sections,
gp_disp_p);
if (r != bfd_reloc_ok)
@@ -2459,6 +2760,11 @@ _bfd_score_elf_relocate_section (bfd *output_bfd,
msg = _("internal error: dangerous error");
goto common_error;
+ /* Use bfd_reloc_other to check lw48, sw48 word align. */
+ case bfd_reloc_other:
+ msg = _("address not word align");
+ goto common_error;
+
default:
msg = _("internal error: unknown error");
/* fall through */
@@ -2477,12 +2783,11 @@ _bfd_score_elf_relocate_section (bfd *output_bfd,
/* Look through the relocs for a section during the first phase, and
allocate space in the global offset table. */
-
static bfd_boolean
-_bfd_score_elf_check_relocs (bfd *abfd,
- struct bfd_link_info *info,
- asection *sec,
- const Elf_Internal_Rela *relocs)
+s3_bfd_score_elf_check_relocs (bfd *abfd,
+ struct bfd_link_info *info,
+ asection *sec,
+ const Elf_Internal_Rela *relocs)
{
const char *name;
bfd *dynobj;
@@ -2502,7 +2807,7 @@ _bfd_score_elf_check_relocs (bfd *abfd,
dynobj = elf_hash_table (info)->dynobj;
symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
sym_hashes = elf_sym_hashes (abfd);
- extsymoff = symtab_hdr->sh_info;
+ extsymoff = (elf_bad_symtab (abfd)) ? 0 : symtab_hdr->sh_info;
name = bfd_get_section_name (abfd, sec);
@@ -2537,9 +2842,9 @@ _bfd_score_elf_check_relocs (bfd *abfd,
r_type = ELF32_R_TYPE (rel->r_info);
if (r_symndx < extsymoff)
- {
+ {
h = NULL;
- }
+ }
else if (r_symndx >= extsymoff + NUM_SHDR_ENTRIES (symtab_hdr))
{
(*_bfd_error_handler) (_("%s: Malformed reloc detected for section %s"), abfd, name);
@@ -2583,90 +2888,90 @@ _bfd_score_elf_check_relocs (bfd *abfd,
if (!h && (r_type == R_SCORE_GOT_LO16))
{
- if (! score_elf_record_local_got_symbol (abfd, r_symndx, rel->r_addend, g))
- return FALSE;
+ if (! score_elf_record_local_got_symbol (abfd, r_symndx, rel->r_addend, g))
+ return FALSE;
}
switch (r_type)
{
case R_SCORE_CALL15:
- if (h == NULL)
- {
- (*_bfd_error_handler)
- (_("%B: CALL15 reloc at 0x%lx not against global symbol"),
- abfd, (unsigned long) rel->r_offset);
- bfd_set_error (bfd_error_bad_value);
- return FALSE;
- }
- else
- {
- /* This symbol requires a global offset table entry. */
- if (! score_elf_record_global_got_symbol (h, abfd, info, g))
- return FALSE;
-
- /* We need a stub, not a plt entry for the undefined function. But we record
+ if (h == NULL)
+ {
+ (*_bfd_error_handler)
+ (_("%B: CALL15 reloc at 0x%lx not against global symbol"),
+ abfd, (unsigned long) rel->r_offset);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
+ else
+ {
+ /* This symbol requires a global offset table entry. */
+ if (! score_elf_record_global_got_symbol (h, abfd, info, g))
+ return FALSE;
+
+ /* We need a stub, not a plt entry for the undefined function. But we record
it as if it needs plt. See _bfd_elf_adjust_dynamic_symbol. */
- h->needs_plt = 1;
- h->type = STT_FUNC;
- }
+ h->needs_plt = 1;
+ h->type = STT_FUNC;
+ }
+ break;
+ case R_SCORE_GOT15:
+ if (h && ! score_elf_record_global_got_symbol (h, abfd, info, g))
+ return FALSE;
break;
- case R_SCORE_GOT15:
- if (h && ! score_elf_record_global_got_symbol (h, abfd, info, g))
- return FALSE;
- break;
case R_SCORE_ABS32:
case R_SCORE_REL32:
- if ((info->shared || h != NULL) && (sec->flags & SEC_ALLOC) != 0)
- {
- if (sreloc == NULL)
- {
- sreloc = score_elf_rel_dyn_section (dynobj, TRUE);
- if (sreloc == NULL)
- return FALSE;
- }
+ if ((info->shared || h != NULL) && (sec->flags & SEC_ALLOC) != 0)
+ {
+ if (sreloc == NULL)
+ {
+ sreloc = score_elf_rel_dyn_section (dynobj, TRUE);
+ if (sreloc == NULL)
+ return FALSE;
+ }
#define SCORE_READONLY_SECTION (SEC_ALLOC | SEC_LOAD | SEC_READONLY)
- if (info->shared)
- {
- /* When creating a shared object, we must copy these reloc types into
+ if (info->shared)
+ {
+ /* When creating a shared object, we must copy these reloc types into
the output file as R_SCORE_REL32 relocs. We make room for this reloc
in the .rel.dyn reloc section. */
- score_elf_allocate_dynamic_relocations (dynobj, 1);
- if ((sec->flags & SCORE_READONLY_SECTION)
- == SCORE_READONLY_SECTION)
- /* We tell the dynamic linker that there are
- relocations against the text segment. */
- info->flags |= DF_TEXTREL;
- }
- else
- {
- struct score_elf_link_hash_entry *hscore;
-
- /* We only need to copy this reloc if the symbol is
+ score_elf_allocate_dynamic_relocations (dynobj, 1);
+ if ((sec->flags & SCORE_READONLY_SECTION)
+ == SCORE_READONLY_SECTION)
+ /* We tell the dynamic linker that there are
+ relocations against the text segment. */
+ info->flags |= DF_TEXTREL;
+ }
+ else
+ {
+ struct score_elf_link_hash_entry *hscore;
+
+ /* We only need to copy this reloc if the symbol is
defined in a dynamic object. */
- hscore = (struct score_elf_link_hash_entry *)h;
- ++hscore->possibly_dynamic_relocs;
- if ((sec->flags & SCORE_READONLY_SECTION)
- == SCORE_READONLY_SECTION)
- /* We need it to tell the dynamic linker if there
- are relocations against the text segment. */
- hscore->readonly_reloc = TRUE;
- }
-
- /* Even though we don't directly need a GOT entry for this symbol,
+ hscore = (struct score_elf_link_hash_entry *)h;
+ ++hscore->possibly_dynamic_relocs;
+ if ((sec->flags & SCORE_READONLY_SECTION)
+ == SCORE_READONLY_SECTION)
+ /* We need it to tell the dynamic linker if there
+ are relocations against the text segment. */
+ hscore->readonly_reloc = TRUE;
+ }
+
+ /* Even though we don't directly need a GOT entry for this symbol,
a symbol must have a dynamic symbol table index greater that
DT_SCORE_GOTSYM if there are dynamic relocations against it. */
- if (h != NULL)
- {
- if (dynobj == NULL)
- elf_hash_table (info)->dynobj = dynobj = abfd;
- if (! score_elf_create_got_section (dynobj, info, TRUE))
- return FALSE;
- g = score_elf_got_info (dynobj, &sgot);
- if (! score_elf_record_global_got_symbol (h, abfd, info, g))
- return FALSE;
- }
- }
- break;
+ if (h != NULL)
+ {
+ if (dynobj == NULL)
+ elf_hash_table (info)->dynobj = dynobj = abfd;
+ if (! score_elf_create_got_section (dynobj, info, TRUE))
+ return FALSE;
+ g = score_elf_got_info (dynobj, &sgot);
+ if (! score_elf_record_global_got_symbol (h, abfd, info, g))
+ return FALSE;
+ }
+ }
+ break;
/* This relocation describes the C++ object vtable hierarchy.
Reconstruct it for later use during GC. */
@@ -2678,9 +2983,7 @@ _bfd_score_elf_check_relocs (bfd *abfd,
/* This relocation describes which C++ vtable entries are actually
used. Record for later use during GC. */
case R_SCORE_GNU_VTENTRY:
- BFD_ASSERT (h != NULL);
- if (h != NULL
- && !bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
+ if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
return FALSE;
break;
default:
@@ -2690,32 +2993,32 @@ _bfd_score_elf_check_relocs (bfd *abfd,
/* We must not create a stub for a symbol that has relocations
related to taking the function's address. */
switch (r_type)
- {
- default:
- if (h != NULL)
- {
- struct score_elf_link_hash_entry *sh;
+ {
+ default:
+ if (h != NULL)
+ {
+ struct score_elf_link_hash_entry *sh;
- sh = (struct score_elf_link_hash_entry *) h;
- sh->no_fn_stub = TRUE;
- }
- break;
- case R_SCORE_CALL15:
- break;
- }
+ sh = (struct score_elf_link_hash_entry *) h;
+ sh->no_fn_stub = TRUE;
+ }
+ break;
+ case R_SCORE_CALL15:
+ break;
+ }
}
return TRUE;
}
static bfd_boolean
-_bfd_score_elf_add_symbol_hook (bfd *abfd,
- struct bfd_link_info *info ATTRIBUTE_UNUSED,
- Elf_Internal_Sym *sym,
- const char **namep ATTRIBUTE_UNUSED,
- flagword *flagsp ATTRIBUTE_UNUSED,
- asection **secp,
- bfd_vma *valp)
+s3_bfd_score_elf_add_symbol_hook (bfd *abfd,
+ struct bfd_link_info *info ATTRIBUTE_UNUSED,
+ Elf_Internal_Sym *sym,
+ const char **namep ATTRIBUTE_UNUSED,
+ flagword *flagsp ATTRIBUTE_UNUSED,
+ asection **secp,
+ bfd_vma *valp)
{
switch (sym->st_shndx)
{
@@ -2734,7 +3037,7 @@ _bfd_score_elf_add_symbol_hook (bfd *abfd,
}
static void
-_bfd_score_elf_symbol_processing (bfd *abfd, asymbol *asym)
+s3_bfd_score_elf_symbol_processing (bfd *abfd, asymbol *asym)
{
elf_symbol_type *elfsym;
@@ -2766,11 +3069,11 @@ _bfd_score_elf_symbol_processing (bfd *abfd, asymbol *asym)
}
static bfd_boolean
-_bfd_score_elf_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED,
- const char *name ATTRIBUTE_UNUSED,
- Elf_Internal_Sym *sym,
- asection *input_sec,
- struct elf_link_hash_entry *h ATTRIBUTE_UNUSED)
+s3_bfd_score_elf_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED,
+ const char *name ATTRIBUTE_UNUSED,
+ Elf_Internal_Sym *sym,
+ asection *input_sec,
+ struct elf_link_hash_entry *h ATTRIBUTE_UNUSED)
{
/* If we see a common symbol, which implies a relocatable link, then
if a symbol was small common in an input file, mark it as small
@@ -2782,9 +3085,9 @@ _bfd_score_elf_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNU
}
static bfd_boolean
-_bfd_score_elf_section_from_bfd_section (bfd *abfd ATTRIBUTE_UNUSED,
- asection *sec,
- int *retval)
+s3_bfd_score_elf_section_from_bfd_section (bfd *abfd ATTRIBUTE_UNUSED,
+ asection *sec,
+ int *retval)
{
if (strcmp (bfd_get_section_name (abfd, sec), ".scommon") == 0)
{
@@ -2799,10 +3102,9 @@ _bfd_score_elf_section_from_bfd_section (bfd *abfd ATTRIBUTE_UNUSED,
regular object. The current definition is in some section of the
dynamic object, but we're not including those sections. We have to
change the definition to something the rest of the link can understand. */
-
static bfd_boolean
-_bfd_score_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
- struct elf_link_hash_entry *h)
+s3_bfd_score_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
+ struct elf_link_hash_entry *h)
{
bfd *dynobj;
struct score_elf_link_hash_entry *hscore;
@@ -2888,10 +3190,9 @@ _bfd_score_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
/* This function is called after all the input files have been read,
and the input sections have been assigned to output sections. */
-
static bfd_boolean
-_bfd_score_elf_always_size_sections (bfd *output_bfd,
- struct bfd_link_info *info)
+s3_bfd_score_elf_always_size_sections (bfd *output_bfd,
+ struct bfd_link_info *info)
{
bfd *dynobj;
asection *s;
@@ -2917,14 +3218,14 @@ _bfd_score_elf_always_size_sections (bfd *output_bfd,
asection *subsection;
for (subsection = sub->sections;
- subsection;
- subsection = subsection->next)
- {
- if ((subsection->flags & SEC_ALLOC) == 0)
- continue;
- loadable_size += ((subsection->size + 0xf)
- &~ (bfd_size_type) 0xf);
- }
+ subsection;
+ subsection = subsection->next)
+ {
+ if ((subsection->flags & SEC_ALLOC) == 0)
+ continue;
+ loadable_size += ((subsection->size + 0xf)
+ &~ (bfd_size_type) 0xf);
+ }
}
/* There has to be a global GOT entry for every symbol with
@@ -2966,9 +3267,8 @@ _bfd_score_elf_always_size_sections (bfd *output_bfd,
}
/* Set the sizes of the dynamic sections. */
-
static bfd_boolean
-_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
+s3_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
{
bfd *dynobj;
asection *s;
@@ -3045,10 +3345,10 @@ _bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *inf
}
else if (CONST_STRNEQ (name, ".got"))
{
- /* _bfd_score_elf_always_size_sections() has already done
- most of the work, but some symbols may have been mapped
- to versions that we must now resolve in the got_entries
- hash tables. */
+ /* s3_bfd_score_elf_always_size_sections() has already done
+ most of the work, but some symbols may have been mapped
+ to versions that we must now resolve in the got_entries
+ hash tables. */
}
else if (strcmp (name, SCORE_ELF_STUB_SECTION_NAME) == 0)
{
@@ -3074,37 +3374,37 @@ _bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *inf
if (elf_hash_table (info)->dynamic_sections_created)
{
/* Add some entries to the .dynamic section. We fill in the
- values later, in _bfd_score_elf_finish_dynamic_sections, but we
- must add the entries now so that we get the correct size for
- the .dynamic section. The DT_DEBUG entry is filled in by the
- dynamic linker and used by the debugger. */
+ values later, in s3_bfd_score_elf_finish_dynamic_sections, but we
+ must add the entries now so that we get the correct size for
+ the .dynamic section. The DT_DEBUG entry is filled in by the
+ dynamic linker and used by the debugger. */
if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_DEBUG, 0))
- return FALSE;
+ return FALSE;
if (reltext)
- info->flags |= DF_TEXTREL;
+ info->flags |= DF_TEXTREL;
if ((info->flags & DF_TEXTREL) != 0)
- {
- if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_TEXTREL, 0))
- return FALSE;
- }
+ {
+ if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_TEXTREL, 0))
+ return FALSE;
+ }
if (! SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_PLTGOT, 0))
- return FALSE;
+ return FALSE;
if (score_elf_rel_dyn_section (dynobj, FALSE))
- {
- if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_REL, 0))
- return FALSE;
+ {
+ if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_REL, 0))
+ return FALSE;
- if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_RELSZ, 0))
- return FALSE;
+ if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_RELSZ, 0))
+ return FALSE;
- if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_RELENT, 0))
- return FALSE;
- }
+ if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_RELENT, 0))
+ return FALSE;
+ }
if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_SCORE_BASE_ADDRESS, 0))
return FALSE;
@@ -3122,14 +3422,14 @@ _bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *inf
return FALSE;
if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_SCORE_HIPAGENO, 0))
- return FALSE;
+ return FALSE;
}
return TRUE;
}
static bfd_boolean
-_bfd_score_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
+s3_bfd_score_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
{
struct elf_link_hash_entry *h;
struct bfd_link_hash_entry *bh;
@@ -3173,7 +3473,7 @@ _bfd_score_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
bh = NULL;
if (!(_bfd_generic_link_add_one_symbol
(info, abfd, name, BSF_GLOBAL, bfd_abs_section_ptr,
- (bfd_vma) 0, (const char *)NULL, FALSE, get_elf_backend_data (abfd)->collect, &bh)))
+ (bfd_vma) 0, NULL, FALSE, get_elf_backend_data (abfd)->collect, &bh)))
return FALSE;
h = (struct elf_link_hash_entry *)bh;
@@ -3191,12 +3491,11 @@ _bfd_score_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
/* Finish up dynamic symbol handling. We set the contents of various
dynamic sections here. */
-
static bfd_boolean
-_bfd_score_elf_finish_dynamic_symbol (bfd *output_bfd,
- struct bfd_link_info *info,
- struct elf_link_hash_entry *h,
- Elf_Internal_Sym *sym)
+s3_bfd_score_elf_finish_dynamic_symbol (bfd *output_bfd,
+ struct bfd_link_info *info,
+ struct elf_link_hash_entry *h,
+ Elf_Internal_Sym *sym)
{
bfd *dynobj;
asection *sgot;
@@ -3218,24 +3517,24 @@ _bfd_score_elf_finish_dynamic_symbol (bfd *output_bfd,
/* FIXME: Can h->dynindex be more than 64K? */
if (h->dynindx & 0xffff0000)
- return FALSE;
+ return FALSE;
/* Fill the stub. */
- bfd_put_32 (output_bfd, STUB_LW, stub);
- bfd_put_32 (output_bfd, STUB_MOVE, stub + 4);
- bfd_put_32 (output_bfd, STUB_LI16 | (h->dynindx << 1), stub + 8);
- bfd_put_32 (output_bfd, STUB_BRL, stub + 12);
+ score_bfd_put_32 (output_bfd, STUB_LW, stub);
+ score_bfd_put_32 (output_bfd, STUB_MOVE, stub + 4);
+ score_bfd_put_32 (output_bfd, STUB_LI16 | (h->dynindx << 1), stub + 8);
+ score_bfd_put_32 (output_bfd, STUB_BRL, stub + 12);
BFD_ASSERT (h->plt.offset <= s->size);
memcpy (s->contents + h->plt.offset, stub, SCORE_FUNCTION_STUB_SIZE);
/* Mark the symbol as undefined. plt.offset != -1 occurs
- only for the referenced symbol. */
+ only for the referenced symbol. */
sym->st_shndx = SHN_UNDEF;
/* The run-time linker uses the st_value field of the symbol
- to reset the global offset table entry for this external
- to its stub address when unlinking a shared object. */
+ to reset the global offset table entry for this external
+ to its stub address when unlinking a shared object. */
sym->st_value = (s->output_section->vma + s->output_offset + h->plt.offset);
}
@@ -3256,7 +3555,7 @@ _bfd_score_elf_finish_dynamic_symbol (bfd *output_bfd,
value = sym->st_value;
offset = score_elf_global_got_index (dynobj, h);
- bfd_put_32 (output_bfd, value, sgot->contents + offset);
+ score_bfd_put_32 (output_bfd, value, sgot->contents + offset);
}
/* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
@@ -3280,10 +3579,9 @@ _bfd_score_elf_finish_dynamic_symbol (bfd *output_bfd,
}
/* Finish up the dynamic sections. */
-
static bfd_boolean
-_bfd_score_elf_finish_dynamic_sections (bfd *output_bfd,
- struct bfd_link_info *info)
+s3_bfd_score_elf_finish_dynamic_sections (bfd *output_bfd,
+ struct bfd_link_info *info)
{
bfd *dynobj;
asection *sdyn;
@@ -3313,88 +3611,88 @@ _bfd_score_elf_finish_dynamic_sections (bfd *output_bfd,
BFD_ASSERT (g != NULL);
for (b = sdyn->contents;
- b < sdyn->contents + sdyn->size;
- b += SCORE_ELF_DYN_SIZE (dynobj))
- {
- Elf_Internal_Dyn dyn;
- const char *name;
- size_t elemsize;
- bfd_boolean swap_out_p;
-
- /* Read in the current dynamic entry. */
- (*get_elf_backend_data (dynobj)->s->swap_dyn_in) (dynobj, b, &dyn);
-
- /* Assume that we're going to modify it and write it out. */
- swap_out_p = TRUE;
-
- switch (dyn.d_tag)
- {
- case DT_RELENT:
- s = score_elf_rel_dyn_section (dynobj, FALSE);
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_val = SCORE_ELF_REL_SIZE (dynobj);
- break;
-
- case DT_STRSZ:
- /* Rewrite DT_STRSZ. */
- dyn.d_un.d_val = _bfd_elf_strtab_size (elf_hash_table (info)->dynstr);
- break;
-
- case DT_PLTGOT:
- name = ".got";
- s = bfd_get_section_by_name (output_bfd, name);
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma;
- break;
-
- case DT_SCORE_BASE_ADDRESS:
- s = output_bfd->sections;
- BFD_ASSERT (s != NULL);
- dyn.d_un.d_ptr = s->vma & ~(bfd_vma) 0xffff;
- break;
-
- case DT_SCORE_LOCAL_GOTNO:
- dyn.d_un.d_val = g->local_gotno;
- break;
-
- case DT_SCORE_UNREFEXTNO:
- /* The index into the dynamic symbol table which is the
- entry of the first external symbol that is not
- referenced within the same object. */
- dyn.d_un.d_val = bfd_count_sections (output_bfd) + 1;
- break;
-
- case DT_SCORE_GOTSYM:
- if (g->global_gotsym)
- {
- dyn.d_un.d_val = g->global_gotsym->dynindx;
- break;
- }
- /* In case if we don't have global got symbols we default
- to setting DT_SCORE_GOTSYM to the same value as
- DT_SCORE_SYMTABNO, so we just fall through. */
-
- case DT_SCORE_SYMTABNO:
- name = ".dynsym";
- elemsize = SCORE_ELF_SYM_SIZE (output_bfd);
- s = bfd_get_section_by_name (output_bfd, name);
- BFD_ASSERT (s != NULL);
-
- dyn.d_un.d_val = s->size / elemsize;
- break;
-
- case DT_SCORE_HIPAGENO:
- dyn.d_un.d_val = g->local_gotno - SCORE_RESERVED_GOTNO;
- break;
-
- default:
- swap_out_p = FALSE;
- break;
- }
-
- if (swap_out_p)
- (*get_elf_backend_data (dynobj)->s->swap_dyn_out) (dynobj, &dyn, b);
- }
+ b < sdyn->contents + sdyn->size;
+ b += SCORE_ELF_DYN_SIZE (dynobj))
+ {
+ Elf_Internal_Dyn dyn;
+ const char *name;
+ size_t elemsize;
+ bfd_boolean swap_out_p;
+
+ /* Read in the current dynamic entry. */
+ (*get_elf_backend_data (dynobj)->s->swap_dyn_in) (dynobj, b, &dyn);
+
+ /* Assume that we're going to modify it and write it out. */
+ swap_out_p = TRUE;
+
+ switch (dyn.d_tag)
+ {
+ case DT_RELENT:
+ s = score_elf_rel_dyn_section (dynobj, FALSE);
+ BFD_ASSERT (s != NULL);
+ dyn.d_un.d_val = SCORE_ELF_REL_SIZE (dynobj);
+ break;
+
+ case DT_STRSZ:
+ /* Rewrite DT_STRSZ. */
+ dyn.d_un.d_val = _bfd_elf_strtab_size (elf_hash_table (info)->dynstr);
+ break;
+
+ case DT_PLTGOT:
+ name = ".got";
+ s = bfd_get_section_by_name (output_bfd, name);
+ BFD_ASSERT (s != NULL);
+ dyn.d_un.d_ptr = s->vma;
+ break;
+
+ case DT_SCORE_BASE_ADDRESS:
+ s = output_bfd->sections;
+ BFD_ASSERT (s != NULL);
+ dyn.d_un.d_ptr = s->vma & ~(bfd_vma) 0xffff;
+ break;
+
+ case DT_SCORE_LOCAL_GOTNO:
+ dyn.d_un.d_val = g->local_gotno;
+ break;
+
+ case DT_SCORE_UNREFEXTNO:
+ /* The index into the dynamic symbol table which is the
+ entry of the first external symbol that is not
+ referenced within the same object. */
+ dyn.d_un.d_val = bfd_count_sections (output_bfd) + 1;
+ break;
+
+ case DT_SCORE_GOTSYM:
+ if (g->global_gotsym)
+ {
+ dyn.d_un.d_val = g->global_gotsym->dynindx;
+ break;
+ }
+ /* In case if we don't have global got symbols we default
+ to setting DT_SCORE_GOTSYM to the same value as
+ DT_SCORE_SYMTABNO, so we just fall through. */
+
+ case DT_SCORE_SYMTABNO:
+ name = ".dynsym";
+ elemsize = SCORE_ELF_SYM_SIZE (output_bfd);
+ s = bfd_get_section_by_name (output_bfd, name);
+ BFD_ASSERT (s != NULL);
+
+ dyn.d_un.d_val = s->size / elemsize;
+ break;
+
+ case DT_SCORE_HIPAGENO:
+ dyn.d_un.d_val = g->local_gotno - SCORE_RESERVED_GOTNO;
+ break;
+
+ default:
+ swap_out_p = FALSE;
+ break;
+ }
+
+ if (swap_out_p)
+ (*get_elf_backend_data (dynobj)->s->swap_dyn_out) (dynobj, &dyn, b);
+ }
}
/* The first entry of the global offset table will be filled at
@@ -3402,8 +3700,8 @@ _bfd_score_elf_finish_dynamic_sections (bfd *output_bfd,
This isn't the case of IRIX rld. */
if (sgot != NULL && sgot->size > 0)
{
- bfd_put_32 (output_bfd, 0, sgot->contents);
- bfd_put_32 (output_bfd, 0x80000000, sgot->contents + SCORE_ELF_GOT_SIZE (output_bfd));
+ score_bfd_put_32 (output_bfd, 0, sgot->contents);
+ score_bfd_put_32 (output_bfd, 0x80000000, sgot->contents + SCORE_ELF_GOT_SIZE (output_bfd));
}
if (sgot != NULL)
@@ -3418,7 +3716,7 @@ _bfd_score_elf_finish_dynamic_sections (bfd *output_bfd,
{
reldyn_sorting_bfd = output_bfd;
qsort ((Elf32_External_Rel *) s->contents + 1, s->reloc_count - 1,
- sizeof (Elf32_External_Rel), score_elf_sort_dynamic_relocs);
+ sizeof (Elf32_External_Rel), score_elf_sort_dynamic_relocs);
}
return TRUE;
@@ -3426,11 +3724,10 @@ _bfd_score_elf_finish_dynamic_sections (bfd *output_bfd,
/* This function set up the ELF section header for a BFD section in preparation for writing
it out. This is where the flags and type fields are set for unusual sections. */
-
static bfd_boolean
-_bfd_score_elf_fake_sections (bfd *abfd ATTRIBUTE_UNUSED,
- Elf_Internal_Shdr *hdr,
- asection *sec)
+s3_bfd_score_elf_fake_sections (bfd *abfd ATTRIBUTE_UNUSED,
+ Elf_Internal_Shdr *hdr,
+ asection *sec)
{
const char *name;
@@ -3452,38 +3749,35 @@ _bfd_score_elf_fake_sections (bfd *abfd ATTRIBUTE_UNUSED,
warning message will be issued. backend_fake_section is called before
assign_file_positions_except_relocs(); backend_section_processing after it. so, we
modify section flag there, but not backend_fake_section. */
-
static bfd_boolean
-_bfd_score_elf_section_processing (bfd *abfd ATTRIBUTE_UNUSED, Elf_Internal_Shdr *hdr)
+s3_bfd_score_elf_section_processing (bfd *abfd ATTRIBUTE_UNUSED, Elf_Internal_Shdr *hdr)
{
if (hdr->bfd_section != NULL)
{
const char *name = bfd_get_section_name (abfd, hdr->bfd_section);
if (strcmp (name, ".sdata") == 0)
- {
- hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_SCORE_GPREL;
- hdr->sh_type = SHT_PROGBITS;
- }
+ {
+ hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_SCORE_GPREL;
+ hdr->sh_type = SHT_PROGBITS;
+ }
else if (strcmp (name, ".sbss") == 0)
- {
- hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_SCORE_GPREL;
- hdr->sh_type = SHT_NOBITS;
- }
+ {
+ hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_SCORE_GPREL;
+ hdr->sh_type = SHT_NOBITS;
+ }
else if (strcmp (name, ".srdata") == 0)
- {
- hdr->sh_flags |= SHF_ALLOC | SHF_SCORE_GPREL;
- hdr->sh_type = SHT_PROGBITS;
- }
+ {
+ hdr->sh_flags |= SHF_ALLOC | SHF_SCORE_GPREL;
+ hdr->sh_type = SHT_PROGBITS;
+ }
}
return TRUE;
}
static bfd_boolean
-_bfd_score_elf_write_section (bfd *output_bfd,
- struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
- asection *sec, bfd_byte *contents)
+s3_bfd_score_elf_write_section (bfd *output_bfd, asection *sec, bfd_byte *contents)
{
bfd_byte *to, *from, *end;
int i;
@@ -3514,11 +3808,10 @@ _bfd_score_elf_write_section (bfd *output_bfd,
/* Copy data from a SCORE ELF indirect symbol to its direct symbol, hiding the old
indirect symbol. Process additional relocation information. */
-
static void
-_bfd_score_elf_copy_indirect_symbol (struct bfd_link_info *info,
- struct elf_link_hash_entry *dir,
- struct elf_link_hash_entry *ind)
+s3_bfd_score_elf_copy_indirect_symbol (struct bfd_link_info *info,
+ struct elf_link_hash_entry *dir,
+ struct elf_link_hash_entry *ind)
{
struct score_elf_link_hash_entry *dirscore, *indscore;
@@ -3539,10 +3832,9 @@ _bfd_score_elf_copy_indirect_symbol (struct bfd_link_info *info,
}
/* Remove information about discarded functions from other sections which mention them. */
-
static bfd_boolean
-_bfd_score_elf_discard_info (bfd *abfd, struct elf_reloc_cookie *cookie,
- struct bfd_link_info *info)
+s3_bfd_score_elf_discard_info (bfd *abfd, struct elf_reloc_cookie *cookie,
+ struct bfd_link_info *info)
{
asection *o;
bfd_boolean ret = FALSE;
@@ -3593,9 +3885,8 @@ _bfd_score_elf_discard_info (bfd *abfd, struct elf_reloc_cookie *cookie,
}
/* Signal that discard_info() has removed the discarded relocations for this section. */
-
static bfd_boolean
-_bfd_score_elf_ignore_discarded_relocs (asection *sec)
+s3_bfd_score_elf_ignore_discarded_relocs (asection *sec)
{
if (strcmp (sec->name, ".pdr") == 0)
return TRUE;
@@ -3604,20 +3895,19 @@ _bfd_score_elf_ignore_discarded_relocs (asection *sec)
/* Return the section that should be marked against GC for a given
relocation. */
-
static asection *
-_bfd_score_elf_gc_mark_hook (asection *sec,
- struct bfd_link_info *info,
- Elf_Internal_Rela *rel,
- struct elf_link_hash_entry *h,
- Elf_Internal_Sym *sym)
+s3_bfd_score_elf_gc_mark_hook (asection *sec,
+ struct bfd_link_info *info,
+ Elf_Internal_Rela *rel,
+ struct elf_link_hash_entry *h,
+ Elf_Internal_Sym *sym)
{
if (h != NULL)
switch (ELF32_R_TYPE (rel->r_info))
{
case R_SCORE_GNU_VTINHERIT:
case R_SCORE_GNU_VTENTRY:
- return NULL;
+ return NULL;
}
return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
@@ -3626,7 +3916,7 @@ _bfd_score_elf_gc_mark_hook (asection *sec,
/* Support for core dump NOTE sections. */
static bfd_boolean
-_bfd_score_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
+s3_bfd_score_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
{
int offset;
unsigned int raw_size;
@@ -3638,10 +3928,10 @@ _bfd_score_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
case 148: /* Linux/Score 32-bit. */
/* pr_cursig */
- elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+ elf_tdata (abfd)->core_signal = score_bfd_get_16 (abfd, note->descdata + 12);
/* pr_pid */
- elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
+ elf_tdata (abfd)->core_pid = score_bfd_get_32 (abfd, note->descdata + 24);
/* pr_reg */
offset = 72;
@@ -3655,7 +3945,7 @@ _bfd_score_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
}
static bfd_boolean
-_bfd_score_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
+s3_bfd_score_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
{
switch (note->descsz)
{
@@ -3684,13 +3974,12 @@ _bfd_score_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
/* Score BFD functions. */
-
static reloc_howto_type *
-elf32_score_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, bfd_reloc_code_real_type code)
+s3_elf32_score_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, bfd_reloc_code_real_type code)
{
unsigned int i;
- for (i = 0; i < NUM_ELEM (elf32_score_reloc_map); i++)
+ for (i = 0; i < ARRAY_SIZE (elf32_score_reloc_map); i++)
if (elf32_score_reloc_map[i].bfd_reloc_val == code)
return &elf32_score_howto_table[elf32_score_reloc_map[i].elf_reloc_val];
@@ -3699,16 +3988,16 @@ elf32_score_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, bfd_reloc_code_real_t
static reloc_howto_type *
elf32_score_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
- const char *r_name)
+ const char *r_name)
{
unsigned int i;
for (i = 0;
i < (sizeof (elf32_score_howto_table)
- / sizeof (elf32_score_howto_table[0]));
+ / sizeof (elf32_score_howto_table[0]));
i++)
if (elf32_score_howto_table[i].name != NULL
- && strcasecmp (elf32_score_howto_table[i].name, r_name) == 0)
+ && strcasecmp (elf32_score_howto_table[i].name, r_name) == 0)
return &elf32_score_howto_table[i];
return NULL;
@@ -3717,7 +4006,7 @@ elf32_score_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
/* Create a score elf linker hash table. */
static struct bfd_link_hash_table *
-elf32_score_link_hash_table_create (bfd *abfd)
+s3_elf32_score_link_hash_table_create (bfd *abfd)
{
struct score_elf_link_hash_table *ret;
bfd_size_type amt = sizeof (struct score_elf_link_hash_table);
@@ -3727,7 +4016,7 @@ elf32_score_link_hash_table_create (bfd *abfd)
return NULL;
if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, score_elf_link_hash_newfunc,
- sizeof (struct score_elf_link_hash_entry)))
+ sizeof (struct score_elf_link_hash_entry)))
{
free (ret);
return NULL;
@@ -3737,7 +4026,7 @@ elf32_score_link_hash_table_create (bfd *abfd)
}
static bfd_boolean
-elf32_score_print_private_bfd_data (bfd *abfd, void * ptr)
+s3_elf32_score_print_private_bfd_data (bfd *abfd, void * ptr)
{
FILE *file = (FILE *) ptr;
@@ -3762,7 +4051,7 @@ elf32_score_print_private_bfd_data (bfd *abfd, void * ptr)
}
static bfd_boolean
-elf32_score_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
+s3_elf32_score_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
{
flagword in_flags;
flagword out_flags;
@@ -3786,10 +4075,10 @@ elf32_score_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
elf_elfheader (obfd)->e_flags = in_flags;
if (bfd_get_arch (obfd) == bfd_get_arch (ibfd)
- && bfd_get_arch_info (obfd)->the_default)
- {
- return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), bfd_get_mach (ibfd));
- }
+ && bfd_get_arch_info (obfd)->the_default)
+ {
+ return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), bfd_get_mach (ibfd));
+ }
return TRUE;
}
@@ -3805,7 +4094,7 @@ elf32_score_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
}
static bfd_boolean
-elf32_score_new_section_hook (bfd *abfd, asection *sec)
+s3_elf32_score_new_section_hook (bfd *abfd, asection *sec)
{
struct _score_elf_section_data *sdata;
bfd_size_type amt = sizeof (*sdata);
@@ -3818,6 +4107,363 @@ elf32_score_new_section_hook (bfd *abfd, asection *sec)
return _bfd_elf_new_section_hook (abfd, sec);
}
+/*****************************************************************************/
+
+/* s3_s7: backend hooks. */
+static void
+_bfd_score_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+ arelent *bfd_reloc,
+ Elf_Internal_Rela *elf_reloc)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_bfd_score_info_to_howto (abfd, bfd_reloc, elf_reloc);
+ else
+ return s7_bfd_score_info_to_howto (abfd, bfd_reloc, elf_reloc);
+}
+
+static bfd_boolean
+_bfd_score_elf_relocate_section (bfd *output_bfd,
+ struct bfd_link_info *info,
+ bfd *input_bfd,
+ asection *input_section,
+ bfd_byte *contents,
+ Elf_Internal_Rela *relocs,
+ Elf_Internal_Sym *local_syms,
+ asection **local_sections)
+{
+ if (bfd_get_mach (output_bfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_relocate_section (output_bfd,
+ info, input_bfd, input_section, contents, relocs,
+ local_syms, local_sections);
+ else
+ return s7_bfd_score_elf_relocate_section (output_bfd,
+ info, input_bfd, input_section, contents, relocs,
+ local_syms, local_sections);
+}
+
+static bfd_boolean
+_bfd_score_elf_check_relocs (bfd *abfd,
+ struct bfd_link_info *info,
+ asection *sec,
+ const Elf_Internal_Rela *relocs)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_check_relocs (abfd, info, sec, relocs);
+ else
+ return s7_bfd_score_elf_check_relocs (abfd, info, sec, relocs);
+}
+
+static bfd_boolean
+_bfd_score_elf_add_symbol_hook (bfd *abfd,
+ struct bfd_link_info *info ATTRIBUTE_UNUSED,
+ Elf_Internal_Sym *sym,
+ const char **namep ATTRIBUTE_UNUSED,
+ flagword *flagsp ATTRIBUTE_UNUSED,
+ asection **secp,
+ bfd_vma *valp)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_add_symbol_hook (abfd, info, sym, namep, flagsp,
+ secp, valp);
+ else
+ return s7_bfd_score_elf_add_symbol_hook (abfd, info, sym, namep, flagsp,
+ secp, valp);
+}
+
+static void
+_bfd_score_elf_symbol_processing (bfd *abfd, asymbol *asym)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_symbol_processing (abfd, asym);
+ else
+ return s7_bfd_score_elf_symbol_processing (abfd, asym);
+}
+
+static bfd_boolean
+_bfd_score_elf_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED,
+ const char *name ATTRIBUTE_UNUSED,
+ Elf_Internal_Sym *sym,
+ asection *input_sec,
+ struct elf_link_hash_entry *h ATTRIBUTE_UNUSED)
+{
+ /* If link a empty .o, then this filed is NULL. */
+ if (info->input_bfds == NULL)
+ {
+ /* If we see a common symbol, which implies a relocatable link, then
+ if a symbol was small common in an input file, mark it as small
+ common in the output file. */
+ if (sym->st_shndx == SHN_COMMON && strcmp (input_sec->name, ".scommon") == 0)
+ sym->st_shndx = SHN_SCORE_SCOMMON;
+ return TRUE;
+ }
+
+ if (bfd_get_mach (info->input_bfds) == bfd_mach_score3)
+ return s3_bfd_score_elf_link_output_symbol_hook (info, name, sym, input_sec, h);
+ else
+ return s7_bfd_score_elf_link_output_symbol_hook (info, name, sym, input_sec, h);
+}
+
+static bfd_boolean
+_bfd_score_elf_section_from_bfd_section (bfd *abfd ATTRIBUTE_UNUSED,
+ asection *sec,
+ int *retval)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_section_from_bfd_section (abfd, sec, retval);
+ else
+ return s7_bfd_score_elf_section_from_bfd_section (abfd, sec, retval);
+}
+
+static bfd_boolean
+_bfd_score_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
+ struct elf_link_hash_entry *h)
+{
+ if (bfd_get_mach (info->input_bfds) == bfd_mach_score3)
+ return s3_bfd_score_elf_adjust_dynamic_symbol (info, h);
+ else
+ return s7_bfd_score_elf_adjust_dynamic_symbol (info, h);
+}
+
+static bfd_boolean
+_bfd_score_elf_always_size_sections (bfd *output_bfd,
+ struct bfd_link_info *info)
+{
+ if (bfd_get_mach (output_bfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_always_size_sections (output_bfd, info);
+ else
+ return s7_bfd_score_elf_always_size_sections (output_bfd, info);
+}
+
+static bfd_boolean
+_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
+{
+ if (bfd_get_mach (output_bfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_size_dynamic_sections (output_bfd, info);
+ else
+ return s7_bfd_score_elf_size_dynamic_sections (output_bfd, info);
+}
+
+static bfd_boolean
+_bfd_score_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_create_dynamic_sections (abfd, info);
+ else
+ return s7_bfd_score_elf_create_dynamic_sections (abfd, info);
+}
+
+static bfd_boolean
+_bfd_score_elf_finish_dynamic_symbol (bfd *output_bfd,
+ struct bfd_link_info *info,
+ struct elf_link_hash_entry *h,
+ Elf_Internal_Sym *sym)
+{
+ if (bfd_get_mach (output_bfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_finish_dynamic_symbol (output_bfd, info, h, sym);
+ else
+ return s7_bfd_score_elf_finish_dynamic_symbol (output_bfd, info, h, sym);
+}
+
+static bfd_boolean
+_bfd_score_elf_finish_dynamic_sections (bfd *output_bfd,
+ struct bfd_link_info *info)
+{
+ if (bfd_get_mach (output_bfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_finish_dynamic_sections (output_bfd, info);
+ else
+ return s7_bfd_score_elf_finish_dynamic_sections (output_bfd, info);
+}
+
+static bfd_boolean
+_bfd_score_elf_fake_sections (bfd *abfd ATTRIBUTE_UNUSED,
+ Elf_Internal_Shdr *hdr,
+ asection *sec)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_fake_sections (abfd, hdr, sec);
+ else
+ return s7_bfd_score_elf_fake_sections (abfd, hdr, sec);
+}
+
+static bfd_boolean
+_bfd_score_elf_section_processing (bfd *abfd ATTRIBUTE_UNUSED, Elf_Internal_Shdr *hdr)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_section_processing (abfd, hdr);
+ else
+ return s7_bfd_score_elf_section_processing (abfd, hdr);
+}
+
+static bfd_boolean
+_bfd_score_elf_write_section (bfd *output_bfd,
+ struct bfd_link_info *link_info ATTRIBUTE_UNUSED,
+ asection *sec, bfd_byte *contents)
+{
+ if (bfd_get_mach (output_bfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_write_section (output_bfd, sec, contents);
+ else
+ return s7_bfd_score_elf_write_section (output_bfd, sec, contents);
+}
+
+static void
+_bfd_score_elf_copy_indirect_symbol (struct bfd_link_info *info,
+ struct elf_link_hash_entry *dir,
+ struct elf_link_hash_entry *ind)
+{
+ if (bfd_get_mach (info->input_bfds) == bfd_mach_score3)
+ return s3_bfd_score_elf_copy_indirect_symbol (info, dir, ind);
+ else
+ return s7_bfd_score_elf_copy_indirect_symbol (info, dir, ind);
+}
+
+static void
+_bfd_score_elf_hide_symbol (struct bfd_link_info *info,
+ struct elf_link_hash_entry *entry,
+ bfd_boolean force_local)
+{
+ if (bfd_get_mach (info->input_bfds) == bfd_mach_score3)
+ return s3_bfd_score_elf_hide_symbol (info, entry, force_local);
+ else
+ return s7_bfd_score_elf_hide_symbol (info, entry, force_local);
+}
+
+static bfd_boolean
+_bfd_score_elf_discard_info (bfd *abfd, struct elf_reloc_cookie *cookie,
+ struct bfd_link_info *info)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_discard_info (abfd, cookie, info);
+ else
+ return s7_bfd_score_elf_discard_info (abfd, cookie, info);
+}
+
+static bfd_boolean
+_bfd_score_elf_ignore_discarded_relocs (asection *sec)
+{
+ if (bfd_get_mach (sec->owner) == bfd_mach_score3)
+ return s3_bfd_score_elf_ignore_discarded_relocs (sec);
+ else
+ return s7_bfd_score_elf_ignore_discarded_relocs (sec);
+}
+
+static asection *
+_bfd_score_elf_gc_mark_hook (asection *sec,
+ struct bfd_link_info *info,
+ Elf_Internal_Rela *rel,
+ struct elf_link_hash_entry *h,
+ Elf_Internal_Sym *sym)
+{
+ if (bfd_get_mach (info->input_bfds) == bfd_mach_score3)
+ return s3_bfd_score_elf_gc_mark_hook (sec, info, rel, h, sym);
+ else
+ return s7_bfd_score_elf_gc_mark_hook (sec, info, rel, h, sym);
+}
+
+static bfd_boolean
+_bfd_score_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_grok_prstatus (abfd, note);
+ else
+ return s7_bfd_score_elf_grok_prstatus (abfd, note);
+}
+
+static bfd_boolean
+_bfd_score_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_bfd_score_elf_grok_psinfo (abfd, note);
+ else
+ return s7_bfd_score_elf_grok_psinfo (abfd, note);
+}
+
+static reloc_howto_type *
+elf32_score_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, bfd_reloc_code_real_type code)
+{
+ /* s3: NOTE!!!
+ gas will call elf32_score_reloc_type_lookup, and don't write elf file.
+ So just using score3, but we don't know ld will call this or not.
+ If so, this way can't work. */
+
+ if (score3)
+ return s3_elf32_score_reloc_type_lookup (abfd, code);
+ else
+ return s7_elf32_score_reloc_type_lookup (abfd, code);
+}
+
+static struct bfd_link_hash_table *
+elf32_score_link_hash_table_create (bfd *abfd)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_elf32_score_link_hash_table_create (abfd);
+ else
+ return s7_elf32_score_link_hash_table_create (abfd);
+}
+
+static bfd_boolean
+elf32_score_print_private_bfd_data (bfd *abfd, void * ptr)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_elf32_score_print_private_bfd_data (abfd, ptr);
+ else
+ return s7_elf32_score_print_private_bfd_data (abfd, ptr);
+}
+
+static bfd_boolean
+elf32_score_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
+{
+ if (bfd_get_mach (obfd) == bfd_mach_score3)
+ return s3_elf32_score_merge_private_bfd_data (ibfd, obfd);
+ else
+ return s7_elf32_score_merge_private_bfd_data (ibfd, obfd);
+}
+
+static bfd_boolean
+elf32_score_new_section_hook (bfd *abfd, asection *sec)
+{
+ if (bfd_get_mach (abfd) == bfd_mach_score3)
+ return s3_elf32_score_new_section_hook (abfd, sec);
+ else
+ return s7_elf32_score_new_section_hook (abfd, sec);
+}
+
+
+/* s3_s7: don't need to split. */
+
+/* Set the right machine number. */
+static bfd_boolean
+_bfd_score_elf_score_object_p (bfd * abfd)
+{
+ int e_set = bfd_mach_score7;
+
+ if (elf_elfheader (abfd)->e_machine == EM_SCORE)
+ {
+ int e_mach = elf_elfheader (abfd)->e_flags & EF_SCORE_MACH & EF_OMIT_PIC_FIXDD;
+ switch (e_mach)
+ {
+ /* Set default target is score7. */
+ default:
+ case E_SCORE_MACH_SCORE7:
+ e_set = bfd_mach_score7;
+ break;
+
+ case E_SCORE_MACH_SCORE3:
+ e_set = bfd_mach_score3;
+ break;
+ }
+ }
+
+ return bfd_default_set_arch_mach (abfd, bfd_arch_score, e_set);
+}
+
+bfd_boolean
+_bfd_score_elf_common_definition (Elf_Internal_Sym *sym)
+{
+ return (sym->st_shndx == SHN_COMMON || sym->st_shndx == SHN_SCORE_SCOMMON);
+}
+
+/*****************************************************************************/
+
#define USE_REL 1
#define TARGET_LITTLE_SYM bfd_elf32_littlescore_vec
@@ -3826,6 +4472,7 @@ elf32_score_new_section_hook (bfd *abfd, asection *sec)
#define TARGET_BIG_NAME "elf32-bigscore"
#define ELF_ARCH bfd_arch_score
#define ELF_MACHINE_CODE EM_SCORE
+#define ELF_MACHINE_ALT1 EM_SCORE_OLD
#define ELF_MAXPAGESIZE 0x8000
#define elf_info_to_howto 0
@@ -3869,6 +4516,7 @@ elf32_score_new_section_hook (bfd *abfd, asection *sec)
#define elf_backend_plt_header_size 0
#define elf_backend_collect TRUE
#define elf_backend_type_change_ok TRUE
+#define elf_backend_object_p _bfd_score_elf_score_object_p
#define bfd_elf32_bfd_reloc_type_lookup elf32_score_reloc_type_lookup
#define bfd_elf32_bfd_reloc_name_lookup \
diff --git a/bfd/elf32-score.h b/bfd/elf32-score.h
new file mode 100644
index 00000000000..d842051f696
--- /dev/null
+++ b/bfd/elf32-score.h
@@ -0,0 +1,152 @@
+/* 32-bit ELF support for S+core.
+ Copyright 2009 Free Software Foundation, Inc.
+ Contributed by
+ Brain.lin (brain.lin@sunplusct.com)
+ Mei Ligang (ligang@sunnorth.com.cn)
+ Pei-Lin Tsai (pltsai@sunplus.com)
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+ MA 02110-1301, USA. */
+
+#include "elf/common.h"
+#include "elf/internal.h"
+
+extern void
+s7_bfd_score_elf_hide_symbol (struct bfd_link_info *,
+ struct elf_link_hash_entry *,
+ bfd_boolean);
+
+extern void
+s7_bfd_score_info_to_howto (bfd *, arelent *, Elf_Internal_Rela *);
+
+extern bfd_boolean
+s7_bfd_score_elf_relocate_section (bfd *,
+ struct bfd_link_info *,
+ bfd *,
+ asection *,
+ bfd_byte *,
+ Elf_Internal_Rela *,
+ Elf_Internal_Sym *,
+ asection **);
+
+extern bfd_boolean
+s7_bfd_score_elf_check_relocs (bfd *,
+ struct bfd_link_info *,
+ asection *,
+ const Elf_Internal_Rela *);
+
+extern bfd_boolean
+s7_bfd_score_elf_add_symbol_hook (bfd *,
+ struct bfd_link_info *,
+ Elf_Internal_Sym *,
+ const char **,
+ flagword *,
+ asection **,
+ bfd_vma *);
+
+extern void
+s7_bfd_score_elf_symbol_processing (bfd *, asymbol *);
+
+extern bfd_boolean
+s7_bfd_score_elf_link_output_symbol_hook (struct bfd_link_info *,
+ const char *,
+ Elf_Internal_Sym *,
+ asection *,
+ struct elf_link_hash_entry *);
+
+extern bfd_boolean
+s7_bfd_score_elf_section_from_bfd_section (bfd *,
+ asection *,
+ int *);
+
+extern bfd_boolean
+s7_bfd_score_elf_adjust_dynamic_symbol (struct bfd_link_info *,
+ struct elf_link_hash_entry *);
+
+extern bfd_boolean
+s7_bfd_score_elf_always_size_sections (bfd *, struct bfd_link_info *);
+
+extern bfd_boolean
+s7_bfd_score_elf_size_dynamic_sections (bfd *, struct bfd_link_info *);
+
+extern bfd_boolean
+s7_bfd_score_elf_create_dynamic_sections (bfd *, struct bfd_link_info *);
+
+extern bfd_boolean
+s7_bfd_score_elf_finish_dynamic_symbol (bfd *,
+ struct bfd_link_info *,
+ struct elf_link_hash_entry *,
+ Elf_Internal_Sym *);
+
+extern bfd_boolean
+s7_bfd_score_elf_finish_dynamic_sections (bfd *, struct bfd_link_info *);
+
+extern bfd_boolean
+s7_bfd_score_elf_fake_sections (bfd *,
+ Elf_Internal_Shdr *,
+ asection *);
+
+extern bfd_boolean
+s7_bfd_score_elf_section_processing (bfd *, Elf_Internal_Shdr *);
+
+extern bfd_boolean
+s7_bfd_score_elf_write_section (bfd *, asection *, bfd_byte *);
+
+extern void
+s7_bfd_score_elf_copy_indirect_symbol (struct bfd_link_info *,
+ struct elf_link_hash_entry *,
+ struct elf_link_hash_entry *);
+
+extern bfd_boolean
+s7_bfd_score_elf_discard_info (bfd *, struct elf_reloc_cookie *,
+ struct bfd_link_info *);
+
+extern bfd_boolean
+s7_bfd_score_elf_ignore_discarded_relocs (asection *);
+
+extern asection *
+s7_bfd_score_elf_gc_mark_hook (asection *,
+ struct bfd_link_info *,
+ Elf_Internal_Rela *,
+ struct elf_link_hash_entry *,
+ Elf_Internal_Sym *);
+
+extern bfd_boolean
+s7_bfd_score_elf_grok_prstatus (bfd *, Elf_Internal_Note *);
+
+extern bfd_boolean
+s7_bfd_score_elf_grok_psinfo (bfd *, Elf_Internal_Note *);
+
+extern reloc_howto_type *
+s7_elf32_score_reloc_type_lookup (bfd *, bfd_reloc_code_real_type);
+
+extern struct bfd_link_hash_table *
+s7_elf32_score_link_hash_table_create (bfd *);
+
+extern bfd_boolean
+s7_elf32_score_print_private_bfd_data (bfd *, void *);
+
+extern bfd_boolean
+s7_elf32_score_merge_private_bfd_data (bfd *, bfd *);
+
+extern bfd_boolean
+s7_elf32_score_new_section_hook (bfd *, asection *);
+
+extern bfd_boolean
+_bfd_score_elf_common_definition (Elf_Internal_Sym *);
+
+#define elf_backend_common_definition _bfd_score_elf_common_definition
diff --git a/bfd/elf32-score7.c b/bfd/elf32-score7.c
new file mode 100644
index 00000000000..81d0dcb6941
--- /dev/null
+++ b/bfd/elf32-score7.c
@@ -0,0 +1,3947 @@
+/* 32-bit ELF support for S+core.
+ Copyright 2009 Free Software Foundation, Inc.
+ Contributed by
+ Brain.lin (brain.lin@sunplusct.com)
+ Mei Ligang (ligang@sunnorth.com.cn)
+ Pei-Lin Tsai (pltsai@sunplus.com)
+
+ This file is part of BFD, the Binary File Descriptor library.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
+ MA 02110-1301, USA. */
+
+#include "bfd.h"
+#include "sysdep.h"
+#include "libbfd.h"
+#include "libiberty.h"
+#include "elf-bfd.h"
+#include "elf/score.h"
+#include "elf/common.h"
+#include "elf/internal.h"
+#include "hashtab.h"
+#include "elf32-score.h"
+
+
+/* Score ELF linker hash table. */
+struct score_elf_link_hash_table
+{
+ /* The main hash table. */
+ struct elf_link_hash_table root;
+};
+
+/* The SCORE ELF linker needs additional information for each symbol in
+ the global hash table. */
+struct score_elf_link_hash_entry
+{
+ struct elf_link_hash_entry root;
+
+ /* Number of R_SCORE_ABS32, R_SCORE_REL32 relocs against this symbol. */
+ unsigned int possibly_dynamic_relocs;
+
+ /* If the R_SCORE_ABS32, R_SCORE_REL32 reloc is against a readonly section. */
+ bfd_boolean readonly_reloc;
+
+ /* We must not create a stub for a symbol that has relocations related to
+ taking the function's address, i.e. any but R_SCORE_CALL15 ones. */
+ bfd_boolean no_fn_stub;
+
+ /* Are we forced local? This will only be set if we have converted
+ the initial global GOT entry to a local GOT entry. */
+ bfd_boolean forced_local;
+};
+
+/* Traverse a score ELF linker hash table. */
+#define score_elf_link_hash_traverse(table, func, info) \
+ (elf_link_hash_traverse \
+ (&(table)->root, \
+ (bfd_boolean (*) (struct elf_link_hash_entry *, void *)) (func), \
+ (info)))
+
+/* Get the SCORE elf linker hash table from a link_info structure. */
+#define score_elf_hash_table(info) \
+ ((struct score_elf_link_hash_table *) ((info)->hash))
+
+/* This structure is used to hold .got entries while estimating got sizes. */
+struct score_got_entry
+{
+ /* The input bfd in which the symbol is defined. */
+ bfd *abfd;
+ /* The index of the symbol, as stored in the relocation r_info, if
+ we have a local symbol; -1 otherwise. */
+ long symndx;
+ union
+ {
+ /* If abfd == NULL, an address that must be stored in the got. */
+ bfd_vma address;
+ /* If abfd != NULL && symndx != -1, the addend of the relocation
+ that should be added to the symbol value. */
+ bfd_vma addend;
+ /* If abfd != NULL && symndx == -1, the hash table entry
+ corresponding to a global symbol in the got (or, local, if
+ h->forced_local). */
+ struct score_elf_link_hash_entry *h;
+ } d;
+
+ /* The offset from the beginning of the .got section to the entry
+ corresponding to this symbol+addend. If it's a global symbol
+ whose offset is yet to be decided, it's going to be -1. */
+ long gotidx;
+};
+
+/* This structure is passed to score_elf_sort_hash_table_f when sorting
+ the dynamic symbols. */
+struct score_elf_hash_sort_data
+{
+ /* The symbol in the global GOT with the lowest dynamic symbol table index. */
+ struct elf_link_hash_entry *low;
+ /* The least dynamic symbol table index corresponding to a symbol with a GOT entry. */
+ long min_got_dynindx;
+ /* The greatest dynamic symbol table index corresponding to a symbol
+ with a GOT entry that is not referenced (e.g., a dynamic symbol
+ with dynamic relocations pointing to it from non-primary GOTs). */
+ long max_unref_got_dynindx;
+ /* The greatest dynamic symbol table index not corresponding to a
+ symbol without a GOT entry. */
+ long max_non_got_dynindx;
+};
+
+struct score_got_info
+{
+ /* The global symbol in the GOT with the lowest index in the dynamic
+ symbol table. */
+ struct elf_link_hash_entry *global_gotsym;
+ /* The number of global .got entries. */
+ unsigned int global_gotno;
+ /* The number of local .got entries. */
+ unsigned int local_gotno;
+ /* The number of local .got entries we have used. */
+ unsigned int assigned_gotno;
+ /* A hash table holding members of the got. */
+ struct htab *got_entries;
+ /* In multi-got links, a pointer to the next got (err, rather, most
+ of the time, it points to the previous got). */
+ struct score_got_info *next;
+};
+
+/* A structure used to count GOT entries, for GOT entry or ELF symbol table traversal. */
+struct _score_elf_section_data
+{
+ struct bfd_elf_section_data elf;
+ union
+ {
+ struct score_got_info *got_info;
+ bfd_byte *tdata;
+ }
+ u;
+};
+
+#define score_elf_section_data(sec) \
+ ((struct _score_elf_section_data *) elf_section_data (sec))
+
+/* The size of a symbol-table entry. */
+#define SCORE_ELF_SYM_SIZE(abfd) \
+ (get_elf_backend_data (abfd)->s->sizeof_sym)
+
+/* In case we're on a 32-bit machine, construct a 64-bit "-1" value
+ from smaller values. Start with zero, widen, *then* decrement. */
+#define MINUS_ONE (((bfd_vma)0) - 1)
+#define MINUS_TWO (((bfd_vma)0) - 2)
+
+#define PDR_SIZE 32
+
+
+/* The number of local .got entries we reserve. */
+#define SCORE_RESERVED_GOTNO (2)
+#define ELF_DYNAMIC_INTERPRETER "/usr/lib/ld.so.1"
+
+/* The offset of $gp from the beginning of the .got section. */
+#define ELF_SCORE_GP_OFFSET(abfd) (0x3ff0)
+
+/* The maximum size of the GOT for it to be addressable using 15-bit offsets from $gp. */
+#define SCORE_ELF_GOT_MAX_SIZE(abfd) (ELF_SCORE_GP_OFFSET(abfd) + 0x3fff)
+
+#define SCORE_ELF_STUB_SECTION_NAME (".SCORE.stub")
+#define SCORE_FUNCTION_STUB_SIZE (16)
+
+#define STUB_LW 0xc3bcc010 /* lw r29, [r28, -0x3ff0] */
+#define STUB_MOVE 0x8323bc56 /* mv r25, r3 */
+#define STUB_LI16 0x87548000 /* ori r26, .dynsym_index */
+#define STUB_BRL 0x801dbc09 /* brl r29 */
+
+#define SCORE_ELF_GOT_SIZE(abfd) \
+ (get_elf_backend_data (abfd)->s->arch_size / 8)
+
+#define SCORE_ELF_ADD_DYNAMIC_ENTRY(info, tag, val) \
+ (_bfd_elf_add_dynamic_entry (info, (bfd_vma) tag, (bfd_vma) val))
+
+/* The size of an external dynamic table entry. */
+#define SCORE_ELF_DYN_SIZE(abfd) \
+ (get_elf_backend_data (abfd)->s->sizeof_dyn)
+
+/* The size of an external REL relocation. */
+#define SCORE_ELF_REL_SIZE(abfd) \
+ (get_elf_backend_data (abfd)->s->sizeof_rel)
+
+/* The default alignment for sections, as a power of two. */
+#define SCORE_ELF_LOG_FILE_ALIGN(abfd)\
+ (get_elf_backend_data (abfd)->s->log_file_align)
+
+static bfd_byte *hi16_rel_addr;
+
+/* This will be used when we sort the dynamic relocation records. */
+static bfd *reldyn_sorting_bfd;
+
+/* SCORE ELF uses two common sections. One is the usual one, and the
+ other is for small objects. All the small objects are kept
+ together, and then referenced via the gp pointer, which yields
+ faster assembler code. This is what we use for the small common
+ section. This approach is copied from ecoff.c. */
+static asection score_elf_scom_section;
+static asymbol score_elf_scom_symbol;
+static asymbol * score_elf_scom_symbol_ptr;
+
+static bfd_reloc_status_type
+score_elf_hi16_reloc (bfd *abfd ATTRIBUTE_UNUSED,
+ arelent *reloc_entry,
+ asymbol *symbol ATTRIBUTE_UNUSED,
+ void * data,
+ asection *input_section ATTRIBUTE_UNUSED,
+ bfd *output_bfd ATTRIBUTE_UNUSED,
+ char **error_message ATTRIBUTE_UNUSED)
+{
+ hi16_rel_addr = (bfd_byte *) data + reloc_entry->address;
+ return bfd_reloc_ok;
+}
+
+static bfd_reloc_status_type
+score_elf_lo16_reloc (bfd *abfd,
+ arelent *reloc_entry,
+ asymbol *symbol ATTRIBUTE_UNUSED,
+ void * data,
+ asection *input_section,
+ bfd *output_bfd ATTRIBUTE_UNUSED,
+ char **error_message ATTRIBUTE_UNUSED)
+{
+ bfd_vma addend = 0, offset = 0;
+ unsigned long val;
+ unsigned long hi16_offset, hi16_value, uvalue;
+
+ hi16_value = bfd_get_32 (abfd, hi16_rel_addr);
+ hi16_offset = ((((hi16_value >> 16) & 0x3) << 15) | (hi16_value & 0x7fff)) >> 1;
+ addend = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
+ offset = ((((addend >> 16) & 0x3) << 15) | (addend & 0x7fff)) >> 1;
+ val = reloc_entry->addend;
+ if (reloc_entry->address > input_section->size)
+ return bfd_reloc_outofrange;
+ uvalue = ((hi16_offset << 16) | (offset & 0xffff)) + val;
+ hi16_offset = (uvalue >> 16) << 1;
+ hi16_value = (hi16_value & ~0x37fff) | (hi16_offset & 0x7fff) | ((hi16_offset << 1) & 0x30000);
+ bfd_put_32 (abfd, hi16_value, hi16_rel_addr);
+ offset = (uvalue & 0xffff) << 1;
+ addend = (addend & ~0x37fff) | (offset & 0x7fff) | ((offset << 1) & 0x30000);
+ bfd_put_32 (abfd, addend, (bfd_byte *) data + reloc_entry->address);
+ return bfd_reloc_ok;
+}
+
+/* Set the GP value for OUTPUT_BFD. Returns FALSE if this is a
+ dangerous relocation. */
+
+static bfd_boolean
+score_elf_assign_gp (bfd *output_bfd, bfd_vma *pgp)
+{
+ unsigned int count;
+ asymbol **sym;
+ unsigned int i;
+
+ /* If we've already figured out what GP will be, just return it. */
+ *pgp = _bfd_get_gp_value (output_bfd);
+ if (*pgp)
+ return TRUE;
+
+ count = bfd_get_symcount (output_bfd);
+ sym = bfd_get_outsymbols (output_bfd);
+
+ /* The linker script will have created a symbol named `_gp' with the
+ appropriate value. */
+ if (sym == NULL)
+ i = count;
+ else
+ {
+ for (i = 0; i < count; i++, sym++)
+ {
+ const char *name;
+
+ name = bfd_asymbol_name (*sym);
+ if (*name == '_' && strcmp (name, "_gp") == 0)
+ {
+ *pgp = bfd_asymbol_value (*sym);
+ _bfd_set_gp_value (output_bfd, *pgp);
+ break;
+ }
+ }
+ }
+
+ if (i >= count)
+ {
+ /* Only get the error once. */
+ *pgp = 4;
+ _bfd_set_gp_value (output_bfd, *pgp);
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+/* We have to figure out the gp value, so that we can adjust the
+ symbol value correctly. We look up the symbol _gp in the output
+ BFD. If we can't find it, we're stuck. We cache it in the ELF
+ target data. We don't need to adjust the symbol value for an
+ external symbol if we are producing relocatable output. */
+
+static bfd_reloc_status_type
+score_elf_final_gp (bfd *output_bfd,
+ asymbol *symbol,
+ bfd_boolean relocatable,
+ char **error_message,
+ bfd_vma *pgp)
+{
+ if (bfd_is_und_section (symbol->section)
+ && ! relocatable)
+ {
+ *pgp = 0;
+ return bfd_reloc_undefined;
+ }
+
+ *pgp = _bfd_get_gp_value (output_bfd);
+ if (*pgp == 0
+ && (! relocatable
+ || (symbol->flags & BSF_SECTION_SYM) != 0))
+ {
+ if (relocatable)
+ {
+ /* Make up a value. */
+ *pgp = symbol->section->output_section->vma + 0x4000;
+ _bfd_set_gp_value (output_bfd, *pgp);
+ }
+ else if (!score_elf_assign_gp (output_bfd, pgp))
+ {
+ *error_message =
+ (char *) _("GP relative relocation when _gp not defined");
+ return bfd_reloc_dangerous;
+ }
+ }
+
+ return bfd_reloc_ok;
+}
+
+static bfd_reloc_status_type
+score_elf_gprel15_with_gp (bfd *abfd,
+ asymbol *symbol,
+ arelent *reloc_entry,
+ asection *input_section,
+ bfd_boolean relocateable,
+ void * data,
+ bfd_vma gp ATTRIBUTE_UNUSED)
+{
+ bfd_vma relocation;
+ unsigned long insn;
+
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+ if (reloc_entry->address > input_section->size)
+ return bfd_reloc_outofrange;
+
+ insn = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
+ if (((reloc_entry->addend & 0xffffc000) != 0)
+ && ((reloc_entry->addend & 0xffffc000) != 0xffffc000))
+ return bfd_reloc_overflow;
+
+ insn = (insn & ~0x7fff) | (reloc_entry->addend & 0x7fff);
+ bfd_put_32 (abfd, insn, (bfd_byte *) data + reloc_entry->address);
+ if (relocateable)
+ reloc_entry->address += input_section->output_offset;
+
+ return bfd_reloc_ok;
+}
+
+static bfd_reloc_status_type
+gprel32_with_gp (bfd *abfd, asymbol *symbol, arelent *reloc_entry,
+ asection *input_section, bfd_boolean relocatable,
+ void *data, bfd_vma gp)
+{
+ bfd_vma relocation;
+ bfd_vma val;
+
+ if (bfd_is_com_section (symbol->section))
+ relocation = 0;
+ else
+ relocation = symbol->value;
+
+ relocation += symbol->section->output_section->vma;
+ relocation += symbol->section->output_offset;
+
+ if (reloc_entry->address > bfd_get_section_limit (abfd, input_section))
+ return bfd_reloc_outofrange;
+
+ /* Set val to the offset into the section or symbol. */
+ val = reloc_entry->addend;
+
+ if (reloc_entry->howto->partial_inplace)
+ val += bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
+
+ /* Adjust val for the final section location and GP value. If we
+ are producing relocatable output, we don't want to do this for
+ an external symbol. */
+ if (! relocatable
+ || (symbol->flags & BSF_SECTION_SYM) != 0)
+ val += relocation - gp;
+
+ if (reloc_entry->howto->partial_inplace)
+ bfd_put_32 (abfd, val, (bfd_byte *) data + reloc_entry->address);
+ else
+ reloc_entry->addend = val;
+
+ if (relocatable)
+ reloc_entry->address += input_section->output_offset;
+
+ return bfd_reloc_ok;
+}
+
+static bfd_reloc_status_type
+score_elf_gprel15_reloc (bfd *abfd,
+ arelent *reloc_entry,
+ asymbol *symbol,
+ void * data,
+ asection *input_section,
+ bfd *output_bfd,
+ char **error_message)
+{
+ bfd_boolean relocateable;
+ bfd_reloc_status_type ret;
+ bfd_vma gp;
+
+ if (output_bfd != NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0 && reloc_entry->addend == 0)
+ {
+ reloc_entry->address += input_section->output_offset;
+ return bfd_reloc_ok;
+ }
+ if (output_bfd != NULL)
+ relocateable = TRUE;
+ else
+ {
+ relocateable = FALSE;
+ output_bfd = symbol->section->output_section->owner;
+ }
+
+ ret = score_elf_final_gp (output_bfd, symbol, relocateable, error_message, &gp);
+ if (ret != bfd_reloc_ok)
+ return ret;
+
+ return score_elf_gprel15_with_gp (abfd, symbol, reloc_entry,
+ input_section, relocateable, data, gp);
+}
+
+/* Do a R_SCORE_GPREL32 relocation. This is a 32 bit value which must
+ become the offset from the gp register. */
+
+static bfd_reloc_status_type
+score_elf_gprel32_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
+ void *data, asection *input_section, bfd *output_bfd,
+ char **error_message)
+{
+ bfd_boolean relocatable;
+ bfd_reloc_status_type ret;
+ bfd_vma gp;
+
+ /* R_SCORE_GPREL32 relocations are defined for local symbols only. */
+ if (output_bfd != NULL
+ && (symbol->flags & BSF_SECTION_SYM) == 0
+ && (symbol->flags & BSF_LOCAL) != 0)
+ {
+ *error_message = (char *)
+ _("32bits gp relative relocation occurs for an external symbol");
+ return bfd_reloc_outofrange;
+ }
+
+ if (output_bfd != NULL)
+ relocatable = TRUE;
+ else
+ {
+ relocatable = FALSE;
+ output_bfd = symbol->section->output_section->owner;
+ }
+
+ ret = score_elf_final_gp (output_bfd, symbol, relocatable, error_message, &gp);
+ if (ret != bfd_reloc_ok)
+ return ret;
+
+ gp = 0;
+ return gprel32_with_gp (abfd, symbol, reloc_entry, input_section,
+ relocatable, data, gp);
+}
+
+/* A howto special_function for R_SCORE_GOT15 relocations. This is just
+ like any other 16-bit relocation when applied to global symbols, but is
+ treated in the same as R_SCORE_HI16 when applied to local symbols. */
+
+static bfd_reloc_status_type
+score_elf_got15_reloc (bfd *abfd, arelent *reloc_entry, asymbol *symbol,
+ void *data, asection *input_section,
+ bfd *output_bfd, char **error_message)
+{
+ if ((symbol->flags & (BSF_GLOBAL | BSF_WEAK)) != 0
+ || bfd_is_und_section (bfd_get_section (symbol))
+ || bfd_is_com_section (bfd_get_section (symbol)))
+ /* The relocation is against a global symbol. */
+ return bfd_elf_generic_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd,
+ error_message);
+
+ return score_elf_hi16_reloc (abfd, reloc_entry, symbol, data,
+ input_section, output_bfd, error_message);
+}
+
+static bfd_reloc_status_type
+score_elf_got_lo16_reloc (bfd *abfd,
+ arelent *reloc_entry,
+ asymbol *symbol ATTRIBUTE_UNUSED,
+ void * data,
+ asection *input_section,
+ bfd *output_bfd ATTRIBUTE_UNUSED,
+ char **error_message ATTRIBUTE_UNUSED)
+{
+ bfd_vma addend = 0, offset = 0;
+ signed long val;
+ signed long hi16_offset, hi16_value, uvalue;
+
+ hi16_value = bfd_get_32 (abfd, hi16_rel_addr);
+ hi16_offset = ((((hi16_value >> 16) & 0x3) << 15) | (hi16_value & 0x7fff)) >> 1;
+ addend = bfd_get_32 (abfd, (bfd_byte *) data + reloc_entry->address);
+ offset = ((((addend >> 16) & 0x3) << 15) | (addend & 0x7fff)) >> 1;
+ val = reloc_entry->addend;
+ if (reloc_entry->address > input_section->size)
+ return bfd_reloc_outofrange;
+ uvalue = ((hi16_offset << 16) | (offset & 0xffff)) + val;
+ if ((uvalue > -0x8000) && (uvalue < 0x7fff))
+ hi16_offset = 0;
+ else
+ hi16_offset = (uvalue >> 16) & 0x7fff;
+ hi16_value = (hi16_value & ~0x37fff) | (hi16_offset & 0x7fff) | ((hi16_offset << 1) & 0x30000);
+ bfd_put_32 (abfd, hi16_value, hi16_rel_addr);
+ offset = (uvalue & 0xffff) << 1;
+ addend = (addend & ~0x37fff) | (offset & 0x7fff) | ((offset << 1) & 0x30000);
+ bfd_put_32 (abfd, addend, (bfd_byte *) data + reloc_entry->address);
+ return bfd_reloc_ok;
+}
+
+static reloc_howto_type elf32_score_howto_table[] =
+{
+ /* No relocation. */
+ HOWTO (R_SCORE_NONE, /* type */
+ 0, /* rightshift */
+ 0, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_SCORE_NONE", /* name */
+ FALSE, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ /* R_SCORE_HI16 */
+ HOWTO (R_SCORE_HI16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ FALSE, /* pc_relative */
+ 1, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ score_elf_hi16_reloc, /* special_function */
+ "R_SCORE_HI16", /* name */
+ TRUE, /* partial_inplace */
+ 0x37fff, /* src_mask */
+ 0x37fff, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ /* R_SCORE_LO16 */
+ HOWTO (R_SCORE_LO16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ FALSE, /* pc_relative */
+ 1, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ score_elf_lo16_reloc, /* special_function */
+ "R_SCORE_LO16", /* name */
+ TRUE, /* partial_inplace */
+ 0x37fff, /* src_mask */
+ 0x37fff, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ /* R_SCORE_BCMP */
+ HOWTO (R_SCORE_BCMP, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ FALSE, /* pc_relative */
+ 1, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_SCORE_BCMP", /* name */
+ TRUE, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ HOWTO (R_SCORE_24, /* type */
+ 1, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 24, /* bitsize */
+ FALSE, /* pc_relative */
+ 1, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_SCORE_24", /* name */
+ FALSE, /* partial_inplace */
+ 0x3ff7fff, /* src_mask */
+ 0x3ff7fff, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ /*R_SCORE_PC19 */
+ HOWTO (R_SCORE_PC19, /* type */
+ 1, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 19, /* bitsize */
+ TRUE, /* pc_relative */
+ 1, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_SCORE_PC19", /* name */
+ FALSE, /* partial_inplace */
+ 0x3ff03fe, /* src_mask */
+ 0x3ff03fe, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ /*R_SCORE16_11 */
+ HOWTO (R_SCORE16_11, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 11, /* bitsize */
+ FALSE, /* pc_relative */
+ 1, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_SCORE16_11", /* name */
+ FALSE, /* partial_inplace */
+ 0x000000ffe, /* src_mask */
+ 0x000000ffe, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ /* R_SCORE16_PC8 */
+ HOWTO (R_SCORE16_PC8, /* type */
+ 1, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 8, /* bitsize */
+ TRUE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_SCORE16_PC8", /* name */
+ FALSE, /* partial_inplace */
+ 0x000000ff, /* src_mask */
+ 0x000000ff, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ /* 32 bit absolute */
+ HOWTO (R_SCORE_ABS32, /* type 8 */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_SCORE_ABS32", /* name */
+ FALSE, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ /* 16 bit absolute */
+ HOWTO (R_SCORE_ABS16, /* type 11 */
+ 0, /* rightshift */
+ 1, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_bitfield, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_SCORE_ABS16", /* name */
+ FALSE, /* partial_inplace */
+ 0x0000ffff, /* src_mask */
+ 0x0000ffff, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ /* R_SCORE_DUMMY2 */
+ HOWTO (R_SCORE_DUMMY2, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_SCORE_DUMMY2", /* name */
+ TRUE, /* partial_inplace */
+ 0x00007fff, /* src_mask */
+ 0x00007fff, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ /* R_SCORE_GP15 */
+ HOWTO (R_SCORE_GP15, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ score_elf_gprel15_reloc,/* special_function */
+ "R_SCORE_GP15", /* name */
+ TRUE, /* partial_inplace */
+ 0x00007fff, /* src_mask */
+ 0x00007fff, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ /* GNU extension to record C++ vtable hierarchy. */
+ HOWTO (R_SCORE_GNU_VTINHERIT, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ NULL, /* special_function */
+ "R_SCORE_GNU_VTINHERIT", /* name */
+ FALSE, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ /* GNU extension to record C++ vtable member usage */
+ HOWTO (R_SCORE_GNU_VTENTRY, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 0, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ _bfd_elf_rel_vtable_reloc_fn, /* special_function */
+ "R_SCORE_GNU_VTENTRY", /* name */
+ FALSE, /* partial_inplace */
+ 0, /* src_mask */
+ 0, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ /* Reference to global offset table. */
+ HOWTO (R_SCORE_GOT15, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ score_elf_got15_reloc, /* special_function */
+ "R_SCORE_GOT15", /* name */
+ TRUE, /* partial_inplace */
+ 0x00007fff, /* src_mask */
+ 0x00007fff, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ /* Low 16 bits of displacement in global offset table. */
+ HOWTO (R_SCORE_GOT_LO16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ FALSE, /* pc_relative */
+ 1, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ score_elf_got_lo16_reloc, /* special_function */
+ "R_SCORE_GOT_LO16", /* name */
+ TRUE, /* partial_inplace */
+ 0x37ffe, /* src_mask */
+ 0x37ffe, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ /* 15 bit call through global offset table. */
+ HOWTO (R_SCORE_CALL15, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_signed, /* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_SCORE_CALL15", /* name */
+ TRUE, /* partial_inplace */
+ 0x00007fff, /* src_mask */
+ 0x00007fff, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ /* 32 bit GP relative reference. */
+ HOWTO (R_SCORE_GPREL32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ score_elf_gprel32_reloc, /* special_function */
+ "R_SCORE_GPREL32", /* name */
+ TRUE, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ /* 32 bit symbol relative relocation. */
+ HOWTO (R_SCORE_REL32, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 32, /* bitsize */
+ FALSE, /* pc_relative */
+ 0, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ bfd_elf_generic_reloc, /* special_function */
+ "R_SCORE_REL32", /* name */
+ TRUE, /* partial_inplace */
+ 0xffffffff, /* src_mask */
+ 0xffffffff, /* dst_mask */
+ FALSE), /* pcrel_offset */
+
+ /* R_SCORE_DUMMY_HI16 */
+ HOWTO (R_SCORE_DUMMY_HI16, /* type */
+ 0, /* rightshift */
+ 2, /* size (0 = byte, 1 = short, 2 = long) */
+ 16, /* bitsize */
+ FALSE, /* pc_relative */
+ 1, /* bitpos */
+ complain_overflow_dont,/* complain_on_overflow */
+ score_elf_hi16_reloc, /* special_function */
+ "R_SCORE_DUMMY_HI16", /* name */
+ TRUE, /* partial_inplace */
+ 0x37fff, /* src_mask */
+ 0x37fff, /* dst_mask */
+ FALSE), /* pcrel_offset */
+};
+
+struct score_reloc_map
+{
+ bfd_reloc_code_real_type bfd_reloc_val;
+ unsigned char elf_reloc_val;
+};
+
+static const struct score_reloc_map elf32_score_reloc_map[] =
+{
+ {BFD_RELOC_NONE, R_SCORE_NONE},
+ {BFD_RELOC_HI16_S, R_SCORE_HI16},
+ {BFD_RELOC_LO16, R_SCORE_LO16},
+ {BFD_RELOC_SCORE_BCMP, R_SCORE_BCMP},
+ {BFD_RELOC_SCORE_JMP, R_SCORE_24},
+ {BFD_RELOC_SCORE_BRANCH, R_SCORE_PC19},
+ {BFD_RELOC_SCORE16_JMP, R_SCORE16_11},
+ {BFD_RELOC_SCORE16_BRANCH, R_SCORE16_PC8},
+ {BFD_RELOC_32, R_SCORE_ABS32},
+ {BFD_RELOC_16, R_SCORE_ABS16},
+ {BFD_RELOC_SCORE_DUMMY2, R_SCORE_DUMMY2},
+ {BFD_RELOC_SCORE_GPREL15, R_SCORE_GP15},
+ {BFD_RELOC_VTABLE_INHERIT, R_SCORE_GNU_VTINHERIT},
+ {BFD_RELOC_VTABLE_ENTRY, R_SCORE_GNU_VTENTRY},
+ {BFD_RELOC_SCORE_GOT15, R_SCORE_GOT15},
+ {BFD_RELOC_SCORE_GOT_LO16, R_SCORE_GOT_LO16},
+ {BFD_RELOC_SCORE_CALL15, R_SCORE_CALL15},
+ {BFD_RELOC_GPREL32, R_SCORE_GPREL32},
+ {BFD_RELOC_32_PCREL, R_SCORE_REL32},
+ {BFD_RELOC_SCORE_DUMMY_HI16, R_SCORE_DUMMY_HI16},
+};
+
+static INLINE hashval_t
+score_elf_hash_bfd_vma (bfd_vma addr)
+{
+#ifdef BFD64
+ return addr + (addr >> 32);
+#else
+ return addr;
+#endif
+}
+
+/* got_entries only match if they're identical, except for gotidx, so
+ use all fields to compute the hash, and compare the appropriate
+ union members. */
+
+static hashval_t
+score_elf_got_entry_hash (const void *entry_)
+{
+ const struct score_got_entry *entry = (struct score_got_entry *) entry_;
+
+ return entry->symndx
+ + (! entry->abfd ? score_elf_hash_bfd_vma (entry->d.address)
+ : entry->abfd->id
+ + (entry->symndx >= 0 ? score_elf_hash_bfd_vma (entry->d.addend)
+ : entry->d.h->root.root.root.hash));
+}
+
+static int
+score_elf_got_entry_eq (const void *entry1, const void *entry2)
+{
+ const struct score_got_entry *e1 = (struct score_got_entry *) entry1;
+ const struct score_got_entry *e2 = (struct score_got_entry *) entry2;
+
+ return e1->abfd == e2->abfd && e1->symndx == e2->symndx
+ && (! e1->abfd ? e1->d.address == e2->d.address
+ : e1->symndx >= 0 ? e1->d.addend == e2->d.addend
+ : e1->d.h == e2->d.h);
+}
+
+/* If H needs a GOT entry, assign it the highest available dynamic
+ index. Otherwise, assign it the lowest available dynamic
+ index. */
+
+static bfd_boolean
+score_elf_sort_hash_table_f (struct score_elf_link_hash_entry *h, void *data)
+{
+ struct score_elf_hash_sort_data *hsd = data;
+
+ if (h->root.root.type == bfd_link_hash_warning)
+ h = (struct score_elf_link_hash_entry *) h->root.root.u.i.link;
+
+ /* Symbols without dynamic symbol table entries aren't interesting at all. */
+ if (h->root.dynindx == -1)
+ return TRUE;
+
+ /* Global symbols that need GOT entries that are not explicitly
+ referenced are marked with got offset 2. Those that are
+ referenced get a 1, and those that don't need GOT entries get
+ -1. */
+ if (h->root.got.offset == 2)
+ {
+ if (hsd->max_unref_got_dynindx == hsd->min_got_dynindx)
+ hsd->low = (struct elf_link_hash_entry *) h;
+ h->root.dynindx = hsd->max_unref_got_dynindx++;
+ }
+ else if (h->root.got.offset != 1)
+ h->root.dynindx = hsd->max_non_got_dynindx++;
+ else
+ {
+ h->root.dynindx = --hsd->min_got_dynindx;
+ hsd->low = (struct elf_link_hash_entry *) h;
+ }
+
+ return TRUE;
+}
+
+static asection *
+score_elf_got_section (bfd *abfd, bfd_boolean maybe_excluded)
+{
+ asection *sgot = bfd_get_section_by_name (abfd, ".got");
+
+ if (sgot == NULL || (! maybe_excluded && (sgot->flags & SEC_EXCLUDE) != 0))
+ return NULL;
+ return sgot;
+}
+
+/* Returns the GOT information associated with the link indicated by
+ INFO. If SGOTP is non-NULL, it is filled in with the GOT section. */
+
+static struct score_got_info *
+score_elf_got_info (bfd *abfd, asection **sgotp)
+{
+ asection *sgot;
+ struct score_got_info *g;
+
+ sgot = score_elf_got_section (abfd, TRUE);
+ BFD_ASSERT (sgot != NULL);
+ BFD_ASSERT (elf_section_data (sgot) != NULL);
+ g = score_elf_section_data (sgot)->u.got_info;
+ BFD_ASSERT (g != NULL);
+
+ if (sgotp)
+ *sgotp = sgot;
+ return g;
+}
+
+/* Sort the dynamic symbol table so that symbols that need GOT entries
+ appear towards the end. This reduces the amount of GOT space
+ required. MAX_LOCAL is used to set the number of local symbols
+ known to be in the dynamic symbol table. During
+ s7_bfd_score_elf_size_dynamic_sections, this value is 1. Afterward, the
+ section symbols are added and the count is higher. */
+
+static bfd_boolean
+score_elf_sort_hash_table (struct bfd_link_info *info,
+ unsigned long max_local)
+{
+ struct score_elf_hash_sort_data hsd;
+ struct score_got_info *g;
+ bfd *dynobj;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ g = score_elf_got_info (dynobj, NULL);
+
+ hsd.low = NULL;
+ hsd.max_unref_got_dynindx =
+ hsd.min_got_dynindx = elf_hash_table (info)->dynsymcount
+ /* In the multi-got case, assigned_gotno of the master got_info
+ indicate the number of entries that aren't referenced in the
+ primary GOT, but that must have entries because there are
+ dynamic relocations that reference it. Since they aren't
+ referenced, we move them to the end of the GOT, so that they
+ don't prevent other entries that are referenced from getting
+ too large offsets. */
+ - (g->next ? g->assigned_gotno : 0);
+ hsd.max_non_got_dynindx = max_local;
+ score_elf_link_hash_traverse (((struct score_elf_link_hash_table *)
+ elf_hash_table (info)),
+ score_elf_sort_hash_table_f,
+ &hsd);
+
+ /* There should have been enough room in the symbol table to
+ accommodate both the GOT and non-GOT symbols. */
+ BFD_ASSERT (hsd.max_non_got_dynindx <= hsd.min_got_dynindx);
+ BFD_ASSERT ((unsigned long) hsd.max_unref_got_dynindx
+ <= elf_hash_table (info)->dynsymcount);
+
+ /* Now we know which dynamic symbol has the lowest dynamic symbol
+ table index in the GOT. */
+ g->global_gotsym = hsd.low;
+
+ return TRUE;
+}
+
+/* Create an entry in an score ELF linker hash table. */
+
+static struct bfd_hash_entry *
+score_elf_link_hash_newfunc (struct bfd_hash_entry *entry,
+ struct bfd_hash_table *table,
+ const char *string)
+{
+ struct score_elf_link_hash_entry *ret = (struct score_elf_link_hash_entry *) entry;
+
+ /* Allocate the structure if it has not already been allocated by a subclass. */
+ if (ret == NULL)
+ ret = bfd_hash_allocate (table, sizeof (struct score_elf_link_hash_entry));
+ if (ret == NULL)
+ return (struct bfd_hash_entry *) ret;
+
+ /* Call the allocation method of the superclass. */
+ ret = ((struct score_elf_link_hash_entry *)
+ _bfd_elf_link_hash_newfunc ((struct bfd_hash_entry *) ret, table, string));
+
+ if (ret != NULL)
+ {
+ ret->possibly_dynamic_relocs = 0;
+ ret->readonly_reloc = FALSE;
+ ret->no_fn_stub = FALSE;
+ ret->forced_local = FALSE;
+ }
+
+ return (struct bfd_hash_entry *) ret;
+}
+
+/* Returns the first relocation of type r_type found, beginning with
+ RELOCATION. RELEND is one-past-the-end of the relocation table. */
+
+static const Elf_Internal_Rela *
+score_elf_next_relocation (bfd *abfd ATTRIBUTE_UNUSED, unsigned int r_type,
+ const Elf_Internal_Rela *relocation,
+ const Elf_Internal_Rela *relend)
+{
+ while (relocation < relend)
+ {
+ if (ELF32_R_TYPE (relocation->r_info) == r_type)
+ return relocation;
+
+ ++relocation;
+ }
+
+ /* We didn't find it. */
+ bfd_set_error (bfd_error_bad_value);
+ return NULL;
+}
+
+/* This function is called via qsort() to sort the dynamic relocation
+ entries by increasing r_symndx value. */
+static int
+score_elf_sort_dynamic_relocs (const void *arg1, const void *arg2)
+{
+ Elf_Internal_Rela int_reloc1;
+ Elf_Internal_Rela int_reloc2;
+
+ bfd_elf32_swap_reloc_in (reldyn_sorting_bfd, arg1, &int_reloc1);
+ bfd_elf32_swap_reloc_in (reldyn_sorting_bfd, arg2, &int_reloc2);
+
+ return (ELF32_R_SYM (int_reloc1.r_info) - ELF32_R_SYM (int_reloc2.r_info));
+}
+
+/* Return whether a relocation is against a local symbol. */
+static bfd_boolean
+score_elf_local_relocation_p (bfd *input_bfd,
+ const Elf_Internal_Rela *relocation,
+ asection **local_sections,
+ bfd_boolean check_forced)
+{
+ unsigned long r_symndx;
+ Elf_Internal_Shdr *symtab_hdr;
+ struct score_elf_link_hash_entry *h;
+ size_t extsymoff;
+
+ r_symndx = ELF32_R_SYM (relocation->r_info);
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ extsymoff = (elf_bad_symtab (input_bfd)) ? 0 : symtab_hdr->sh_info;
+
+ if (r_symndx < extsymoff)
+ return TRUE;
+ if (elf_bad_symtab (input_bfd) && local_sections[r_symndx] != NULL)
+ return TRUE;
+
+ if (check_forced)
+ {
+ /* Look up the hash table to check whether the symbol was forced local. */
+ h = (struct score_elf_link_hash_entry *)
+ elf_sym_hashes (input_bfd) [r_symndx - extsymoff];
+ /* Find the real hash-table entry for this symbol. */
+ while (h->root.root.type == bfd_link_hash_indirect
+ || h->root.root.type == bfd_link_hash_warning)
+ h = (struct score_elf_link_hash_entry *) h->root.root.u.i.link;
+ if (h->root.forced_local)
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/* Returns the dynamic relocation section for DYNOBJ. */
+
+static asection *
+score_elf_rel_dyn_section (bfd *dynobj, bfd_boolean create_p)
+{
+ static const char dname[] = ".rel.dyn";
+ asection *sreloc;
+
+ sreloc = bfd_get_section_by_name (dynobj, dname);
+ if (sreloc == NULL && create_p)
+ {
+ sreloc = bfd_make_section_with_flags (dynobj, dname,
+ (SEC_ALLOC
+ | SEC_LOAD
+ | SEC_HAS_CONTENTS
+ | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED
+ | SEC_READONLY));
+ if (sreloc == NULL
+ || ! bfd_set_section_alignment (dynobj, sreloc,
+ SCORE_ELF_LOG_FILE_ALIGN (dynobj)))
+ return NULL;
+ }
+ return sreloc;
+}
+
+static void
+score_elf_allocate_dynamic_relocations (bfd *abfd, unsigned int n)
+{
+ asection *s;
+
+ s = score_elf_rel_dyn_section (abfd, FALSE);
+ BFD_ASSERT (s != NULL);
+
+ if (s->size == 0)
+ {
+ /* Make room for a null element. */
+ s->size += SCORE_ELF_REL_SIZE (abfd);
+ ++s->reloc_count;
+ }
+ s->size += n * SCORE_ELF_REL_SIZE (abfd);
+}
+
+/* Create a rel.dyn relocation for the dynamic linker to resolve. REL
+ is the original relocation, which is now being transformed into a
+ dynamic relocation. The ADDENDP is adjusted if necessary; the
+ caller should store the result in place of the original addend. */
+
+static bfd_boolean
+score_elf_create_dynamic_relocation (bfd *output_bfd,
+ struct bfd_link_info *info,
+ const Elf_Internal_Rela *rel,
+ struct score_elf_link_hash_entry *h,
+ bfd_vma symbol,
+ bfd_vma *addendp, asection *input_section)
+{
+ Elf_Internal_Rela outrel[3];
+ asection *sreloc;
+ bfd *dynobj;
+ int r_type;
+ long indx;
+ bfd_boolean defined_p;
+
+ r_type = ELF32_R_TYPE (rel->r_info);
+ dynobj = elf_hash_table (info)->dynobj;
+ sreloc = score_elf_rel_dyn_section (dynobj, FALSE);
+ BFD_ASSERT (sreloc != NULL);
+ BFD_ASSERT (sreloc->contents != NULL);
+ BFD_ASSERT (sreloc->reloc_count * SCORE_ELF_REL_SIZE (output_bfd) < sreloc->size);
+
+ outrel[0].r_offset =
+ _bfd_elf_section_offset (output_bfd, info, input_section, rel[0].r_offset);
+ outrel[1].r_offset =
+ _bfd_elf_section_offset (output_bfd, info, input_section, rel[1].r_offset);
+ outrel[2].r_offset =
+ _bfd_elf_section_offset (output_bfd, info, input_section, rel[2].r_offset);
+
+ if (outrel[0].r_offset == MINUS_ONE)
+ /* The relocation field has been deleted. */
+ return TRUE;
+
+ if (outrel[0].r_offset == MINUS_TWO)
+ {
+ /* The relocation field has been converted into a relative value of
+ some sort. Functions like _bfd_elf_write_section_eh_frame expect
+ the field to be fully relocated, so add in the symbol's value. */
+ *addendp += symbol;
+ return TRUE;
+ }
+
+ /* We must now calculate the dynamic symbol table index to use
+ in the relocation. */
+ if (h != NULL
+ && (! info->symbolic || !h->root.def_regular)
+ /* h->root.dynindx may be -1 if this symbol was marked to
+ become local. */
+ && h->root.dynindx != -1)
+ {
+ indx = h->root.dynindx;
+ /* ??? glibc's ld.so just adds the final GOT entry to the
+ relocation field. It therefore treats relocs against
+ defined symbols in the same way as relocs against
+ undefined symbols. */
+ defined_p = FALSE;
+ }
+ else
+ {
+ indx = 0;
+ defined_p = TRUE;
+ }
+
+ /* If the relocation was previously an absolute relocation and
+ this symbol will not be referred to by the relocation, we must
+ adjust it by the value we give it in the dynamic symbol table.
+ Otherwise leave the job up to the dynamic linker. */
+ if (defined_p && r_type != R_SCORE_REL32)
+ *addendp += symbol;
+
+ /* The relocation is always an REL32 relocation because we don't
+ know where the shared library will wind up at load-time. */
+ outrel[0].r_info = ELF32_R_INFO ((unsigned long) indx, R_SCORE_REL32);
+
+ /* For strict adherence to the ABI specification, we should
+ generate a R_SCORE_64 relocation record by itself before the
+ _REL32/_64 record as well, such that the addend is read in as
+ a 64-bit value (REL32 is a 32-bit relocation, after all).
+ However, since none of the existing ELF64 SCORE dynamic
+ loaders seems to care, we don't waste space with these
+ artificial relocations. If this turns out to not be true,
+ score_elf_allocate_dynamic_relocations() should be tweaked so
+ as to make room for a pair of dynamic relocations per
+ invocation if ABI_64_P, and here we should generate an
+ additional relocation record with R_SCORE_64 by itself for a
+ NULL symbol before this relocation record. */
+ outrel[1].r_info = ELF32_R_INFO (0, R_SCORE_NONE);
+ outrel[2].r_info = ELF32_R_INFO (0, R_SCORE_NONE);
+
+ /* Adjust the output offset of the relocation to reference the
+ correct location in the output file. */
+ outrel[0].r_offset += (input_section->output_section->vma
+ + input_section->output_offset);
+ outrel[1].r_offset += (input_section->output_section->vma
+ + input_section->output_offset);
+ outrel[2].r_offset += (input_section->output_section->vma
+ + input_section->output_offset);
+
+ /* Put the relocation back out. We have to use the special
+ relocation outputter in the 64-bit case since the 64-bit
+ relocation format is non-standard. */
+ bfd_elf32_swap_reloc_out
+ (output_bfd, &outrel[0],
+ (sreloc->contents + sreloc->reloc_count * sizeof (Elf32_External_Rel)));
+
+ /* We've now added another relocation. */
+ ++sreloc->reloc_count;
+
+ /* Make sure the output section is writable. The dynamic linker
+ will be writing to it. */
+ elf_section_data (input_section->output_section)->this_hdr.sh_flags |= SHF_WRITE;
+
+ return TRUE;
+}
+
+static bfd_boolean
+score_elf_create_got_section (bfd *abfd,
+ struct bfd_link_info *info,
+ bfd_boolean maybe_exclude)
+{
+ flagword flags;
+ asection *s;
+ struct elf_link_hash_entry *h;
+ struct bfd_link_hash_entry *bh;
+ struct score_got_info *g;
+ bfd_size_type amt;
+
+ /* This function may be called more than once. */
+ s = score_elf_got_section (abfd, TRUE);
+ if (s)
+ {
+ if (! maybe_exclude)
+ s->flags &= ~SEC_EXCLUDE;
+ return TRUE;
+ }
+
+ flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY | SEC_LINKER_CREATED);
+
+ if (maybe_exclude)
+ flags |= SEC_EXCLUDE;
+
+ /* We have to use an alignment of 2**4 here because this is hardcoded
+ in the function stub generation and in the linker script. */
+ s = bfd_make_section_with_flags (abfd, ".got", flags);
+ if (s == NULL
+ || ! bfd_set_section_alignment (abfd, s, 4))
+ return FALSE;
+
+ /* Define the symbol _GLOBAL_OFFSET_TABLE_. We don't do this in the
+ linker script because we don't want to define the symbol if we
+ are not creating a global offset table. */
+ bh = NULL;
+ if (! (_bfd_generic_link_add_one_symbol
+ (info, abfd, "_GLOBAL_OFFSET_TABLE_", BSF_GLOBAL, s,
+ 0, NULL, FALSE, get_elf_backend_data (abfd)->collect, &bh)))
+ return FALSE;
+
+ h = (struct elf_link_hash_entry *) bh;
+ h->non_elf = 0;
+ h->def_regular = 1;
+ h->type = STT_OBJECT;
+
+ if (info->shared && ! bfd_elf_link_record_dynamic_symbol (info, h))
+ return FALSE;
+
+ amt = sizeof (struct score_got_info);
+ g = bfd_alloc (abfd, amt);
+ if (g == NULL)
+ return FALSE;
+
+ g->global_gotsym = NULL;
+ g->global_gotno = 0;
+
+ g->local_gotno = SCORE_RESERVED_GOTNO;
+ g->assigned_gotno = SCORE_RESERVED_GOTNO;
+ g->next = NULL;
+
+ g->got_entries = htab_try_create (1, score_elf_got_entry_hash,
+ score_elf_got_entry_eq, NULL);
+ if (g->got_entries == NULL)
+ return FALSE;
+ score_elf_section_data (s)->u.got_info = g;
+ score_elf_section_data (s)->elf.this_hdr.sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_SCORE_GPREL;
+
+ return TRUE;
+}
+
+/* Calculate the %high function. */
+
+static bfd_vma
+score_elf_high (bfd_vma value)
+{
+ return ((value + (bfd_vma) 0x8000) >> 16) & 0xffff;
+}
+
+/* Create a local GOT entry for VALUE. Return the index of the entry,
+ or -1 if it could not be created. */
+
+static struct score_got_entry *
+score_elf_create_local_got_entry (bfd *abfd,
+ bfd *ibfd ATTRIBUTE_UNUSED,
+ struct score_got_info *gg,
+ asection *sgot, bfd_vma value,
+ unsigned long r_symndx ATTRIBUTE_UNUSED,
+ struct score_elf_link_hash_entry *h ATTRIBUTE_UNUSED,
+ int r_type ATTRIBUTE_UNUSED)
+{
+ struct score_got_entry entry, **loc;
+ struct score_got_info *g;
+
+ entry.abfd = NULL;
+ entry.symndx = -1;
+ entry.d.address = value;
+
+ g = gg;
+ loc = (struct score_got_entry **) htab_find_slot (g->got_entries, &entry, INSERT);
+ if (*loc)
+ return *loc;
+
+ entry.gotidx = SCORE_ELF_GOT_SIZE (abfd) * g->assigned_gotno++;
+
+ *loc = bfd_alloc (abfd, sizeof entry);
+
+ if (! *loc)
+ return NULL;
+
+ memcpy (*loc, &entry, sizeof entry);
+
+ if (g->assigned_gotno >= g->local_gotno)
+ {
+ (*loc)->gotidx = -1;
+ /* We didn't allocate enough space in the GOT. */
+ (*_bfd_error_handler)
+ (_("not enough GOT space for local GOT entries"));
+ bfd_set_error (bfd_error_bad_value);
+ return NULL;
+ }
+
+ bfd_put_32 (abfd, value, (sgot->contents + entry.gotidx));
+
+ return *loc;
+}
+
+/* Find a GOT entry whose higher-order 16 bits are the same as those
+ for value. Return the index into the GOT for this entry. */
+
+static bfd_vma
+score_elf_got16_entry (bfd *abfd, bfd *ibfd, struct bfd_link_info *info,
+ bfd_vma value, bfd_boolean external)
+{
+ asection *sgot;
+ struct score_got_info *g;
+ struct score_got_entry *entry;
+
+ if (!external)
+ {
+ /* Although the ABI says that it is "the high-order 16 bits" that we
+ want, it is really the %high value. The complete value is
+ calculated with a `addiu' of a LO16 relocation, just as with a
+ HI16/LO16 pair. */
+ value = score_elf_high (value) << 16;
+ }
+
+ g = score_elf_got_info (elf_hash_table (info)->dynobj, &sgot);
+
+ entry = score_elf_create_local_got_entry (abfd, ibfd, g, sgot, value, 0, NULL,
+ R_SCORE_GOT15);
+ if (entry)
+ return entry->gotidx;
+ else
+ return MINUS_ONE;
+}
+
+void
+s7_bfd_score_elf_hide_symbol (struct bfd_link_info *info,
+ struct elf_link_hash_entry *entry,
+ bfd_boolean force_local)
+{
+ bfd *dynobj;
+ asection *got;
+ struct score_got_info *g;
+ struct score_elf_link_hash_entry *h;
+
+ h = (struct score_elf_link_hash_entry *) entry;
+ if (h->forced_local)
+ return;
+ h->forced_local = TRUE;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ if (dynobj != NULL && force_local)
+ {
+ got = score_elf_got_section (dynobj, FALSE);
+ if (got == NULL)
+ return;
+ g = score_elf_section_data (got)->u.got_info;
+
+ if (g->next)
+ {
+ struct score_got_entry e;
+ struct score_got_info *gg = g;
+
+ /* Since we're turning what used to be a global symbol into a
+ local one, bump up the number of local entries of each GOT
+ that had an entry for it. This will automatically decrease
+ the number of global entries, since global_gotno is actually
+ the upper limit of global entries. */
+ e.abfd = dynobj;
+ e.symndx = -1;
+ e.d.h = h;
+
+ for (g = g->next; g != gg; g = g->next)
+ if (htab_find (g->got_entries, &e))
+ {
+ BFD_ASSERT (g->global_gotno > 0);
+ g->local_gotno++;
+ g->global_gotno--;
+ }
+
+ /* If this was a global symbol forced into the primary GOT, we
+ no longer need an entry for it. We can't release the entry
+ at this point, but we must at least stop counting it as one
+ of the symbols that required a forced got entry. */
+ if (h->root.got.offset == 2)
+ {
+ BFD_ASSERT (gg->assigned_gotno > 0);
+ gg->assigned_gotno--;
+ }
+ }
+ else if (g->global_gotno == 0 && g->global_gotsym == NULL)
+ /* If we haven't got through GOT allocation yet, just bump up the
+ number of local entries, as this symbol won't be counted as
+ global. */
+ g->local_gotno++;
+ else if (h->root.got.offset == 1)
+ {
+ /* If we're past non-multi-GOT allocation and this symbol had
+ been marked for a global got entry, give it a local entry
+ instead. */
+ BFD_ASSERT (g->global_gotno > 0);
+ g->local_gotno++;
+ g->global_gotno--;
+ }
+ }
+
+ _bfd_elf_link_hash_hide_symbol (info, &h->root, force_local);
+}
+
+/* If H is a symbol that needs a global GOT entry, but has a dynamic
+ symbol table index lower than any we've seen to date, record it for
+ posterity. */
+
+static bfd_boolean
+score_elf_record_global_got_symbol (struct elf_link_hash_entry *h,
+ bfd *abfd,
+ struct bfd_link_info *info,
+ struct score_got_info *g)
+{
+ struct score_got_entry entry, **loc;
+
+ /* A global symbol in the GOT must also be in the dynamic symbol table. */
+ if (h->dynindx == -1)
+ {
+ switch (ELF_ST_VISIBILITY (h->other))
+ {
+ case STV_INTERNAL:
+ case STV_HIDDEN:
+ s7_bfd_score_elf_hide_symbol (info, h, TRUE);
+ break;
+ }
+ if (!bfd_elf_link_record_dynamic_symbol (info, h))
+ return FALSE;
+ }
+
+ entry.abfd = abfd;
+ entry.symndx = -1;
+ entry.d.h = (struct score_elf_link_hash_entry *) h;
+
+ loc = (struct score_got_entry **) htab_find_slot (g->got_entries, &entry, INSERT);
+
+ /* If we've already marked this entry as needing GOT space, we don't
+ need to do it again. */
+ if (*loc)
+ return TRUE;
+
+ *loc = bfd_alloc (abfd, sizeof entry);
+ if (! *loc)
+ return FALSE;
+
+ entry.gotidx = -1;
+
+ memcpy (*loc, &entry, sizeof (entry));
+
+ if (h->got.offset != MINUS_ONE)
+ return TRUE;
+
+ /* By setting this to a value other than -1, we are indicating that
+ there needs to be a GOT entry for H. Avoid using zero, as the
+ generic ELF copy_indirect_symbol tests for <= 0. */
+ h->got.offset = 1;
+
+ return TRUE;
+}
+
+/* Reserve space in G for a GOT entry containing the value of symbol
+ SYMNDX in input bfd ABDF, plus ADDEND. */
+
+static bfd_boolean
+score_elf_record_local_got_symbol (bfd *abfd,
+ long symndx,
+ bfd_vma addend,
+ struct score_got_info *g)
+{
+ struct score_got_entry entry, **loc;
+
+ entry.abfd = abfd;
+ entry.symndx = symndx;
+ entry.d.addend = addend;
+ loc = (struct score_got_entry **) htab_find_slot (g->got_entries, &entry, INSERT);
+
+ if (*loc)
+ return TRUE;
+
+ entry.gotidx = g->local_gotno++;
+
+ *loc = bfd_alloc (abfd, sizeof(entry));
+ if (! *loc)
+ return FALSE;
+
+ memcpy (*loc, &entry, sizeof (entry));
+
+ return TRUE;
+}
+
+/* Returns the GOT offset at which the indicated address can be found.
+ If there is not yet a GOT entry for this value, create one.
+ Returns -1 if no satisfactory GOT offset can be found. */
+
+static bfd_vma
+score_elf_local_got_index (bfd *abfd, bfd *ibfd, struct bfd_link_info *info,
+ bfd_vma value, unsigned long r_symndx,
+ struct score_elf_link_hash_entry *h, int r_type)
+{
+ asection *sgot;
+ struct score_got_info *g;
+ struct score_got_entry *entry;
+
+ g = score_elf_got_info (elf_hash_table (info)->dynobj, &sgot);
+
+ entry = score_elf_create_local_got_entry (abfd, ibfd, g, sgot, value,
+ r_symndx, h, r_type);
+ if (!entry)
+ return MINUS_ONE;
+
+ else
+ return entry->gotidx;
+}
+
+/* Returns the GOT index for the global symbol indicated by H. */
+
+static bfd_vma
+score_elf_global_got_index (bfd *abfd, struct elf_link_hash_entry *h)
+{
+ bfd_vma index;
+ asection *sgot;
+ struct score_got_info *g;
+ long global_got_dynindx = 0;
+
+ g = score_elf_got_info (abfd, &sgot);
+ if (g->global_gotsym != NULL)
+ global_got_dynindx = g->global_gotsym->dynindx;
+
+ /* Once we determine the global GOT entry with the lowest dynamic
+ symbol table index, we must put all dynamic symbols with greater
+ indices into the GOT. That makes it easy to calculate the GOT
+ offset. */
+ BFD_ASSERT (h->dynindx >= global_got_dynindx);
+ index = ((h->dynindx - global_got_dynindx + g->local_gotno) * SCORE_ELF_GOT_SIZE (abfd));
+ BFD_ASSERT (index < sgot->size);
+
+ return index;
+}
+
+/* Returns the offset for the entry at the INDEXth position in the GOT. */
+
+static bfd_vma
+score_elf_got_offset_from_index (bfd *dynobj, bfd *output_bfd,
+ bfd *input_bfd ATTRIBUTE_UNUSED, bfd_vma index)
+{
+ asection *sgot;
+ bfd_vma gp;
+ struct score_got_info *g;
+
+ g = score_elf_got_info (dynobj, &sgot);
+ gp = _bfd_get_gp_value (output_bfd);
+
+ return sgot->output_section->vma + sgot->output_offset + index - gp;
+}
+
+/* Follow indirect and warning hash entries so that each got entry
+ points to the final symbol definition. P must point to a pointer
+ to the hash table we're traversing. Since this traversal may
+ modify the hash table, we set this pointer to NULL to indicate
+ we've made a potentially-destructive change to the hash table, so
+ the traversal must be restarted. */
+
+static int
+score_elf_resolve_final_got_entry (void **entryp, void *p)
+{
+ struct score_got_entry *entry = (struct score_got_entry *) *entryp;
+ htab_t got_entries = *(htab_t *) p;
+
+ if (entry->abfd != NULL && entry->symndx == -1)
+ {
+ struct score_elf_link_hash_entry *h = entry->d.h;
+
+ while (h->root.root.type == bfd_link_hash_indirect
+ || h->root.root.type == bfd_link_hash_warning)
+ h = (struct score_elf_link_hash_entry *) h->root.root.u.i.link;
+
+ if (entry->d.h == h)
+ return 1;
+
+ entry->d.h = h;
+
+ /* If we can't find this entry with the new bfd hash, re-insert
+ it, and get the traversal restarted. */
+ if (! htab_find (got_entries, entry))
+ {
+ htab_clear_slot (got_entries, entryp);
+ entryp = htab_find_slot (got_entries, entry, INSERT);
+ if (! *entryp)
+ *entryp = entry;
+ /* Abort the traversal, since the whole table may have
+ moved, and leave it up to the parent to restart the
+ process. */
+ *(htab_t *) p = NULL;
+ return 0;
+ }
+ /* We might want to decrement the global_gotno count, but it's
+ either too early or too late for that at this point. */
+ }
+
+ return 1;
+}
+
+/* Turn indirect got entries in a got_entries table into their final locations. */
+
+static void
+score_elf_resolve_final_got_entries (struct score_got_info *g)
+{
+ htab_t got_entries;
+
+ do
+ {
+ got_entries = g->got_entries;
+
+ htab_traverse (got_entries,
+ score_elf_resolve_final_got_entry,
+ &got_entries);
+ }
+ while (got_entries == NULL);
+}
+
+/* Add INCREMENT to the reloc (of type HOWTO) at ADDRESS. for -r */
+
+static void
+score_elf_add_to_rel (bfd *abfd,
+ bfd_byte *address,
+ reloc_howto_type *howto,
+ bfd_signed_vma increment)
+{
+ bfd_signed_vma addend;
+ bfd_vma contents;
+ unsigned long offset;
+ unsigned long r_type = howto->type;
+ unsigned long hi16_addend, hi16_offset, hi16_value, uvalue;
+
+ contents = bfd_get_32 (abfd, address);
+ /* Get the (signed) value from the instruction. */
+ addend = contents & howto->src_mask;
+ if (addend & ((howto->src_mask + 1) >> 1))
+ {
+ bfd_signed_vma mask;
+
+ mask = -1;
+ mask &= ~howto->src_mask;
+ addend |= mask;
+ }
+ /* Add in the increment, (which is a byte value). */
+ switch (r_type)
+ {
+ case R_SCORE_PC19:
+ offset =
+ (((contents & howto->src_mask) & 0x3ff0000) >> 6) | ((contents & howto->src_mask) & 0x3ff);
+ offset += increment;
+ contents =
+ (contents & ~howto->
+ src_mask) | (((offset << 6) & howto->src_mask) & 0x3ff0000) | (offset & 0x3ff);
+ bfd_put_32 (abfd, contents, address);
+ break;
+ case R_SCORE_HI16:
+ break;
+ case R_SCORE_LO16:
+ hi16_addend = bfd_get_32 (abfd, address - 4);
+ hi16_offset = ((((hi16_addend >> 16) & 0x3) << 15) | (hi16_addend & 0x7fff)) >> 1;
+ offset = ((((contents >> 16) & 0x3) << 15) | (contents & 0x7fff)) >> 1;
+ offset = (hi16_offset << 16) | (offset & 0xffff);
+ uvalue = increment + offset;
+ hi16_offset = (uvalue >> 16) << 1;
+ hi16_value = (hi16_addend & (~(howto->dst_mask)))
+ | (hi16_offset & 0x7fff) | ((hi16_offset << 1) & 0x30000);
+ bfd_put_32 (abfd, hi16_value, address - 4);
+ offset = (uvalue & 0xffff) << 1;
+ contents = (contents & (~(howto->dst_mask))) | (offset & 0x7fff) | ((offset << 1) & 0x30000);
+ bfd_put_32 (abfd, contents, address);
+ break;
+ case R_SCORE_24:
+ offset =
+ (((contents & howto->src_mask) >> 1) & 0x1ff8000) | ((contents & howto->src_mask) & 0x7fff);
+ offset += increment;
+ contents =
+ (contents & ~howto->
+ src_mask) | (((offset << 1) & howto->src_mask) & 0x3ff0000) | (offset & 0x7fff);
+ bfd_put_32 (abfd, contents, address);
+ break;
+ case R_SCORE16_11:
+
+ contents = bfd_get_16 (abfd, address);
+ offset = contents & howto->src_mask;
+ offset += increment;
+ contents = (contents & ~howto->src_mask) | (offset & howto->src_mask);
+ bfd_put_16 (abfd, contents, address);
+
+ break;
+ case R_SCORE16_PC8:
+
+ contents = bfd_get_16 (abfd, address);
+ offset = (contents & howto->src_mask) + ((increment >> 1) & 0xff);
+ contents = (contents & (~howto->src_mask)) | (offset & howto->src_mask);
+ bfd_put_16 (abfd, contents, address);
+
+ break;
+ case R_SCORE_GOT15:
+ case R_SCORE_GOT_LO16:
+ break;
+
+ default:
+ addend += increment;
+ contents = (contents & ~howto->dst_mask) | (addend & howto->dst_mask);
+ bfd_put_32 (abfd, contents, address);
+ break;
+ }
+}
+
+/* Perform a relocation as part of a final link. */
+
+static bfd_reloc_status_type
+score_elf_final_link_relocate (reloc_howto_type *howto,
+ bfd *input_bfd,
+ bfd *output_bfd,
+ asection *input_section,
+ bfd_byte *contents,
+ Elf_Internal_Rela *rel,
+ Elf_Internal_Rela *relocs,
+ bfd_vma symbol,
+ struct bfd_link_info *info,
+ const char *sym_name ATTRIBUTE_UNUSED,
+ int sym_flags ATTRIBUTE_UNUSED,
+ struct score_elf_link_hash_entry *h,
+ Elf_Internal_Sym *local_syms,
+ asection **local_sections,
+ bfd_boolean gp_disp_p)
+{
+ unsigned long r_type;
+ unsigned long r_symndx;
+ bfd_byte *hit_data = contents + rel->r_offset;
+ bfd_vma addend;
+ /* The final GP value to be used for the relocatable, executable, or
+ shared object file being produced. */
+ bfd_vma gp = MINUS_ONE;
+ /* The place (section offset or address) of the storage unit being relocated. */
+ bfd_vma rel_addr;
+ /* The value of GP used to create the relocatable object. */
+ bfd_vma gp0 = MINUS_ONE;
+ /* The offset into the global offset table at which the address of the relocation entry
+ symbol, adjusted by the addend, resides during execution. */
+ bfd_vma g = MINUS_ONE;
+ /* TRUE if the symbol referred to by this relocation is a local symbol. */
+ bfd_boolean local_p;
+ /* The eventual value we will relocate. */
+ bfd_vma value = symbol;
+ unsigned long hi16_addend, hi16_offset, hi16_value, uvalue, offset, abs_value = 0;
+
+ Elf_Internal_Sym *sym = 0;
+ asection *sec = NULL;
+ bfd_boolean merge_p = 0;
+
+
+ if (elf_gp (output_bfd) == 0)
+ {
+ struct bfd_link_hash_entry *bh;
+ asection *o;
+
+ bh = bfd_link_hash_lookup (info->hash, "_gp", 0, 0, 1);
+ if (bh != NULL && bh->type == bfd_link_hash_defined)
+ elf_gp (output_bfd) = (bh->u.def.value
+ + bh->u.def.section->output_section->vma
+ + bh->u.def.section->output_offset);
+ else if (info->relocatable)
+ {
+ bfd_vma lo = -1;
+
+ /* Find the GP-relative section with the lowest offset. */
+ for (o = output_bfd->sections; o != NULL; o = o->next)
+ if (o->vma < lo)
+ lo = o->vma;
+ /* And calculate GP relative to that. */
+ elf_gp (output_bfd) = lo + ELF_SCORE_GP_OFFSET (input_bfd);
+ }
+ else
+ {
+ /* If the relocate_section function needs to do a reloc
+ involving the GP value, it should make a reloc_dangerous
+ callback to warn that GP is not defined. */
+ }
+ }
+
+ /* Parse the relocation. */
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ r_type = ELF32_R_TYPE (rel->r_info);
+ rel_addr = (input_section->output_section->vma + input_section->output_offset + rel->r_offset);
+
+ /* For hidden symbol. */
+ local_p = score_elf_local_relocation_p (input_bfd, rel, local_sections, FALSE);
+ if (local_p)
+ {
+ sym = local_syms + r_symndx;
+ sec = local_sections[r_symndx];
+
+ symbol = sec->output_section->vma + sec->output_offset;
+ if (ELF_ST_TYPE (sym->st_info) != STT_SECTION
+ || (sec->flags & SEC_MERGE))
+ symbol += sym->st_value;
+ if ((sec->flags & SEC_MERGE)
+ && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ merge_p = 1;
+ }
+
+ if (r_type == R_SCORE_GOT15)
+ {
+ const Elf_Internal_Rela *relend;
+ const Elf_Internal_Rela *lo16_rel;
+ const struct elf_backend_data *bed;
+ bfd_vma lo_value = 0;
+
+ bed = get_elf_backend_data (output_bfd);
+ relend = relocs + input_section->reloc_count * bed->s->int_rels_per_ext_rel;
+ lo16_rel = score_elf_next_relocation (input_bfd, R_SCORE_GOT_LO16, rel, relend);
+ if ((local_p) && (lo16_rel != NULL))
+ {
+ bfd_vma tmp = 0;
+ tmp = bfd_get_32 (input_bfd, contents + lo16_rel->r_offset);
+ lo_value = (((tmp >> 16) & 0x3) << 14) | ((tmp & 0x7fff) >> 1);
+ if (merge_p)
+ {
+ asection *msec = sec;
+ lo_value = _bfd_elf_rel_local_sym (output_bfd, sym, &msec, lo_value);
+ lo_value -= symbol;
+ lo_value += msec->output_section->vma + msec->output_offset;
+ }
+ }
+ addend = lo_value;
+ }
+ else
+ {
+ addend = (bfd_get_32 (input_bfd, hit_data) >> howto->bitpos) & howto->src_mask;
+ }
+
+ /* Figure out the value of the symbol. */
+ if (local_p && !merge_p)
+ {
+ if (r_type == R_SCORE_GOT15)
+ {
+ const Elf_Internal_Rela *relend;
+ const Elf_Internal_Rela *lo16_rel;
+ const struct elf_backend_data *bed;
+ bfd_vma lo_value = 0;
+
+ value = bfd_get_32 (input_bfd, contents + rel->r_offset);
+ addend = value & 0x7fff;
+ if ((addend & 0x4000) == 0x4000)
+ addend |= 0xffffc000;
+
+ bed = get_elf_backend_data (output_bfd);
+ relend = relocs + input_section->reloc_count * bed->s->int_rels_per_ext_rel;
+ lo16_rel = score_elf_next_relocation (input_bfd, R_SCORE_GOT_LO16, rel, relend);
+ if ((local_p) && (lo16_rel != NULL))
+ {
+ bfd_vma tmp = 0;
+ tmp = bfd_get_32 (input_bfd, contents + lo16_rel->r_offset);
+ lo_value = (((tmp >> 16) & 0x3) << 14) | ((tmp & 0x7fff) >> 1);
+ }
+
+ addend <<= 16;
+ addend += lo_value;
+ }
+ }
+
+ local_p = score_elf_local_relocation_p (input_bfd, rel, local_sections, TRUE);
+
+ /* If we haven't already determined the GOT offset, or the GP value,
+ and we're going to need it, get it now. */
+ switch (r_type)
+ {
+ case R_SCORE_CALL15:
+ case R_SCORE_GOT15:
+ if (!local_p)
+ {
+ g = score_elf_global_got_index (elf_hash_table (info)->dynobj,
+ (struct elf_link_hash_entry *) h);
+ if ((! elf_hash_table(info)->dynamic_sections_created
+ || (info->shared
+ && (info->symbolic || h->root.dynindx == -1)
+ && h->root.def_regular)))
+ {
+ /* This is a static link or a -Bsymbolic link. The
+ symbol is defined locally, or was forced to be local.
+ We must initialize this entry in the GOT. */
+ bfd *tmpbfd = elf_hash_table (info)->dynobj;
+ asection *sgot = score_elf_got_section (tmpbfd, FALSE);
+ bfd_put_32 (tmpbfd, value, sgot->contents + g);
+ }
+ }
+ else if (r_type == R_SCORE_GOT15 || r_type == R_SCORE_CALL15)
+ {
+ /* There's no need to create a local GOT entry here; the
+ calculation for a local GOT15 entry does not involve G. */
+ ;
+ }
+ else
+ {
+ g = score_elf_local_got_index (output_bfd, input_bfd, info,
+ symbol + addend, r_symndx, h, r_type);
+ if (g == MINUS_ONE)
+ return bfd_reloc_outofrange;
+ }
+
+ /* Convert GOT indices to actual offsets. */
+ g = score_elf_got_offset_from_index (elf_hash_table (info)->dynobj,
+ output_bfd, input_bfd, g);
+ break;
+
+ case R_SCORE_HI16:
+ case R_SCORE_LO16:
+ case R_SCORE_GPREL32:
+ gp0 = _bfd_get_gp_value (input_bfd);
+ gp = _bfd_get_gp_value (output_bfd);
+ break;
+
+ case R_SCORE_GP15:
+ gp = _bfd_get_gp_value (output_bfd);
+
+ default:
+ break;
+ }
+
+ switch (r_type)
+ {
+ case R_SCORE_NONE:
+ return bfd_reloc_ok;
+
+ case R_SCORE_ABS32:
+ case R_SCORE_REL32:
+ if ((info->shared
+ || (elf_hash_table (info)->dynamic_sections_created
+ && h != NULL
+ && h->root.def_dynamic
+ && !h->root.def_regular))
+ && r_symndx != 0
+ && (input_section->flags & SEC_ALLOC) != 0)
+ {
+ /* If we're creating a shared library, or this relocation is against a symbol
+ in a shared library, then we can't know where the symbol will end up.
+ So, we create a relocation record in the output, and leave the job up
+ to the dynamic linker. */
+ value = addend;
+ if (!score_elf_create_dynamic_relocation (output_bfd, info, rel, h,
+ symbol, &value,
+ input_section))
+ return bfd_reloc_undefined;
+ }
+ else if (r_symndx == 0)
+ /* r_symndx will be zero only for relocs against symbols
+ from removed linkonce sections, or sections discarded by
+ a linker script. */
+ value = 0;
+ else
+ {
+ if (r_type != R_SCORE_REL32)
+ value = symbol + addend;
+ else
+ value = addend;
+ }
+ value &= howto->dst_mask;
+ bfd_put_32 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_SCORE_ABS16:
+ value += addend;
+ if ((long) value > 0x7fff || (long) value < -0x8000)
+ return bfd_reloc_overflow;
+ bfd_put_16 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_SCORE_24:
+ addend = bfd_get_32 (input_bfd, hit_data);
+ offset = (((addend & howto->src_mask) >> 1) & 0x1ff8000) | ((addend & howto->src_mask) & 0x7fff);
+ if ((offset & 0x1000000) != 0)
+ offset |= 0xfe000000;
+ value += offset;
+ abs_value = abs (value - rel_addr);
+ if ((abs_value & 0xfe000000) != 0)
+ return bfd_reloc_overflow;
+ addend = (addend & ~howto->src_mask)
+ | (((value << 1) & howto->src_mask) & 0x3ff0000) | (value & 0x7fff);
+ bfd_put_32 (input_bfd, addend, hit_data);
+ return bfd_reloc_ok;
+
+ case R_SCORE_PC19:
+ addend = bfd_get_32 (input_bfd, hit_data);
+ offset = (((addend & howto->src_mask) & 0x3ff0000) >> 6) | ((addend & howto->src_mask) & 0x3ff);
+ if ((offset & 0x80000) != 0)
+ offset |= 0xfff00000;
+ abs_value = value = value - rel_addr + offset;
+ /* exceed 20 bit : overflow. */
+ if ((abs_value & 0x80000000) == 0x80000000)
+ abs_value = 0xffffffff - value + 1;
+ if ((abs_value & 0xfff80000) != 0)
+ return bfd_reloc_overflow;
+ addend = (addend & ~howto->src_mask)
+ | (((value << 6) & howto->src_mask) & 0x3ff0000) | (value & 0x3ff);
+ bfd_put_32 (input_bfd, addend, hit_data);
+ return bfd_reloc_ok;
+
+ case R_SCORE16_11:
+ addend = bfd_get_16 (input_bfd, hit_data);
+ offset = addend & howto->src_mask;
+ if ((offset & 0x800) != 0) /* Offset is negative. */
+ offset |= 0xfffff000;
+ value += offset;
+ abs_value = abs (value - rel_addr);
+ if ((abs_value & 0xfffff000) != 0)
+ return bfd_reloc_overflow;
+ addend = (addend & ~howto->src_mask) | (value & howto->src_mask);
+ bfd_put_16 (input_bfd, addend, hit_data);
+ return bfd_reloc_ok;
+
+ case R_SCORE16_PC8:
+ addend = bfd_get_16 (input_bfd, hit_data);
+ offset = (addend & howto->src_mask) << 1;
+ if ((offset & 0x100) != 0) /* Offset is negative. */
+ offset |= 0xfffffe00;
+ abs_value = value = value - rel_addr + offset;
+ /* Sign bit + exceed 9 bit. */
+ if (((value & 0xffffff00) != 0) && ((value & 0xffffff00) != 0xffffff00))
+ return bfd_reloc_overflow;
+ value >>= 1;
+ addend = (addend & ~howto->src_mask) | (value & howto->src_mask);
+ bfd_put_16 (input_bfd, addend, hit_data);
+ return bfd_reloc_ok;
+
+ case R_SCORE_HI16:
+ return bfd_reloc_ok;
+
+ case R_SCORE_LO16:
+ hi16_addend = bfd_get_32 (input_bfd, hit_data - 4);
+ hi16_offset = ((((hi16_addend >> 16) & 0x3) << 15) | (hi16_addend & 0x7fff)) >> 1;
+ addend = bfd_get_32 (input_bfd, hit_data);
+ offset = ((((addend >> 16) & 0x3) << 15) | (addend & 0x7fff)) >> 1;
+ offset = (hi16_offset << 16) | (offset & 0xffff);
+
+ if (!gp_disp_p)
+ uvalue = value + offset;
+ else
+ uvalue = offset + gp - rel_addr + 4;
+
+ hi16_offset = (uvalue >> 16) << 1;
+ hi16_value = (hi16_addend & (~(howto->dst_mask)))
+ | (hi16_offset & 0x7fff) | ((hi16_offset << 1) & 0x30000);
+ bfd_put_32 (input_bfd, hi16_value, hit_data - 4);
+ offset = (uvalue & 0xffff) << 1;
+ value = (addend & (~(howto->dst_mask))) | (offset & 0x7fff) | ((offset << 1) & 0x30000);
+ bfd_put_32 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_SCORE_GP15:
+ addend = bfd_get_32 (input_bfd, hit_data);
+ offset = addend & 0x7fff;
+ if ((offset & 0x4000) == 0x4000)
+ offset |= 0xffffc000;
+ value = value + offset - gp;
+ if (((value & 0xffffc000) != 0) && ((value & 0xffffc000) != 0xffffc000))
+ return bfd_reloc_overflow;
+ value = (addend & ~howto->src_mask) | (value & howto->src_mask);
+ bfd_put_32 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_SCORE_GOT15:
+ case R_SCORE_CALL15:
+ if (local_p)
+ {
+ bfd_boolean forced;
+
+ /* The special case is when the symbol is forced to be local. We need the
+ full address in the GOT since no R_SCORE_GOT_LO16 relocation follows. */
+ forced = ! score_elf_local_relocation_p (input_bfd, rel,
+ local_sections, FALSE);
+ value = score_elf_got16_entry (output_bfd, input_bfd, info,
+ symbol + addend, forced);
+ if (value == MINUS_ONE)
+ return bfd_reloc_outofrange;
+ value = score_elf_got_offset_from_index (elf_hash_table (info)->dynobj,
+ output_bfd, input_bfd, value);
+ }
+ else
+ {
+ value = g;
+ }
+
+ if ((long) value > 0x3fff || (long) value < -0x4000)
+ return bfd_reloc_overflow;
+
+ addend = bfd_get_32 (input_bfd, hit_data);
+ value = (addend & ~howto->dst_mask) | (value & howto->dst_mask);
+ bfd_put_32 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_SCORE_GPREL32:
+ value = (addend + symbol + gp0 - gp);
+ value &= howto->dst_mask;
+ bfd_put_32 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_SCORE_GOT_LO16:
+ addend = bfd_get_32 (input_bfd, hit_data);
+ value = (((addend >> 16) & 0x3) << 14) | ((addend & 0x7fff) >> 1);
+ value += symbol;
+ value = (addend & (~(howto->dst_mask))) | ((value & 0x3fff) << 1)
+ | (((value >> 14) & 0x3) << 16);
+
+ bfd_put_32 (input_bfd, value, hit_data);
+ return bfd_reloc_ok;
+
+ case R_SCORE_DUMMY_HI16:
+ return bfd_reloc_ok;
+
+ case R_SCORE_GNU_VTINHERIT:
+ case R_SCORE_GNU_VTENTRY:
+ /* We don't do anything with these at present. */
+ return bfd_reloc_continue;
+
+ default:
+ return bfd_reloc_notsupported;
+ }
+}
+
+/* Score backend functions. */
+
+void
+s7_bfd_score_info_to_howto (bfd *abfd ATTRIBUTE_UNUSED,
+ arelent *bfd_reloc,
+ Elf_Internal_Rela *elf_reloc)
+{
+ unsigned int r_type;
+
+ r_type = ELF32_R_TYPE (elf_reloc->r_info);
+ if (r_type >= ARRAY_SIZE (elf32_score_howto_table))
+ bfd_reloc->howto = NULL;
+ else
+ bfd_reloc->howto = &elf32_score_howto_table[r_type];
+}
+
+/* Relocate an score ELF section. */
+
+bfd_boolean
+s7_bfd_score_elf_relocate_section (bfd *output_bfd,
+ struct bfd_link_info *info,
+ bfd *input_bfd,
+ asection *input_section,
+ bfd_byte *contents,
+ Elf_Internal_Rela *relocs,
+ Elf_Internal_Sym *local_syms,
+ asection **local_sections)
+{
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ Elf_Internal_Rela *rel;
+ Elf_Internal_Rela *relend;
+ const char *name;
+ unsigned long offset;
+ unsigned long hi16_addend, hi16_offset, hi16_value, uvalue;
+ size_t extsymoff;
+ bfd_boolean gp_disp_p = FALSE;
+
+ /* Sort dynsym. */
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ bfd_size_type dynsecsymcount = 0;
+ if (info->shared)
+ {
+ asection * p;
+ const struct elf_backend_data *bed = get_elf_backend_data (output_bfd);
+
+ for (p = output_bfd->sections; p ; p = p->next)
+ if ((p->flags & SEC_EXCLUDE) == 0
+ && (p->flags & SEC_ALLOC) != 0
+ && !(*bed->elf_backend_omit_section_dynsym) (output_bfd, info, p))
+ ++ dynsecsymcount;
+ }
+
+ if (!score_elf_sort_hash_table (info, dynsecsymcount + 1))
+ return FALSE;
+ }
+
+ symtab_hdr = &elf_tdata (input_bfd)->symtab_hdr;
+ extsymoff = (elf_bad_symtab (input_bfd)) ? 0 : symtab_hdr->sh_info;
+ sym_hashes = elf_sym_hashes (input_bfd);
+ rel = relocs;
+ relend = relocs + input_section->reloc_count;
+ for (; rel < relend; rel++)
+ {
+ int r_type;
+ reloc_howto_type *howto;
+ unsigned long r_symndx;
+ Elf_Internal_Sym *sym;
+ asection *sec;
+ struct score_elf_link_hash_entry *h;
+ bfd_vma relocation = 0;
+ bfd_reloc_status_type r;
+ arelent bfd_reloc;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ r_type = ELF32_R_TYPE (rel->r_info);
+
+ s7_bfd_score_info_to_howto (input_bfd, &bfd_reloc, (Elf_Internal_Rela *) rel);
+ howto = bfd_reloc.howto;
+
+ h = NULL;
+ sym = NULL;
+ sec = NULL;
+
+ if (r_symndx < extsymoff)
+ {
+ sym = local_syms + r_symndx;
+ sec = local_sections[r_symndx];
+ relocation = sec->output_section->vma + sec->output_offset;
+ name = bfd_elf_sym_name (input_bfd, symtab_hdr, sym, sec);
+
+ if (!info->relocatable)
+ {
+ if (ELF_ST_TYPE (sym->st_info) != STT_SECTION
+ || (sec->flags & SEC_MERGE))
+ {
+ relocation += sym->st_value;
+ }
+
+ if ((sec->flags & SEC_MERGE)
+ && ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ {
+ asection *msec;
+ bfd_vma addend, value;
+
+ switch (r_type)
+ {
+ case R_SCORE_HI16:
+ break;
+ case R_SCORE_LO16:
+ hi16_addend = bfd_get_32 (input_bfd, contents + rel->r_offset - 4);
+ hi16_offset = ((((hi16_addend >> 16) & 0x3) << 15) | (hi16_addend & 0x7fff)) >> 1;
+ value = bfd_get_32 (input_bfd, contents + rel->r_offset);
+ offset = ((((value >> 16) & 0x3) << 15) | (value & 0x7fff)) >> 1;
+ addend = (hi16_offset << 16) | (offset & 0xffff);
+ msec = sec;
+ addend = _bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend);
+ addend -= relocation;
+ addend += msec->output_section->vma + msec->output_offset;
+ uvalue = addend;
+ hi16_offset = (uvalue >> 16) << 1;
+ hi16_value = (hi16_addend & (~(howto->dst_mask)))
+ | (hi16_offset & 0x7fff) | ((hi16_offset << 1) & 0x30000);
+ bfd_put_32 (input_bfd, hi16_value, contents + rel->r_offset - 4);
+ offset = (uvalue & 0xffff) << 1;
+ value = (value & (~(howto->dst_mask)))
+ | (offset & 0x7fff) | ((offset << 1) & 0x30000);
+ bfd_put_32 (input_bfd, value, contents + rel->r_offset);
+ break;
+ case R_SCORE_GOT_LO16:
+ value = bfd_get_32 (input_bfd, contents + rel->r_offset);
+ addend = (((value >> 16) & 0x3) << 14) | ((value & 0x7fff) >> 1);
+ msec = sec;
+ addend = _bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend) - relocation;
+ addend += msec->output_section->vma + msec->output_offset;
+ value = (value & (~(howto->dst_mask))) | ((addend & 0x3fff) << 1)
+ | (((addend >> 14) & 0x3) << 16);
+
+ bfd_put_32 (input_bfd, value, contents + rel->r_offset);
+ break;
+ default:
+ value = bfd_get_32 (input_bfd, contents + rel->r_offset);
+ /* Get the (signed) value from the instruction. */
+ addend = value & howto->src_mask;
+ if (addend & ((howto->src_mask + 1) >> 1))
+ {
+ bfd_signed_vma mask;
+
+ mask = -1;
+ mask &= ~howto->src_mask;
+ addend |= mask;
+ }
+ msec = sec;
+ addend = _bfd_elf_rel_local_sym (output_bfd, sym, &msec, addend) - relocation;
+ addend += msec->output_section->vma + msec->output_offset;
+ value = (value & ~howto->dst_mask) | (addend & howto->dst_mask);
+ bfd_put_32 (input_bfd, value, contents + rel->r_offset);
+ break;
+ }
+ }
+ }
+ }
+ else
+ {
+ /* For global symbols we look up the symbol in the hash-table. */
+ h = ((struct score_elf_link_hash_entry *)
+ elf_sym_hashes (input_bfd) [r_symndx - extsymoff]);
+ /* Find the real hash-table entry for this symbol. */
+ while (h->root.root.type == bfd_link_hash_indirect
+ || h->root.root.type == bfd_link_hash_warning)
+ h = (struct score_elf_link_hash_entry *) h->root.root.u.i.link;
+
+ /* Record the name of this symbol, for our caller. */
+ name = h->root.root.root.string;
+
+ /* See if this is the special GP_DISP_LABEL symbol. Note that such a
+ symbol must always be a global symbol. */
+ if (strcmp (name, GP_DISP_LABEL) == 0)
+ {
+ /* Relocations against GP_DISP_LABEL are permitted only with
+ R_SCORE_HI16 and R_SCORE_LO16 relocations. */
+ if (r_type != R_SCORE_HI16 && r_type != R_SCORE_LO16)
+ return bfd_reloc_notsupported;
+
+ gp_disp_p = TRUE;
+ }
+
+ /* If this symbol is defined, calculate its address. Note that
+ GP_DISP_LABEL is a magic symbol, always implicitly defined by the
+ linker, so it's inappropriate to check to see whether or not
+ its defined. */
+ else if ((h->root.root.type == bfd_link_hash_defined
+ || h->root.root.type == bfd_link_hash_defweak)
+ && h->root.root.u.def.section)
+ {
+ sec = h->root.root.u.def.section;
+ if (sec->output_section)
+ relocation = (h->root.root.u.def.value
+ + sec->output_section->vma
+ + sec->output_offset);
+ else
+ {
+ relocation = h->root.root.u.def.value;
+ }
+ }
+ else if (h->root.root.type == bfd_link_hash_undefweak)
+ /* We allow relocations against undefined weak symbols, giving
+ it the value zero, so that you can undefined weak functions
+ and check to see if they exist by looking at their addresses. */
+ relocation = 0;
+ else if (info->unresolved_syms_in_objects == RM_IGNORE
+ && ELF_ST_VISIBILITY (h->root.other) == STV_DEFAULT)
+ relocation = 0;
+ else if (strcmp (name, "_DYNAMIC_LINK") == 0)
+ {
+ /* If this is a dynamic link, we should have created a _DYNAMIC_LINK symbol
+ in s7_bfd_score_elf_create_dynamic_sections. Otherwise, we should define
+ the symbol with a value of 0. */
+ BFD_ASSERT (! info->shared);
+ BFD_ASSERT (bfd_get_section_by_name (output_bfd, ".dynamic") == NULL);
+ relocation = 0;
+ }
+ else if (!info->relocatable)
+ {
+ if (! ((*info->callbacks->undefined_symbol)
+ (info, h->root.root.root.string, input_bfd,
+ input_section, rel->r_offset,
+ (info->unresolved_syms_in_objects == RM_GENERATE_ERROR)
+ || ELF_ST_VISIBILITY (h->root.other))))
+ return bfd_reloc_undefined;
+ relocation = 0;
+ }
+ }
+
+ if (sec != NULL && elf_discarded_section (sec))
+ {
+ /* For relocs against symbols from removed linkonce sections,
+ or sections discarded by a linker script, we just want the
+ section contents zeroed. Avoid any special processing. */
+ _bfd_clear_contents (howto, input_bfd, contents + rel->r_offset);
+ rel->r_info = 0;
+ rel->r_addend = 0;
+ continue;
+ }
+
+ if (info->relocatable)
+ {
+ /* This is a relocatable link. We don't have to change
+ anything, unless the reloc is against a section symbol,
+ in which case we have to adjust according to where the
+ section symbol winds up in the output section. */
+ if (r_symndx < symtab_hdr->sh_info)
+ {
+ sym = local_syms + r_symndx;
+
+ if (r_type == R_SCORE_GOT15)
+ {
+ const Elf_Internal_Rela *relend;
+ const Elf_Internal_Rela *lo16_rel;
+ const struct elf_backend_data *bed;
+ bfd_vma lo_addend = 0, lo_value = 0;
+ bfd_vma addend, value;
+
+ value = bfd_get_32 (input_bfd, contents + rel->r_offset);
+ addend = value & 0x7fff;
+ if ((addend & 0x4000) == 0x4000)
+ addend |= 0xffffc000;
+
+ bed = get_elf_backend_data (output_bfd);
+ relend = relocs + input_section->reloc_count * bed->s->int_rels_per_ext_rel;
+ lo16_rel = score_elf_next_relocation (input_bfd, R_SCORE_GOT_LO16, rel, relend);
+ if (lo16_rel != NULL)
+ {
+ lo_value = bfd_get_32 (input_bfd, contents + lo16_rel->r_offset);
+ lo_addend = (((lo_value >> 16) & 0x3) << 14) | ((lo_value & 0x7fff) >> 1);
+ }
+
+ addend <<= 16;
+ addend += lo_addend;
+
+ if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ addend += local_sections[r_symndx]->output_offset;
+
+ lo_addend = addend & 0xffff;
+ lo_value = (lo_value & (~(howto->dst_mask))) | ((lo_addend & 0x3fff) << 1)
+ | (((lo_addend >> 14) & 0x3) << 16);
+ bfd_put_32 (input_bfd, lo_value, contents + lo16_rel->r_offset);
+
+ addend = addend >> 16;
+ value = (value & ~howto->src_mask) | (addend & howto->src_mask);
+ bfd_put_32 (input_bfd, value, contents + rel->r_offset);
+ }
+ else if (ELF_ST_TYPE (sym->st_info) == STT_SECTION)
+ {
+ sec = local_sections[r_symndx];
+ score_elf_add_to_rel (input_bfd, contents + rel->r_offset,
+ howto, (bfd_signed_vma) (sec->output_offset + sym->st_value));
+ }
+ }
+ continue;
+ }
+
+ /* This is a final link. */
+ r = score_elf_final_link_relocate (howto, input_bfd, output_bfd,
+ input_section, contents, rel, relocs,
+ relocation, info, name,
+ (h ? ELF_ST_TYPE ((unsigned int) h->root.root.type) :
+ ELF_ST_TYPE ((unsigned int) sym->st_info)), h, local_syms,
+ local_sections, gp_disp_p);
+
+ if (r != bfd_reloc_ok)
+ {
+ const char *msg = (const char *)0;
+
+ switch (r)
+ {
+ case bfd_reloc_overflow:
+ /* If the overflowing reloc was to an undefined symbol,
+ we have already printed one error message and there
+ is no point complaining again. */
+ if (((!h) || (h->root.root.type != bfd_link_hash_undefined))
+ && (!((*info->callbacks->reloc_overflow)
+ (info, NULL, name, howto->name, (bfd_vma) 0,
+ input_bfd, input_section, rel->r_offset))))
+ return FALSE;
+ break;
+ case bfd_reloc_undefined:
+ if (!((*info->callbacks->undefined_symbol)
+ (info, name, input_bfd, input_section, rel->r_offset, TRUE)))
+ return FALSE;
+ break;
+
+ case bfd_reloc_outofrange:
+ msg = _("internal error: out of range error");
+ goto common_error;
+
+ case bfd_reloc_notsupported:
+ msg = _("internal error: unsupported relocation error");
+ goto common_error;
+
+ case bfd_reloc_dangerous:
+ msg = _("internal error: dangerous error");
+ goto common_error;
+
+ default:
+ msg = _("internal error: unknown error");
+ /* fall through */
+
+ common_error:
+ if (!((*info->callbacks->warning)
+ (info, msg, name, input_bfd, input_section, rel->r_offset)))
+ return FALSE;
+ break;
+ }
+ }
+ }
+
+ return TRUE;
+}
+
+/* Look through the relocs for a section during the first phase, and
+ allocate space in the global offset table. */
+
+bfd_boolean
+s7_bfd_score_elf_check_relocs (bfd *abfd,
+ struct bfd_link_info *info,
+ asection *sec,
+ const Elf_Internal_Rela *relocs)
+{
+ const char *name;
+ bfd *dynobj;
+ Elf_Internal_Shdr *symtab_hdr;
+ struct elf_link_hash_entry **sym_hashes;
+ struct score_got_info *g;
+ size_t extsymoff;
+ const Elf_Internal_Rela *rel;
+ const Elf_Internal_Rela *rel_end;
+ asection *sgot;
+ asection *sreloc;
+ const struct elf_backend_data *bed;
+
+ if (info->relocatable)
+ return TRUE;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ symtab_hdr = &elf_tdata (abfd)->symtab_hdr;
+ sym_hashes = elf_sym_hashes (abfd);
+ extsymoff = (elf_bad_symtab (abfd)) ? 0 : symtab_hdr->sh_info;
+
+ name = bfd_get_section_name (abfd, sec);
+
+ if (dynobj == NULL)
+ {
+ sgot = NULL;
+ g = NULL;
+ }
+ else
+ {
+ sgot = score_elf_got_section (dynobj, FALSE);
+ if (sgot == NULL)
+ g = NULL;
+ else
+ {
+ BFD_ASSERT (score_elf_section_data (sgot) != NULL);
+ g = score_elf_section_data (sgot)->u.got_info;
+ BFD_ASSERT (g != NULL);
+ }
+ }
+
+ sreloc = NULL;
+ bed = get_elf_backend_data (abfd);
+ rel_end = relocs + sec->reloc_count * bed->s->int_rels_per_ext_rel;
+ for (rel = relocs; rel < rel_end; ++rel)
+ {
+ unsigned long r_symndx;
+ unsigned int r_type;
+ struct elf_link_hash_entry *h;
+
+ r_symndx = ELF32_R_SYM (rel->r_info);
+ r_type = ELF32_R_TYPE (rel->r_info);
+
+ if (r_symndx < extsymoff)
+ {
+ h = NULL;
+ }
+ else if (r_symndx >= extsymoff + NUM_SHDR_ENTRIES (symtab_hdr))
+ {
+ (*_bfd_error_handler) (_("%s: Malformed reloc detected for section %s"), abfd, name);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
+ else
+ {
+ h = sym_hashes[r_symndx - extsymoff];
+
+ /* This may be an indirect symbol created because of a version. */
+ if (h != NULL)
+ {
+ while (h->root.type == bfd_link_hash_indirect)
+ h = (struct elf_link_hash_entry *) h->root.u.i.link;
+ }
+ }
+
+ /* Some relocs require a global offset table. */
+ if (dynobj == NULL || sgot == NULL)
+ {
+ switch (r_type)
+ {
+ case R_SCORE_GOT15:
+ case R_SCORE_CALL15:
+ if (dynobj == NULL)
+ elf_hash_table (info)->dynobj = dynobj = abfd;
+ if (!score_elf_create_got_section (dynobj, info, FALSE))
+ return FALSE;
+ g = score_elf_got_info (dynobj, &sgot);
+ break;
+ case R_SCORE_ABS32:
+ case R_SCORE_REL32:
+ if (dynobj == NULL && (info->shared || h != NULL) && (sec->flags & SEC_ALLOC) != 0)
+ elf_hash_table (info)->dynobj = dynobj = abfd;
+ break;
+ default:
+ break;
+ }
+ }
+
+ if (!h && (r_type == R_SCORE_GOT_LO16))
+ {
+ if (! score_elf_record_local_got_symbol (abfd, r_symndx, rel->r_addend, g))
+ return FALSE;
+ }
+
+ switch (r_type)
+ {
+ case R_SCORE_CALL15:
+ if (h == NULL)
+ {
+ (*_bfd_error_handler)
+ (_("%B: CALL15 reloc at 0x%lx not against global symbol"),
+ abfd, (unsigned long) rel->r_offset);
+ bfd_set_error (bfd_error_bad_value);
+ return FALSE;
+ }
+ else
+ {
+ /* This symbol requires a global offset table entry. */
+ if (! score_elf_record_global_got_symbol (h, abfd, info, g))
+ return FALSE;
+
+ /* We need a stub, not a plt entry for the undefined function. But we record
+ it as if it needs plt. See _bfd_elf_adjust_dynamic_symbol. */
+ h->needs_plt = 1;
+ h->type = STT_FUNC;
+ }
+ break;
+ case R_SCORE_GOT15:
+ if (h && ! score_elf_record_global_got_symbol (h, abfd, info, g))
+ return FALSE;
+ break;
+ case R_SCORE_ABS32:
+ case R_SCORE_REL32:
+ if ((info->shared || h != NULL) && (sec->flags & SEC_ALLOC) != 0)
+ {
+ if (sreloc == NULL)
+ {
+ sreloc = score_elf_rel_dyn_section (dynobj, TRUE);
+ if (sreloc == NULL)
+ return FALSE;
+ }
+#define SCORE_READONLY_SECTION (SEC_ALLOC | SEC_LOAD | SEC_READONLY)
+ if (info->shared)
+ {
+ /* When creating a shared object, we must copy these reloc types into
+ the output file as R_SCORE_REL32 relocs. We make room for this reloc
+ in the .rel.dyn reloc section. */
+ score_elf_allocate_dynamic_relocations (dynobj, 1);
+ if ((sec->flags & SCORE_READONLY_SECTION)
+ == SCORE_READONLY_SECTION)
+ /* We tell the dynamic linker that there are
+ relocations against the text segment. */
+ info->flags |= DF_TEXTREL;
+ }
+ else
+ {
+ struct score_elf_link_hash_entry *hscore;
+
+ /* We only need to copy this reloc if the symbol is
+ defined in a dynamic object. */
+ hscore = (struct score_elf_link_hash_entry *) h;
+ ++hscore->possibly_dynamic_relocs;
+ if ((sec->flags & SCORE_READONLY_SECTION)
+ == SCORE_READONLY_SECTION)
+ /* We need it to tell the dynamic linker if there
+ are relocations against the text segment. */
+ hscore->readonly_reloc = TRUE;
+ }
+
+ /* Even though we don't directly need a GOT entry for this symbol,
+ a symbol must have a dynamic symbol table index greater that
+ DT_SCORE_GOTSYM if there are dynamic relocations against it. */
+ if (h != NULL)
+ {
+ if (dynobj == NULL)
+ elf_hash_table (info)->dynobj = dynobj = abfd;
+ if (! score_elf_create_got_section (dynobj, info, TRUE))
+ return FALSE;
+ g = score_elf_got_info (dynobj, &sgot);
+ if (! score_elf_record_global_got_symbol (h, abfd, info, g))
+ return FALSE;
+ }
+ }
+ break;
+
+ /* This relocation describes the C++ object vtable hierarchy.
+ Reconstruct it for later use during GC. */
+ case R_SCORE_GNU_VTINHERIT:
+ if (!bfd_elf_gc_record_vtinherit (abfd, sec, h, rel->r_offset))
+ return FALSE;
+ break;
+
+ /* This relocation describes which C++ vtable entries are actually
+ used. Record for later use during GC. */
+ case R_SCORE_GNU_VTENTRY:
+ if (!bfd_elf_gc_record_vtentry (abfd, sec, h, rel->r_offset))
+ return FALSE;
+ break;
+ default:
+ break;
+ }
+
+ /* We must not create a stub for a symbol that has relocations
+ related to taking the function's address. */
+ switch (r_type)
+ {
+ default:
+ if (h != NULL)
+ {
+ struct score_elf_link_hash_entry *sh;
+
+ sh = (struct score_elf_link_hash_entry *) h;
+ sh->no_fn_stub = TRUE;
+ }
+ break;
+ case R_SCORE_CALL15:
+ break;
+ }
+ }
+
+ return TRUE;
+}
+
+bfd_boolean
+s7_bfd_score_elf_add_symbol_hook (bfd *abfd,
+ struct bfd_link_info *info ATTRIBUTE_UNUSED,
+ Elf_Internal_Sym *sym,
+ const char **namep ATTRIBUTE_UNUSED,
+ flagword *flagsp ATTRIBUTE_UNUSED,
+ asection **secp,
+ bfd_vma *valp)
+{
+ switch (sym->st_shndx)
+ {
+ case SHN_COMMON:
+ if (sym->st_size > elf_gp_size (abfd))
+ break;
+ /* Fall through. */
+ case SHN_SCORE_SCOMMON:
+ *secp = bfd_make_section_old_way (abfd, ".scommon");
+ (*secp)->flags |= SEC_IS_COMMON;
+ *valp = sym->st_size;
+ break;
+ }
+
+ return TRUE;
+}
+
+void
+s7_bfd_score_elf_symbol_processing (bfd *abfd, asymbol *asym)
+{
+ elf_symbol_type *elfsym;
+
+ elfsym = (elf_symbol_type *) asym;
+ switch (elfsym->internal_elf_sym.st_shndx)
+ {
+ case SHN_COMMON:
+ if (asym->value > elf_gp_size (abfd))
+ break;
+ /* Fall through. */
+ case SHN_SCORE_SCOMMON:
+ if (score_elf_scom_section.name == NULL)
+ {
+ /* Initialize the small common section. */
+ score_elf_scom_section.name = ".scommon";
+ score_elf_scom_section.flags = SEC_IS_COMMON;
+ score_elf_scom_section.output_section = &score_elf_scom_section;
+ score_elf_scom_section.symbol = &score_elf_scom_symbol;
+ score_elf_scom_section.symbol_ptr_ptr = &score_elf_scom_symbol_ptr;
+ score_elf_scom_symbol.name = ".scommon";
+ score_elf_scom_symbol.flags = BSF_SECTION_SYM;
+ score_elf_scom_symbol.section = &score_elf_scom_section;
+ score_elf_scom_symbol_ptr = &score_elf_scom_symbol;
+ }
+ asym->section = &score_elf_scom_section;
+ asym->value = elfsym->internal_elf_sym.st_size;
+ break;
+ }
+}
+
+bfd_boolean
+s7_bfd_score_elf_link_output_symbol_hook (struct bfd_link_info *info ATTRIBUTE_UNUSED,
+ const char *name ATTRIBUTE_UNUSED,
+ Elf_Internal_Sym *sym,
+ asection *input_sec,
+ struct elf_link_hash_entry *h ATTRIBUTE_UNUSED)
+{
+ /* If we see a common symbol, which implies a relocatable link, then
+ if a symbol was small common in an input file, mark it as small
+ common in the output file. */
+ if (sym->st_shndx == SHN_COMMON && strcmp (input_sec->name, ".scommon") == 0)
+ sym->st_shndx = SHN_SCORE_SCOMMON;
+
+ return TRUE;
+}
+
+bfd_boolean
+s7_bfd_score_elf_section_from_bfd_section (bfd *abfd ATTRIBUTE_UNUSED,
+ asection *sec,
+ int *retval)
+{
+ if (strcmp (bfd_get_section_name (abfd, sec), ".scommon") == 0)
+ {
+ *retval = SHN_SCORE_SCOMMON;
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/* Adjust a symbol defined by a dynamic object and referenced by a
+ regular object. The current definition is in some section of the
+ dynamic object, but we're not including those sections. We have to
+ change the definition to something the rest of the link can understand. */
+
+bfd_boolean
+s7_bfd_score_elf_adjust_dynamic_symbol (struct bfd_link_info *info,
+ struct elf_link_hash_entry *h)
+{
+ bfd *dynobj;
+ struct score_elf_link_hash_entry *hscore;
+ asection *s;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ /* Make sure we know what is going on here. */
+ BFD_ASSERT (dynobj != NULL
+ && (h->needs_plt
+ || h->u.weakdef != NULL
+ || (h->def_dynamic && h->ref_regular && !h->def_regular)));
+
+ /* If this symbol is defined in a dynamic object, we need to copy
+ any R_SCORE_ABS32 or R_SCORE_REL32 relocs against it into the output
+ file. */
+ hscore = (struct score_elf_link_hash_entry *) h;
+ if (!info->relocatable
+ && hscore->possibly_dynamic_relocs != 0
+ && (h->root.type == bfd_link_hash_defweak || !h->def_regular))
+ {
+ score_elf_allocate_dynamic_relocations (dynobj, hscore->possibly_dynamic_relocs);
+ if (hscore->readonly_reloc)
+ /* We tell the dynamic linker that there are relocations
+ against the text segment. */
+ info->flags |= DF_TEXTREL;
+ }
+
+ /* For a function, create a stub, if allowed. */
+ if (!hscore->no_fn_stub && h->needs_plt)
+ {
+ if (!elf_hash_table (info)->dynamic_sections_created)
+ return TRUE;
+
+ /* If this symbol is not defined in a regular file, then set
+ the symbol to the stub location. This is required to make
+ function pointers compare as equal between the normal
+ executable and the shared library. */
+ if (!h->def_regular)
+ {
+ /* We need .stub section. */
+ s = bfd_get_section_by_name (dynobj, SCORE_ELF_STUB_SECTION_NAME);
+ BFD_ASSERT (s != NULL);
+
+ h->root.u.def.section = s;
+ h->root.u.def.value = s->size;
+
+ /* XXX Write this stub address somewhere. */
+ h->plt.offset = s->size;
+
+ /* Make room for this stub code. */
+ s->size += SCORE_FUNCTION_STUB_SIZE;
+
+ /* The last half word of the stub will be filled with the index
+ of this symbol in .dynsym section. */
+ return TRUE;
+ }
+ }
+ else if ((h->type == STT_FUNC) && !h->needs_plt)
+ {
+ /* This will set the entry for this symbol in the GOT to 0, and
+ the dynamic linker will take care of this. */
+ h->root.u.def.value = 0;
+ return TRUE;
+ }
+
+ /* If this is a weak symbol, and there is a real definition, the
+ processor independent code will have arranged for us to see the
+ real definition first, and we can just use the same value. */
+ if (h->u.weakdef != NULL)
+ {
+ BFD_ASSERT (h->u.weakdef->root.type == bfd_link_hash_defined
+ || h->u.weakdef->root.type == bfd_link_hash_defweak);
+ h->root.u.def.section = h->u.weakdef->root.u.def.section;
+ h->root.u.def.value = h->u.weakdef->root.u.def.value;
+ return TRUE;
+ }
+
+ /* This is a reference to a symbol defined by a dynamic object which
+ is not a function. */
+ return TRUE;
+}
+
+/* This function is called after all the input files have been read,
+ and the input sections have been assigned to output sections. */
+
+bfd_boolean
+s7_bfd_score_elf_always_size_sections (bfd *output_bfd,
+ struct bfd_link_info *info)
+{
+ bfd *dynobj;
+ asection *s;
+ struct score_got_info *g;
+ int i;
+ bfd_size_type loadable_size = 0;
+ bfd_size_type local_gotno;
+ bfd *sub;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ if (dynobj == NULL)
+ /* Relocatable links don't have it. */
+ return TRUE;
+
+ g = score_elf_got_info (dynobj, &s);
+ if (s == NULL)
+ return TRUE;
+
+ /* Calculate the total loadable size of the output. That will give us the
+ maximum number of GOT_PAGE entries required. */
+ for (sub = info->input_bfds; sub; sub = sub->link_next)
+ {
+ asection *subsection;
+
+ for (subsection = sub->sections;
+ subsection;
+ subsection = subsection->next)
+ {
+ if ((subsection->flags & SEC_ALLOC) == 0)
+ continue;
+ loadable_size += ((subsection->size + 0xf)
+ &~ (bfd_size_type) 0xf);
+ }
+ }
+
+ /* There has to be a global GOT entry for every symbol with
+ a dynamic symbol table index of DT_SCORE_GOTSYM or
+ higher. Therefore, it make sense to put those symbols
+ that need GOT entries at the end of the symbol table. We
+ do that here. */
+ if (! score_elf_sort_hash_table (info, 1))
+ return FALSE;
+
+ if (g->global_gotsym != NULL)
+ i = elf_hash_table (info)->dynsymcount - g->global_gotsym->dynindx;
+ else
+ /* If there are no global symbols, or none requiring
+ relocations, then GLOBAL_GOTSYM will be NULL. */
+ i = 0;
+
+ /* In the worst case, we'll get one stub per dynamic symbol. */
+ loadable_size += SCORE_FUNCTION_STUB_SIZE * i;
+
+ /* Assume there are two loadable segments consisting of
+ contiguous sections. Is 5 enough? */
+ local_gotno = (loadable_size >> 16) + 5;
+
+ g->local_gotno += local_gotno;
+ s->size += g->local_gotno * SCORE_ELF_GOT_SIZE (output_bfd);
+
+ g->global_gotno = i;
+ s->size += i * SCORE_ELF_GOT_SIZE (output_bfd);
+
+ score_elf_resolve_final_got_entries (g);
+
+ if (s->size > SCORE_ELF_GOT_MAX_SIZE (output_bfd))
+ {
+ /* Fixme. Error message or Warning message should be issued here. */
+ }
+
+ return TRUE;
+}
+
+/* Set the sizes of the dynamic sections. */
+
+bfd_boolean
+s7_bfd_score_elf_size_dynamic_sections (bfd *output_bfd, struct bfd_link_info *info)
+{
+ bfd *dynobj;
+ asection *s;
+ bfd_boolean reltext;
+
+ dynobj = elf_hash_table (info)->dynobj;
+ BFD_ASSERT (dynobj != NULL);
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ /* Set the contents of the .interp section to the interpreter. */
+ if (!info->shared)
+ {
+ s = bfd_get_section_by_name (dynobj, ".interp");
+ BFD_ASSERT (s != NULL);
+ s->size = strlen (ELF_DYNAMIC_INTERPRETER) + 1;
+ s->contents = (bfd_byte *) ELF_DYNAMIC_INTERPRETER;
+ }
+ }
+
+ /* The check_relocs and adjust_dynamic_symbol entry points have
+ determined the sizes of the various dynamic sections. Allocate
+ memory for them. */
+ reltext = FALSE;
+ for (s = dynobj->sections; s != NULL; s = s->next)
+ {
+ const char *name;
+
+ if ((s->flags & SEC_LINKER_CREATED) == 0)
+ continue;
+
+ /* It's OK to base decisions on the section name, because none
+ of the dynobj section names depend upon the input files. */
+ name = bfd_get_section_name (dynobj, s);
+
+ if (CONST_STRNEQ (name, ".rel"))
+ {
+ if (s->size == 0)
+ {
+ /* We only strip the section if the output section name
+ has the same name. Otherwise, there might be several
+ input sections for this output section. FIXME: This
+ code is probably not needed these days anyhow, since
+ the linker now does not create empty output sections. */
+ if (s->output_section != NULL
+ && strcmp (name,
+ bfd_get_section_name (s->output_section->owner,
+ s->output_section)) == 0)
+ s->flags |= SEC_EXCLUDE;
+ }
+ else
+ {
+ const char *outname;
+ asection *target;
+
+ /* If this relocation section applies to a read only
+ section, then we probably need a DT_TEXTREL entry.
+ If the relocation section is .rel.dyn, we always
+ assert a DT_TEXTREL entry rather than testing whether
+ there exists a relocation to a read only section or
+ not. */
+ outname = bfd_get_section_name (output_bfd, s->output_section);
+ target = bfd_get_section_by_name (output_bfd, outname + 4);
+ if ((target != NULL
+ && (target->flags & SEC_READONLY) != 0
+ && (target->flags & SEC_ALLOC) != 0) || strcmp (outname, ".rel.dyn") == 0)
+ reltext = TRUE;
+
+ /* We use the reloc_count field as a counter if we need
+ to copy relocs into the output file. */
+ if (strcmp (name, ".rel.dyn") != 0)
+ s->reloc_count = 0;
+ }
+ }
+ else if (CONST_STRNEQ (name, ".got"))
+ {
+ /* s7_bfd_score_elf_always_size_sections() has already done
+ most of the work, but some symbols may have been mapped
+ to versions that we must now resolve in the got_entries
+ hash tables. */
+ }
+ else if (strcmp (name, SCORE_ELF_STUB_SECTION_NAME) == 0)
+ {
+ /* IRIX rld assumes that the function stub isn't at the end
+ of .text section. So put a dummy. XXX */
+ s->size += SCORE_FUNCTION_STUB_SIZE;
+ }
+ else if (! CONST_STRNEQ (name, ".init"))
+ {
+ /* It's not one of our sections, so don't allocate space. */
+ continue;
+ }
+
+ /* Allocate memory for the section contents. */
+ s->contents = bfd_zalloc (dynobj, s->size);
+ if (s->contents == NULL && s->size != 0)
+ {
+ bfd_set_error (bfd_error_no_memory);
+ return FALSE;
+ }
+ }
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ /* Add some entries to the .dynamic section. We fill in the
+ values later, in s7_bfd_score_elf_finish_dynamic_sections, but we
+ must add the entries now so that we get the correct size for
+ the .dynamic section. The DT_DEBUG entry is filled in by the
+ dynamic linker and used by the debugger. */
+
+ if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_DEBUG, 0))
+ return FALSE;
+
+ if (reltext)
+ info->flags |= DF_TEXTREL;
+
+ if ((info->flags & DF_TEXTREL) != 0)
+ {
+ if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_TEXTREL, 0))
+ return FALSE;
+ }
+
+ if (! SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_PLTGOT, 0))
+ return FALSE;
+
+ if (score_elf_rel_dyn_section (dynobj, FALSE))
+ {
+ if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_REL, 0))
+ return FALSE;
+
+ if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_RELSZ, 0))
+ return FALSE;
+
+ if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_RELENT, 0))
+ return FALSE;
+ }
+
+ if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_SCORE_BASE_ADDRESS, 0))
+ return FALSE;
+
+ if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_SCORE_LOCAL_GOTNO, 0))
+ return FALSE;
+
+ if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_SCORE_SYMTABNO, 0))
+ return FALSE;
+
+ if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_SCORE_UNREFEXTNO, 0))
+ return FALSE;
+
+ if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_SCORE_GOTSYM, 0))
+ return FALSE;
+
+ if (!SCORE_ELF_ADD_DYNAMIC_ENTRY (info, DT_SCORE_HIPAGENO, 0))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+bfd_boolean
+s7_bfd_score_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
+{
+ struct elf_link_hash_entry *h;
+ struct bfd_link_hash_entry *bh;
+ flagword flags;
+ asection *s;
+
+ flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS | SEC_IN_MEMORY
+ | SEC_LINKER_CREATED | SEC_READONLY);
+
+ /* ABI requests the .dynamic section to be read only. */
+ s = bfd_get_section_by_name (abfd, ".dynamic");
+ if (s != NULL)
+ {
+ if (!bfd_set_section_flags (abfd, s, flags))
+ return FALSE;
+ }
+
+ /* We need to create .got section. */
+ if (!score_elf_create_got_section (abfd, info, FALSE))
+ return FALSE;
+
+ if (!score_elf_rel_dyn_section (elf_hash_table (info)->dynobj, TRUE))
+ return FALSE;
+
+ /* Create .stub section. */
+ if (bfd_get_section_by_name (abfd, SCORE_ELF_STUB_SECTION_NAME) == NULL)
+ {
+ s = bfd_make_section_with_flags (abfd, SCORE_ELF_STUB_SECTION_NAME,
+ flags | SEC_CODE);
+ if (s == NULL
+ || !bfd_set_section_alignment (abfd, s, 2))
+
+ return FALSE;
+ }
+
+ if (!info->shared)
+ {
+ const char *name;
+
+ name = "_DYNAMIC_LINK";
+ bh = NULL;
+ if (!(_bfd_generic_link_add_one_symbol
+ (info, abfd, name, BSF_GLOBAL, bfd_abs_section_ptr,
+ (bfd_vma) 0, NULL, FALSE, get_elf_backend_data (abfd)->collect, &bh)))
+ return FALSE;
+
+ h = (struct elf_link_hash_entry *) bh;
+ h->non_elf = 0;
+ h->def_regular = 1;
+ h->type = STT_SECTION;
+
+ if (!bfd_elf_link_record_dynamic_symbol (info, h))
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+/* Finish up dynamic symbol handling. We set the contents of various
+ dynamic sections here. */
+
+bfd_boolean
+s7_bfd_score_elf_finish_dynamic_symbol (bfd *output_bfd,
+ struct bfd_link_info *info,
+ struct elf_link_hash_entry *h,
+ Elf_Internal_Sym *sym)
+{
+ bfd *dynobj;
+ asection *sgot;
+ struct score_got_info *g;
+ const char *name;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ if (h->plt.offset != MINUS_ONE)
+ {
+ asection *s;
+ bfd_byte stub[SCORE_FUNCTION_STUB_SIZE];
+
+ /* This symbol has a stub. Set it up. */
+ BFD_ASSERT (h->dynindx != -1);
+
+ s = bfd_get_section_by_name (dynobj, SCORE_ELF_STUB_SECTION_NAME);
+ BFD_ASSERT (s != NULL);
+
+ /* FIXME: Can h->dynindex be more than 64K? */
+ if (h->dynindx & 0xffff0000)
+ return FALSE;
+
+ /* Fill the stub. */
+ bfd_put_32 (output_bfd, STUB_LW, stub);
+ bfd_put_32 (output_bfd, STUB_MOVE, stub + 4);
+ bfd_put_32 (output_bfd, STUB_LI16 | (h->dynindx << 1), stub + 8);
+ bfd_put_32 (output_bfd, STUB_BRL, stub + 12);
+
+ BFD_ASSERT (h->plt.offset <= s->size);
+ memcpy (s->contents + h->plt.offset, stub, SCORE_FUNCTION_STUB_SIZE);
+
+ /* Mark the symbol as undefined. plt.offset != -1 occurs
+ only for the referenced symbol. */
+ sym->st_shndx = SHN_UNDEF;
+
+ /* The run-time linker uses the st_value field of the symbol
+ to reset the global offset table entry for this external
+ to its stub address when unlinking a shared object. */
+ sym->st_value = (s->output_section->vma + s->output_offset + h->plt.offset);
+ }
+
+ BFD_ASSERT (h->dynindx != -1 || h->forced_local);
+
+ sgot = score_elf_got_section (dynobj, FALSE);
+ BFD_ASSERT (sgot != NULL);
+ BFD_ASSERT (score_elf_section_data (sgot) != NULL);
+ g = score_elf_section_data (sgot)->u.got_info;
+ BFD_ASSERT (g != NULL);
+
+ /* Run through the global symbol table, creating GOT entries for all
+ the symbols that need them. */
+ if (g->global_gotsym != NULL && h->dynindx >= g->global_gotsym->dynindx)
+ {
+ bfd_vma offset;
+ bfd_vma value;
+
+ value = sym->st_value;
+ offset = score_elf_global_got_index (dynobj, h);
+ bfd_put_32 (output_bfd, value, sgot->contents + offset);
+ }
+
+ /* Mark _DYNAMIC and _GLOBAL_OFFSET_TABLE_ as absolute. */
+ name = h->root.root.string;
+ if (strcmp (name, "_DYNAMIC") == 0 || strcmp (name, "_GLOBAL_OFFSET_TABLE_") == 0)
+ sym->st_shndx = SHN_ABS;
+ else if (strcmp (name, "_DYNAMIC_LINK") == 0)
+ {
+ sym->st_shndx = SHN_ABS;
+ sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
+ sym->st_value = 1;
+ }
+ else if (strcmp (name, GP_DISP_LABEL) == 0)
+ {
+ sym->st_shndx = SHN_ABS;
+ sym->st_info = ELF_ST_INFO (STB_GLOBAL, STT_SECTION);
+ sym->st_value = elf_gp (output_bfd);
+ }
+
+ return TRUE;
+}
+
+/* Finish up the dynamic sections. */
+
+bfd_boolean
+s7_bfd_score_elf_finish_dynamic_sections (bfd *output_bfd,
+ struct bfd_link_info *info)
+{
+ bfd *dynobj;
+ asection *sdyn;
+ asection *sgot;
+ asection *s;
+ struct score_got_info *g;
+
+ dynobj = elf_hash_table (info)->dynobj;
+
+ sdyn = bfd_get_section_by_name (dynobj, ".dynamic");
+
+ sgot = score_elf_got_section (dynobj, FALSE);
+ if (sgot == NULL)
+ g = NULL;
+ else
+ {
+ BFD_ASSERT (score_elf_section_data (sgot) != NULL);
+ g = score_elf_section_data (sgot)->u.got_info;
+ BFD_ASSERT (g != NULL);
+ }
+
+ if (elf_hash_table (info)->dynamic_sections_created)
+ {
+ bfd_byte *b;
+
+ BFD_ASSERT (sdyn != NULL);
+ BFD_ASSERT (g != NULL);
+
+ for (b = sdyn->contents;
+ b < sdyn->contents + sdyn->size;
+ b += SCORE_ELF_DYN_SIZE (dynobj))
+ {
+ Elf_Internal_Dyn dyn;
+ const char *name;
+ size_t elemsize;
+ bfd_boolean swap_out_p;
+
+ /* Read in the current dynamic entry. */
+ (*get_elf_backend_data (dynobj)->s->swap_dyn_in) (dynobj, b, &dyn);
+
+ /* Assume that we're going to modify it and write it out. */
+ swap_out_p = TRUE;
+
+ switch (dyn.d_tag)
+ {
+ case DT_RELENT:
+ s = score_elf_rel_dyn_section (dynobj, FALSE);
+ BFD_ASSERT (s != NULL);
+ dyn.d_un.d_val = SCORE_ELF_REL_SIZE (dynobj);
+ break;
+
+ case DT_STRSZ:
+ /* Rewrite DT_STRSZ. */
+ dyn.d_un.d_val = _bfd_elf_strtab_size (elf_hash_table (info)->dynstr);
+ break;
+
+ case DT_PLTGOT:
+ name = ".got";
+ s = bfd_get_section_by_name (output_bfd, name);
+ BFD_ASSERT (s != NULL);
+ dyn.d_un.d_ptr = s->vma;
+ break;
+
+ case DT_SCORE_BASE_ADDRESS:
+ s = output_bfd->sections;
+ BFD_ASSERT (s != NULL);
+ dyn.d_un.d_ptr = s->vma & ~(bfd_vma) 0xffff;
+ break;
+
+ case DT_SCORE_LOCAL_GOTNO:
+ dyn.d_un.d_val = g->local_gotno;
+ break;
+
+ case DT_SCORE_UNREFEXTNO:
+ /* The index into the dynamic symbol table which is the
+ entry of the first external symbol that is not
+ referenced within the same object. */
+ dyn.d_un.d_val = bfd_count_sections (output_bfd) + 1;
+ break;
+
+ case DT_SCORE_GOTSYM:
+ if (g->global_gotsym)
+ {
+ dyn.d_un.d_val = g->global_gotsym->dynindx;
+ break;
+ }
+ /* In case if we don't have global got symbols we default
+ to setting DT_SCORE_GOTSYM to the same value as
+ DT_SCORE_SYMTABNO, so we just fall through. */
+
+ case DT_SCORE_SYMTABNO:
+ name = ".dynsym";
+ elemsize = SCORE_ELF_SYM_SIZE (output_bfd);
+ s = bfd_get_section_by_name (output_bfd, name);
+ BFD_ASSERT (s != NULL);
+
+ dyn.d_un.d_val = s->size / elemsize;
+ break;
+
+ case DT_SCORE_HIPAGENO:
+ dyn.d_un.d_val = g->local_gotno - SCORE_RESERVED_GOTNO;
+ break;
+
+ default:
+ swap_out_p = FALSE;
+ break;
+ }
+
+ if (swap_out_p)
+ (*get_elf_backend_data (dynobj)->s->swap_dyn_out) (dynobj, &dyn, b);
+ }
+ }
+
+ /* The first entry of the global offset table will be filled at
+ runtime. The second entry will be used by some runtime loaders.
+ This isn't the case of IRIX rld. */
+ if (sgot != NULL && sgot->size > 0)
+ {
+ bfd_put_32 (output_bfd, 0, sgot->contents);
+ bfd_put_32 (output_bfd, 0x80000000, sgot->contents + SCORE_ELF_GOT_SIZE (output_bfd));
+ }
+
+ if (sgot != NULL)
+ elf_section_data (sgot->output_section)->this_hdr.sh_entsize
+ = SCORE_ELF_GOT_SIZE (output_bfd);
+
+
+ /* We need to sort the entries of the dynamic relocation section. */
+ s = score_elf_rel_dyn_section (dynobj, FALSE);
+
+ if (s != NULL && s->size > (bfd_vma)2 * SCORE_ELF_REL_SIZE (output_bfd))
+ {
+ reldyn_sorting_bfd = output_bfd;
+ qsort ((Elf32_External_Rel *) s->contents + 1, s->reloc_count - 1,
+ sizeof (Elf32_External_Rel), score_elf_sort_dynamic_relocs);
+ }
+
+ return TRUE;
+}
+
+/* This function set up the ELF section header for a BFD section in preparation for writing
+ it out. This is where the flags and type fields are set for unusual sections. */
+
+bfd_boolean
+s7_bfd_score_elf_fake_sections (bfd *abfd ATTRIBUTE_UNUSED,
+ Elf_Internal_Shdr *hdr,
+ asection *sec)
+{
+ const char *name;
+
+ name = bfd_get_section_name (abfd, sec);
+
+ if (strcmp (name, ".got") == 0
+ || strcmp (name, ".srdata") == 0
+ || strcmp (name, ".sdata") == 0
+ || strcmp (name, ".sbss") == 0)
+ hdr->sh_flags |= SHF_SCORE_GPREL;
+
+ return TRUE;
+}
+
+/* This function do additional processing on the ELF section header before writing
+ it out. This is used to set the flags and type fields for some sections. */
+
+/* assign_file_positions_except_relocs() check section flag and if it is allocatable,
+ warning message will be issued. backend_fake_section is called before
+ assign_file_positions_except_relocs(); backend_section_processing after it. so, we
+ modify section flag there, but not backend_fake_section. */
+
+bfd_boolean
+s7_bfd_score_elf_section_processing (bfd *abfd ATTRIBUTE_UNUSED, Elf_Internal_Shdr *hdr)
+{
+ if (hdr->bfd_section != NULL)
+ {
+ const char *name = bfd_get_section_name (abfd, hdr->bfd_section);
+
+ if (strcmp (name, ".sdata") == 0)
+ {
+ hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_SCORE_GPREL;
+ hdr->sh_type = SHT_PROGBITS;
+ }
+ else if (strcmp (name, ".sbss") == 0)
+ {
+ hdr->sh_flags |= SHF_ALLOC | SHF_WRITE | SHF_SCORE_GPREL;
+ hdr->sh_type = SHT_NOBITS;
+ }
+ else if (strcmp (name, ".srdata") == 0)
+ {
+ hdr->sh_flags |= SHF_ALLOC | SHF_SCORE_GPREL;
+ hdr->sh_type = SHT_PROGBITS;
+ }
+ }
+
+ return TRUE;
+}
+
+bfd_boolean
+s7_bfd_score_elf_write_section (bfd *output_bfd, asection *sec, bfd_byte *contents)
+{
+ bfd_byte *to, *from, *end;
+ int i;
+
+ if (strcmp (sec->name, ".pdr") != 0)
+ return FALSE;
+
+ if (score_elf_section_data (sec)->u.tdata == NULL)
+ return FALSE;
+
+ to = contents;
+ end = contents + sec->size;
+ for (from = contents, i = 0; from < end; from += PDR_SIZE, i++)
+ {
+ if ((score_elf_section_data (sec)->u.tdata)[i] == 1)
+ continue;
+
+ if (to != from)
+ memcpy (to, from, PDR_SIZE);
+
+ to += PDR_SIZE;
+ }
+ bfd_set_section_contents (output_bfd, sec->output_section, contents,
+ (file_ptr) sec->output_offset, sec->size);
+
+ return TRUE;
+}
+
+/* Copy data from a SCORE ELF indirect symbol to its direct symbol, hiding the old
+ indirect symbol. Process additional relocation information. */
+
+void
+s7_bfd_score_elf_copy_indirect_symbol (struct bfd_link_info *info,
+ struct elf_link_hash_entry *dir,
+ struct elf_link_hash_entry *ind)
+{
+ struct score_elf_link_hash_entry *dirscore, *indscore;
+
+ _bfd_elf_link_hash_copy_indirect (info, dir, ind);
+
+ if (ind->root.type != bfd_link_hash_indirect)
+ return;
+
+ dirscore = (struct score_elf_link_hash_entry *) dir;
+ indscore = (struct score_elf_link_hash_entry *) ind;
+ dirscore->possibly_dynamic_relocs += indscore->possibly_dynamic_relocs;
+
+ if (indscore->readonly_reloc)
+ dirscore->readonly_reloc = TRUE;
+
+ if (indscore->no_fn_stub)
+ dirscore->no_fn_stub = TRUE;
+}
+
+/* Remove information about discarded functions from other sections which mention them. */
+
+bfd_boolean
+s7_bfd_score_elf_discard_info (bfd *abfd,
+ struct elf_reloc_cookie *cookie,
+ struct bfd_link_info *info)
+{
+ asection *o;
+ bfd_boolean ret = FALSE;
+ unsigned char *tdata;
+ size_t i, skip;
+
+ o = bfd_get_section_by_name (abfd, ".pdr");
+ if ((!o) || (o->size == 0) || (o->size % PDR_SIZE != 0)
+ || (o->output_section != NULL && bfd_is_abs_section (o->output_section)))
+ return FALSE;
+
+ tdata = bfd_zmalloc (o->size / PDR_SIZE);
+ if (!tdata)
+ return FALSE;
+
+ cookie->rels = _bfd_elf_link_read_relocs (abfd, o, NULL, NULL, info->keep_memory);
+ if (!cookie->rels)
+ {
+ free (tdata);
+ return FALSE;
+ }
+
+ cookie->rel = cookie->rels;
+ cookie->relend = cookie->rels + o->reloc_count;
+
+ for (i = 0, skip = 0; i < o->size; i++)
+ {
+ if (bfd_elf_reloc_symbol_deleted_p (i * PDR_SIZE, cookie))
+ {
+ tdata[i] = 1;
+ skip++;
+ }
+ }
+
+ if (skip != 0)
+ {
+ score_elf_section_data (o)->u.tdata = tdata;
+ o->size -= skip * PDR_SIZE;
+ ret = TRUE;
+ }
+ else
+ free (tdata);
+
+ if (!info->keep_memory)
+ free (cookie->rels);
+
+ return ret;
+}
+
+/* Signal that discard_info() has removed the discarded relocations for this section. */
+
+bfd_boolean
+s7_bfd_score_elf_ignore_discarded_relocs (asection *sec)
+{
+ if (strcmp (sec->name, ".pdr") == 0)
+ return TRUE;
+ return FALSE;
+}
+
+/* Return the section that should be marked against GC for a given
+ relocation. */
+
+asection *
+s7_bfd_score_elf_gc_mark_hook (asection *sec,
+ struct bfd_link_info *info,
+ Elf_Internal_Rela *rel,
+ struct elf_link_hash_entry *h,
+ Elf_Internal_Sym *sym)
+{
+ if (h != NULL)
+ switch (ELF32_R_TYPE (rel->r_info))
+ {
+ case R_SCORE_GNU_VTINHERIT:
+ case R_SCORE_GNU_VTENTRY:
+ return NULL;
+ }
+
+ return _bfd_elf_gc_mark_hook (sec, info, rel, h, sym);
+}
+
+/* Support for core dump NOTE sections. */
+
+bfd_boolean
+s7_bfd_score_elf_grok_prstatus (bfd *abfd, Elf_Internal_Note *note)
+{
+ int offset;
+ unsigned int raw_size;
+
+ switch (note->descsz)
+ {
+ default:
+ return FALSE;
+ case 272: /* Linux/Score elf_prstatus */
+
+ /* pr_cursig */
+ elf_tdata (abfd)->core_signal = bfd_get_16 (abfd, note->descdata + 12);
+
+ /* pr_pid */
+ elf_tdata (abfd)->core_pid = bfd_get_32 (abfd, note->descdata + 24);
+
+ /* pr_reg */
+ offset = 72;
+
+ /* sizeof(elf_gregset_t) */
+ raw_size = 196;
+
+ break;
+ }
+
+ /* Make a ".reg/999" section. */
+ return _bfd_elfcore_make_pseudosection (abfd, ".reg", raw_size, note->descpos + offset);
+}
+
+bfd_boolean
+s7_bfd_score_elf_grok_psinfo (bfd *abfd, Elf_Internal_Note *note)
+{
+ switch (note->descsz)
+ {
+ default:
+ return FALSE;
+
+ case 128: /* Linux/Score elf_prpsinfo. */
+ /* pr_fname */
+ elf_tdata (abfd)->core_program = _bfd_elfcore_strndup (abfd, note->descdata + 32, 16);
+
+ /* pr_psargs */
+ elf_tdata (abfd)->core_command = _bfd_elfcore_strndup (abfd, note->descdata + 48, 80);
+ break;
+ }
+
+ /* Note that for some reason, a spurious space is tacked
+ onto the end of the args in some (at least one anyway)
+ implementations, so strip it off if it exists. */
+
+ {
+ char *command = elf_tdata (abfd)->core_command;
+ int n = strlen (command);
+
+ if (0 < n && command[n - 1] == ' ')
+ command[n - 1] = '\0';
+ }
+
+ return TRUE;
+}
+
+
+/* Score BFD functions. */
+
+reloc_howto_type *
+s7_elf32_score_reloc_type_lookup (bfd *abfd ATTRIBUTE_UNUSED, bfd_reloc_code_real_type code)
+{
+ unsigned int i;
+
+ for (i = 0; i < ARRAY_SIZE (elf32_score_reloc_map); i++)
+ if (elf32_score_reloc_map[i].bfd_reloc_val == code)
+ return &elf32_score_howto_table[elf32_score_reloc_map[i].elf_reloc_val];
+
+ return NULL;
+}
+
+/* Create a score elf linker hash table. */
+
+struct bfd_link_hash_table *
+s7_elf32_score_link_hash_table_create (bfd *abfd)
+{
+ struct score_elf_link_hash_table *ret;
+ bfd_size_type amt = sizeof (struct score_elf_link_hash_table);
+
+ ret = bfd_malloc (amt);
+ if (ret == NULL)
+ return NULL;
+
+ if (!_bfd_elf_link_hash_table_init (&ret->root, abfd, score_elf_link_hash_newfunc,
+ sizeof (struct score_elf_link_hash_entry)))
+ {
+ free (ret);
+ return NULL;
+ }
+
+ return &ret->root.root;
+}
+
+bfd_boolean
+s7_elf32_score_print_private_bfd_data (bfd *abfd, void * ptr)
+{
+ FILE *file = (FILE *) ptr;
+
+ BFD_ASSERT (abfd != NULL && ptr != NULL);
+
+ /* Print normal ELF private data. */
+ _bfd_elf_print_private_bfd_data (abfd, ptr);
+
+ /* xgettext:c-format */
+ fprintf (file, _("private flags = %lx:"), elf_elfheader (abfd)->e_flags);
+ if (elf_elfheader (abfd)->e_flags & EF_SCORE_PIC)
+ {
+ fprintf (file, _(" [pic]"));
+ }
+ if (elf_elfheader (abfd)->e_flags & EF_SCORE_FIXDEP)
+ {
+ fprintf (file, _(" [fix dep]"));
+ }
+ fputc ('\n', file);
+
+ return TRUE;
+}
+
+bfd_boolean
+s7_elf32_score_merge_private_bfd_data (bfd *ibfd, bfd *obfd)
+{
+ flagword in_flags;
+ flagword out_flags;
+
+ if (!_bfd_generic_verify_endian_match (ibfd, obfd))
+ return FALSE;
+
+ in_flags = elf_elfheader (ibfd)->e_flags;
+ out_flags = elf_elfheader (obfd)->e_flags;
+
+ if (bfd_get_flavour (ibfd) != bfd_target_elf_flavour
+ || bfd_get_flavour (obfd) != bfd_target_elf_flavour)
+ return TRUE;
+
+ in_flags = elf_elfheader (ibfd)->e_flags;
+ out_flags = elf_elfheader (obfd)->e_flags;
+
+ if (! elf_flags_init (obfd))
+ {
+ elf_flags_init (obfd) = TRUE;
+ elf_elfheader (obfd)->e_flags = in_flags;
+
+ if (bfd_get_arch (obfd) == bfd_get_arch (ibfd)
+ && bfd_get_arch_info (obfd)->the_default)
+ {
+ return bfd_set_arch_mach (obfd, bfd_get_arch (ibfd), bfd_get_mach (ibfd));
+ }
+
+ return TRUE;
+ }
+
+ if (((in_flags & EF_SCORE_PIC) != 0) != ((out_flags & EF_SCORE_PIC) != 0))
+ {
+ (*_bfd_error_handler) (_("%B: warning: linking PIC files with non-PIC files"), ibfd);
+ }
+
+ /* Maybe dependency fix compatibility should be checked here. */
+ return TRUE;
+}
+
+bfd_boolean
+s7_elf32_score_new_section_hook (bfd *abfd, asection *sec)
+{
+ struct _score_elf_section_data *sdata;
+ bfd_size_type amt = sizeof (*sdata);
+
+ sdata = bfd_zalloc (abfd, amt);
+ if (sdata == NULL)
+ return FALSE;
+ sec->used_by_bfd = sdata;
+
+ return _bfd_elf_new_section_hook (abfd, sec);
+}
+
+#define elf_backend_omit_section_dynsym \
+ ((bfd_boolean (*) (bfd *, struct bfd_link_info *, asection *)) bfd_true)
diff --git a/bfd/libbfd.h b/bfd/libbfd.h
index 2ba7fc8b9df..5814863f9d8 100644
--- a/bfd/libbfd.h
+++ b/bfd/libbfd.h
@@ -1683,13 +1683,15 @@ static const char *const bfd_reloc_code_real_names[] = { "@@uninitialized@@",
"BFD_RELOC_390_GOT20",
"BFD_RELOC_390_GOTPLT20",
"BFD_RELOC_390_TLS_GOTIE20",
- "BFD_RELOC_SCORE_DUMMY1",
"BFD_RELOC_SCORE_GPREL15",
"BFD_RELOC_SCORE_DUMMY2",
"BFD_RELOC_SCORE_JMP",
"BFD_RELOC_SCORE_BRANCH",
+ "BFD_RELOC_SCORE_IMM30",
+ "BFD_RELOC_SCORE_IMM32",
"BFD_RELOC_SCORE16_JMP",
"BFD_RELOC_SCORE16_BRANCH",
+ "BFD_RELOC_SCORE_BCMP",
"BFD_RELOC_SCORE_GOT15",
"BFD_RELOC_SCORE_GOT_LO16",
"BFD_RELOC_SCORE_CALL15",
diff --git a/bfd/reloc.c b/bfd/reloc.c
index 781147e98aa..9e610255b1f 100644
--- a/bfd/reloc.c
+++ b/bfd/reloc.c
@@ -4195,12 +4195,9 @@ ENUMDOC
Long displacement extension.
ENUM
- BFD_RELOC_SCORE_DUMMY1
-ENUMDOC
- Score relocations
-ENUM
BFD_RELOC_SCORE_GPREL15
ENUMDOC
+ Score relocations
Low 16 bit for load/store
ENUM
BFD_RELOC_SCORE_DUMMY2
@@ -4213,6 +4210,14 @@ ENUM
ENUMDOC
This is a 19-bit reloc with the right 1 bit assumed to be 0
ENUM
+ BFD_RELOC_SCORE_IMM30
+ENUMDOC
+ This is a 32-bit reloc for 48-bit instructions.
+ENUM
+ BFD_RELOC_SCORE_IMM32
+ENUMDOC
+ This is a 32-bit reloc for 48-bit instructions.
+ENUM
BFD_RELOC_SCORE16_JMP
ENUMDOC
This is a 11-bit reloc with the right 1 bit assumed to be 0
@@ -4221,6 +4226,10 @@ ENUM
ENUMDOC
This is a 8-bit reloc with the right 1 bit assumed to be 0
ENUM
+ BFD_RELOC_SCORE_BCMP
+ENUMDOC
+ This is a 9-bit reloc with the right 1 bit assumed to be 0
+ENUM
BFD_RELOC_SCORE_GOT15
ENUMX
BFD_RELOC_SCORE_GOT_LO16
diff --git a/include/elf/ChangeLog b/include/elf/ChangeLog
index e882628b269..606a170f61f 100644
--- a/include/elf/ChangeLog
+++ b/include/elf/ChangeLog
@@ -1,3 +1,8 @@
+2009-03-02 Qinwei <qinwei@sunnorth.com.cn>
+
+ * score.h (RELOC_NUMBER): Add R_SCORE_IMM32.
+ * common.h (EM_SCORE_OLD): Define.
+
2009-02-23 H.J. Lu <hongjiu.lu@intel.com>
* common.h (STB_LOPROC): Replace Application-specific with
diff --git a/include/elf/common.h b/include/elf/common.h
index 557c650ad3c..3ba44d9462c 100644
--- a/include/elf/common.h
+++ b/include/elf/common.h
@@ -334,6 +334,9 @@
#define EM_CYGNUS_MEP 0xF00D /* Toshiba MeP */
+/* Old Sunplus S+core7 backend magic number. Written in the absence of an ABI. */
+#define EM_SCORE_OLD 95
+
/* See the above comment before you add a new EM_* value here. */
/* Values for e_version. */
diff --git a/include/elf/score.h b/include/elf/score.h
index 72ada054868..8d9c026bb04 100644
--- a/include/elf/score.h
+++ b/include/elf/score.h
@@ -1,6 +1,7 @@
/* Score ELF support for BFD.
- Copyright 2006, 2008 Free Software Foundation, Inc.
+ Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
Contributed by
+ Brain.lin (brain.lin@sunplusct.com)
Mei Ligang (ligang@sunnorth.com.cn)
Pei-Lin Tsai (pltsai@sunplus.com)
@@ -8,7 +9,7 @@
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2 of the License, or
+ the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
@@ -35,6 +36,10 @@
#define GP_DISP_LABEL "_gp_disp"
/* Processor specific flags for the ELF header e_flags field: */
+#define EF_SCORE_MACH 0xffff0000
+#define EF_OMIT_PIC_FIXDD 0x0fff0000
+#define E_SCORE_MACH_SCORE3 0x00030000
+#define E_SCORE_MACH_SCORE7 0x00070000
/* File contains position independent code. */
#define EF_SCORE_PIC 0x80000000
@@ -101,7 +106,7 @@ START_RELOC_NUMBERS (elf_score_reloc_type)
RELOC_NUMBER (R_SCORE_NONE, 0)
RELOC_NUMBER (R_SCORE_HI16, 1)
RELOC_NUMBER (R_SCORE_LO16, 2)
- RELOC_NUMBER (R_SCORE_DUMMY1, 3)
+ RELOC_NUMBER (R_SCORE_BCMP, 3)
RELOC_NUMBER (R_SCORE_24, 4)
RELOC_NUMBER (R_SCORE_PC19, 5)
RELOC_NUMBER (R_SCORE16_11, 6)
@@ -118,6 +123,8 @@ START_RELOC_NUMBERS (elf_score_reloc_type)
RELOC_NUMBER (R_SCORE_GPREL32, 17)
RELOC_NUMBER (R_SCORE_REL32, 18)
RELOC_NUMBER (R_SCORE_DUMMY_HI16, 19)
+ RELOC_NUMBER (R_SCORE_IMM30, 20)
+ RELOC_NUMBER (R_SCORE_IMM32, 21)
END_RELOC_NUMBERS (R_SCORE_max)
#endif /* _ELF_SCORE_H */
diff --git a/include/opcode/ChangeLog b/include/opcode/ChangeLog
index f7018b845db..2a03208a94f 100644
--- a/include/opcode/ChangeLog
+++ b/include/opcode/ChangeLog
@@ -1,3 +1,9 @@
+2009-03-02 Qinwei <qinwei@sunnorth.com.cn>
+
+ * score-inst.h (score_insn_type, score_data_type): Add Ra_I9_I5
+ and _IMM11 for mbitclr and mbitset.
+ * score-datadep.h: Update dependency information.
+
2009-02-26 Peter Bergner <bergner@vnet.ibm.com>
* ppc.h (PPC_OPCODE_POWER7): New.
diff --git a/include/opcode/score-datadep.h b/include/opcode/score-datadep.h
index 8ef35adc807..33c05c060fc 100644
--- a/include/opcode/score-datadep.h
+++ b/include/opcode/score-datadep.h
@@ -1,6 +1,7 @@
/* score-datadep.h -- Score Instructions data dependency table
- Copyright 2006 Free Software Foundation, Inc.
+ Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
Contributed by:
+ Brain.lin (brain.lin@sunplusct.com)
Mei Ligang (ligang@sunnorth.com.cn)
Pei-Lin Tsai (pltsai@sunplus.com)
@@ -8,7 +9,7 @@
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
+ the Free Software Foundation; either version 3, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
@@ -28,20 +29,7 @@
enum insn_type_for_dependency
{
- D_pce,
- D_cond_br,
- D_cond_mv,
- D_cached,
- D_cachei,
- D_ldst,
- D_ldcombine,
D_mtcr,
- D_mfcr,
- D_mfsr,
- D_mftlb,
- D_mtptlb,
- D_mtrtlb,
- D_stlb,
D_all_insn
};
@@ -58,225 +46,20 @@ struct data_dependency
enum insn_type_for_dependency cur_insn_type;
char cur_reg[6];
int bubblenum_7;
- int bubblenum_5;
+ int bubblenum_3;
int warn_or_error; /* warning - 0; error - 1 */
};
static const struct insn_to_dependency insn_to_dependency_table[] =
{
- /* pce instruction. */
- {"pce", D_pce},
- /* conditional branch instruction. */
- {"bcs", D_cond_br},
- {"bcc", D_cond_br},
- {"bgtu", D_cond_br},
- {"bleu", D_cond_br},
- {"beq", D_cond_br},
- {"bne", D_cond_br},
- {"bgt", D_cond_br},
- {"ble", D_cond_br},
- {"bge", D_cond_br},
- {"blt", D_cond_br},
- {"bmi", D_cond_br},
- {"bpl", D_cond_br},
- {"bvs", D_cond_br},
- {"bvc", D_cond_br},
- {"bcsl", D_cond_br},
- {"bccl", D_cond_br},
- {"bgtul", D_cond_br},
- {"bleul", D_cond_br},
- {"beql", D_cond_br},
- {"bnel", D_cond_br},
- {"bgtl", D_cond_br},
- {"blel", D_cond_br},
- {"bgel", D_cond_br},
- {"bltl", D_cond_br},
- {"bmil", D_cond_br},
- {"bpll", D_cond_br},
- {"bvsl", D_cond_br},
- {"bvcl", D_cond_br},
- {"bcs!", D_cond_br},
- {"bcc!", D_cond_br},
- {"bgtu!", D_cond_br},
- {"bleu!", D_cond_br},
- {"beq!", D_cond_br},
- {"bne!", D_cond_br},
- {"bgt!", D_cond_br},
- {"ble!", D_cond_br},
- {"bge!", D_cond_br},
- {"blt!", D_cond_br},
- {"bmi!", D_cond_br},
- {"bpl!", D_cond_br},
- {"bvs!", D_cond_br},
- {"bvc!", D_cond_br},
- {"brcs", D_cond_br},
- {"brcc", D_cond_br},
- {"brgtu", D_cond_br},
- {"brleu", D_cond_br},
- {"breq", D_cond_br},
- {"brne", D_cond_br},
- {"brgt", D_cond_br},
- {"brle", D_cond_br},
- {"brge", D_cond_br},
- {"brlt", D_cond_br},
- {"brmi", D_cond_br},
- {"brpl", D_cond_br},
- {"brvs", D_cond_br},
- {"brvc", D_cond_br},
- {"brcsl", D_cond_br},
- {"brccl", D_cond_br},
- {"brgtul", D_cond_br},
- {"brleul", D_cond_br},
- {"breql", D_cond_br},
- {"brnel", D_cond_br},
- {"brgtl", D_cond_br},
- {"brlel", D_cond_br},
- {"brgel", D_cond_br},
- {"brltl", D_cond_br},
- {"brmil", D_cond_br},
- {"brpll", D_cond_br},
- {"brvsl", D_cond_br},
- {"brvcl", D_cond_br},
- {"brcs!", D_cond_br},
- {"brcc!", D_cond_br},
- {"brgtu!", D_cond_br},
- {"brleu!", D_cond_br},
- {"breq!", D_cond_br},
- {"brne!", D_cond_br},
- {"brgt!", D_cond_br},
- {"brle!", D_cond_br},
- {"brge!", D_cond_br},
- {"brlt!", D_cond_br},
- {"brmi!", D_cond_br},
- {"brpl!", D_cond_br},
- {"brvs!", D_cond_br},
- {"brvc!", D_cond_br},
- {"brcsl!", D_cond_br},
- {"brccl!", D_cond_br},
- {"brgtul!", D_cond_br},
- {"brleul!", D_cond_br},
- {"breql!", D_cond_br},
- {"brnel!", D_cond_br},
- {"brgtl!", D_cond_br},
- {"brlel!", D_cond_br},
- {"brgel!", D_cond_br},
- {"brltl!", D_cond_br},
- {"brmil!", D_cond_br},
- {"brpll!", D_cond_br},
- {"brvsl!", D_cond_br},
- {"brvcl!", D_cond_br},
- /* conditional move instruction. */
- {"mvcs", D_cond_mv},
- {"mvcc", D_cond_mv},
- {"mvgtu", D_cond_mv},
- {"mvleu", D_cond_mv},
- {"mveq", D_cond_mv},
- {"mvne", D_cond_mv},
- {"mvgt", D_cond_mv},
- {"mvle", D_cond_mv},
- {"mvge", D_cond_mv},
- {"mvlt", D_cond_mv},
- {"mvmi", D_cond_mv},
- {"mvpl", D_cond_mv},
- {"mvvs", D_cond_mv},
- {"mvvc", D_cond_mv},
/* move spectial instruction. */
{"mtcr", D_mtcr},
- {"mftlb", D_mftlb},
- {"mtptlb", D_mtptlb},
- {"mtrtlb", D_mtrtlb},
- {"stlb", D_stlb},
- {"mfcr", D_mfcr},
- {"mfsr", D_mfsr},
- /* cache instruction. */
- {"cache 8", D_cached},
- {"cache 9", D_cached},
- {"cache 10", D_cached},
- {"cache 11", D_cached},
- {"cache 12", D_cached},
- {"cache 13", D_cached},
- {"cache 14", D_cached},
- {"cache 24", D_cached},
- {"cache 26", D_cached},
- {"cache 27", D_cached},
- {"cache 29", D_cached},
- {"cache 30", D_cached},
- {"cache 31", D_cached},
- {"cache 0", D_cachei},
- {"cache 1", D_cachei},
- {"cache 2", D_cachei},
- {"cache 3", D_cachei},
- {"cache 4", D_cachei},
- {"cache 16", D_cachei},
- {"cache 17", D_cachei},
- /* load/store instruction. */
- {"lb", D_ldst},
- {"lbu", D_ldst},
- {"lbu!", D_ldst},
- {"lbup!", D_ldst},
- {"lh", D_ldst},
- {"lhu", D_ldst},
- {"lh!", D_ldst},
- {"lhp!", D_ldst},
- {"lw", D_ldst},
- {"lw!", D_ldst},
- {"lwp!", D_ldst},
- {"sb", D_ldst},
- {"sb!", D_ldst},
- {"sbp!", D_ldst},
- {"sh", D_ldst},
- {"sh!", D_ldst},
- {"shp!", D_ldst},
- {"sw", D_ldst},
- {"sw!", D_ldst},
- {"swp!", D_ldst},
- {"alw", D_ldst},
- {"asw", D_ldst},
- {"push!", D_ldst},
- {"pushhi!", D_ldst},
- {"pop!", D_ldst},
- {"pophi!", D_ldst},
- {"ldc1", D_ldst},
- {"ldc2", D_ldst},
- {"ldc3", D_ldst},
- {"stc1", D_ldst},
- {"stc2", D_ldst},
- {"stc3", D_ldst},
- {"scb", D_ldst},
- {"scw", D_ldst},
- {"sce", D_ldst},
- /* load combine instruction. */
- {"lcb", D_ldcombine},
- {"lcw", D_ldcombine},
- {"lce", D_ldcombine},
};
static const struct data_dependency data_dependency_table[] =
{
- /* Condition register. */
- {D_mtcr, "cr1", D_pce, "", 2, 1, 1},
- {D_mtcr, "cr1", D_cond_br, "", 1, 0, 1},
- {D_mtcr, "cr1", D_cond_mv, "", 1, 0, 1},
/* Status regiser. */
- {D_mtcr, "cr0", D_all_insn, "", 5, 4, 0},
- /* CCR regiser. */
- {D_mtcr, "cr4", D_all_insn, "", 6, 5, 0},
- /* EntryHi/EntryLo register. */
- {D_mftlb, "", D_mtptlb, "", 1, 1, 1},
- {D_mftlb, "", D_mtrtlb, "", 1, 1, 1},
- {D_mftlb, "", D_stlb, "", 1, 1,1},
- {D_mftlb, "", D_mfcr, "cr11", 1, 1, 1},
- {D_mftlb, "", D_mfcr, "cr12", 1, 1, 1},
- /* Index register. */
- {D_stlb, "", D_mtptlb, "", 1, 1, 1},
- {D_stlb, "", D_mftlb, "", 1, 1, 1},
- {D_stlb, "", D_mfcr, "cr8", 2, 2, 1},
- /* Cache. */
- {D_cached, "", D_ldst, "", 1, 1, 0},
- {D_cached, "", D_ldcombine, "", 1, 1, 0},
- {D_cachei, "", D_all_insn, "", 5, 4, 0},
- /* Load combine. */
- {D_ldcombine, "", D_mfsr, "sr1", 3, 3, 1},
+ {D_mtcr, "cr0", D_all_insn, "", 5, 1, 0},
};
#endif
diff --git a/include/opcode/score-inst.h b/include/opcode/score-inst.h
index e87794f7744..0eac3824caa 100644
--- a/include/opcode/score-inst.h
+++ b/include/opcode/score-inst.h
@@ -1,6 +1,7 @@
/* score-inst.h -- Score Instructions Table
- Copyright 2006 Free Software Foundation, Inc.
+ Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
Contributed by:
+ Brain.lin (brain.lin@sunplusct.com)
Mei Ligang (ligang@sunnorth.com.cn)
Pei-Lin Tsai (pltsai@sunplus.com)
@@ -8,7 +9,7 @@
GAS is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
- the Free Software Foundation; either version 2, or (at your option)
+ the Free Software Foundation; either version 3, or (at your option)
any later version.
GAS is distributed in the hope that it will be useful,
@@ -96,6 +97,8 @@ enum score_insn_type
Rd_Rs_I14,
I15,
Rd_I16,
+ Rd_I30,
+ Rd_I32,
Rd_rvalueRs_SI10,
Rd_lvalueRs_SI10,
Rd_rvalueRs_preSI12,
@@ -105,6 +108,8 @@ enum score_insn_type
Rd_Rs_SI14,
Rd_rvalueRs_SI15,
Rd_lvalueRs_SI15,
+ Rd_SI5,
+ Rd_SI6,
Rd_SI16,
PC_DISP8div2,
PC_DISP11div2,
@@ -139,6 +144,8 @@ enum score_insn_type
Insn_GP,
Insn_PIC,
Insn_internal,
+ Insn_BCMP,
+ Ra_I9_I5,
};
enum score_data_type
@@ -178,6 +185,13 @@ enum score_data_type
_SIMM16_pic = 42, /* Index in score_df_range. */
_IMM16_LO16_pic = 43,
_IMM16_pic = 44,
+
+ _SIMM5 = 45,
+ _SIMM6 = 46,
+ _IMM32 = 47,
+ _SIMM32 = 48,
+ _IMM11 = 49,
+ _IMM5_MULTI_LOAD = 50,
};
#define REG_TMP 1
@@ -206,302 +220,17 @@ enum score_data_type
#define OP16_SH_DISP8 (OP_IMM_TYPE | 0)
#define OP16_SH_DISP11 (OP_IMM_TYPE | 1)
-struct datafield_range
-{
- int data_type;
- int bits;
- int range[2];
-};
-
-struct datafield_range score_df_range[] =
-{
- {_IMM4, 4, {0, (1 << 4) - 1}}, /* ( 0 ~ 15 ) */
- {_IMM5, 5, {0, (1 << 5) - 1}}, /* ( 0 ~ 31 ) */
- {_IMM8, 8, {0, (1 << 8) - 1}}, /* ( 0 ~ 255 ) */
- {_IMM14, 14, {0, (1 << 14) - 1}}, /* ( 0 ~ 16383) */
- {_IMM15, 15, {0, (1 << 15) - 1}}, /* ( 0 ~ 32767) */
- {_IMM16, 16, {0, (1 << 16) - 1}}, /* ( 0 ~ 65535) */
- {_SIMM10, 10, {-(1 << 9), (1 << 9) - 1}}, /* ( -512 ~ 511 ) */
- {_SIMM12, 12, {-(1 << 11), (1 << 11) - 1}}, /* ( -2048 ~ 2047 ) */
- {_SIMM14, 14, {-(1 << 13), (1 << 13) - 1}}, /* ( -8192 ~ 8191 ) */
- {_SIMM15, 15, {-(1 << 14), (1 << 14) - 1}}, /* (-16384 ~ 16383) */
- {_SIMM16, 16, {-(1 << 15), (1 << 15) - 1}}, /* (-32768 ~ 32767) */
- {_SIMM14_NEG, 14, {-(1 << 13), (1 << 13) - 1}}, /* ( -8191 ~ 8192 ) */
- {_IMM16_NEG, 16, {0, (1 << 16) - 1}}, /* (-65535 ~ 0 ) */
- {_SIMM16_NEG, 16, {-(1 << 15), (1 << 15) - 1}}, /* (-32768 ~ 32767) */
- {_IMM20, 20, {0, (1 << 20) - 1}},
- {_IMM25, 25, {0, (1 << 25) - 1}},
- {_DISP8div2, 8, {-(1 << 8), (1 << 8) - 1}}, /* ( -256 ~ 255 ) */
- {_DISP11div2, 11, {0, 0}},
- {_DISP19div2, 19, {-(1 << 19), (1 << 19) - 1}}, /* (-524288 ~ 524287) */
- {_DISP24div2, 24, {0, 0}},
- {_VALUE, 32, {0, ((unsigned int)1 << 31) - 1}},
- {_VALUE_HI16, 16, {0, (1 << 16) - 1}},
- {_VALUE_LO16, 16, {0, (1 << 16) - 1}},
- {_VALUE_LDST_LO16, 16, {0, (1 << 16) - 1}},
- {_SIMM16_LA, 16, {-(1 << 15), (1 << 15) - 1}}, /* (-32768 ~ 32767) */
- {_IMM5_RSHIFT_1, 5, {0, (1 << 6) - 1}}, /* ( 0 ~ 63 ) */
- {_IMM5_RSHIFT_2, 5, {0, (1 << 7) - 1}}, /* ( 0 ~ 127 ) */
- {_SIMM16_LA_POS, 16, {0, (1 << 15) - 1}}, /* ( 0 ~ 32767) */
- {_IMM5_RANGE_8_31, 5, {8, 31}}, /* But for cop0 the valid data : (8 ~ 31). */
- {_IMM10_RSHIFT_2, 10, {-(1 << 11), (1 << 11) - 1}}, /* For ldc#, stc#. */
- {_SIMM10, 10, {0, (1 << 10) - 1}}, /* ( -1024 ~ 1023 ) */
- {_SIMM12, 12, {0, (1 << 12) - 1}}, /* ( -2048 ~ 2047 ) */
- {_SIMM14, 14, {0, (1 << 14) - 1}}, /* ( -8192 ~ 8191 ) */
- {_SIMM15, 15, {0, (1 << 15) - 1}}, /* (-16384 ~ 16383) */
- {_SIMM16, 16, {0, (1 << 16) - 1}}, /* (-65536 ~ 65536) */
- {_SIMM14_NEG, 14, {0, (1 << 16) - 1}}, /* ( -8191 ~ 8192 ) */
- {_IMM16_NEG, 16, {0, (1 << 16) - 1}}, /* ( 65535 ~ 0 ) */
- {_SIMM16_NEG, 16, {0, (1 << 16) - 1}}, /* ( 65535 ~ 0 ) */
- {_IMM20, 20, {0, (1 << 20) - 1}}, /* (-32768 ~ 32767) */
- {_IMM25, 25, {0, (1 << 25) - 1}}, /* (-32768 ~ 32767) */
- {_GP_IMM15, 15, {0, (1 << 15) - 1}}, /* ( 0 ~ 65535) */
- {_GP_IMM14, 14, {0, (1 << 14) - 1}}, /* ( 0 ~ 65535) */
- {_SIMM16_pic, 16, {-(1 << 15), (1 << 15) - 1}}, /* (-32768 ~ 32767) */
- {_IMM16_LO16_pic, 16, {0, (1 << 16) - 1}}, /* ( 65535 ~ 0 ) */
- {_IMM16_pic, 16, {0, (1 << 16) - 1}}, /* ( 0 ~ 65535) */
-};
-
-struct shift_bitmask
-{
- int opd_type;
- int opd_num;
- struct datafield_range *df_range;
- int sh[4];
- long fieldbits[4];
-};
-
-struct shift_bitmask score_sh_bits_map[] =
-{
- {
- Rd_I4, 2, &score_df_range[_IMM4],
- {OP16_SH_REGD, OP16_SH_I45, 0, 0},
- {0xf, 0xf, 0, 0},
- },
- {
- Rd_I5, 2, &score_df_range[_IMM5],
- {OP16_SH_REGD, OP16_SH_I45, 0, 0},
- {0xf, 0x1f, 0, 0},
- },
- {
- Rd_rvalueBP_I5, 2, &score_df_range[_IMM5],
- {OP16_SH_REGD, OP16_SH_I45, 0, 0},
- {0xf, 0x1f, 0, 0},
- },
- {
- Rd_lvalueBP_I5, 2, &score_df_range[_IMM5],
- {OP16_SH_REGD, OP16_SH_I45, 0, 0},
- {0xf, 0x1f, 0, 0},
- },
- {
- Rd_Rs_I5, 3, &score_df_range[_IMM5],
- {OP_SH_REGD, OP_SH_REGS1, OP_SH_I5, 0},
- {0x1f, 0x1f, 0x1f, 0},
- },
- {
- x_Rs_I5, 2, &score_df_range[_IMM5],
- {OP_SH_REGS1, OP_SH_I5, 0, 0},
- {0x1f, 0x1f, 0, 0},
- },
- {
- x_I5_x, 1, &score_df_range[_IMM5],
- {OP_SH_TRAPI5, 0, 0, 0},
- {0x1f, 0, 0, 0},
- },
- {
- Rd_I8, 2, &score_df_range[_IMM8],
- {OP16_SH_REGD, OP16_SH_I8, 0, 0},
- {0xf, 0xff, 0, 0},
- },
- {
- Rd_Rs_I14, 3, &score_df_range[_IMM14],
- {OP_SH_REGD, OP_SH_REGS1, OP_SH_I, 0},
- {0x1f, 0x1f, 0x3fff, 0},
- },
- {
- I15, 1, &score_df_range[_IMM15],
- {OP_SH_I15, 0, 0, 0},
- {0x7fff, 0, 0, 0},
- },
- {
- Rd_I16, 2, &score_df_range[_IMM16],
- {OP_SH_REGD, OP_SH_I, 0, 0},
- {0x1f, 0xffff, 0, 0},
- },
- {
- Rd_rvalueRs_SI10, 3, &score_df_range[_SIMM10],
- {OP_SH_REGD, OP_SH_REGS1, OP_SH_I10, 0},
- {0x1f, 0x1f, 0x3ff, 0},
- },
- {
- Rd_lvalueRs_SI10, 3, &score_df_range[_SIMM10],
- {OP_SH_REGD, OP_SH_REGS1, OP_SH_I10, 0},
- {0x1f, 0x1f, 0x3ff, 0},
- },
- {
- Rd_rvalueRs_preSI12, 3, &score_df_range[_SIMM12],
- {OP_SH_REGD, OP_SH_REGS1, OP_SH_I12, 0},
- {0xf, 0xf, 0xfff, 0},
- },
- {
- Rd_rvalueRs_postSI12, 3, &score_df_range[_SIMM12],
- {OP_SH_REGD, OP_SH_REGS1, OP_SH_I12, 0},
- {0xf, 0xf, 0xfff, 0},
- },
- {
- Rd_lvalueRs_preSI12, 3, &score_df_range[_SIMM12],
- {OP_SH_REGD, OP_SH_REGS1, OP_SH_I12, 0},
- {0xf, 0xf, 0xfff, 0},
- },
- {
- Rd_lvalueRs_postSI12, 3, &score_df_range[_SIMM12],
- {OP_SH_REGD, OP_SH_REGS1, OP_SH_I12, 0},
- {0xf, 0xf, 0xfff, 0},
- },
- {
- Rd_Rs_SI14, 3, &score_df_range[_SIMM14],
- {OP_SH_REGD, OP_SH_REGS1, OP_SH_I, 0},
- {0x1f, 0x1f, 0x3fff, 0},
- },
- {
- Rd_rvalueRs_SI15, 3, &score_df_range[_SIMM15],
- {OP_SH_REGD, OP_SH_REGS1, OP_SH_RI15, 0},
- {0x1f, 0x1f, 0x7fff, 0},
- },
- {
- Rd_lvalueRs_SI15, 3, &score_df_range[_SIMM15],
- {OP_SH_REGD, OP_SH_REGS1, OP_SH_RI15, 0},
- {0x1f, 0x1f, 0x7fff, 0},
- },
- {
- Rd_SI16, 2, &score_df_range[_SIMM16],
- {OP_SH_REGD, OP_SH_I, 0, 0},
- {0x1f, 0xffff, 0, 0},
- },
- {
- PC_DISP8div2, 1, &score_df_range[_DISP8div2],
- {OP16_SH_DISP8, 0, 0, 0},
- {0xff, 0, 0, 0},
- },
- {
- PC_DISP11div2, 1, &score_df_range[_DISP11div2],
- {OP16_SH_DISP11, 0, 0, 0},
- {0x7ff, 0, 0, 0},
- },
- {
- PC_DISP19div2, 2, &score_df_range[_DISP19div2],
- {OP_SH_DISP19_p1, OP_SH_DISP19_p2, 0, 0},
- {0x3ff, 0x1ff, 0, 0},
- },
- {
- PC_DISP24div2, 1, &score_df_range[_DISP24div2],
- {OP_SH_DISP24, 0, 0, 0},
- {0xffffff, 0, 0, 0},
- },
- {
- Rd_Rs_Rs, 3, NULL,
- {OP_SH_REGD, OP_SH_REGS1, OP_SH_REGS2, 0},
- {0x1f, 0x1f, 0x1f, 0}
- },
- {
- Rd_Rs_x, 2, NULL,
- {OP_SH_REGD, OP_SH_REGS1, 0, 0},
- {0x1f, 0x1f, 0, 0},
- },
- {
- Rd_x_Rs, 2, NULL,
- {OP_SH_REGD, OP_SH_REGS2, 0, 0},
- {0x1f, 0x1f, 0, 0},
- },
- {
- Rd_x_x, 1, NULL,
- {OP_SH_REGD, 0, 0, 0},
- {0x1f, 0, 0, 0},
- },
- {
- x_Rs_Rs, 2, NULL,
- {OP_SH_REGS1, OP_SH_REGS2, 0, 0},
- {0x1f, 0x1f, 0, 0},
- },
- {
- x_Rs_x, 1, NULL,
- {OP_SH_REGS1, 0, 0, 0},
- {0x1f, 0, 0, 0},
- },
- {
- Rd_Rs, 2, NULL,
- {OP16_SH_REGD, OP16_SH_REGS1, 0, 0},
- {0xf, 0xf, 0, 0},
- },
- {
- Rd_HighRs, 2, NULL,
- {OP16_SH_REGD, OP16_SH_REGS1, 0, 0},
- {0xf, 0xf, 0x1f, 0},
- },
- {
- Rd_rvalueRs, 2, NULL,
- {OP16_SH_REGD, OP16_SH_REGS1, 0, 0},
- {0xf, 0xf, 0, 0},
- },
- {
- Rd_lvalueRs, 2, NULL,
- {OP16_SH_REGD, OP16_SH_REGS1, 0, 0},
- {0xf, 0xf, 0, 0}
- },
- {
- Rd_lvalue32Rs, 2, NULL,
- {OP_SH_REGD, OP_SH_REGS1, 0, 0},
- {0x1f, 0x1f, 0, 0},
- },
- {
- Rd_rvalue32Rs, 2, NULL,
- {OP_SH_REGD, OP_SH_REGS1, 0, 0},
- {0x1f, 0x1f, 0, 0},
- },
- {
- x_Rs, 1, NULL,
- {OP16_SH_REGS1, 0, 0, 0},
- {0xf, 0, 0, 0},
- },
- {
- NO_OPD, 0, NULL,
- {0, 0, 0, 0},
- {0, 0, 0, 0},
- },
- {
- NO16_OPD, 0, NULL,
- {0, 0, 0, 0},
- {0, 0, 0, 0},
- },
-};
-
-struct asm_opcode
-{
- /* Instruction name. */
- const char *template;
-
- /* Instruction Opcode. */
- unsigned long value;
-
- /* Instruction bit mask. */
- unsigned long bitmask;
-
- /* Relax instruction opcode. 0x8000 imply no relaxation. */
- unsigned long relax_value;
-
- /* Instruction type. */
- enum score_insn_type type;
-
- /* Function to call to parse args. */
- void (*parms) (char *);
-};
-
enum insn_class
{
INSN_CLASS_16,
INSN_CLASS_32,
+ INSN_CLASS_48,
INSN_CLASS_PCE,
INSN_CLASS_SYN
};
+/* s3_s7: Globals for both tc-score.c and elf32-score.c. */
+extern int score3;
+extern int score7;
+
#endif
diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index 80e8681a7ff..34230ec7625 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,3 +1,13 @@
+2009-03-02 Qinwei <qinwei@sunnorth.com.cn>
+
+ * score7-dis.c: New file.
+ * Makefile.am: Add dependencies for score7-dis.c.
+ * Makefile.in: Regenerate.
+ * configure.in: Add score7-dis to score files.
+ * configure: Regenerate.
+ * score-dis.c: Add support for score7 architecture.
+ * score-opc.h: Likewise.
+
2009-03-01 Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
* configure: Regenerate.
diff --git a/opcodes/Makefile.am b/opcodes/Makefile.am
index 390dba32994..6264e0750f7 100644
--- a/opcodes/Makefile.am
+++ b/opcodes/Makefile.am
@@ -189,6 +189,7 @@ CFILES = \
s390-opc.c \
s390-dis.c \
score-dis.c \
+ score7-dis.c \
sh-dis.c \
sh64-dis.c \
sh64-opc.c \
@@ -337,6 +338,7 @@ ALL_MACHINES = \
s390-dis.lo \
s390-opc.lo \
score-dis.lo \
+ score7-dis.lo \
sh-dis.lo \
sh64-dis.lo \
sh64-opc.lo \
@@ -1125,6 +1127,11 @@ score-dis.lo: score-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
opintl.h $(BFDDIR)/elf-bfd.h $(INCDIR)/elf/common.h \
$(INCDIR)/elf/external.h $(INCDIR)/elf/internal.h $(INCDIR)/bfdlink.h \
$(INCDIR)/elf/score.h $(INCDIR)/elf/reloc-macros.h
+score7-dis.lo: score7-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
+ $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/symcat.h score-opc.h \
+ opintl.h $(BFDDIR)/elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/external.h $(INCDIR)/elf/internal.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/score.h $(INCDIR)/elf/reloc-macros.h
sh-dis.lo: sh-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
sh-opc.h $(BFD_H) $(INCDIR)/symcat.h $(INCDIR)/dis-asm.h
sh64-dis.lo: sh64-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
diff --git a/opcodes/Makefile.in b/opcodes/Makefile.in
index 9e12b0800d1..2429d82d61c 100644
--- a/opcodes/Makefile.in
+++ b/opcodes/Makefile.in
@@ -427,6 +427,7 @@ CFILES = \
s390-opc.c \
s390-dis.c \
score-dis.c \
+ score7-dis.c \
sh-dis.c \
sh64-dis.c \
sh64-opc.c \
@@ -575,6 +576,7 @@ ALL_MACHINES = \
s390-dis.lo \
s390-opc.lo \
score-dis.lo \
+ score7-dis.lo \
sh-dis.lo \
sh64-dis.lo \
sh64-opc.lo \
@@ -1689,6 +1691,11 @@ score-dis.lo: score-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
opintl.h $(BFDDIR)/elf-bfd.h $(INCDIR)/elf/common.h \
$(INCDIR)/elf/external.h $(INCDIR)/elf/internal.h $(INCDIR)/bfdlink.h \
$(INCDIR)/elf/score.h $(INCDIR)/elf/reloc-macros.h
+score7-dis.lo: score7-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
+ $(INCDIR)/dis-asm.h $(BFD_H) $(INCDIR)/symcat.h score-opc.h \
+ opintl.h $(BFDDIR)/elf-bfd.h $(INCDIR)/elf/common.h \
+ $(INCDIR)/elf/external.h $(INCDIR)/elf/internal.h $(INCDIR)/bfdlink.h \
+ $(INCDIR)/elf/score.h $(INCDIR)/elf/reloc-macros.h
sh-dis.lo: sh-dis.c sysdep.h config.h $(INCDIR)/ansidecl.h \
sh-opc.h $(BFD_H) $(INCDIR)/symcat.h $(INCDIR)/dis-asm.h
sh64-dis.lo: sh64-dis.c $(INCDIR)/dis-asm.h $(BFD_H) \
diff --git a/opcodes/configure b/opcodes/configure
index 3c6d3c82faa..998baf46b18 100755
--- a/opcodes/configure
+++ b/opcodes/configure
@@ -12558,7 +12558,7 @@ if test x${all_targets} = xfalse ; then
bfd_romp_arch) ;;
bfd_rs6000_arch) ta="$ta ppc-dis.lo ppc-opc.lo" ;;
bfd_s390_arch) ta="$ta s390-dis.lo s390-opc.lo" ;;
- bfd_score_arch) ta="$ta score-dis.lo" ;;
+ bfd_score_arch) ta="$ta score-dis.lo score7-dis.lo" ;;
bfd_sh_arch)
# We can't decide what we want just from the CPU family.
# We want SH5 support unless a specific version of sh is
diff --git a/opcodes/configure.in b/opcodes/configure.in
index 60149adc10e..8bebe7e3235 100644
--- a/opcodes/configure.in
+++ b/opcodes/configure.in
@@ -231,7 +231,7 @@ if test x${all_targets} = xfalse ; then
bfd_romp_arch) ;;
bfd_rs6000_arch) ta="$ta ppc-dis.lo ppc-opc.lo" ;;
bfd_s390_arch) ta="$ta s390-dis.lo s390-opc.lo" ;;
- bfd_score_arch) ta="$ta score-dis.lo" ;;
+ bfd_score_arch) ta="$ta score-dis.lo score7-dis.lo" ;;
bfd_sh_arch)
# We can't decide what we want just from the CPU family.
# We want SH5 support unless a specific version of sh is
diff --git a/opcodes/score-dis.c b/opcodes/score-dis.c
index 1210115b3d2..732ddfb612a 100644
--- a/opcodes/score-dis.c
+++ b/opcodes/score-dis.c
@@ -1,6 +1,7 @@
/* Instruction printing code for Score
- Copyright 2006, 2007 Free Software Foundation, Inc.
+ Copyright 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
Contributed by:
+ Brain.lin (brain.lin@sunplusct.com)
Mei Ligang (ligang@sunnorth.com.cn)
Pei-Lin Tsai (pltsai@sunplus.com)
@@ -24,7 +25,7 @@
#include "sysdep.h"
#include "dis-asm.h"
#define DEFINE_TABLE
-#include "score-opc.h"
+/*****************************************************************************/
#include "opintl.h"
#include "bfd.h"
@@ -33,12 +34,455 @@
#include "elf/internal.h"
#include "elf/score.h"
+/*****************************************************************************/
+/* s3_s7: opcodes and export prototypes. */
+extern int
+s7_print_insn (bfd_vma pc, struct disassemble_info *info, bfd_boolean little);
+
+struct score_opcode
+{
+ bfd_vma value;
+ bfd_vma mask; /* Recognise instruction if (op & mask) == value. */
+ char *assembler; /* Disassembly string. */
+};
+
+/* Note: There is a partial ordering in this table - it must be searched from
+ the top to obtain a correct match. */
+
+static struct score_opcode score_opcodes[] =
+{
+ /* Score Instructions. */
+ {0x3800000a, 0x3e007fff, "abs\t\t%20-24r, %15-19r"},
+ {0x3800004b, 0x3e007fff, "abs.s\t\t%20-24r, %15-19r"},
+ {0x00000010, 0x3e0003ff, "add\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000011, 0x3e0003ff, "add.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x38000048, 0x3e0003ff, "add.s\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000012, 0x3e0003ff, "addc\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000013, 0x3e0003ff, "addc.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x02000000, 0x3e0e0001, "addi\t\t%20-24r, %1-16i"},
+ {0x02000001, 0x3e0e0001, "addi.c\t\t%20-24r, %1-16i"},
+ {0x0a000000, 0x3e0e0001, "addis\t\t%20-24r, %1-16d(0x%1-16x)"},
+ {0x0a000001, 0x3e0e0001, "addis.c\t\t%20-24r, %1-16d(0x%1-16x)"},
+ {0x10000000, 0x3e000001, "addri\t\t%20-24r, %15-19r, %1-14i"},
+ {0x10000001, 0x3e000001, "addri.c\t\t%20-24r, %15-19r, %1-14i"},
+ {0x00004800, 0x00007f00, "add!\t\t%4-7r, %0-3r"},
+ {0x00005c00, 0x00007c00, "addi!\t\t%6-9r, %0-5i"},
+ {0x00000020, 0x3e0003ff, "and\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000021, 0x3e0003ff, "and.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x040000000000LL, 0x1c0000000003LL, "andri48\t\t%38-41r,%34-37r, 0x%2-33x"},
+ {0x040000000001LL, 0x1c0000000003LL, "andri48.c\t\t%38-41r,%34-37r, 0x%2-33x"},
+ {0x02080000, 0x3e0e0001, "andi\t\t%20-24r, 0x%1-16x"},
+ {0x02080001, 0x3e0e0001, "andi.c\t\t%20-24r, 0x%1-16x"},
+ {0x0a080000, 0x3e0e0001, "andis\t\t%20-24r, 0x%1-16x"},
+ {0x0a080001, 0x3e0e0001, "andis.c\t\t%20-24r, 0x%1-16x"},
+ {0x18000000, 0x3e000001, "andri\t\t%20-24r, %15-19r, 0x%1-14x"},
+ {0x18000001, 0x3e000001, "andri.c\t\t%20-24r, %15-19r,0x%1-14x"},
+ {0x00004b00, 0x00007f00, "and!\t\t%4-7r, %0-3r"},
+ {0x08000000, 0x3e007c01, "bcs\t\t%b"},
+ {0x08000400, 0x3e007c01, "bcc\t\t%b"},
+ {0x08003800, 0x3e007c01, "bcnz\t\t%b"},
+ {0x08000001, 0x3e007c01, "bcsl\t\t%b"},
+ {0x08000401, 0x3e007c01, "bccl\t\t%b"},
+ {0x08003801, 0x3e007c01, "bcnzl\t\t%b"},
+ {0x0000004c, 0x3e00007e, "bcmpeqz\t\t%15-19r, %z"},
+ {0x0000004c, 0x3e00007e, "bcmpeq\t\t%15-19r, %z"},
+ {0x0000004e, 0x3e00007e, "bcmpnez\t\t%15-19r, %z"},
+ {0x0000004e, 0x3e00007e, "bcmpne\t\t%15-19r, %z"},
+ {0x00003200, 0x00007e00, "bcnz!\t\t%b"},
+ {0x08001000, 0x3e007c01, "beq\t\t%b"},
+ {0x08001001, 0x3e007c01, "beql\t\t%b"},
+ {0x00003800, 0x00007e00, "beq!\t\t%b"},
+ {0x08000800, 0x3e007c01, "bgtu\t\t%b"},
+ {0x08001800, 0x3e007c01, "bgt\t\t%b"},
+ {0x08002000, 0x3e007c01, "bge\t\t%b"},
+ {0x08000801, 0x3e007c01, "bgtul\t\t%b"},
+ {0x08001801, 0x3e007c01, "bgtl\t\t%b"},
+ {0x08002001, 0x3e007c01, "bgel\t\t%b"},
+ {0x00003400, 0x00007e00, "bgtu!\t\t%b"},
+ {0x00003c00, 0x00007e00, "bgt!\t\t%b"},
+ {0x00000029, 0x3e0003ff, "bitclr.c\t%20-24r, %15-19r, 0x%10-14x"},
+ {0x00000028, 0x3e0003ff, "bitclr\t%20-24r, %15-19r, 0x%10-14x"},
+ {0x0000002b, 0x3e0003ff, "bitset.c\t%20-24r, %15-19r, 0x%10-14x"},
+ {0x0000002a, 0x3e0003ff, "bitset\t%20-24r, %15-19r, 0x%10-14x"},
+ {0x0000002d, 0x3e0003ff, "bittst.c\t%15-19r, 0x%10-14x"},
+ {0x0000002f, 0x3e0003ff, "bittgl.c\t%20-24r, %15-19r, 0x%10-14x"},
+ {0x0000002e, 0x3e0003ff, "bittgl\t%20-24r, %15-19r, 0x%10-14x"},
+ {0x00005000, 0x00007e00, "bitclr!\t\t%5-8r, 0x%0-4x"},
+ {0x3800000c, 0x3e0003ff, "bitrev\t\t%20-24r, %15-19r,%10-14r"},
+ {0x00005200, 0x00007e00, "bitset!\t\t%5-8r, 0x%0-4x"},
+ {0x00005400, 0x00007e00, "bittst!\t\t%5-8r, 0x%0-4x"},
+ {0x00005600, 0x00007e00, "bittgl!\t\t%5-8r, 0x%0-4x"},
+ {0x08000c00, 0x3e007c01, "bleu\t\t%b"},
+ {0x08001c00, 0x3e007c01, "ble\t\t%b"},
+ {0x08002400, 0x3e007c01, "blt\t\t%b"},
+ {0x08000c01, 0x3e007c01, "bleul\t\t%b"},
+ {0x08001c01, 0x3e007c01, "blel\t\t%b"},
+ {0x08002401, 0x3e007c01, "bltl\t\t%b"},
+ {0x08003c01, 0x3e007c01, "bl\t\t%b"},
+ {0x00003600, 0x00007e00, "bleu!\t\t%b"},
+ {0x00003e00, 0x00007e00, "ble!\t\t%b"},
+ {0x08002800, 0x3e007c01, "bmi\t\t%b"},
+ {0x08002801, 0x3e007c01, "bmil\t\t%b"},
+ {0x08001400, 0x3e007c01, "bne\t\t%b"},
+ {0x08001401, 0x3e007c01, "bnel\t\t%b"},
+ {0x00003a00, 0x00007e00, "bne!\t\t%b"},
+ {0x08002c00, 0x3e007c01, "bpl\t\t%b"},
+ {0x08002c01, 0x3e007c01, "bpll\t\t%b"},
+ {0x00000008, 0x3e007fff, "brcs\t\t%15-19r"},
+ {0x00000408, 0x3e007fff, "brcc\t\t%15-19r"},
+ {0x00000808, 0x3e007fff, "brgtu\t\t%15-19r"},
+ {0x00000c08, 0x3e007fff, "brleu\t\t%15-19r"},
+ {0x00001008, 0x3e007fff, "breq\t\t%15-19r"},
+ {0x00001408, 0x3e007fff, "brne\t\t%15-19r"},
+ {0x00001808, 0x3e007fff, "brgt\t\t%15-19r"},
+ {0x00001c08, 0x3e007fff, "brle\t\t%15-19r"},
+ {0x00002008, 0x3e007fff, "brge\t\t%15-19r"},
+ {0x00002408, 0x3e007fff, "brlt\t\t%15-19r"},
+ {0x00002808, 0x3e007fff, "brmi\t\t%15-19r"},
+ {0x00002c08, 0x3e007fff, "brpl\t\t%15-19r"},
+ {0x00003008, 0x3e007fff, "brvs\t\t%15-19r"},
+ {0x00003408, 0x3e007fff, "brvc\t\t%15-19r"},
+ {0x00003808, 0x3e007fff, "brcnz\t\t%15-19r"},
+ {0x00003c08, 0x3e007fff, "br\t\t%15-19r"},
+ {0x00000009, 0x3e007fff, "brcsl\t\t%15-19r"},
+ {0x00000409, 0x3e007fff, "brccl\t\t%15-19r"},
+ {0x00000809, 0x3e007fff, "brgtul\t\t%15-19r"},
+ {0x00000c09, 0x3e007fff, "brleul\t\t%15-19r"},
+ {0x00001009, 0x3e007fff, "breql\t\t%15-19r"},
+ {0x00001409, 0x3e007fff, "brnel\t\t%15-19r"},
+ {0x00001809, 0x3e007fff, "brgtl\t\t%15-19r"},
+ {0x00001c09, 0x3e007fff, "brlel\t\t%15-19r"},
+ {0x00002009, 0x3e007fff, "brgel\t\t%15-19r"},
+ {0x00002409, 0x3e007fff, "brltl\t\t%15-19r"},
+ {0x00002809, 0x3e007fff, "brmil\t\t%15-19r"},
+ {0x00002c09, 0x3e007fff, "brpll\t\t%15-19r"},
+ {0x00003009, 0x3e007fff, "brvsl\t\t%15-19r"},
+ {0x00003409, 0x3e007fff, "brvcl\t\t%15-19r"},
+ {0x00003809, 0x3e007fff, "brcnzl\t\t%15-19r"},
+ {0x00003c09, 0x3e007fff, "brl\t\t%15-19r"},
+ {0x00000080, 0x00007fe0, "br!\t\t%0-4r"},
+ {0x000000a0, 0x00007fe0, "brl!\t\t%0-4r"},
+ {0x000000c0, 0x00007fe0, "brr!\t\t%0-4r"},
+ {0x08003000, 0x3e007c01, "bvs\t\t%b"},
+ {0x08003400, 0x3e007c01, "bvc\t\t%b"},
+ {0x08003001, 0x3e007c01, "bvsl\t\t%b"},
+ {0x08003401, 0x3e007c01, "bvcl\t\t%b"},
+ {0x00003000, 0x00007e00, "b!\t\t%b"},
+ {0x08003c00, 0x3e007c01, "b\t\t%b"},
+ {0x30000000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30100000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30200000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30300000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30400000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30800000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30900000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30a00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30b00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30c00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30d00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30e00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x31000000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x31100000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x31800000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x31a00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x31b00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x31c00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x31d00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x31e00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x31f00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x38000000, 0x3ff003ff, "mad\t\t%15-19r, %10-14r"},
+ {0x38000020, 0x3ff003ff, "madu\t\t%15-19r, %10-14r"},
+ {0x38000080, 0x3ff003ff, "mad.f\t\t%15-19r, %10-14r"},
+ {0x38000001, 0x3ff003ff, "msb\t\t%15-19r, %10-14r"},
+ {0x38000021, 0x3ff003ff, "msbu\t\t%15-19r, %10-14r"},
+ {0x38000081, 0x3ff003ff, "msb.f\t\t%15-19r, %10-14r"},
+ {0x38000102, 0x3ff003ff, "mazl\t\t%15-19r, %10-14r"},
+ {0x38000182, 0x3ff003ff, "mazl.f\t\t%15-19r, %10-14r"},
+ {0x38000002, 0x3ff003ff, "madl\t\t%15-19r, %10-14r"},
+ {0x380000c2, 0x3ff003ff, "madl.fs\t\t%15-19r, %10-14r"},
+ {0x38000303, 0x3ff003ff, "mazh\t\t%15-19r, %10-14r"},
+ {0x38000383, 0x3ff003ff, "mazh.f\t\t%15-19r, %10-14r"},
+ {0x38000203, 0x3ff003ff, "madh\t\t%15-19r, %10-14r"},
+ {0x380002c3, 0x3ff003ff, "madh.fs\t\t%15-19r, %10-14r"},
+ {0x38000007, 0x3e0003ff, "max\t\t%20-24r, %15-19r, %10-14r"},
+
+ {0x00000064, 0x3e00007e, "mbitclr\t\t[%15-19r, %m], %10-14d"},
+ {0x0000006c, 0x3e00007e, "mbitset\t\t[%15-19r, %m], %10-14d"},
+
+ {0x38000006, 0x3e0003ff, "min\t\t%20-24r, %15-19r, %10-14r"},
+ {0x38000104, 0x3ff003ff, "mszl\t\t%15-19r, %10-14r"},
+ {0x38000184, 0x3ff003ff, "mszl.f\t\t%15-19r, %10-14r"},
+ {0x38000004, 0x3ff003ff, "msbl\t\t%15-19r, %10-14r"},
+ {0x380000c4, 0x3ff003ff, "msbl.fs\t\t%15-19r, %10-14r"},
+ {0x38000305, 0x3ff003ff, "mszh\t\t%15-19r, %10-14r"},
+ {0x38000385, 0x3ff003ff, "mszh.f\t\t%15-19r, %10-14r"},
+ {0x38000205, 0x3ff003ff, "msbh\t\t%15-19r, %10-14r"},
+ {0x380002c5, 0x3ff003ff, "msbh.fs\t\t%15-19r, %10-14r"},
+ {0x3800004e, 0x3e0003ff, "sll.s\t\t%20-24r, %15-19r, %10-14r"},
+ {0x38000049, 0x3e0003ff, "sub.s\t\t%20-24r, %15-19r, %10-14r"},
+ {0x0000001c, 0x3e007fff, "clz\t\t%20-24r, %15-19r"},
+ {0x38000000, 0x3e000000, "ceinst\t\t%20-24d, %15-19r, %10-14r, %5-9d, %0-4d"},
+ {0x00000019, 0x3ff003ff, "cmpteq.c\t\t%15-19r, %10-14r"},
+ {0x00100019, 0x3ff003ff, "cmptmi.c\t\t%15-19r, %10-14r"},
+ {0x00300019, 0x3ff003ff, "cmp.c\t\t%15-19r, %10-14r"},
+ {0x0000001b, 0x3ff07fff, "cmpzteq.c\t%15-19r"},
+ {0x0010001b, 0x3ff07fff, "cmpztmi.c\t%15-19r"},
+ {0x0030001b, 0x3ff07fff, "cmpz.c\t\t%15-19r"},
+ {0x02040001, 0x3e0e0001, "cmpi.c\t\t%20-24r, %1-16i"},
+ {0x00004400, 0x00007c00, "cmp!\t\t%5-9r, %0-4r"},
+ {0x00006000, 0x00007c00, "cmpi!\t\t%5-9r, %0-4i"},
+ {0x0c00000c, 0x3e00001f, "cop1\t\tc%20-24r, c%15-19r, c%10-14r, %5-9d"},
+ {0x0c000014, 0x3e00001f, "cop2\t\tc%20-24r, c%15-19r, c%10-14r, %5-9d"},
+ {0x0c00001c, 0x3e00001f, "cop3\t\tc%20-24r, c%15-19r, c%10-14r, %5-9d"},
+ {0x00000044, 0x3e0003ff, "div\t\t%15-19r, %10-14r"},
+ {0x00000144, 0x3e0003ff, "divr.q\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000244, 0x3e0003ff, "divr.r\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000344, 0x3e0003ff, "divr\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000046, 0x3e0003ff, "divu\t\t%15-19r, %10-14r"},
+ {0x00000146, 0x3e0003ff, "divur.q\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000246, 0x3e0003ff, "divur.r\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000346, 0x3e0003ff, "divur\t\t%20-24r,%15-19r, %10-14r"},
+ {0x0c0000a4, 0x3e0003ff, "drte"},
+ {0x00e0, 0xffe1, "disint!"},
+ {0x00e1, 0xffe1, "enint!"},
+ {0x00000058, 0x3e0003ff, "extsb\t\t%20-24r, %15-19r"},
+ {0x00000059, 0x3e0003ff, "extsb.c\t\t%20-24r, %15-19r"},
+ {0x0000005a, 0x3e0003ff, "extsh\t\t%20-24r, %15-19r"},
+ {0x0000005b, 0x3e0003ff, "extsh.c\t\t%20-24r, %15-19r"},
+ {0x0000005c, 0x3e0003ff, "extzb\t\t%20-24r, %15-19r"},
+ {0x0000005d, 0x3e0003ff, "extzb.c\t\t%20-24r, %15-19r"},
+ {0x0000005e, 0x3e0003ff, "extzh\t\t%20-24r, %15-19r"},
+ {0x0000005f, 0x3e0003ff, "extzh.c\t\t%20-24r, %15-19r"},
+ {0x04000001, 0x3e000001, "jl\t\t%j"},
+ {0x04000000, 0x3e000001, "j\t\t%j"},
+ {0x26000000, 0x3e000000, "lb\t\t%20-24r, [%15-19r, %0-14i]"},
+ {0x2c000000, 0x3e000000, "lbu\t\t%20-24r, [%15-19r, %0-14i]"},
+ {0x06000003, 0x3e000007, "lb\t\t%20-24r, [%15-19r, %3-14i]+"},
+ {0x06000006, 0x3e000007, "lbu\t\t%20-24r, [%15-19r, %3-14i]+"},
+ {0x0e000003, 0x3e000007, "lb\t\t%20-24r, [%15-19r]+, %3-14i"},
+ {0x0e000006, 0x3e000007, "lbu\t\t%20-24r, [%15-19r]+, %3-14i"},
+ {0x00000060, 0x3e0003ff, "lcb\t\t[%15-19r]+"},
+ {0x00000062, 0x3e0003ff, "lcw\t\t%20-24r, [%15-19r]+"},
+ {0x00000066, 0x3e0003ff, "lce\t\t%20-24r, [%15-19r]+"},
+ {0x0c00000a, 0x3e00001f, "ldc1\t\tc%15-19r, [%20-24r, %5-14i]"},
+ {0x0c000012, 0x3e00001f, "ldc2\t\tc%15-19r, [%20-24r, %5-14i]"},
+ {0x0c00001a, 0x3e00001f, "ldc3\t\tc%15-19r, [%20-24r, %5-14i]"},
+ {0x000000000001LL, 0x1c000000001fLL, "ldi48\t\t%37-41r, %5-36i"},
+ {0x22000000, 0x3e000000, "lh\t\t%20-24r, [%15-19r, %0-14i]"},
+ {0x24000000, 0x3e000000, "lhu\t\t%20-24r, [%15-19r, %0-14i]"},
+ {0x06000001, 0x3e000007, "lh\t\t%20-24r, [%15-19r, %3-14i]+"},
+ {0x06000002, 0x3e000007, "lhu\t\t%20-24r, [%15-19r, %3-14i]+"},
+ {0x0e000001, 0x3e000007, "lh\t\t%20-24r, [%15-19r]+, %3-14i"},
+ {0x0e000002, 0x3e000007, "lhu\t\t%20-24r, [%15-19r]+, %3-14i"},
+ {0x020c0000, 0x3e0e0000, "ldi\t\t%20-24r, 0x%1-16x(%1-16i)"},
+ {0x0a0c0000, 0x3e0e0000, "ldis\t\t%20-24r, 0x%1-16x(%1-16i)"},
+ {0x00006400, 0x00007c00, "ldiu!\t\t%5-9r, %0-4d"},
+ {0x00000032, 0x3e0003ff, "ltbw\t\t%20-24r, [%15-19r, %10-14r]"},
+ {0x00000132, 0x3e0003ff, "ltbh\t\t%20-24r, [%15-19r, %10-14r]"},
+ {0x00000332, 0x3e0003ff, "ltbb\t\t%20-24r, [%15-19r, %10-14r]"},
+ {0x0000000c, 0x3e0003ff, "alw\t\t%20-24r, [%15-19r]"},
+ {0x20000000, 0x3e000000, "lw\t\t%20-24r, [%15-19r, %0-14i]"},
+ {0x06000000, 0x3e000007, "lw\t\t%20-24r, [%15-19r, %3-14i]+"},
+ {0x0e000000, 0x3e000007, "lw\t\t%20-24r, [%15-19r]+, %3-14i"},
+ {0x00001000, 0x00007000, "lw!\t\t%8-11r, [%5-7r,%0-4d2]"},
+ {0x000000000002LL, 0x1c000000001fLL, "lw48\t\t%37-41r,[0x%7-36w]"},
+ {0x00007a00, 0x00007f00, "madl.fs!\t\t%4-7r, %0-3r"},
+ {0x00007500, 0x00007f00, "madu!\t\t%4-7r, %0-3r"},
+ {0x00007400, 0x00007f00, "mad.f!\t\t%4-7r, %0-3r"},
+ {0x00007900, 0x00007f00, "mazh.f!\t\t%4-7r, %0-3r"},
+ {0x00007800, 0x00007f00, "mazl.f!\t\t%4-7r, %0-3r"},
+ {0x00000448, 0x3e007fff, "mfcel\t\t%20-24r"},
+ {0x00007100, 0x00007ff0, "mfcel!\t\t%0-3r"},
+ {0x00000848, 0x3e007fff, "mfceh\t\t%20-24r"},
+ {0x00007110, 0x00007ff0, "mfceh!\t\t%0-3r"},
+ {0x00000c48, 0x3e007fff, "mfcehl\t\t%20-24r, %15-19r"},
+ {0x00000048, 0x3e0003ff, "mfce\t\t%20-24r, er%10-14d"},
+ {0x00000050, 0x3e0003ff, "mfsr\t\t%20-24r, sr%10-14d"},
+ {0x0c000001, 0x3e00001f, "mfcr\t\t%20-24r, c%15-19r"},
+ {0x0c000009, 0x3e00001f, "mfc1\t\t%20-24r, c%15-19r"},
+ {0x0c000011, 0x3e00001f, "mfc2\t\t%20-24r, c%15-19r"},
+ {0x0c000019, 0x3e00001f, "mfc3\t\t%20-24r, c%15-19r"},
+ {0x0c00000f, 0x3e00001f, "mfcc1\t\t%20-24r, c%15-19r"},
+ {0x0c000017, 0x3e00001f, "mfcc2\t\t%20-24r, c%15-19r"},
+ {0x0c00001f, 0x3e00001f, "mfcc3\t\t%20-24r, c%15-19r"},
+ /* confilct: push! mhfl!. */
+ {0x00000040, 0x00007fe0, "pop!\t\t%0-4r"},
+ {0x00000060, 0x00007fe0, "push!\t\t%0-4r"},
+ {0x00006800, 0x00007c00, "rpop!\t\t%5-9r, %0-4d"},
+ {0x00006c00, 0x00007c00, "rpush!\t\t%5-9r, %0-4d"},
+ {0x00007600, 0x00007f00, "msb.f!\t\t%4-7r, %0-3r"},
+ {0x00007f00, 0x00007f00, "msbh.fs!\t\t%4-7r, %0-3r"},
+ {0x00007e00, 0x00007f00, "msbl.fs!\t\t%4-7r, %0-3r"},
+ {0x00007700, 0x00007f00, "msbu!\t\t%4-7r, %0-3r"},
+ {0x00007d00, 0x00007f00, "mszh.f!\t\t%4-7r, %0-3r"},
+ {0x00007c00, 0x00007f00, "mszl.f!\t\t%4-7r, %0-3r"},
+ {0x0000044a, 0x3e007fff, "mtcel\t\t%20-24r"},
+ {0x00007000, 0x00007ff0, "mtcel!\t\t%0-3r"},
+ {0x0000084a, 0x3e007fff, "mtceh\t\t%20-24r"},
+ {0x00007010, 0x00007ff0, "mtceh!\t\t%0-3r"},
+ {0x00000c4a, 0x3e007fff, "mtcehl\t\t%20-24r, %15-19r"},
+ {0x0000004a, 0x3e0003ff, "mtce\t\t%20-24r, er%10-14d"},
+ {0x00000052, 0x3e0003ff, "mtsr\t\t%15-19r, sr%10-14d"},
+ {0x0c000000, 0x3e00001f, "mtcr\t\t%20-24r, c%15-19r"},
+ {0x0c000008, 0x3e00001f, "mtc1\t\t%20-24r, c%15-19r"},
+ {0x0c000010, 0x3e00001f, "mtc2\t\t%20-24r, c%15-19r"},
+ {0x0c000018, 0x3e00001f, "mtc3\t\t%20-24r, c%15-19r"},
+ {0x0c00000e, 0x3e00001f, "mtcc1\t\t%20-24r, c%15-19r"},
+ {0x0c000016, 0x3e00001f, "mtcc2\t\t%20-24r, c%15-19r"},
+ {0x0c00001e, 0x3e00001f, "mtcc3\t\t%20-24r, c%15-19r"},
+ {0x00000040, 0x3e0003ff, "mul\t\t%15-19r, %10-14r"},
+ {0x00000140, 0x3e0003ff, "mulr.l\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000240, 0x3e0003ff, "mulr.h\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000340, 0x3e0003ff, "mulr\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000141, 0x3e0003ff, "mulr.lf\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000241, 0x3e0003ff, "mulr.hf\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000341, 0x3e0003ff, "mulr.f\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000040, 0x3e0003ff, "maz\t\t%15-19r, %10-14r"},
+ {0x00000041, 0x3e0003ff, "mul.f\t\t%15-19r, %10-14r"},
+ {0x00000041, 0x3e0003ff, "maz.f\t\t%15-19r, %10-14r"},
+ {0x00007200, 0x00007f00, "mul.f!\t\t%4-7r, %0-3r"},
+ {0x00000042, 0x3e0003ff, "mulu\t\t%15-19r, %10-14r"},
+ {0x00000142, 0x3e0003ff, "mulur.l\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000242, 0x3e0003ff, "mulur.h\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000342, 0x3e0003ff, "mulur\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000042, 0x3e0003ff, "mazu\t\t%15-19r, %10-14r"},
+ {0x00007300, 0x00007f00, "mulu!\t\t%4-7r, %0-3r"},
+ {0x00000056, 0x3e007fff, "mvcs\t\t%20-24r, %15-19r"},
+ {0x00000456, 0x3e007fff, "mvcc\t\t%20-24r, %15-19r"},
+ {0x00000856, 0x3e007fff, "mvgtu\t\t%20-24r, %15-19r"},
+ {0x00000c56, 0x3e007fff, "mvleu\t\t%20-24r, %15-19r"},
+ {0x00001056, 0x3e007fff, "mveq\t\t%20-24r, %15-19r"},
+ {0x00001456, 0x3e007fff, "mvne\t\t%20-24r, %15-19r"},
+ {0x00001856, 0x3e007fff, "mvgt\t\t%20-24r, %15-19r"},
+ {0x00001c56, 0x3e007fff, "mvle\t\t%20-24r, %15-19r"},
+ {0x00002056, 0x3e007fff, "mvge\t\t%20-24r, %15-19r"},
+ {0x00002456, 0x3e007fff, "mvlt\t\t%20-24r, %15-19r"},
+ {0x00002856, 0x3e007fff, "mvmi\t\t%20-24r, %15-19r"},
+ {0x00002c56, 0x3e007fff, "mvpl\t\t%20-24r, %15-19r"},
+ {0x00003056, 0x3e007fff, "mvvs\t\t%20-24r, %15-19r"},
+ {0x00003456, 0x3e007fff, "mvvc\t\t%20-24r, %15-19r"},
+ {0x00003c56, 0x3e007fff, "mv\t\t%20-24r, %15-19r"},
+ {0x00004000, 0x00007c00, "mv!\t\t%5-9r, %0-4r"},
+ {0x0000001e, 0x3e0003ff, "neg\t\t%20-24r, %10-14r"},
+ {0x0000001f, 0x3e0003ff, "neg.c\t\t%20-24r, %10-14r"},
+ {0x00000000, 0x3e0003ff, "nop"},
+ {0x00000024, 0x3e0003ff, "not\t\t%20-24r, %15-19r"},
+ {0x00000025, 0x3e0003ff, "not.c\t\t%20-24r, %15-19r"},
+ {0x00000000, 0x00007fff, "nop!"},
+ {0x00000022, 0x3e0003ff, "or\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000023, 0x3e0003ff, "or.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x020a0000, 0x3e0e0001, "ori\t\t%20-24r, 0x%1-16x"},
+ {0x020a0001, 0x3e0e0001, "ori.c\t\t%20-24r, 0x%1-16x"},
+ {0x0a0a0000, 0x3e0e0001, "oris\t\t%20-24r, 0x%1-16x"},
+ {0x0a0a0001, 0x3e0e0001, "oris.c\t\t%20-24r, 0x%1-16x"},
+ {0x1a000000, 0x3e000001, "orri\t\t%20-24r, %15-19r, 0x%1-14x"},
+ {0x1a000001, 0x3e000001, "orri.c\t\t%20-24r, %15-19r, 0x%1-14x"},
+ {0x00004a00, 0x00007f00, "or!\t\t%4-7r, %0-3r"},
+ {0x040000000002LL, 0x1c0000000003LL, "orri48\t\t%38-41r,%34-37r, 0x%2-33x"},
+ {0x040000000003LL, 0x1c0000000003LL, "orri48.c\t\t%38-41r,%34-37r, 0x%2-33x"},
+ {0x0000000a, 0x3e0003ff, "pflush"},
+ {0x00000038, 0x3e0003ff, "ror\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000039, 0x3e0003ff, "ror.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x0000003b, 0x3e0003ff, "rorc.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x0000003c, 0x3e0003ff, "rol\t\t%20-24r, %15-19r, %10-14r"},
+ {0x0000003d, 0x3e0003ff, "rol.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x0000003f, 0x3e0003ff, "rolc.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000078, 0x3e0003ff, "rori\t\t%20-24r, %15-19r, %10-14d"},
+ {0x00000079, 0x3e0003ff, "rori.c\t\t%20-24r, %15-19r, %10-14d"},
+ {0x0000007b, 0x3e0003ff, "roric.c\t\t%20-24r, %15-19r, %10-14d"},
+ {0x0000007c, 0x3e0003ff, "roli\t\t%20-24r, %15-19r, %10-14d"},
+ {0x0000007d, 0x3e0003ff, "roli.c\t\t%20-24r, %15-19r, %10-14d"},
+ {0x0000007f, 0x3e0003ff, "rolic.c\t\t%20-24r, %15-19r, %10-14d"},
+ {0x0c000084, 0x3e0003ff, "rte"},
+ {0x2e000000, 0x3e000000, "sb\t\t%20-24r, [%15-19r, %0-14i]"},
+ {0x06000007, 0x3e000007, "sb\t\t%20-24r, [%15-19r, %3-14i]+"},
+ {0x0e000007, 0x3e000007, "sb\t\t%20-24r, [%15-19r]+, %3-14i"},
+ {0x0000000e, 0x3e0003ff, "asw\t\t%20-24r, [%15-19r]"},
+ {0x00000068, 0x3e0003ff, "scb\t\t%20-24r, [%15-19r]+"},
+ {0x0000006a, 0x3e0003ff, "scw\t\t%20-24r, [%15-19r]+"},
+ {0x0000006e, 0x3e0003ff, "sce\t\t[%15-19r]+"},
+ {0x00000006, 0x3e0003ff, "sdbbp\t\t%15-19d"},
+ {0x00000020, 0x00007fe0, "sdbbp!\t\t%0-4d"},
+ {0x000000000000LL, 0x1c000000001fLL, "sdbbp48\t\t%5-9d"},
+ {0x2a000000, 0x3e000000, "sh\t\t%20-24r, [%15-19r, %0-14i]"},
+ {0x06000005, 0x3e000007, "sh\t\t%20-24r, [%15-19r, %3-14i]+"},
+ {0x0e000005, 0x3e000007, "sh\t\t%20-24r, [%15-19r]+, %3-14i"},
+ {0x0c0000c4, 0x3e0003ff, "sleep"},
+ {0x0c0000e4, 0x3e0003ff, "rti"},
+ {0x00000030, 0x3e0003ff, "sll\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000031, 0x3e0003ff, "sll.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000070, 0x3e0003ff, "slli\t\t%20-24r, %15-19r, %10-14d"},
+ {0x00000071, 0x3e0003ff, "slli.c\t\t%20-24r, %15-19r, %10-14d"},
+ {0x00005800, 0x00007e00, "slli!\t\t%5-8r, %0-4d"},
+ {0x00000034, 0x3e0003ff, "srl\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000035, 0x3e0003ff, "srl.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000036, 0x3e0003ff, "sra\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000037, 0x3e0003ff, "sra.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000074, 0x3e0003ff, "srli\t\t%20-24r, %15-19r, %10-14d"},
+ {0x00000075, 0x3e0003ff, "srli.c\t\t%20-24r, %15-19r, %10-14d"},
+ {0x00000076, 0x3e0003ff, "srai\t\t%20-24r, %15-19r, %10-14d"},
+ {0x00000077, 0x3e0003ff, "srai.c\t\t%20-24r, %15-19r, %10-14d"},
+ {0x00005a00, 0x00007e00, "srli!\t\t%5-8r, %0-4d"},
+ {0x0c00000b, 0x3e00001f, "stc1\t\tc%15-19r, [%20-24r, %5-14i]"},
+ {0x0c000013, 0x3e00001f, "stc2\t\tc%15-19r, [%20-24r, %5-14i]"},
+ {0x0c00001b, 0x3e00001f, "stc3\t\tc%15-19r, [%20-24r, %5-14i]"},
+ {0x00000014, 0x3e0003ff, "sub\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000015, 0x3e0003ff, "sub.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000016, 0x3e0003ff, "subc\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000017, 0x3e0003ff, "subc.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00004900, 0x00007f00, "sub!\t\t%4-7r, %0-3r"},
+ {0x28000000, 0x3e000000, "sw\t\t%20-24r, [%15-19r, %0-14i]"},
+ {0x06000004, 0x3e000007, "sw\t\t%20-24r, [%15-19r, %3-14i]+"},
+ {0x0e000004, 0x3e000007, "sw\t\t%20-24r, [%15-19r]+, %3-14i"},
+ {0x00002000, 0x00007000, "sw!\t\t%8-11r, [%5-7r,%0-4d2]"},
+ {0x000000000003LL, 0x1c000000001fLL, "sw48\t\t%37-41r, [0x%7-36w]"},
+ {0x00000002, 0x3e0003ff, "syscall\t\t%10-24d"},
+ {0x00000054, 0x3e007fff, "tcs"},
+ {0x00000454, 0x3e007fff, "tcc"},
+ {0x00003854, 0x3e007fff, "tcnz"},
+ {0x00001054, 0x3e007fff, "teq"},
+ {0x00000854, 0x3e007fff, "tgtu"},
+ {0x00001854, 0x3e007fff, "tgt"},
+ {0x00002054, 0x3e007fff, "tge"},
+ {0x00000c54, 0x3e007fff, "tleu"},
+ {0x00001c54, 0x3e007fff, "tle"},
+ {0x00002454, 0x3e007fff, "tlt"},
+ {0x0c000004, 0x3e0003ff, "stlb"},
+ {0x0c000024, 0x3e0003ff, "mftlb"},
+ {0x0c000044, 0x3e0003ff, "mtptlb"},
+ {0x0c000064, 0x3e0003ff, "mtrtlb"},
+ {0x00002854, 0x3e007fff, "tmi"},
+ {0x00001454, 0x3e007fff, "tne"},
+ {0x00002c54, 0x3e007fff, "tpl"},
+ {0x00000004, 0x3e007fff, "trapcs\t\t%15-19d"},
+ {0x00000404, 0x3e007fff, "trapcc\t\t%15-19d"},
+ {0x00000804, 0x3e007fff, "trapgtu\t\t%15-19d"},
+ {0x00000c04, 0x3e007fff, "trapleu\t\t%15-19d"},
+ {0x00001004, 0x3e007fff, "trapeq\t\t%15-19d"},
+ {0x00001404, 0x3e007fff, "trapne\t\t%15-19d"},
+ {0x00001804, 0x3e007fff, "trapgt\t\t%15-19d"},
+ {0x00001c04, 0x3e007fff, "traple\t\t%15-19d"},
+ {0x00002004, 0x3e007fff, "trapge\t\t%15-19d"},
+ {0x00002404, 0x3e007fff, "traplt\t\t%15-19d"},
+ {0x00002804, 0x3e007fff, "trapmi\t\t%15-19d"},
+ {0x00002c04, 0x3e007fff, "trappl\t\t%15-19d"},
+ {0x00003004, 0x3e007fff, "trapvs\t\t%15-19d"},
+ {0x00003404, 0x3e007fff, "trapvc\t\t%15-19d"},
+ {0x00003c04, 0x3e007fff, "trap\t\t%15-19d"},
+ {0x00003c54, 0x3e007fff, "tset"},
+ {0x00003054, 0x3e007fff, "tvs"},
+ {0x00003454, 0x3e007fff, "tvc"},
+ {0x00000026, 0x3e0003ff, "xor\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000027, 0x3e0003ff, "xor.c\t\t%20-24r, %15-19r, %10-14r"},
+};
+/*****************************************************************************/
+
#ifndef streq
-#define streq(a,b) (strcmp ((a), (b)) == 0)
+#define streq(a,b) (strcmp ((a), (b)) == 0)
#endif
#ifndef strneq
-#define strneq(a,b,n) (strncmp ((a), (b), (n)) == 0)
+#define strneq(a,b,n) (strncmp ((a), (b), (n)) == 0)
#endif
#ifndef NUM_ELEM
@@ -68,16 +512,188 @@ static unsigned int regname_selected = 0;
/* Print one instruction from PC on INFO->STREAM.
Return the size of the instruction. */
static int
+print_insn_score48 (struct disassemble_info *info, bfd_vma given)
+{
+ struct score_opcode *insn;
+ void *stream = info->stream;
+ fprintf_ftype func = info->fprintf_func;
+
+ for (insn = score_opcodes; insn->assembler; insn++)
+ {
+ /* using insn->mask &0xff00000000 to distinguish 48/32 bit */
+ if (((insn->mask & 0xff0000000000LL)!=0) && (given & insn->mask) == insn->value)
+ {
+ info->bytes_per_chunk = 2;
+ info->bytes_per_line =6;
+
+ char *c;
+
+ for (c = insn->assembler; *c; c++)
+ {
+ if (*c == '%')
+ {
+ switch (*++c)
+ {
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ {
+ int bitstart = *c++ - '0';
+ int bitend = 0;
+
+ while (*c >= '0' && *c <= '9')
+ bitstart = (bitstart * 10) + *c++ - '0';
+
+ switch (*c)
+ {
+ case '-':
+ c++;
+ while (*c >= '0' && *c <= '9')
+ bitend = (bitend * 10) + *c++ - '0';
+
+ if (!bitend)
+ abort ();
+
+ switch (*c)
+ {
+ case 'r':
+ {
+ long reg;
+
+ reg = given >> bitstart;
+ reg &= (2 << (bitend - bitstart)) - 1;
+
+ func (stream, "%s", score_regnames[reg]);
+ }
+ break;
+ case 'd':
+ {
+ long reg;
+
+ reg = given >> bitstart;
+ reg &= (2 << (bitend - bitstart)) - 1;
+
+ func (stream, "%ld", reg);
+ }
+ break;
+ case 'i':
+ {
+ long reg;
+ reg = given >> bitstart;
+ reg &= (2 << (bitend - bitstart)) - 1;
+ reg = ((reg ^ (1 << (bitend - bitstart))) -
+ (1 << (bitend - bitstart)));
+ /* Fix bug: s3_testsuite 64-bit.
+ Remove high 32 bits. */
+ reg = (int) reg;
+
+ if (((given & insn->mask) == 0x0c00000a) /* ldc1 */
+ || ((given & insn->mask) == 0x0c000012) /* ldc2 */
+ || ((given & insn->mask) == 0x0c00001c) /* ldc3 */
+ || ((given & insn->mask) == 0x0c00000b) /* stc1 */
+ || ((given & insn->mask) == 0x0c000013) /* stc2 */
+ || ((given & insn->mask) == 0x0c00001b)) /* stc3 */
+ reg <<= 2;
+
+ func (stream, "%ld", reg);
+ }
+ break;
+ case 'x':
+ {
+ long reg;
+
+ reg = given >> bitstart;
+ reg &= (2 << (bitend - bitstart)) - 1;
+ /* Fix bug: s3_testsuite 64-bit.
+ Remove high 32 bits. */
+ reg = (int) reg;
+
+ func (stream, "%lx", reg);
+ }
+ break;
+ case 'w':
+ {
+ long reg;
+ reg = given >> bitstart;
+ reg &= (2 << (bitend - bitstart)) - 1;
+ reg <<=2;
+ func (stream, "%lx", reg);
+ }
+ break;
+
+ default:
+ abort ();
+ }
+ break;
+
+ case '`':
+ c++;
+ if ((given & (1 << bitstart)) == 0)
+ func (stream, "%c", *c);
+ break;
+ case '\'':
+ c++;
+ if ((given & (1 << bitstart)) != 0)
+ func (stream, "%c", *c);
+ break;
+ default:
+ abort ();
+ }
+ break;
+
+ default:
+ abort ();
+ }
+ }
+ }
+ else
+ func (stream, "%c", *c);
+ }
+ return 6;
+ }
+ }
+
+#if (SCORE_SIMULATOR_ACTIVE)
+ func (stream, _("<illegal instruction>"));
+ return 6;
+#endif
+
+ abort ();
+}
+
+/* Print one instruction from PC on INFO->STREAM.
+ Return the size of the instruction. */
+static int
print_insn_score32 (bfd_vma pc, struct disassemble_info *info, long given)
{
struct score_opcode *insn;
void *stream = info->stream;
+ int rb_equal_zero=1;
fprintf_ftype func = info->fprintf_func;
for (insn = score_opcodes; insn->assembler; insn++)
{
- if ((insn->mask & 0xffff0000) && (given & insn->mask) == insn->value)
+ if (((insn->mask & 0xff0000000000LL)==0)&&(insn->mask & 0xffff0000) && (given & insn->mask) == insn->value)
{
+ /* check for bcmpeq / bcmpeqz / bcmpne / bcmpnez */
+ /* given &0x7c00 is for to test if rb is zero ,
+ rb_equal_zero =1 : index to bcmpeqz
+ rb_equal_zero =0 , index to bcmpeq
+ this checking rule only for branch compare ( insn->mask ==0x3e00007e*/
+ if (((given & 0x7c00) !=0)&&(rb_equal_zero ==1)&&(insn->mask == 0x3e00007e)
+ && (insn->value == 0x0000004c || insn->value == 0x0000004e))
+ {
+ rb_equal_zero =0;
+ continue;
+ }
+
char *c;
for (c = insn->assembler; *c; c++)
@@ -106,6 +722,41 @@ print_insn_score32 (bfd_vma pc, struct disassemble_info *info, long given)
(*info->print_address_func) (target, info);
}
break;
+ case 'z':
+ {
+#define SEXT10(x) ((((x) & 0x3ff) ^ (~ 0x1ff)) + 0x200)
+ if ((given & 0x7c00 ) == 0)
+ {
+ /* Sign-extend a 20-bit number. */
+ /* disp : [24 -20] , [9-7 ] , [0] */
+ int disp = (given&1)<<1 |((given>>7)&7)<<2 |((given>>20)&0x1f)<<5;
+ int target = (pc + SEXT10 (disp));
+ (*info->print_address_func) (target, info);
+ }
+ else
+ {
+ long reg;
+ int bitstart = 10;
+ int bitend = 14;
+ reg = given >> bitstart;
+ reg &= (2 << (bitend - bitstart)) - 1;
+ /* Sign-extend a 20-bit number. */
+ int disp = (given&1)<<1 |((given>>7)&7)<<2 |((given>>20)&0x1f)<<5;
+ int target = (pc + SEXT10 (disp));
+ func (stream, "%s ,", score_regnames[reg] );
+ (*info->print_address_func) (target, info);
+
+ }
+
+ }
+ break;
+ case 'm':
+ {
+ /* disp : [24 -20] , [9-7 ] , [0] */
+ int disp = (given&1)<<2 |((given>>7)&7)<<3 |((given>>20)&0x1f)<<6;
+ (*info->print_address_func) (disp, info);
+ }
+ break;
case '0':
case '1':
case '2':
@@ -189,6 +840,7 @@ print_insn_score32 (bfd_vma pc, struct disassemble_info *info, long given)
abort ();
}
break;
+
case '`':
c++;
if ((given & (1 << bitstart)) == 0)
@@ -224,18 +876,6 @@ print_insn_score32 (bfd_vma pc, struct disassemble_info *info, long given)
abort ();
}
-static void
-print_insn_parallel_sym (struct disassemble_info *info)
-{
- void *stream = info->stream;
- fprintf_ftype func = info->fprintf_func;
-
- /* 10: 0000 nop!
- 4 space + 1 colon + 1 space + 1 tab + 8 opcode + 2 space + 1 tab.
- FIXME: the space number is not accurate. */
- func (stream, "%s", " ||\n \t \t");
-}
-
/* Print one instruction from PC on INFO->STREAM.
Return the size of the instruction. */
static int
@@ -248,7 +888,7 @@ print_insn_score16 (bfd_vma pc, struct disassemble_info *info, long given)
given &= 0xffff;
for (insn = score_opcodes; insn->assembler; insn++)
{
- if (!(insn->mask & 0xffff0000) && (given & insn->mask) == insn->value)
+ if (((insn->mask & 0xff0000000000LL)==0) &&!(insn->mask & 0xffff0000) && (given & insn->mask) == insn->value)
{
char *c = insn->assembler;
@@ -277,9 +917,9 @@ print_insn_score16 (bfd_vma pc, struct disassemble_info *info, long given)
case 'b':
{
/* Sign-extend a 9-bit number. */
-#define SEXT9(x) ((((x) & 0x1ff) ^ (~ 0xff)) + 0x100)
- int disp = (given & 0xff) << 1;
- int target = (pc + SEXT9 (disp));
+#define SEXT10(x) ((((x) & 0x3ff) ^ (~ 0x1ff)) + 0x200)
+ int disp = (given & 0x1ff) << 1;
+ int target = (pc + SEXT10 (disp));
(*info->print_address_func) (target, info);
}
@@ -315,6 +955,16 @@ print_insn_score16 (bfd_vma pc, struct disassemble_info *info, long given)
abort ();
reg = given >> bitstart;
reg &= (2 << (bitend - bitstart)) - 1;
+
+ /* Check rpush rd, 0 and rpop! rd, 0.
+ If reg = 0, then set to 32. */
+ if (((given & 0x00007c00) == 0x00006c00
+ || (given & 0x00007c00) == 0x00006800)
+ && reg == 0)
+ {
+ reg = 32;
+ }
+
switch (*c)
{
case 'R':
@@ -349,8 +999,8 @@ print_insn_score16 (bfd_vma pc, struct disassemble_info *info, long given)
}
break;
case 'i':
- reg = ((reg ^ (1 << bitend)) - (1 << bitend));
- func (stream, "%ld", reg);
+ reg = ((reg ^ (1 << bitend)) - (1 << bitend));
+ func (stream, "%ld", reg);
break;
default:
abort ();
@@ -390,37 +1040,72 @@ print_insn_score16 (bfd_vma pc, struct disassemble_info *info, long given)
/* NOTE: There are no checks in these routines that
the relevant number of data bytes exist. */
static int
-print_insn (bfd_vma pc, struct disassemble_info *info, bfd_boolean little)
+s3_print_insn (bfd_vma pc, struct disassemble_info *info, bfd_boolean little)
{
- unsigned char b[4];
- long given;
- long ridparity;
- int status;
- bfd_boolean insn_pce_p = FALSE;
- bfd_boolean insn_16_p = FALSE;
+ unsigned char b[6];
+ bfd_vma given,given_h , given_l, given_16, given_32, given_48;
+ bfd_vma ridparity;
+ int status;
+ void *stream = info->stream;
+ fprintf_ftype func = info->fprintf_func;
info->display_endian = little ? BFD_ENDIAN_LITTLE : BFD_ENDIAN_BIG;
-
- if (pc & 0x2)
+ info->bytes_per_chunk = 2;
+ status = info->read_memory_func (pc, (bfd_byte *) & b[0], 4, info);
+ if (status != 0)
{
info->bytes_per_chunk = 2;
status = info->read_memory_func (pc, (bfd_byte *) b, 2, info);
b[3] = b[2] = 0;
- insn_16_p = TRUE;
+ if (status != 0)
+ {
+ info->memory_error_func (status, pc, info);
+ return -1;
+ }
+ }
+ if (little)
+ {
+ given = b[0] | (b[1] << 8);
}
else
{
- info->bytes_per_chunk = 4;
- status = info->read_memory_func (pc, (bfd_byte *) & b[0], 4, info);
- if (status != 0)
- {
- info->bytes_per_chunk = 2;
- status = info->read_memory_func (pc, (bfd_byte *) b, 2, info);
- b[3] = b[2] = 0;
- insn_16_p = TRUE;
- }
+ given = (b[0] << 8) | b[1];
}
+ /* Set given_16. */
+ given_16 = given;
+
+ /* judge if now is insn_16_p */
+ if ((given & 0x8000)==0)
+ return print_insn_score16 (pc, info, given);
+
+ else
+ {
+ if (little)
+ {
+ given = ((bfd_vma)b[2]) | ((bfd_vma)b[3] << 8) | ((bfd_vma)b[0] << 16) | ((bfd_vma)b[1] << 24);
+ }
+ else
+ {
+ given = ((bfd_vma)b[0] << 24) | ((bfd_vma)b[1] << 16) | ((bfd_vma)b[2] << 8) | ((bfd_vma)b[3]);
+ }
+
+ /* Set given_32. */
+ given_32 = given;
+
+ /* judge if now is insn_32 */
+ if ((given &0x80008000)==0x80000000)
+ {
+ /* Get rid of parity. */
+ ridparity = (given & 0x7FFF);
+ ridparity |= (given & 0x7FFF0000) >> 1;
+ given = ridparity;
+ return print_insn_score32 (pc, info, given);
+ }
+ }
+
+ /* the insn is 48 bit */
+ status = info->read_memory_func (pc, (bfd_byte *) & b[0], 6, info);
if (status != 0)
{
info->memory_error_func (status, pc, info);
@@ -429,76 +1114,83 @@ print_insn (bfd_vma pc, struct disassemble_info *info, bfd_boolean little)
if (little)
{
- given = (b[0]) | (b[1] << 8) | (b[2] << 16) | (b[3] << 24);
+ given = ((bfd_vma)b[4]) | ((bfd_vma)b[5] << 8) | ((bfd_vma)b[2] << 16) | ((bfd_vma)b[3] << 24)
+ | ((bfd_vma)b[0] << 32) | ((bfd_vma)b[1] << 40);
}
else
{
- given = (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | (b[3]);
+ given_l = ((bfd_vma)b[5]) | ((bfd_vma)b[4] << 8) | ((bfd_vma)b[3] << 16) | ((bfd_vma)b[2] << 24) ;
+ given_h = ((bfd_vma)b[1] )|((bfd_vma)b[0] <<8);
+ given = ((bfd_vma)given_h<<32) | (bfd_vma)given_l ;
+
}
- if ((given & 0x80008000) == 0x80008000)
- {
- insn_pce_p = FALSE;
- insn_16_p = FALSE;
- }
- else if ((given & 0x8000) == 0x8000)
- {
- insn_pce_p = TRUE;
- }
- else
- {
- insn_16_p = TRUE;
- }
+ /* Set given_48. */
+ given_48 = given;
- /* 16 bit instruction. */
- if (insn_16_p)
- {
- if (little)
- {
- given = b[0] | (b[1] << 8);
- }
- else
- {
- given = (b[0] << 8) | b[1];
- }
+ if ((given & 0x800080008000LL) == 0x800080000000LL)
+ {
+ /* Get rid of parity. */
+ ridparity = (given & 0x7FFF);
+ ridparity |= (given & 0x7FFF0000) >> 1;
+ ridparity |= (given & 0x7FFF00000000LL) >> 2;
+ given = ridparity;
+ status = print_insn_score48 (info, given);
+ return status;
+ }
- status = print_insn_score16 (pc, info, given);
- }
- /* pce instruction. */
- else if (insn_pce_p)
- {
- long other;
+ /* Check 0x800080008000, 0x80008000, 0x8000. */
- other = given & 0xFFFF;
- given = (given & 0xFFFF0000) >> 16;
+ if ((given_48 & 0x800080008000LL) != 0x800080000000LL)
+ {
+#if (SCORE_SIMULATOR_ACTIVE)
+ func (stream, _("<illegal instruction>"));
+ return 6;
+#endif
+ }
+ if (((given_32 & 0xffff00000000LL) == 0) && ((given_32 & 0x80008000) != 0x80000000))
+ {
+#if (SCORE_SIMULATOR_ACTIVE)
+ func (stream, _("<illegal instruction>"));
+ return 4;
+#endif
+ }
+ if (((given_16 & 0xffffffff0000LL) == 0) && ((given_16 & 0x8000) != 0))
+ {
+#if (SCORE_SIMULATOR_ACTIVE)
+ func (stream, _("<illegal instruction>"));
+ return 2;
+#endif
+ }
+ else
+ {
+ return 0;
+ }
+}
- status = print_insn_score16 (pc, info, given);
- print_insn_parallel_sym (info);
- status += print_insn_score16 (pc, info, other);
- /* disassemble_bytes() will output 4 byte per chunk for pce instructio. */
- info->bytes_per_chunk = 4;
- }
- /* 32 bit instruction. */
+static unsigned long
+score_get_arch (disassemble_info *info)
+{
+ if (info->arch == bfd_arch_score)
+ return info->mach;
else
- {
- /* Get rid of parity. */
- ridparity = (given & 0x7FFF);
- ridparity |= (given & 0x7FFF0000) >> 1;
- given = ridparity;
- status = print_insn_score32 (pc, info, given);
- }
-
- return status;
+ return 0;
}
int
print_insn_big_score (bfd_vma pc, struct disassemble_info *info)
{
- return print_insn (pc, info, FALSE);
+ if (score_get_arch (info) == bfd_mach_score3)
+ return s3_print_insn (pc, info, FALSE);
+ else
+ return s7_print_insn (pc, info, FALSE);
}
int
print_insn_little_score (bfd_vma pc, struct disassemble_info *info)
{
- return print_insn (pc, info, TRUE);
+ if (score_get_arch (info) == bfd_mach_score3)
+ return s3_print_insn (pc, info, TRUE);
+ else
+ return s7_print_insn (pc, info, TRUE);
}
diff --git a/opcodes/score-opc.h b/opcodes/score-opc.h
index 8c4e6c00b39..6cfc20f82af 100644
--- a/opcodes/score-opc.h
+++ b/opcodes/score-opc.h
@@ -19,9 +19,9 @@
struct score_opcode
{
- unsigned long value;
- unsigned long mask; /* Recognise instruction if (op & mask) == value. */
- char *assembler; /* Disassembly string. */
+ bfd_vma value;
+ bfd_vma mask; /* Recognise instruction if (op & mask) == value. */
+ char *assembler; /* Disassembly string. */
};
/* Note: There is a partial ordering in this table - it must be searched from
@@ -31,7 +31,7 @@ static struct score_opcode score_opcodes[] =
{
/* Score Instructions. */
{0x3800000a, 0x3e007fff, "abs\t\t%20-24r, %15-19r"},
- {0x3800004b, 0x3e007fff, "abs.s\t\t%20-24r, %15-19r"},
+ {0x3800004b, 0x3e007fff, "abs.s\t\t%20-24r, %15-19r"},
{0x00000010, 0x3e0003ff, "add\t\t%20-24r, %15-19r, %10-14r"},
{0x00000011, 0x3e0003ff, "add.c\t\t%20-24r, %15-19r, %10-14r"},
{0x38000048, 0x3e0003ff, "add.s\t\t%20-24r, %15-19r, %10-14r"},
@@ -43,139 +43,110 @@ static struct score_opcode score_opcodes[] =
{0x0a000001, 0x3e0e0001, "addis.c\t\t%20-24r, %1-16d(0x%1-16x)"},
{0x10000000, 0x3e000001, "addri\t\t%20-24r, %15-19r, %1-14i"},
{0x10000001, 0x3e000001, "addri.c\t\t%20-24r, %15-19r, %1-14i"},
- {0x00000009, 0x0000700f, "addc!\t\t%8-11r, %4-7r"},
- {0x00002000, 0x0000700f, "add!\t\t%8-11r, %4-7r"},
- {0x00006000, 0x00007087, "addei!\t\t%8-11r, %3-6d"},
+ {0x00004800, 0x00007f00, "add!\t\t%4-7r, %0-3r"},
+ {0x00005c00, 0x00007c00, "addi!\t\t%6-9r, %0-5i"},
{0x00000020, 0x3e0003ff, "and\t\t%20-24r, %15-19r, %10-14r"},
{0x00000021, 0x3e0003ff, "and.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x040000000000LL, 0x1c0000000003LL, "andri48\t\t%38-41r,%34-37r, 0x%2-33x"},
+ {0x040000000001LL, 0x1c0000000003LL, "andri48.c\t\t%38-41r,%34-37r, 0x%2-33x"},
{0x02080000, 0x3e0e0001, "andi\t\t%20-24r, 0x%1-16x"},
{0x02080001, 0x3e0e0001, "andi.c\t\t%20-24r, 0x%1-16x"},
{0x0a080000, 0x3e0e0001, "andis\t\t%20-24r, 0x%1-16x"},
{0x0a080001, 0x3e0e0001, "andis.c\t\t%20-24r, 0x%1-16x"},
{0x18000000, 0x3e000001, "andri\t\t%20-24r, %15-19r, 0x%1-14x"},
{0x18000001, 0x3e000001, "andri.c\t\t%20-24r, %15-19r,0x%1-14x"},
- {0x00002004, 0x0000700f, "and!\t\t%8-11r, %4-7r"},
- {0x08000000, 0x3e007c01, "bcs\t\t%b" },
- {0x08000400, 0x3e007c01, "bcc\t\t%b" },
- {0x08003800, 0x3e007c01, "bcnz\t\t%b" },
- {0x08000001, 0x3e007c01, "bcsl\t\t%b" },
- {0x08000401, 0x3e007c01, "bccl\t\t%b" },
- {0x08003801, 0x3e007c01, "bcnzl\t\t%b" },
- {0x00004000, 0x00007f00, "bcs!\t\t%b" },
- {0x00004100, 0x00007f00, "bcc!\t\t%b" },
- {0x00004e00, 0x00007f00, "bcnz!\t\t%b" },
- {0x08001000, 0x3e007c01, "beq\t\t%b" },
- {0x08001001, 0x3e007c01, "beql\t\t%b" },
- {0x00004400, 0x00007f00, "beq!\t\t%b" },
- {0x08000800, 0x3e007c01, "bgtu\t\t%b" },
- {0x08001800, 0x3e007c01, "bgt\t\t%b" },
- {0x08002000, 0x3e007c01, "bge\t\t%b" },
- {0x08000801, 0x3e007c01, "bgtul\t\t%b" },
- {0x08001801, 0x3e007c01, "bgtl\t\t%b" },
- {0x08002001, 0x3e007c01, "bgel\t\t%b" },
- {0x00004200, 0x00007f00, "bgtu!\t\t%b" },
- {0x00004600, 0x00007f00, "bgt!\t\t%b" },
- {0x00004800, 0x00007f00, "bge!\t\t%b" },
+ {0x00004b00, 0x00007f00, "and!\t\t%4-7r, %0-3r"},
+ {0x08000000, 0x3e007c01, "bcs\t\t%b"},
+ {0x08000400, 0x3e007c01, "bcc\t\t%b"},
+ {0x08003800, 0x3e007c01, "bcnz\t\t%b"},
+ {0x08000001, 0x3e007c01, "bcsl\t\t%b"},
+ {0x08000401, 0x3e007c01, "bccl\t\t%b"},
+ {0x08003801, 0x3e007c01, "bcnzl\t\t%b"},
+ {0x0000004c, 0x3e00007e, "bcmpeqz\t\t%15-19r, %z"},
+ {0x0000004c, 0x3e00007e, "bcmpeq\t\t%15-19r, %z"},
+ {0x0000004e, 0x3e00007e, "bcmpnez\t\t%15-19r, %z"},
+ {0x0000004e, 0x3e00007e, "bcmpne\t\t%15-19r, %z"},
+ {0x00003200, 0x00007e00, "bcnz!\t\t%b"},
+ {0x08001000, 0x3e007c01, "beq\t\t%b"},
+ {0x08001001, 0x3e007c01, "beql\t\t%b"},
+ {0x00003800, 0x00007e00, "beq!\t\t%b"},
+ {0x08000800, 0x3e007c01, "bgtu\t\t%b"},
+ {0x08001800, 0x3e007c01, "bgt\t\t%b"},
+ {0x08002000, 0x3e007c01, "bge\t\t%b"},
+ {0x08000801, 0x3e007c01, "bgtul\t\t%b"},
+ {0x08001801, 0x3e007c01, "bgtl\t\t%b"},
+ {0x08002001, 0x3e007c01, "bgel\t\t%b"},
+ {0x00003400, 0x00007e00, "bgtu!\t\t%b"},
+ {0x00003c00, 0x00007e00, "bgt!\t\t%b"},
{0x00000029, 0x3e0003ff, "bitclr.c\t%20-24r, %15-19r, 0x%10-14x"},
+ {0x00000028, 0x3e0003ff, "bitclr\t%20-24r, %15-19r, 0x%10-14x"},
{0x0000002b, 0x3e0003ff, "bitset.c\t%20-24r, %15-19r, 0x%10-14x"},
+ {0x0000002a, 0x3e0003ff, "bitset\t%20-24r, %15-19r, 0x%10-14x"},
{0x0000002d, 0x3e0003ff, "bittst.c\t%15-19r, 0x%10-14x"},
{0x0000002f, 0x3e0003ff, "bittgl.c\t%20-24r, %15-19r, 0x%10-14x"},
- {0x00006004, 0x00007007, "bitclr!\t\t%8-11r, 0x%3-7x"},
+ {0x0000002e, 0x3e0003ff, "bittgl\t%20-24r, %15-19r, 0x%10-14x"},
+ {0x00005000, 0x00007e00, "bitclr!\t\t%5-8r, 0x%0-4x"},
{0x3800000c, 0x3e0003ff, "bitrev\t\t%20-24r, %15-19r,%10-14r"},
- {0x00006005, 0x00007007, "bitset!\t\t%8-11r, 0x%3-7x"},
- {0x00006006, 0x00007007, "bittst!\t\t%8-11r, 0x%3-7x"},
- {0x00006007, 0x00007007, "bittgl!\t\t%8-11r, 0x%3-7x"},
- {0x08000c00, 0x3e007c01, "bleu\t\t%b" },
- {0x08001c00, 0x3e007c01, "ble\t\t%b" },
- {0x08002400, 0x3e007c01, "blt\t\t%b" },
- {0x08000c01, 0x3e007c01, "bleul\t\t%b" },
- {0x08001c01, 0x3e007c01, "blel\t\t%b" },
- {0x08002401, 0x3e007c01, "bltl\t\t%b" },
- {0x08003c01, 0x3e007c01, "bl\t\t%b" },
- {0x00004300, 0x00007f00, "bleu!\t\t%b" },
- {0x00004700, 0x00007f00, "ble!\t\t%b" },
- {0x00004900, 0x00007f00, "blt!\t\t%b" },
- {0x08002800, 0x3e007c01, "bmi\t\t%b" },
- {0x08002801, 0x3e007c01, "bmil\t\t%b" },
- {0x00004a00, 0x00007f00, "bmi!\t\t%b" },
- {0x08001400, 0x3e007c01, "bne\t\t%b" },
- {0x08001401, 0x3e007c01, "bnel\t\t%b" },
- {0x00004500, 0x00007f00, "bne!\t\t%b" },
- {0x08002c00, 0x3e007c01, "bpl\t\t%b" },
- {0x08002c01, 0x3e007c01, "bpll\t\t%b" },
- {0x00004b00, 0x00007f00, "bpl!\t\t%b" },
- {0x00000008, 0x3e007fff, "brcs\t\t%15-19r" },
- {0x00000408, 0x3e007fff, "brcc\t\t%15-19r" },
- {0x00000808, 0x3e007fff, "brgtu\t\t%15-19r" },
- {0x00000c08, 0x3e007fff, "brleu\t\t%15-19r" },
- {0x00001008, 0x3e007fff, "breq\t\t%15-19r" },
- {0x00001408, 0x3e007fff, "brne\t\t%15-19r" },
- {0x00001808, 0x3e007fff, "brgt\t\t%15-19r" },
- {0x00001c08, 0x3e007fff, "brle\t\t%15-19r" },
- {0x00002008, 0x3e007fff, "brge\t\t%15-19r" },
- {0x00002408, 0x3e007fff, "brlt\t\t%15-19r" },
- {0x00002808, 0x3e007fff, "brmi\t\t%15-19r" },
- {0x00002c08, 0x3e007fff, "brpl\t\t%15-19r" },
- {0x00003008, 0x3e007fff, "brvs\t\t%15-19r" },
- {0x00003408, 0x3e007fff, "brvc\t\t%15-19r" },
- {0x00003808, 0x3e007fff, "brcnz\t\t%15-19r" },
- {0x00003c08, 0x3e007fff, "br\t\t%15-19r" },
- {0x00000009, 0x3e007fff, "brcsl\t\t%15-19r" },
- {0x00000409, 0x3e007fff, "brccl\t\t%15-19r" },
- {0x00000809, 0x3e007fff, "brgtul\t\t%15-19r" },
- {0x00000c09, 0x3e007fff, "brleul\t\t%15-19r" },
- {0x00001009, 0x3e007fff, "breql\t\t%15-19r" },
- {0x00001409, 0x3e007fff, "brnel\t\t%15-19r" },
- {0x00001809, 0x3e007fff, "brgtl\t\t%15-19r" },
- {0x00001c09, 0x3e007fff, "brlel\t\t%15-19r" },
- {0x00002009, 0x3e007fff, "brgel\t\t%15-19r" },
- {0x00002409, 0x3e007fff, "brltl\t\t%15-19r" },
- {0x00002809, 0x3e007fff, "brmil\t\t%15-19r" },
- {0x00002c09, 0x3e007fff, "brpll\t\t%15-19r" },
- {0x00003009, 0x3e007fff, "brvsl\t\t%15-19r" },
- {0x00003409, 0x3e007fff, "brvcl\t\t%15-19r" },
- {0x00003809, 0x3e007fff, "brcnzl\t\t%15-19r" },
- {0x00003c09, 0x3e007fff, "brl\t\t%15-19r" },
- {0x00000004, 0x00007f0f, "brcs!\t\t%4-7r" },
- {0x00000104, 0x00007f0f, "brcc!\t\t%4-7r" },
- {0x00000204, 0x00007f0f, "brgtu!\t\t%4-7r" },
- {0x00000304, 0x00007f0f, "brleu!\t\t%4-7r" },
- {0x00000404, 0x00007f0f, "breq!\t\t%4-7r" },
- {0x00000504, 0x00007f0f, "brne!\t\t%4-7r" },
- {0x00000604, 0x00007f0f, "brgt!\t\t%4-7r" },
- {0x00000704, 0x00007f0f, "brle!\t\t%4-7r" },
- {0x00000804, 0x00007f0f, "brge!\t\t%4-7r" },
- {0x00000904, 0x00007f0f, "brlt!\t\t%4-7r" },
- {0x00000a04, 0x00007f0f, "brmi!\t\t%4-7r" },
- {0x00000b04, 0x00007f0f, "brpl!\t\t%4-7r" },
- {0x00000c04, 0x00007f0f, "brvs!\t\t%4-7r" },
- {0x00000d04, 0x00007f0f, "brvc!\t\t%4-7r" },
- {0x00000e04, 0x00007f0f, "brcnz!\t\t%4-7r" },
- {0x00000f04, 0x00007f0f, "br!\t\t%4-7r" },
- {0x0000000c, 0x00007f0f, "brcsl!\t\t%4-7r" },
- {0x0000010c, 0x00007f0f, "brccl!\t\t%4-7r" },
- {0x0000020c, 0x00007f0f, "brgtul!\t\t%4-7r" },
- {0x0000030c, 0x00007f0f, "brleul!\t\t%4-7r" },
- {0x0000040c, 0x00007f0f, "breql!\t\t%4-7r" },
- {0x0000050c, 0x00007f0f, "brnel!\t\t%4-7r" },
- {0x0000060c, 0x00007f0f, "brgtl!\t\t%4-7r" },
- {0x0000070c, 0x00007f0f, "brlel!\t\t%4-7r" },
- {0x0000080c, 0x00007f0f, "brgel!\t\t%4-7r" },
- {0x0000090c, 0x00007f0f, "brltl!\t\t%4-7r" },
- {0x00000a0c, 0x00007f0f, "brmil!\t\t%4-7r" },
- {0x00000b0c, 0x00007f0f, "brpll!\t\t%4-7r" },
- {0x00000c0c, 0x00007f0f, "brvsl!\t\t%4-7r" },
- {0x00000d0c, 0x00007f0f, "brvcl!\t\t%4-7r" },
- {0x00000e0c, 0x00007f0f, "brcnzl!\t\t%4-7r" },
- {0x00000f0c, 0x00007f0f, "brl!\t\t%4-7r" },
- {0x08003000, 0x3e007c01, "bvs\t\t%b" },
- {0x08003400, 0x3e007c01, "bvc\t\t%b" },
- {0x08003001, 0x3e007c01, "bvsl\t\t%b" },
- {0x08003401, 0x3e007c01, "bvcl\t\t%b" },
- {0x00004c00, 0x00007f00, "bvs!\t\t%b" },
- {0x00004d00, 0x00007f00, "bvc!\t\t%b" },
- {0x00004f00, 0x00007f00, "b!\t\t%b" },
- {0x08003c00, 0x3e007c01, "b\t\t%b" },
+ {0x00005200, 0x00007e00, "bitset!\t\t%5-8r, 0x%0-4x"},
+ {0x00005400, 0x00007e00, "bittst!\t\t%5-8r, 0x%0-4x"},
+ {0x00005600, 0x00007e00, "bittgl!\t\t%5-8r, 0x%0-4x"},
+ {0x08000c00, 0x3e007c01, "bleu\t\t%b"},
+ {0x08001c00, 0x3e007c01, "ble\t\t%b"},
+ {0x08002400, 0x3e007c01, "blt\t\t%b"},
+ {0x08000c01, 0x3e007c01, "bleul\t\t%b"},
+ {0x08001c01, 0x3e007c01, "blel\t\t%b"},
+ {0x08002401, 0x3e007c01, "bltl\t\t%b"},
+ {0x08003c01, 0x3e007c01, "bl\t\t%b"},
+ {0x00003600, 0x00007e00, "bleu!\t\t%b"},
+ {0x00003e00, 0x00007e00, "ble!\t\t%b"},
+ {0x08002800, 0x3e007c01, "bmi\t\t%b"},
+ {0x08002801, 0x3e007c01, "bmil\t\t%b"},
+ {0x08001400, 0x3e007c01, "bne\t\t%b"},
+ {0x08001401, 0x3e007c01, "bnel\t\t%b"},
+ {0x00003a00, 0x00007e00, "bne!\t\t%b"},
+ {0x08002c00, 0x3e007c01, "bpl\t\t%b"},
+ {0x08002c01, 0x3e007c01, "bpll\t\t%b"},
+ {0x00000008, 0x3e007fff, "brcs\t\t%15-19r"},
+ {0x00000408, 0x3e007fff, "brcc\t\t%15-19r"},
+ {0x00000808, 0x3e007fff, "brgtu\t\t%15-19r"},
+ {0x00000c08, 0x3e007fff, "brleu\t\t%15-19r"},
+ {0x00001008, 0x3e007fff, "breq\t\t%15-19r"},
+ {0x00001408, 0x3e007fff, "brne\t\t%15-19r"},
+ {0x00001808, 0x3e007fff, "brgt\t\t%15-19r"},
+ {0x00001c08, 0x3e007fff, "brle\t\t%15-19r"},
+ {0x00002008, 0x3e007fff, "brge\t\t%15-19r"},
+ {0x00002408, 0x3e007fff, "brlt\t\t%15-19r"},
+ {0x00002808, 0x3e007fff, "brmi\t\t%15-19r"},
+ {0x00002c08, 0x3e007fff, "brpl\t\t%15-19r"},
+ {0x00003008, 0x3e007fff, "brvs\t\t%15-19r"},
+ {0x00003408, 0x3e007fff, "brvc\t\t%15-19r"},
+ {0x00003808, 0x3e007fff, "brcnz\t\t%15-19r"},
+ {0x00003c08, 0x3e007fff, "br\t\t%15-19r"},
+ {0x00000009, 0x3e007fff, "brcsl\t\t%15-19r"},
+ {0x00000409, 0x3e007fff, "brccl\t\t%15-19r"},
+ {0x00000809, 0x3e007fff, "brgtul\t\t%15-19r"},
+ {0x00000c09, 0x3e007fff, "brleul\t\t%15-19r"},
+ {0x00001009, 0x3e007fff, "breql\t\t%15-19r"},
+ {0x00001409, 0x3e007fff, "brnel\t\t%15-19r"},
+ {0x00001809, 0x3e007fff, "brgtl\t\t%15-19r"},
+ {0x00001c09, 0x3e007fff, "brlel\t\t%15-19r"},
+ {0x00002009, 0x3e007fff, "brgel\t\t%15-19r"},
+ {0x00002409, 0x3e007fff, "brltl\t\t%15-19r"},
+ {0x00002809, 0x3e007fff, "brmil\t\t%15-19r"},
+ {0x00002c09, 0x3e007fff, "brpll\t\t%15-19r"},
+ {0x00003009, 0x3e007fff, "brvsl\t\t%15-19r"},
+ {0x00003409, 0x3e007fff, "brvcl\t\t%15-19r"},
+ {0x00003809, 0x3e007fff, "brcnzl\t\t%15-19r"},
+ {0x00003c09, 0x3e007fff, "brl\t\t%15-19r"},
+ {0x00000080, 0x00007fe0, "br!\t\t%0-4r"},
+ {0x000000a0, 0x00007fe0, "brl!\t\t%0-4r"},
+ {0x000000c0, 0x00007fe0, "brr!\t\t%0-4r"},
+ {0x08003000, 0x3e007c01, "bvs\t\t%b"},
+ {0x08003400, 0x3e007c01, "bvc\t\t%b"},
+ {0x08003001, 0x3e007c01, "bvsl\t\t%b"},
+ {0x08003401, 0x3e007c01, "bvcl\t\t%b"},
+ {0x00003000, 0x00007e00, "b!\t\t%b"},
+ {0x08003c00, 0x3e007c01, "b\t\t%b"},
{0x30000000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
{0x30100000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
{0x30200000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
@@ -198,32 +169,36 @@ static struct score_opcode score_opcodes[] =
{0x31e00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
{0x31f00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
{0x38000000, 0x3ff003ff, "mad\t\t%15-19r, %10-14r"},
- {0x38000020, 0x3ff003ff, "madu\t\t%15-19r, %10-14r"},
+ {0x38000020, 0x3ff003ff, "madu\t\t%15-19r, %10-14r"},
{0x38000080, 0x3ff003ff, "mad.f\t\t%15-19r, %10-14r"},
- {0x38000001, 0x3ff003ff, "msb\t\t%15-19r, %10-14r"},
+ {0x38000001, 0x3ff003ff, "msb\t\t%15-19r, %10-14r"},
{0x38000021, 0x3ff003ff, "msbu\t\t%15-19r, %10-14r"},
{0x38000081, 0x3ff003ff, "msb.f\t\t%15-19r, %10-14r"},
- {0x38000102, 0x3ff003ff, "mazl\t\t%15-19r, %10-14r"},
- {0x38000182, 0x3ff003ff, "mazl.f\t\t%15-19r, %10-14r"},
- {0x38000002, 0x3ff003ff, "madl\t\t%15-19r, %10-14r"},
- {0x380000c2, 0x3ff003ff, "madl.fs\t\t%15-19r, %10-14r"},
- {0x38000303, 0x3ff003ff, "mazh\t\t%15-19r, %10-14r"},
- {0x38000383, 0x3ff003ff, "mazh.f\t\t%15-19r, %10-14r"},
- {0x38000203, 0x3ff003ff, "madh\t\t%15-19r, %10-14r"},
- {0x380002c3, 0x3ff003ff, "madh.fs\t\t%15-19r, %10-14r"},
- {0x38000007, 0x3e0003ff, "max\t\t%20-24r, %15-19r, %10-14r"},
+ {0x38000102, 0x3ff003ff, "mazl\t\t%15-19r, %10-14r"},
+ {0x38000182, 0x3ff003ff, "mazl.f\t\t%15-19r, %10-14r"},
+ {0x38000002, 0x3ff003ff, "madl\t\t%15-19r, %10-14r"},
+ {0x380000c2, 0x3ff003ff, "madl.fs\t\t%15-19r, %10-14r"},
+ {0x38000303, 0x3ff003ff, "mazh\t\t%15-19r, %10-14r"},
+ {0x38000383, 0x3ff003ff, "mazh.f\t\t%15-19r, %10-14r"},
+ {0x38000203, 0x3ff003ff, "madh\t\t%15-19r, %10-14r"},
+ {0x380002c3, 0x3ff003ff, "madh.fs\t\t%15-19r, %10-14r"},
+ {0x38000007, 0x3e0003ff, "max\t\t%20-24r, %15-19r, %10-14r"},
+
+ {0x00000064, 0x3e00007e, "mbitclr\t\t[%15-19r, %m], %10-14d"},
+ {0x0000006c, 0x3e00007e, "mbitset\t\t[%20-24r, %m], %10-14d"},
+
{0x38000006, 0x3e0003ff, "min\t\t%20-24r, %15-19r, %10-14r"},
- {0x38000104, 0x3ff003ff, "mszl\t\t%15-19r, %10-14r"},
- {0x38000184, 0x3ff003ff, "mszl.f\t\t%15-19r, %10-14r"},
- {0x38000004, 0x3ff003ff, "msbl\t\t%15-19r, %10-14r"},
+ {0x38000104, 0x3ff003ff, "mszl\t\t%15-19r, %10-14r"},
+ {0x38000184, 0x3ff003ff, "mszl.f\t\t%15-19r, %10-14r"},
+ {0x38000004, 0x3ff003ff, "msbl\t\t%15-19r, %10-14r"},
{0x380000c4, 0x3ff003ff, "msbl.fs\t\t%15-19r, %10-14r"},
- {0x38000305, 0x3ff003ff, "mszh\t\t%15-19r, %10-14r"},
- {0x38000385, 0x3ff003ff, "mszh.f\t\t%15-19r, %10-14r"},
- {0x38000205, 0x3ff003ff, "msbh\t\t%15-19r, %10-14r"},
- {0x380002c5, 0x3ff003ff, "msbh.fs\t\t%15-19r, %10-14r"},
- {0x3800004e, 0x3e0003ff, "sll.s\t\t%20-24r, %15-19r, %10-14r"},
- {0x38000049, 0x3e0003ff, "sub.s\t\t%20-24r, %15-19r, %10-14r"},
- {0x3800000d, 0x3e007fff, "clz\t\t%20-24r, %15-19r"},
+ {0x38000305, 0x3ff003ff, "mszh\t\t%15-19r, %10-14r"},
+ {0x38000385, 0x3ff003ff, "mszh.f\t\t%15-19r, %10-14r"},
+ {0x38000205, 0x3ff003ff, "msbh\t\t%15-19r, %10-14r"},
+ {0x380002c5, 0x3ff003ff, "msbh.fs\t\t%15-19r, %10-14r"},
+ {0x3800004e, 0x3e0003ff, "sll.s\t\t%20-24r, %15-19r, %10-14r"},
+ {0x38000049, 0x3e0003ff, "sub.s\t\t%20-24r, %15-19r, %10-14r"},
+ {0x0000001c, 0x3e007fff, "clz\t\t%20-24r, %15-19r"},
{0x38000000, 0x3e000000, "ceinst\t\t%20-24d, %15-19r, %10-14r, %5-9d, %0-4d"},
{0x00000019, 0x3ff003ff, "cmpteq.c\t\t%15-19r, %10-14r"},
{0x00100019, 0x3ff003ff, "cmptmi.c\t\t%15-19r, %10-14r"},
@@ -232,13 +207,22 @@ static struct score_opcode score_opcodes[] =
{0x0010001b, 0x3ff07fff, "cmpztmi.c\t%15-19r"},
{0x0030001b, 0x3ff07fff, "cmpz.c\t\t%15-19r"},
{0x02040001, 0x3e0e0001, "cmpi.c\t\t%20-24r, %1-16i"},
- {0x00002003, 0x0000700f, "cmp!\t\t%8-11r, %4-7r"},
+ {0x00004400, 0x00007c00, "cmp!\t\t%5-9r, %0-4r"},
+ {0x00006000, 0x00007c00, "cmpi!\t\t%5-9r, %0-4i"},
{0x0c00000c, 0x3e00001f, "cop1\t\tc%20-24r, c%15-19r, c%10-14r, %5-9d"},
{0x0c000014, 0x3e00001f, "cop2\t\tc%20-24r, c%15-19r, c%10-14r, %5-9d"},
{0x0c00001c, 0x3e00001f, "cop3\t\tc%20-24r, c%15-19r, c%10-14r, %5-9d"},
{0x00000044, 0x3e0003ff, "div\t\t%15-19r, %10-14r"},
+ {0x00000144, 0x3e0003ff, "divr.q\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000244, 0x3e0003ff, "divr.r\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000344, 0x3e0003ff, "divr\t\t%20-24r,%15-19r, %10-14r"},
{0x00000046, 0x3e0003ff, "divu\t\t%15-19r, %10-14r"},
- {0x0c0000a4, 0x3e0003ff, "drte" },
+ {0x00000146, 0x3e0003ff, "divur.q\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000246, 0x3e0003ff, "divur.r\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000346, 0x3e0003ff, "divur\t\t%20-24r,%15-19r, %10-14r"},
+ {0x0c0000a4, 0x3e0003ff, "drte"},
+ {0x00e0, 0xffe1, "disint!"},
+ {0x00e1, 0xffe1, "enint!"},
{0x00000058, 0x3e0003ff, "extsb\t\t%20-24r, %15-19r"},
{0x00000059, 0x3e0003ff, "extsb.c\t\t%20-24r, %15-19r"},
{0x0000005a, 0x3e0003ff, "extsh\t\t%20-24r, %15-19r"},
@@ -248,8 +232,6 @@ static struct score_opcode score_opcodes[] =
{0x0000005e, 0x3e0003ff, "extzh\t\t%20-24r, %15-19r"},
{0x0000005f, 0x3e0003ff, "extzh.c\t\t%20-24r, %15-19r"},
{0x04000001, 0x3e000001, "jl\t\t%j"},
- {0x00003001, 0x00007001, "jl!\t\t%j" },
- {0x00003000, 0x00007001, "j!\t\t%j" },
{0x04000000, 0x3e000001, "j\t\t%j"},
{0x26000000, 0x3e000000, "lb\t\t%20-24r, [%15-19r, %0-14i]"},
{0x2c000000, 0x3e000000, "lbu\t\t%20-24r, [%15-19r, %0-14i]"},
@@ -257,41 +239,41 @@ static struct score_opcode score_opcodes[] =
{0x06000006, 0x3e000007, "lbu\t\t%20-24r, [%15-19r, %3-14i]+"},
{0x0e000003, 0x3e000007, "lb\t\t%20-24r, [%15-19r]+, %3-14i"},
{0x0e000006, 0x3e000007, "lbu\t\t%20-24r, [%15-19r]+, %3-14i"},
- {0x0000200b, 0x0000700f, "lbu!\t\t%8-11r, [%4-7r]"},
- {0x00007003, 0x00007007, "lbup!\t\t%8-11r, %3-7d"},
{0x00000060, 0x3e0003ff, "lcb\t\t[%15-19r]+"},
{0x00000062, 0x3e0003ff, "lcw\t\t%20-24r, [%15-19r]+"},
{0x00000066, 0x3e0003ff, "lce\t\t%20-24r, [%15-19r]+"},
{0x0c00000a, 0x3e00001f, "ldc1\t\tc%15-19r, [%20-24r, %5-14i]"},
{0x0c000012, 0x3e00001f, "ldc2\t\tc%15-19r, [%20-24r, %5-14i]"},
{0x0c00001a, 0x3e00001f, "ldc3\t\tc%15-19r, [%20-24r, %5-14i]"},
+ {0x000000000001LL, 0x1c000000001fLL, "ldi48\t\t%37-41r, %5-36i"},
{0x22000000, 0x3e000000, "lh\t\t%20-24r, [%15-19r, %0-14i]"},
{0x24000000, 0x3e000000, "lhu\t\t%20-24r, [%15-19r, %0-14i]"},
{0x06000001, 0x3e000007, "lh\t\t%20-24r, [%15-19r, %3-14i]+"},
{0x06000002, 0x3e000007, "lhu\t\t%20-24r, [%15-19r, %3-14i]+"},
{0x0e000001, 0x3e000007, "lh\t\t%20-24r, [%15-19r]+, %3-14i"},
{0x0e000002, 0x3e000007, "lhu\t\t%20-24r, [%15-19r]+, %3-14i"},
- {0x00002009, 0x0000700f, "lh!\t\t%8-11r, [%4-7r]"},
- {0x00007001, 0x00007007, "lhp!\t\t%8-11r, %3-7d1"},
{0x020c0000, 0x3e0e0000, "ldi\t\t%20-24r, 0x%1-16x(%1-16i)"},
{0x0a0c0000, 0x3e0e0000, "ldis\t\t%20-24r, 0x%1-16x(%1-16i)"},
- {0x00005000, 0x00007000, "ldiu!\t\t%8-11r, %0-7d"},
+ {0x00006400, 0x00007c00, "ldiu!\t\t%5-9r, %0-4d"},
+ {0x00000032, 0x3e0003ff, "ltbw\t\t%20-24r, [%15-19r, %10-14r]"},
+ {0x00000132, 0x3e0003ff, "ltbh\t\t%20-24r, [%15-19r, %10-14r]"},
+ {0x00000332, 0x3e0003ff, "ltbb\t\t%20-24r, [%15-19r, %10-14r]"},
{0x0000000c, 0x3e0003ff, "alw\t\t%20-24r, [%15-19r]"},
{0x20000000, 0x3e000000, "lw\t\t%20-24r, [%15-19r, %0-14i]"},
{0x06000000, 0x3e000007, "lw\t\t%20-24r, [%15-19r, %3-14i]+"},
{0x0e000000, 0x3e000007, "lw\t\t%20-24r, [%15-19r]+, %3-14i"},
- {0x00002008, 0x0000700f, "lw!\t\t%8-11r, [%4-7r]"},
- {0x00007000, 0x00007007, "lwp!\t\t%8-11r, %3-7d2"},
- {0x0000100b, 0x0000700f, "madh.fs!\t\t%8-11r, %4-7r"},
- {0x0000100a, 0x0000700f, "madl.fs!\t\t%8-11r, %4-7r"},
- {0x00001005, 0x0000700f, "madu!\t\t%8-11r, %4-7r"},
- {0x00001004, 0x0000700f, "mad.f!\t\t%8-11r, %4-7r"},
- {0x00001009, 0x0000700f, "mazh.f!\t\t%8-11r, %4-7r"},
- {0x00001008, 0x0000700f, "mazl.f!\t\t%8-11r, %4-7r"},
+ {0x00001000, 0x00007000, "lw!\t\t%8-11r, [%5-7r,%0-4d2]"},
+ {0x000000000002LL, 0x1c000000001fLL, "lw48\t\t%37-41r,[0x%7-36w]"},
+ {0x00007b00, 0x00007f00, "madh.fs!\t\t%8-11r, %4-7r"},
+ {0x00007a00, 0x00007f00, "madl.fs!\t\t%8-11r, %4-7r"},
+ {0x00007500, 0x00007f00, "madu!\t\t%8-11r, %4-7r"},
+ {0x00007400, 0x00007f00, "mad.f!\t\t%8-11r, %4-7r"},
+ {0x00007900, 0x00007f00, "mazh.f!\t\t%8-11r, %4-7r"},
+ {0x00007800, 0x00007f00, "mazl.f!\t\t%8-11r, %4-7r"},
{0x00000448, 0x3e007fff, "mfcel\t\t%20-24r"},
- {0x00001001, 0x00007f0f, "mfcel!\t\t%4-7r"},
+ {0x00007100, 0x00007ff0, "mfcel!\t\t%4-7r"},
{0x00000848, 0x3e007fff, "mfceh\t\t%20-24r"},
- {0x00001101, 0x00007f0f, "mfceh!\t\t%4-7r"},
+ {0x00007110, 0x00007ff0, "mfceh!\t\t%4-7r"},
{0x00000c48, 0x3e007fff, "mfcehl\t\t%20-24r, %15-19r"},
{0x00000048, 0x3e0003ff, "mfce\t\t%20-24r, er%10-14d"},
{0x00000050, 0x3e0003ff, "mfsr\t\t%20-24r, sr%10-14d"},
@@ -302,18 +284,21 @@ static struct score_opcode score_opcodes[] =
{0x0c00000f, 0x3e00001f, "mfcc1\t\t%20-24r, c%15-19r"},
{0x0c000017, 0x3e00001f, "mfcc2\t\t%20-24r, c%15-19r"},
{0x0c00001f, 0x3e00001f, "mfcc3\t\t%20-24r, c%15-19r"},
- {0x00000002, 0x0000700f, "mhfl!\t\t%8-11R, %4-7r"},
- {0x00000001, 0x0000700f, "mlfh!\t\t%8-11r, %4-7R"},
- {0x00001006, 0x0000700f, "msb.f!\t\t%8-11r, %4-7r"},
- {0x0000100f, 0x0000700f, "msbh.fs!\t\t%8-11r, %4-7r"},
- {0x0000100e, 0x0000700f, "msbl.fs!\t\t%8-11r, %4-7r"},
- {0x00001007, 0x0000700f, "msbu!\t\t%8-11r, %4-7r"},
- {0x0000100d, 0x0000700f, "mszh.f!\t\t%8-11r, %4-7r"},
- {0x0000100c, 0x0000700f, "mszl.f!\t\t%8-11r, %4-7r"},
+ /* confilct: push! mhfl!. */
+ {0x00000040, 0x00007fe0, "pop!\t\t%0-4r"},
+ {0x00000060, 0x00007fe0, "push!\t\t%0-4r"},
+ {0x00006800, 0x00007c00, "rpop!\t\t%5-9r, %0-4d"},
+ {0x00006c00, 0x00007c00, "rpush!\t\t%5-9r, %0-4d"},
+ {0x00007600, 0x00007f00, "msb.f!\t\t%8-11r, %4-7r"},
+ {0x00007f00, 0x00007f00, "msbh.fs!\t\t%8-11r, %4-7r"},
+ {0x00007e00, 0x00007f00, "msbl.fs!\t\t%8-11r, %4-7r"},
+ {0x00007700, 0x00007f00, "msbu!\t\t%8-11r, %4-7r"},
+ {0x00007d00, 0x00007f00, "mszh.f!\t\t%8-11r, %4-7r"},
+ {0x00007c00, 0x00007f00, "mszl.f!\t\t%8-11r, %4-7r"},
{0x0000044a, 0x3e007fff, "mtcel\t\t%20-24r"},
- {0x00001000, 0x00007f0f, "mtcel!\t\t%4-7r"},
+ {0x00007000, 0x00007ff0, "mtcel!\t\t%4-7r"},
{0x0000084a, 0x3e007fff, "mtceh\t\t%20-24r"},
- {0x00001100, 0x00007f0f, "mtceh!\t\t%4-7r"},
+ {0x00007010, 0x00007ff0, "mtceh!\t\t%4-7r"},
{0x00000c4a, 0x3e007fff, "mtcehl\t\t%20-24r, %15-19r"},
{0x0000004a, 0x3e0003ff, "mtce\t\t%20-24r, er%10-14d"},
{0x00000052, 0x3e0003ff, "mtsr\t\t%15-19r, sr%10-14d"},
@@ -325,13 +310,22 @@ static struct score_opcode score_opcodes[] =
{0x0c000016, 0x3e00001f, "mtcc2\t\t%20-24r, c%15-19r"},
{0x0c00001e, 0x3e00001f, "mtcc3\t\t%20-24r, c%15-19r"},
{0x00000040, 0x3e0003ff, "mul\t\t%15-19r, %10-14r"},
- {0x00000040, 0x3e0003ff, "maz\t\t%15-19r, %10-14r"},
+ {0x00000140, 0x3e0003ff, "mulr.l\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000240, 0x3e0003ff, "mulr.h\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000340, 0x3e0003ff, "mulr\t\t%20-24r,%15-19r, %10-14r"},
{0x00000041, 0x3e0003ff, "mul.f\t\t%15-19r, %10-14r"},
- {0x00000041, 0x3e0003ff, "maz.f\t\t%15-19r, %10-14r"},
- {0x00001002, 0x0000700f, "mul.f!\t\t%8-11r, %4-7r"},
+ {0x00000141, 0x3e0003ff, "mulr.lf\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000241, 0x3e0003ff, "mulr.hf\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000341, 0x3e0003ff, "mulr.f\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000040, 0x3e0003ff, "maz\t\t%15-19r, %10-14r"},
+ {0x00000041, 0x3e0003ff, "maz.f\t\t%15-19r, %10-14r"},
+ {0x00007200, 0x00007f00, "mul.f!\t\t%8-11r, %4-7r"},
{0x00000042, 0x3e0003ff, "mulu\t\t%15-19r, %10-14r"},
+ {0x00000142, 0x3e0003ff, "mulur.l\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000242, 0x3e0003ff, "mulur.h\t\t%20-24r,%15-19r, %10-14r"},
+ {0x00000342, 0x3e0003ff, "mulur\t\t%20-24r,%15-19r, %10-14r"},
{0x00000042, 0x3e0003ff, "mazu\t\t%15-19r, %10-14r"},
- {0x00001003, 0x0000700f, "mulu!\t\t%8-11r, %4-7r"},
+ {0x00007300, 0x00007f00, "mulu!\t\t%8-11r, %4-7r"},
{0x00000056, 0x3e007fff, "mvcs\t\t%20-24r, %15-19r"},
{0x00000456, 0x3e007fff, "mvcc\t\t%20-24r, %15-19r"},
{0x00000856, 0x3e007fff, "mvgtu\t\t%20-24r, %15-19r"},
@@ -347,29 +341,25 @@ static struct score_opcode score_opcodes[] =
{0x00003056, 0x3e007fff, "mvvs\t\t%20-24r, %15-19r"},
{0x00003456, 0x3e007fff, "mvvc\t\t%20-24r, %15-19r"},
{0x00003c56, 0x3e007fff, "mv\t\t%20-24r, %15-19r"},
- {0x00000003, 0x0000700f, "mv!\t\t%8-11r, %4-7r"},
- {0x0000001e, 0x3e0003ff, "neg\t\t%20-24r, %10-14r" },
- {0x0000001f, 0x3e0003ff, "neg.c\t\t%20-24r, %10-14r" },
- {0x00002002, 0x0000700f, "neg!\t\t%8-11r, %4-7r"},
- {0x00000000, 0x3e0003ff, "nop" },
- {0x00000024, 0x3e0003ff, "not\t\t%20-24r, %15-19r" },
- {0x00000025, 0x3e0003ff, "not.c\t\t%20-24r, %15-19r" },
- {0x00000000, 0x0000700f, "nop!" },
- {0x00002006, 0x0000700f, "not!\t\t%8-11r, %4-7r"},
+ {0x00004000, 0x00007c00, "mv!\t\t%5-9r, %0-4r"},
+ {0x0000001e, 0x3e0003ff, "neg\t\t%20-24r, %10-14r"},
+ {0x0000001f, 0x3e0003ff, "neg.c\t\t%20-24r, %10-14r"},
+ {0x00000000, 0x3e0003ff, "nop"},
+ {0x00000024, 0x3e0003ff, "not\t\t%20-24r, %15-19r"},
+ {0x00000025, 0x3e0003ff, "not.c\t\t%20-24r, %15-19r"},
+ {0x00000000, 0x00007fff, "nop!"},
{0x00000022, 0x3e0003ff, "or\t\t%20-24r, %15-19r, %10-14r"},
{0x00000023, 0x3e0003ff, "or.c\t\t%20-24r, %15-19r, %10-14r"},
- {0x020a0000, 0x3e0e0001, "ori\t\t%20-24r, 0x%1-16x"},
- {0x020a0001, 0x3e0e0001, "ori.c\t\t%20-24r, 0x%1-16x"},
+ {0x020a0000, 0x3e0e0001, "ori\t\t%20-24r, 0x%1-16x"},
+ {0x020a0001, 0x3e0e0001, "ori.c\t\t%20-24r, 0x%1-16x"},
{0x0a0a0000, 0x3e0e0001, "oris\t\t%20-24r, 0x%1-16x"},
{0x0a0a0001, 0x3e0e0001, "oris.c\t\t%20-24r, 0x%1-16x"},
{0x1a000000, 0x3e000001, "orri\t\t%20-24r, %15-19r, 0x%1-14x"},
{0x1a000001, 0x3e000001, "orri.c\t\t%20-24r, %15-19r, 0x%1-14x"},
- {0x00002005, 0x0000700f, "or!\t\t%8-11r, %4-7r"},
+ {0x00004a00, 0x00007f00, "or!\t\t%4-7r, %0-3r"},
+ {0x040000000002LL, 0x1c0000000003LL, "orri48\t\t%38-41r,%34-37r, 0x%2-33x"},
+ {0x040000000003LL, 0x1c0000000003LL, "orri48.c\t\t%38-41r,%34-37r, 0x%2-33x"},
{0x0000000a, 0x3e0003ff, "pflush"},
- {0x0000208a, 0x0000708f, "pop!\t\t%8-11R, [%4-6r]"},
- {0x0000200a, 0x0000700f, "pop!\t\t%8-11r, [%4-7r]"},
- {0x0000208e, 0x0000708f, "push!\t\t%8-11R, [%4-6r]"},
- {0x0000200e, 0x0000700f, "push!\t\t%8-11r, [%4-7r]"},
{0x00000038, 0x3e0003ff, "ror\t\t%20-24r, %15-19r, %10-14r"},
{0x00000039, 0x3e0003ff, "ror.c\t\t%20-24r, %15-19r, %10-14r"},
{0x0000003b, 0x3e0003ff, "rorc.c\t\t%20-24r, %15-19r, %10-14r"},
@@ -382,30 +372,26 @@ static struct score_opcode score_opcodes[] =
{0x0000007c, 0x3e0003ff, "roli\t\t%20-24r, %15-19r, %10-14d"},
{0x0000007d, 0x3e0003ff, "roli.c\t\t%20-24r, %15-19r, %10-14d"},
{0x0000007f, 0x3e0003ff, "rolic.c\t\t%20-24r, %15-19r, %10-14d"},
- {0x0c000084, 0x3e0003ff, "rte" },
+ {0x0c000084, 0x3e0003ff, "rte"},
{0x2e000000, 0x3e000000, "sb\t\t%20-24r, [%15-19r, %0-14i]"},
{0x06000007, 0x3e000007, "sb\t\t%20-24r, [%15-19r, %3-14i]+"},
{0x0e000007, 0x3e000007, "sb\t\t%20-24r, [%15-19r]+, %3-14i"},
- {0x0000200f, 0x0000700f, "sb!\t\t%8-11r, [%4-7r]"},
- {0x00007007, 0x00007007, "sbp!\t\t%8-11r, %3-7d"},
{0x0000000e, 0x3e0003ff, "asw\t\t%20-24r, [%15-19r]"},
{0x00000068, 0x3e0003ff, "scb\t\t%20-24r, [%15-19r]+"},
{0x0000006a, 0x3e0003ff, "scw\t\t%20-24r, [%15-19r]+"},
{0x0000006e, 0x3e0003ff, "sce\t\t[%15-19r]+"},
{0x00000006, 0x3e0003ff, "sdbbp\t\t%15-19d"},
- {0x00006002, 0x00007007, "sdbbp!\t\t%3-7d"},
+ {0x00000020, 0x00007fe0, "sdbbp!\t\t%0-4d"},
+ {0x000000000000LL, 0x1c000000001fLL, "sdbbp48\t\t%5-9d"},
{0x2a000000, 0x3e000000, "sh\t\t%20-24r, [%15-19r, %0-14i]"},
{0x06000005, 0x3e000007, "sh\t\t%20-24r, [%15-19r, %3-14i]+"},
{0x0e000005, 0x3e000007, "sh\t\t%20-24r, [%15-19r]+, %3-14i"},
- {0x0000200d, 0x0000700f, "sh!\t\t%8-11r, [%4-7r]"},
- {0x00007005, 0x00007007, "shp!\t\t%8-11r, %3-7d1"},
- {0x0c0000c4, 0x3e0003ff, "sleep" },
+ {0x0c0000c4, 0x3e0003ff, "sleep"},
{0x00000030, 0x3e0003ff, "sll\t\t%20-24r, %15-19r, %10-14r"},
{0x00000031, 0x3e0003ff, "sll.c\t\t%20-24r, %15-19r, %10-14r"},
{0x00000070, 0x3e0003ff, "slli\t\t%20-24r, %15-19r, %10-14d"},
{0x00000071, 0x3e0003ff, "slli.c\t\t%20-24r, %15-19r, %10-14d"},
- {0x00000008, 0x0000700f, "sll!\t\t%8-11r, %4-7r"},
- {0x00006001, 0x00007007, "slli!\t\t%8-11r, %3-7d"},
+ {0x00005800, 0x00007e00, "slli!\t\t%5-8r, %0-4d"},
{0x00000034, 0x3e0003ff, "srl\t\t%20-24r, %15-19r, %10-14r"},
{0x00000035, 0x3e0003ff, "srl.c\t\t%20-24r, %15-19r, %10-14r"},
{0x00000036, 0x3e0003ff, "sra\t\t%20-24r, %15-19r, %10-14r"},
@@ -414,9 +400,7 @@ static struct score_opcode score_opcodes[] =
{0x00000075, 0x3e0003ff, "srli.c\t\t%20-24r, %15-19r, %10-14d"},
{0x00000076, 0x3e0003ff, "srai\t\t%20-24r, %15-19r, %10-14d"},
{0x00000077, 0x3e0003ff, "srai.c\t\t%20-24r, %15-19r, %10-14d"},
- {0x0000000a, 0x0000700f, "srl!\t\t%8-11r, %4-7r"},
- {0x00006003, 0x00007007, "srli!\t\t%8-11r, %3-7d"},
- {0x0000000b, 0x0000700f, "sra!\t\t%8-11r, %4-7r"},
+ {0x00005a00, 0x00007e00, "srli!\t\t%5-8r, %0-4d"},
{0x0c00000b, 0x3e00001f, "stc1\t\tc%15-19r, [%20-24r, %5-14i]"},
{0x0c000013, 0x3e00001f, "stc2\t\tc%15-19r, [%20-24r, %5-14i]"},
{0x0c00001b, 0x3e00001f, "stc3\t\tc%15-19r, [%20-24r, %5-14i]"},
@@ -424,44 +408,30 @@ static struct score_opcode score_opcodes[] =
{0x00000015, 0x3e0003ff, "sub.c\t\t%20-24r, %15-19r, %10-14r"},
{0x00000016, 0x3e0003ff, "subc\t\t%20-24r, %15-19r, %10-14r"},
{0x00000017, 0x3e0003ff, "subc.c\t\t%20-24r, %15-19r, %10-14r"},
- {0x00002001, 0x0000700f, "sub!\t\t%8-11r, %4-7r"},
- {0x00006080, 0x00007087, "subei!\t\t%8-11r, %3-6d"},
+ {0x00004900, 0x00007f00, "sub!\t\t%4-7r, %0-3r"},
{0x28000000, 0x3e000000, "sw\t\t%20-24r, [%15-19r, %0-14i]"},
{0x06000004, 0x3e000007, "sw\t\t%20-24r, [%15-19r, %3-14i]+"},
{0x0e000004, 0x3e000007, "sw\t\t%20-24r, [%15-19r]+, %3-14i"},
- {0x0000200c, 0x0000700f, "sw!\t\t%8-11r, [%4-7r]"},
- {0x00007004, 0x00007007, "swp!\t\t%8-11r, %3-7d2"},
+ {0x00002000, 0x00007000, "sw!\t\t%8-11r, [%5-7r,%0-4d2]"},
+ {0x000000000003LL, 0x1c000000001fLL, "sw48\t\t%37-41r, [0x%7-36w]"},
{0x00000002, 0x3e0003ff, "syscall\t\t%10-24d"},
- {0x00000054, 0x3e007fff, "tcs" },
- {0x00000454, 0x3e007fff, "tcc" },
- {0x00003854, 0x3e007fff, "tcnz" },
- {0x00000005, 0x00007f0f, "tcs!" },
- {0x00000105, 0x00007f0f, "tcc!" },
- {0x00000e05, 0x00007f0f, "tcnz!" },
- {0x00001054, 0x3e007fff, "teq" },
- {0x00000405, 0x00007f0f, "teq!" },
- {0x00000854, 0x3e007fff, "tgtu" },
- {0x00001854, 0x3e007fff, "tgt" },
- {0x00002054, 0x3e007fff, "tge" },
- {0x00000205, 0x00007f0f, "tgtu!" },
- {0x00000605, 0x00007f0f, "tgt!" },
- {0x00000805, 0x00007f0f, "tge!" },
- {0x00000c54, 0x3e007fff, "tleu" },
- {0x00001c54, 0x3e007fff, "tle" },
- {0x00002454, 0x3e007fff, "tlt" },
- {0x0c000004, 0x3e0003ff, "stlb" },
- {0x0c000024, 0x3e0003ff, "mftlb" },
- {0x0c000044, 0x3e0003ff, "mtptlb" },
- {0x0c000064, 0x3e0003ff, "mtrtlb" },
- {0x00000305, 0x00007f0f, "tleu!" },
- {0x00000705, 0x00007f0f, "tle!" },
- {0x00000905, 0x00007f0f, "tlt!" },
- {0x00002854, 0x3e007fff, "tmi" },
- {0x00000a05, 0x00007f0f, "tmi!" },
- {0x00001454, 0x3e007fff, "tne" },
- {0x00000505, 0x00007f0f, "tne!" },
- {0x00002c54, 0x3e007fff, "tpl" },
- {0x00000b05, 0x00007f0f, "tpl!" },
+ {0x00000054, 0x3e007fff, "tcs"},
+ {0x00000454, 0x3e007fff, "tcc"},
+ {0x00003854, 0x3e007fff, "tcnz"},
+ {0x00001054, 0x3e007fff, "teq"},
+ {0x00000854, 0x3e007fff, "tgtu"},
+ {0x00001854, 0x3e007fff, "tgt"},
+ {0x00002054, 0x3e007fff, "tge"},
+ {0x00000c54, 0x3e007fff, "tleu"},
+ {0x00001c54, 0x3e007fff, "tle"},
+ {0x00002454, 0x3e007fff, "tlt"},
+ {0x0c000004, 0x3e0003ff, "stlb"},
+ {0x0c000024, 0x3e0003ff, "mftlb"},
+ {0x0c000044, 0x3e0003ff, "mtptlb"},
+ {0x0c000064, 0x3e0003ff, "mtrtlb"},
+ {0x00002854, 0x3e007fff, "tmi"},
+ {0x00001454, 0x3e007fff, "tne"},
+ {0x00002c54, 0x3e007fff, "tpl"},
{0x00000004, 0x3e007fff, "trapcs\t\t%15-19d"},
{0x00000404, 0x3e007fff, "trapcc\t\t%15-19d"},
{0x00000804, 0x3e007fff, "trapgtu\t\t%15-19d"},
@@ -477,13 +447,9 @@ static struct score_opcode score_opcodes[] =
{0x00003004, 0x3e007fff, "trapvs\t\t%15-19d"},
{0x00003404, 0x3e007fff, "trapvc\t\t%15-19d"},
{0x00003c04, 0x3e007fff, "trap\t\t%15-19d"},
- {0x00003c54, 0x3e007fff, "tset" },
- {0x00000f05, 0x00007f0f, "tset!" },
- {0x00003054, 0x3e007fff, "tvs" },
- {0x00003454, 0x3e007fff, "tvc" },
- {0x00000c05, 0x00007f0f, "tvs!" },
- {0x00000d05, 0x00007f0f, "tvc!" },
+ {0x00003c54, 0x3e007fff, "tset"},
+ {0x00003054, 0x3e007fff, "tvs"},
+ {0x00003454, 0x3e007fff, "tvc"},
{0x00000026, 0x3e0003ff, "xor\t\t%20-24r, %15-19r, %10-14r"},
{0x00000027, 0x3e0003ff, "xor.c\t\t%20-24r, %15-19r, %10-14r"},
- {0x00002007, 0x0000700f, "xor!\t\t%8-11r, %4-7r"}
};
diff --git a/opcodes/score7-dis.c b/opcodes/score7-dis.c
new file mode 100644
index 00000000000..70ff637d62c
--- /dev/null
+++ b/opcodes/score7-dis.c
@@ -0,0 +1,972 @@
+/* Instruction printing code for Score
+ Copyright 2009 Free Software Foundation, Inc.
+ Contributed by:
+ Brain.lin (brain.lin@sunplusct.com)
+ Mei Ligang (ligang@sunnorth.com.cn)
+ Pei-Lin Tsai (pltsai@sunplus.com)
+
+ This file is part of the GNU opcodes library.
+
+ This library is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 3, or (at your option)
+ any later version.
+
+ It is distributed in the hope that it will be useful, but WITHOUT
+ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
+ License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this file; see the file COPYING. If not, write to the
+ Free Software Foundation, 51 Franklin Street - Fifth Floor, Boston,
+ MA 02110-1301, USA. */
+
+#include "sysdep.h"
+#include "dis-asm.h"
+#define DEFINE_TABLE
+#include "opintl.h"
+#include "bfd.h"
+
+/* FIXME: This shouldn't be done here. */
+#include "elf-bfd.h"
+#include "elf/internal.h"
+#include "elf/score.h"
+
+#ifndef streq
+#define streq(a,b) (strcmp ((a), (b)) == 0)
+#endif
+
+#ifndef strneq
+#define strneq(a,b,n) (strncmp ((a), (b), (n)) == 0)
+#endif
+
+#ifndef NUM_ELEM
+#define NUM_ELEM(a) (sizeof (a) / sizeof (a)[0])
+#endif
+
+struct score_opcode
+{
+ unsigned long value;
+ unsigned long mask; /* Recognise instruction if (op & mask) == value. */
+ char *assembler; /* Disassembly string. */
+};
+
+/* Note: There is a partial ordering in this table - it must be searched from
+ the top to obtain a correct match. */
+
+static struct score_opcode score_opcodes[] =
+{
+ /* Score Instructions. */
+ {0x3800000a, 0x3e007fff, "abs\t\t%20-24r, %15-19r"},
+ {0x3800004b, 0x3e007fff, "abs.s\t\t%20-24r, %15-19r"},
+ {0x00000010, 0x3e0003ff, "add\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000011, 0x3e0003ff, "add.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x38000048, 0x3e0003ff, "add.s\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000012, 0x3e0003ff, "addc\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000013, 0x3e0003ff, "addc.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x02000000, 0x3e0e0001, "addi\t\t%20-24r, %1-16i"},
+ {0x02000001, 0x3e0e0001, "addi.c\t\t%20-24r, %1-16i"},
+ {0x0a000000, 0x3e0e0001, "addis\t\t%20-24r, %1-16d(0x%1-16x)"},
+ {0x0a000001, 0x3e0e0001, "addis.c\t\t%20-24r, %1-16d(0x%1-16x)"},
+ {0x10000000, 0x3e000001, "addri\t\t%20-24r, %15-19r, %1-14i"},
+ {0x10000001, 0x3e000001, "addri.c\t\t%20-24r, %15-19r, %1-14i"},
+ {0x00000009, 0x0000700f, "addc!\t\t%8-11r, %4-7r"},
+ {0x00002000, 0x0000700f, "add!\t\t%8-11r, %4-7r"},
+ {0x00006000, 0x00007087, "addei!\t\t%8-11r, %3-6d"},
+ {0x00000020, 0x3e0003ff, "and\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000021, 0x3e0003ff, "and.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x02080000, 0x3e0e0001, "andi\t\t%20-24r, 0x%1-16x"},
+ {0x02080001, 0x3e0e0001, "andi.c\t\t%20-24r, 0x%1-16x"},
+ {0x0a080000, 0x3e0e0001, "andis\t\t%20-24r, 0x%1-16x"},
+ {0x0a080001, 0x3e0e0001, "andis.c\t\t%20-24r, 0x%1-16x"},
+ {0x18000000, 0x3e000001, "andri\t\t%20-24r, %15-19r, 0x%1-14x"},
+ {0x18000001, 0x3e000001, "andri.c\t\t%20-24r, %15-19r,0x%1-14x"},
+ {0x00002004, 0x0000700f, "and!\t\t%8-11r, %4-7r"},
+ {0x08000000, 0x3e007c01, "bcs\t\t%b"},
+ {0x08000400, 0x3e007c01, "bcc\t\t%b"},
+ {0x08003800, 0x3e007c01, "bcnz\t\t%b"},
+ {0x08000001, 0x3e007c01, "bcsl\t\t%b"},
+ {0x08000401, 0x3e007c01, "bccl\t\t%b"},
+ {0x08003801, 0x3e007c01, "bcnzl\t\t%b"},
+ {0x00004000, 0x00007f00, "bcs!\t\t%b"},
+ {0x00004100, 0x00007f00, "bcc!\t\t%b"},
+ {0x00004e00, 0x00007f00, "bcnz!\t\t%b"},
+ {0x08001000, 0x3e007c01, "beq\t\t%b"},
+ {0x08001001, 0x3e007c01, "beql\t\t%b"},
+ {0x00004400, 0x00007f00, "beq!\t\t%b"},
+ {0x08000800, 0x3e007c01, "bgtu\t\t%b"},
+ {0x08001800, 0x3e007c01, "bgt\t\t%b"},
+ {0x08002000, 0x3e007c01, "bge\t\t%b"},
+ {0x08000801, 0x3e007c01, "bgtul\t\t%b"},
+ {0x08001801, 0x3e007c01, "bgtl\t\t%b"},
+ {0x08002001, 0x3e007c01, "bgel\t\t%b"},
+ {0x00004200, 0x00007f00, "bgtu!\t\t%b"},
+ {0x00004600, 0x00007f00, "bgt!\t\t%b"},
+ {0x00004800, 0x00007f00, "bge!\t\t%b"},
+ {0x00000029, 0x3e0003ff, "bitclr.c\t%20-24r, %15-19r, 0x%10-14x"},
+ {0x0000002b, 0x3e0003ff, "bitset.c\t%20-24r, %15-19r, 0x%10-14x"},
+ {0x0000002d, 0x3e0003ff, "bittst.c\t%15-19r, 0x%10-14x"},
+ {0x0000002f, 0x3e0003ff, "bittgl.c\t%20-24r, %15-19r, 0x%10-14x"},
+ {0x00006004, 0x00007007, "bitclr!\t\t%8-11r, 0x%3-7x"},
+ {0x3800000c, 0x3e0003ff, "bitrev\t\t%20-24r, %15-19r,%10-14r"},
+ {0x00006005, 0x00007007, "bitset!\t\t%8-11r, 0x%3-7x"},
+ {0x00006006, 0x00007007, "bittst!\t\t%8-11r, 0x%3-7x"},
+ {0x00006007, 0x00007007, "bittgl!\t\t%8-11r, 0x%3-7x"},
+ {0x08000c00, 0x3e007c01, "bleu\t\t%b"},
+ {0x08001c00, 0x3e007c01, "ble\t\t%b"},
+ {0x08002400, 0x3e007c01, "blt\t\t%b"},
+ {0x08000c01, 0x3e007c01, "bleul\t\t%b"},
+ {0x08001c01, 0x3e007c01, "blel\t\t%b"},
+ {0x08002401, 0x3e007c01, "bltl\t\t%b"},
+ {0x08003c01, 0x3e007c01, "bl\t\t%b"},
+ {0x00004300, 0x00007f00, "bleu!\t\t%b"},
+ {0x00004700, 0x00007f00, "ble!\t\t%b"},
+ {0x00004900, 0x00007f00, "blt!\t\t%b"},
+ {0x08002800, 0x3e007c01, "bmi\t\t%b"},
+ {0x08002801, 0x3e007c01, "bmil\t\t%b"},
+ {0x00004a00, 0x00007f00, "bmi!\t\t%b"},
+ {0x08001400, 0x3e007c01, "bne\t\t%b"},
+ {0x08001401, 0x3e007c01, "bnel\t\t%b"},
+ {0x00004500, 0x00007f00, "bne!\t\t%b"},
+ {0x08002c00, 0x3e007c01, "bpl\t\t%b"},
+ {0x08002c01, 0x3e007c01, "bpll\t\t%b"},
+ {0x00004b00, 0x00007f00, "bpl!\t\t%b"},
+ {0x00000008, 0x3e007fff, "brcs\t\t%15-19r"},
+ {0x00000408, 0x3e007fff, "brcc\t\t%15-19r"},
+ {0x00000808, 0x3e007fff, "brgtu\t\t%15-19r"},
+ {0x00000c08, 0x3e007fff, "brleu\t\t%15-19r"},
+ {0x00001008, 0x3e007fff, "breq\t\t%15-19r"},
+ {0x00001408, 0x3e007fff, "brne\t\t%15-19r"},
+ {0x00001808, 0x3e007fff, "brgt\t\t%15-19r"},
+ {0x00001c08, 0x3e007fff, "brle\t\t%15-19r"},
+ {0x00002008, 0x3e007fff, "brge\t\t%15-19r"},
+ {0x00002408, 0x3e007fff, "brlt\t\t%15-19r"},
+ {0x00002808, 0x3e007fff, "brmi\t\t%15-19r"},
+ {0x00002c08, 0x3e007fff, "brpl\t\t%15-19r"},
+ {0x00003008, 0x3e007fff, "brvs\t\t%15-19r"},
+ {0x00003408, 0x3e007fff, "brvc\t\t%15-19r"},
+ {0x00003808, 0x3e007fff, "brcnz\t\t%15-19r"},
+ {0x00003c08, 0x3e007fff, "br\t\t%15-19r"},
+ {0x00000009, 0x3e007fff, "brcsl\t\t%15-19r"},
+ {0x00000409, 0x3e007fff, "brccl\t\t%15-19r"},
+ {0x00000809, 0x3e007fff, "brgtul\t\t%15-19r"},
+ {0x00000c09, 0x3e007fff, "brleul\t\t%15-19r"},
+ {0x00001009, 0x3e007fff, "breql\t\t%15-19r"},
+ {0x00001409, 0x3e007fff, "brnel\t\t%15-19r"},
+ {0x00001809, 0x3e007fff, "brgtl\t\t%15-19r"},
+ {0x00001c09, 0x3e007fff, "brlel\t\t%15-19r"},
+ {0x00002009, 0x3e007fff, "brgel\t\t%15-19r"},
+ {0x00002409, 0x3e007fff, "brltl\t\t%15-19r"},
+ {0x00002809, 0x3e007fff, "brmil\t\t%15-19r"},
+ {0x00002c09, 0x3e007fff, "brpll\t\t%15-19r"},
+ {0x00003009, 0x3e007fff, "brvsl\t\t%15-19r"},
+ {0x00003409, 0x3e007fff, "brvcl\t\t%15-19r"},
+ {0x00003809, 0x3e007fff, "brcnzl\t\t%15-19r"},
+ {0x00003c09, 0x3e007fff, "brl\t\t%15-19r"},
+ {0x00000004, 0x00007f0f, "brcs!\t\t%4-7r"},
+ {0x00000104, 0x00007f0f, "brcc!\t\t%4-7r"},
+ {0x00000204, 0x00007f0f, "brgtu!\t\t%4-7r"},
+ {0x00000304, 0x00007f0f, "brleu!\t\t%4-7r"},
+ {0x00000404, 0x00007f0f, "breq!\t\t%4-7r"},
+ {0x00000504, 0x00007f0f, "brne!\t\t%4-7r"},
+ {0x00000604, 0x00007f0f, "brgt!\t\t%4-7r"},
+ {0x00000704, 0x00007f0f, "brle!\t\t%4-7r"},
+ {0x00000804, 0x00007f0f, "brge!\t\t%4-7r"},
+ {0x00000904, 0x00007f0f, "brlt!\t\t%4-7r"},
+ {0x00000a04, 0x00007f0f, "brmi!\t\t%4-7r"},
+ {0x00000b04, 0x00007f0f, "brpl!\t\t%4-7r"},
+ {0x00000c04, 0x00007f0f, "brvs!\t\t%4-7r"},
+ {0x00000d04, 0x00007f0f, "brvc!\t\t%4-7r"},
+ {0x00000e04, 0x00007f0f, "brcnz!\t\t%4-7r"},
+ {0x00000f04, 0x00007f0f, "br!\t\t%4-7r"},
+ {0x0000000c, 0x00007f0f, "brcsl!\t\t%4-7r"},
+ {0x0000010c, 0x00007f0f, "brccl!\t\t%4-7r"},
+ {0x0000020c, 0x00007f0f, "brgtul!\t\t%4-7r"},
+ {0x0000030c, 0x00007f0f, "brleul!\t\t%4-7r"},
+ {0x0000040c, 0x00007f0f, "breql!\t\t%4-7r"},
+ {0x0000050c, 0x00007f0f, "brnel!\t\t%4-7r"},
+ {0x0000060c, 0x00007f0f, "brgtl!\t\t%4-7r"},
+ {0x0000070c, 0x00007f0f, "brlel!\t\t%4-7r"},
+ {0x0000080c, 0x00007f0f, "brgel!\t\t%4-7r"},
+ {0x0000090c, 0x00007f0f, "brltl!\t\t%4-7r"},
+ {0x00000a0c, 0x00007f0f, "brmil!\t\t%4-7r"},
+ {0x00000b0c, 0x00007f0f, "brpll!\t\t%4-7r"},
+ {0x00000c0c, 0x00007f0f, "brvsl!\t\t%4-7r"},
+ {0x00000d0c, 0x00007f0f, "brvcl!\t\t%4-7r"},
+ {0x00000e0c, 0x00007f0f, "brcnzl!\t\t%4-7r"},
+ {0x00000f0c, 0x00007f0f, "brl!\t\t%4-7r"},
+ {0x08003000, 0x3e007c01, "bvs\t\t%b"},
+ {0x08003400, 0x3e007c01, "bvc\t\t%b"},
+ {0x08003001, 0x3e007c01, "bvsl\t\t%b"},
+ {0x08003401, 0x3e007c01, "bvcl\t\t%b"},
+ {0x00004c00, 0x00007f00, "bvs!\t\t%b"},
+ {0x00004d00, 0x00007f00, "bvc!\t\t%b"},
+ {0x00004f00, 0x00007f00, "b!\t\t%b"},
+ {0x08003c00, 0x3e007c01, "b\t\t%b"},
+ {0x30000000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30100000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30200000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30300000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30400000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30800000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30900000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30a00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30b00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30c00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30d00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x30e00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x31000000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x31100000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x31800000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x31a00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x31b00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x31c00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x31d00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x31e00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x31f00000, 0x3ff00000, "cache\t\t%20-24d, [%15-19r, %0-14i]"},
+ {0x38000000, 0x3ff003ff, "mad\t\t%15-19r, %10-14r"},
+ {0x38000020, 0x3ff003ff, "madu\t\t%15-19r, %10-14r"},
+ {0x38000080, 0x3ff003ff, "mad.f\t\t%15-19r, %10-14r"},
+ {0x38000001, 0x3ff003ff, "msb\t\t%15-19r, %10-14r"},
+ {0x38000021, 0x3ff003ff, "msbu\t\t%15-19r, %10-14r"},
+ {0x38000081, 0x3ff003ff, "msb.f\t\t%15-19r, %10-14r"},
+ {0x38000102, 0x3ff003ff, "mazl\t\t%15-19r, %10-14r"},
+ {0x38000182, 0x3ff003ff, "mazl.f\t\t%15-19r, %10-14r"},
+ {0x38000002, 0x3ff003ff, "madl\t\t%15-19r, %10-14r"},
+ {0x380000c2, 0x3ff003ff, "madl.fs\t\t%15-19r, %10-14r"},
+ {0x38000303, 0x3ff003ff, "mazh\t\t%15-19r, %10-14r"},
+ {0x38000383, 0x3ff003ff, "mazh.f\t\t%15-19r, %10-14r"},
+ {0x38000203, 0x3ff003ff, "madh\t\t%15-19r, %10-14r"},
+ {0x380002c3, 0x3ff003ff, "madh.fs\t\t%15-19r, %10-14r"},
+ {0x38000007, 0x3e0003ff, "max\t\t%20-24r, %15-19r, %10-14r"},
+ {0x38000006, 0x3e0003ff, "min\t\t%20-24r, %15-19r, %10-14r"},
+ {0x38000104, 0x3ff003ff, "mszl\t\t%15-19r, %10-14r"},
+ {0x38000184, 0x3ff003ff, "mszl.f\t\t%15-19r, %10-14r"},
+ {0x38000004, 0x3ff003ff, "msbl\t\t%15-19r, %10-14r"},
+ {0x380000c4, 0x3ff003ff, "msbl.fs\t\t%15-19r, %10-14r"},
+ {0x38000305, 0x3ff003ff, "mszh\t\t%15-19r, %10-14r"},
+ {0x38000385, 0x3ff003ff, "mszh.f\t\t%15-19r, %10-14r"},
+ {0x38000205, 0x3ff003ff, "msbh\t\t%15-19r, %10-14r"},
+ {0x380002c5, 0x3ff003ff, "msbh.fs\t\t%15-19r, %10-14r"},
+ {0x3800004e, 0x3e0003ff, "sll.s\t\t%20-24r, %15-19r, %10-14r"},
+ {0x38000049, 0x3e0003ff, "sub.s\t\t%20-24r, %15-19r, %10-14r"},
+ {0x3800000d, 0x3e007fff, "clz\t\t%20-24r, %15-19r"},
+ {0x38000000, 0x3e000000, "ceinst\t\t%20-24d, %15-19r, %10-14r, %5-9d, %0-4d"},
+ {0x00000019, 0x3ff003ff, "cmpteq.c\t\t%15-19r, %10-14r"},
+ {0x00100019, 0x3ff003ff, "cmptmi.c\t\t%15-19r, %10-14r"},
+ {0x00300019, 0x3ff003ff, "cmp.c\t\t%15-19r, %10-14r"},
+ {0x0000001b, 0x3ff07fff, "cmpzteq.c\t%15-19r"},
+ {0x0010001b, 0x3ff07fff, "cmpztmi.c\t%15-19r"},
+ {0x0030001b, 0x3ff07fff, "cmpz.c\t\t%15-19r"},
+ {0x02040001, 0x3e0e0001, "cmpi.c\t\t%20-24r, %1-16i"},
+ {0x00002003, 0x0000700f, "cmp!\t\t%8-11r, %4-7r"},
+ {0x0c00000c, 0x3e00001f, "cop1\t\tc%20-24r, c%15-19r, c%10-14r, %5-9d"},
+ {0x0c000014, 0x3e00001f, "cop2\t\tc%20-24r, c%15-19r, c%10-14r, %5-9d"},
+ {0x0c00001c, 0x3e00001f, "cop3\t\tc%20-24r, c%15-19r, c%10-14r, %5-9d"},
+ {0x00000044, 0x3e0003ff, "div\t\t%15-19r, %10-14r"},
+ {0x00000046, 0x3e0003ff, "divu\t\t%15-19r, %10-14r"},
+ {0x0c0000a4, 0x3e0003ff, "drte"},
+ {0x00000058, 0x3e0003ff, "extsb\t\t%20-24r, %15-19r"},
+ {0x00000059, 0x3e0003ff, "extsb.c\t\t%20-24r, %15-19r"},
+ {0x0000005a, 0x3e0003ff, "extsh\t\t%20-24r, %15-19r"},
+ {0x0000005b, 0x3e0003ff, "extsh.c\t\t%20-24r, %15-19r"},
+ {0x0000005c, 0x3e0003ff, "extzb\t\t%20-24r, %15-19r"},
+ {0x0000005d, 0x3e0003ff, "extzb.c\t\t%20-24r, %15-19r"},
+ {0x0000005e, 0x3e0003ff, "extzh\t\t%20-24r, %15-19r"},
+ {0x0000005f, 0x3e0003ff, "extzh.c\t\t%20-24r, %15-19r"},
+ {0x04000001, 0x3e000001, "jl\t\t%j"},
+ {0x00003001, 0x00007001, "jl!\t\t%j"},
+ {0x00003000, 0x00007001, "j!\t\t%j"},
+ {0x04000000, 0x3e000001, "j\t\t%j"},
+ {0x26000000, 0x3e000000, "lb\t\t%20-24r, [%15-19r, %0-14i]"},
+ {0x2c000000, 0x3e000000, "lbu\t\t%20-24r, [%15-19r, %0-14i]"},
+ {0x06000003, 0x3e000007, "lb\t\t%20-24r, [%15-19r, %3-14i]+"},
+ {0x06000006, 0x3e000007, "lbu\t\t%20-24r, [%15-19r, %3-14i]+"},
+ {0x0e000003, 0x3e000007, "lb\t\t%20-24r, [%15-19r]+, %3-14i"},
+ {0x0e000006, 0x3e000007, "lbu\t\t%20-24r, [%15-19r]+, %3-14i"},
+ {0x0000200b, 0x0000700f, "lbu!\t\t%8-11r, [%4-7r]"},
+ {0x00007003, 0x00007007, "lbup!\t\t%8-11r, %3-7d"},
+ {0x00000060, 0x3e0003ff, "lcb\t\t[%15-19r]+"},
+ {0x00000062, 0x3e0003ff, "lcw\t\t%20-24r, [%15-19r]+"},
+ {0x00000066, 0x3e0003ff, "lce\t\t%20-24r, [%15-19r]+"},
+ {0x0c00000a, 0x3e00001f, "ldc1\t\tc%15-19r, [%20-24r, %5-14i]"},
+ {0x0c000012, 0x3e00001f, "ldc2\t\tc%15-19r, [%20-24r, %5-14i]"},
+ {0x0c00001a, 0x3e00001f, "ldc3\t\tc%15-19r, [%20-24r, %5-14i]"},
+ {0x22000000, 0x3e000000, "lh\t\t%20-24r, [%15-19r, %0-14i]"},
+ {0x24000000, 0x3e000000, "lhu\t\t%20-24r, [%15-19r, %0-14i]"},
+ {0x06000001, 0x3e000007, "lh\t\t%20-24r, [%15-19r, %3-14i]+"},
+ {0x06000002, 0x3e000007, "lhu\t\t%20-24r, [%15-19r, %3-14i]+"},
+ {0x0e000001, 0x3e000007, "lh\t\t%20-24r, [%15-19r]+, %3-14i"},
+ {0x0e000002, 0x3e000007, "lhu\t\t%20-24r, [%15-19r]+, %3-14i"},
+ {0x00002009, 0x0000700f, "lh!\t\t%8-11r, [%4-7r]"},
+ {0x00007001, 0x00007007, "lhp!\t\t%8-11r, %3-7d1"},
+ {0x020c0000, 0x3e0e0000, "ldi\t\t%20-24r, 0x%1-16x(%1-16i)"},
+ {0x0a0c0000, 0x3e0e0000, "ldis\t\t%20-24r, 0x%1-16x(%1-16i)"},
+ {0x00005000, 0x00007000, "ldiu!\t\t%8-11r, %0-7d"},
+ {0x0000000c, 0x3e0003ff, "alw\t\t%20-24r, [%15-19r]"},
+ {0x20000000, 0x3e000000, "lw\t\t%20-24r, [%15-19r, %0-14i]"},
+ {0x06000000, 0x3e000007, "lw\t\t%20-24r, [%15-19r, %3-14i]+"},
+ {0x0e000000, 0x3e000007, "lw\t\t%20-24r, [%15-19r]+, %3-14i"},
+ {0x00002008, 0x0000700f, "lw!\t\t%8-11r, [%4-7r]"},
+ {0x00007000, 0x00007007, "lwp!\t\t%8-11r, %3-7d2"},
+ {0x0000100b, 0x0000700f, "madh.fs!\t\t%8-11r, %4-7r"},
+ {0x0000100a, 0x0000700f, "madl.fs!\t\t%8-11r, %4-7r"},
+ {0x00001005, 0x0000700f, "madu!\t\t%8-11r, %4-7r"},
+ {0x00001004, 0x0000700f, "mad.f!\t\t%8-11r, %4-7r"},
+ {0x00001009, 0x0000700f, "mazh.f!\t\t%8-11r, %4-7r"},
+ {0x00001008, 0x0000700f, "mazl.f!\t\t%8-11r, %4-7r"},
+ {0x00000448, 0x3e007fff, "mfcel\t\t%20-24r"},
+ {0x00001001, 0x00007f0f, "mfcel!\t\t%4-7r"},
+ {0x00000848, 0x3e007fff, "mfceh\t\t%20-24r"},
+ {0x00001101, 0x00007f0f, "mfceh!\t\t%4-7r"},
+ {0x00000c48, 0x3e007fff, "mfcehl\t\t%20-24r, %15-19r"},
+ {0x00000048, 0x3e0003ff, "mfce\t\t%20-24r, er%10-14d"},
+ {0x00000050, 0x3e0003ff, "mfsr\t\t%20-24r, sr%10-14d"},
+ {0x0c000001, 0x3e00001f, "mfcr\t\t%20-24r, c%15-19r"},
+ {0x0c000009, 0x3e00001f, "mfc1\t\t%20-24r, c%15-19r"},
+ {0x0c000011, 0x3e00001f, "mfc2\t\t%20-24r, c%15-19r"},
+ {0x0c000019, 0x3e00001f, "mfc3\t\t%20-24r, c%15-19r"},
+ {0x0c00000f, 0x3e00001f, "mfcc1\t\t%20-24r, c%15-19r"},
+ {0x0c000017, 0x3e00001f, "mfcc2\t\t%20-24r, c%15-19r"},
+ {0x0c00001f, 0x3e00001f, "mfcc3\t\t%20-24r, c%15-19r"},
+ {0x00000002, 0x0000700f, "mhfl!\t\t%8-11R, %4-7r"},
+ {0x00000001, 0x0000700f, "mlfh!\t\t%8-11r, %4-7R"},
+ {0x00001006, 0x0000700f, "msb.f!\t\t%8-11r, %4-7r"},
+ {0x0000100f, 0x0000700f, "msbh.fs!\t\t%8-11r, %4-7r"},
+ {0x0000100e, 0x0000700f, "msbl.fs!\t\t%8-11r, %4-7r"},
+ {0x00001007, 0x0000700f, "msbu!\t\t%8-11r, %4-7r"},
+ {0x0000100d, 0x0000700f, "mszh.f!\t\t%8-11r, %4-7r"},
+ {0x0000100c, 0x0000700f, "mszl.f!\t\t%8-11r, %4-7r"},
+ {0x0000044a, 0x3e007fff, "mtcel\t\t%20-24r"},
+ {0x00001000, 0x00007f0f, "mtcel!\t\t%4-7r"},
+ {0x0000084a, 0x3e007fff, "mtceh\t\t%20-24r"},
+ {0x00001100, 0x00007f0f, "mtceh!\t\t%4-7r"},
+ {0x00000c4a, 0x3e007fff, "mtcehl\t\t%20-24r, %15-19r"},
+ {0x0000004a, 0x3e0003ff, "mtce\t\t%20-24r, er%10-14d"},
+ {0x00000052, 0x3e0003ff, "mtsr\t\t%15-19r, sr%10-14d"},
+ {0x0c000000, 0x3e00001f, "mtcr\t\t%20-24r, c%15-19r"},
+ {0x0c000008, 0x3e00001f, "mtc1\t\t%20-24r, c%15-19r"},
+ {0x0c000010, 0x3e00001f, "mtc2\t\t%20-24r, c%15-19r"},
+ {0x0c000018, 0x3e00001f, "mtc3\t\t%20-24r, c%15-19r"},
+ {0x0c00000e, 0x3e00001f, "mtcc1\t\t%20-24r, c%15-19r"},
+ {0x0c000016, 0x3e00001f, "mtcc2\t\t%20-24r, c%15-19r"},
+ {0x0c00001e, 0x3e00001f, "mtcc3\t\t%20-24r, c%15-19r"},
+ {0x00000040, 0x3e0003ff, "mul\t\t%15-19r, %10-14r"},
+ {0x00000040, 0x3e0003ff, "maz\t\t%15-19r, %10-14r"},
+ {0x00000041, 0x3e0003ff, "mul.f\t\t%15-19r, %10-14r"},
+ {0x00000041, 0x3e0003ff, "maz.f\t\t%15-19r, %10-14r"},
+ {0x00001002, 0x0000700f, "mul.f!\t\t%8-11r, %4-7r"},
+ {0x00000042, 0x3e0003ff, "mulu\t\t%15-19r, %10-14r"},
+ {0x00000042, 0x3e0003ff, "mazu\t\t%15-19r, %10-14r"},
+ {0x00001003, 0x0000700f, "mulu!\t\t%8-11r, %4-7r"},
+ {0x00000056, 0x3e007fff, "mvcs\t\t%20-24r, %15-19r"},
+ {0x00000456, 0x3e007fff, "mvcc\t\t%20-24r, %15-19r"},
+ {0x00000856, 0x3e007fff, "mvgtu\t\t%20-24r, %15-19r"},
+ {0x00000c56, 0x3e007fff, "mvleu\t\t%20-24r, %15-19r"},
+ {0x00001056, 0x3e007fff, "mveq\t\t%20-24r, %15-19r"},
+ {0x00001456, 0x3e007fff, "mvne\t\t%20-24r, %15-19r"},
+ {0x00001856, 0x3e007fff, "mvgt\t\t%20-24r, %15-19r"},
+ {0x00001c56, 0x3e007fff, "mvle\t\t%20-24r, %15-19r"},
+ {0x00002056, 0x3e007fff, "mvge\t\t%20-24r, %15-19r"},
+ {0x00002456, 0x3e007fff, "mvlt\t\t%20-24r, %15-19r"},
+ {0x00002856, 0x3e007fff, "mvmi\t\t%20-24r, %15-19r"},
+ {0x00002c56, 0x3e007fff, "mvpl\t\t%20-24r, %15-19r"},
+ {0x00003056, 0x3e007fff, "mvvs\t\t%20-24r, %15-19r"},
+ {0x00003456, 0x3e007fff, "mvvc\t\t%20-24r, %15-19r"},
+ {0x00003c56, 0x3e007fff, "mv\t\t%20-24r, %15-19r"},
+ {0x00000003, 0x0000700f, "mv!\t\t%8-11r, %4-7r"},
+ {0x0000001e, 0x3e0003ff, "neg\t\t%20-24r, %10-14r"},
+ {0x0000001f, 0x3e0003ff, "neg.c\t\t%20-24r, %10-14r"},
+ {0x00002002, 0x0000700f, "neg!\t\t%8-11r, %4-7r"},
+ {0x00000000, 0x3e0003ff, "nop"},
+ {0x00000024, 0x3e0003ff, "not\t\t%20-24r, %15-19r"},
+ {0x00000025, 0x3e0003ff, "not.c\t\t%20-24r, %15-19r"},
+ {0x00000000, 0x0000700f, "nop!"},
+ {0x00002006, 0x0000700f, "not!\t\t%8-11r, %4-7r"},
+ {0x00000022, 0x3e0003ff, "or\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000023, 0x3e0003ff, "or.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x020a0000, 0x3e0e0001, "ori\t\t%20-24r, 0x%1-16x"},
+ {0x020a0001, 0x3e0e0001, "ori.c\t\t%20-24r, 0x%1-16x"},
+ {0x0a0a0000, 0x3e0e0001, "oris\t\t%20-24r, 0x%1-16x"},
+ {0x0a0a0001, 0x3e0e0001, "oris.c\t\t%20-24r, 0x%1-16x"},
+ {0x1a000000, 0x3e000001, "orri\t\t%20-24r, %15-19r, 0x%1-14x"},
+ {0x1a000001, 0x3e000001, "orri.c\t\t%20-24r, %15-19r, 0x%1-14x"},
+ {0x00002005, 0x0000700f, "or!\t\t%8-11r, %4-7r"},
+ {0x0000000a, 0x3e0003ff, "pflush"},
+ {0x0000208a, 0x0000708f, "pop!\t\t%8-11R, [%4-6r]"},
+ {0x0000200a, 0x0000700f, "pop!\t\t%8-11r, [%4-7r]"},
+ {0x0000208e, 0x0000708f, "push!\t\t%8-11R, [%4-6r]"},
+ {0x0000200e, 0x0000700f, "push!\t\t%8-11r, [%4-7r]"},
+ {0x00000038, 0x3e0003ff, "ror\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000039, 0x3e0003ff, "ror.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x0000003b, 0x3e0003ff, "rorc.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x0000003c, 0x3e0003ff, "rol\t\t%20-24r, %15-19r, %10-14r"},
+ {0x0000003d, 0x3e0003ff, "rol.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x0000003f, 0x3e0003ff, "rolc.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000078, 0x3e0003ff, "rori\t\t%20-24r, %15-19r, %10-14d"},
+ {0x00000079, 0x3e0003ff, "rori.c\t\t%20-24r, %15-19r, %10-14d"},
+ {0x0000007b, 0x3e0003ff, "roric.c\t\t%20-24r, %15-19r, %10-14d"},
+ {0x0000007c, 0x3e0003ff, "roli\t\t%20-24r, %15-19r, %10-14d"},
+ {0x0000007d, 0x3e0003ff, "roli.c\t\t%20-24r, %15-19r, %10-14d"},
+ {0x0000007f, 0x3e0003ff, "rolic.c\t\t%20-24r, %15-19r, %10-14d"},
+ {0x0c000084, 0x3e0003ff, "rte"},
+ {0x2e000000, 0x3e000000, "sb\t\t%20-24r, [%15-19r, %0-14i]"},
+ {0x06000007, 0x3e000007, "sb\t\t%20-24r, [%15-19r, %3-14i]+"},
+ {0x0e000007, 0x3e000007, "sb\t\t%20-24r, [%15-19r]+, %3-14i"},
+ {0x0000200f, 0x0000700f, "sb!\t\t%8-11r, [%4-7r]"},
+ {0x00007007, 0x00007007, "sbp!\t\t%8-11r, %3-7d"},
+ {0x0000000e, 0x3e0003ff, "asw\t\t%20-24r, [%15-19r]"},
+ {0x00000068, 0x3e0003ff, "scb\t\t%20-24r, [%15-19r]+"},
+ {0x0000006a, 0x3e0003ff, "scw\t\t%20-24r, [%15-19r]+"},
+ {0x0000006e, 0x3e0003ff, "sce\t\t[%15-19r]+"},
+ {0x00000006, 0x3e0003ff, "sdbbp\t\t%15-19d"},
+ {0x00006002, 0x00007007, "sdbbp!\t\t%3-7d"},
+ {0x2a000000, 0x3e000000, "sh\t\t%20-24r, [%15-19r, %0-14i]"},
+ {0x06000005, 0x3e000007, "sh\t\t%20-24r, [%15-19r, %3-14i]+"},
+ {0x0e000005, 0x3e000007, "sh\t\t%20-24r, [%15-19r]+, %3-14i"},
+ {0x0000200d, 0x0000700f, "sh!\t\t%8-11r, [%4-7r]"},
+ {0x00007005, 0x00007007, "shp!\t\t%8-11r, %3-7d1"},
+ {0x0c0000c4, 0x3e0003ff, "sleep"},
+ {0x00000030, 0x3e0003ff, "sll\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000031, 0x3e0003ff, "sll.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000070, 0x3e0003ff, "slli\t\t%20-24r, %15-19r, %10-14d"},
+ {0x00000071, 0x3e0003ff, "slli.c\t\t%20-24r, %15-19r, %10-14d"},
+ {0x00000008, 0x0000700f, "sll!\t\t%8-11r, %4-7r"},
+ {0x00006001, 0x00007007, "slli!\t\t%8-11r, %3-7d"},
+ {0x00000034, 0x3e0003ff, "srl\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000035, 0x3e0003ff, "srl.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000036, 0x3e0003ff, "sra\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000037, 0x3e0003ff, "sra.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000074, 0x3e0003ff, "srli\t\t%20-24r, %15-19r, %10-14d"},
+ {0x00000075, 0x3e0003ff, "srli.c\t\t%20-24r, %15-19r, %10-14d"},
+ {0x00000076, 0x3e0003ff, "srai\t\t%20-24r, %15-19r, %10-14d"},
+ {0x00000077, 0x3e0003ff, "srai.c\t\t%20-24r, %15-19r, %10-14d"},
+ {0x0000000a, 0x0000700f, "srl!\t\t%8-11r, %4-7r"},
+ {0x00006003, 0x00007007, "srli!\t\t%8-11r, %3-7d"},
+ {0x0000000b, 0x0000700f, "sra!\t\t%8-11r, %4-7r"},
+ {0x0c00000b, 0x3e00001f, "stc1\t\tc%15-19r, [%20-24r, %5-14i]"},
+ {0x0c000013, 0x3e00001f, "stc2\t\tc%15-19r, [%20-24r, %5-14i]"},
+ {0x0c00001b, 0x3e00001f, "stc3\t\tc%15-19r, [%20-24r, %5-14i]"},
+ {0x00000014, 0x3e0003ff, "sub\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000015, 0x3e0003ff, "sub.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000016, 0x3e0003ff, "subc\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000017, 0x3e0003ff, "subc.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00002001, 0x0000700f, "sub!\t\t%8-11r, %4-7r"},
+ {0x00006080, 0x00007087, "subei!\t\t%8-11r, %3-6d"},
+ {0x28000000, 0x3e000000, "sw\t\t%20-24r, [%15-19r, %0-14i]"},
+ {0x06000004, 0x3e000007, "sw\t\t%20-24r, [%15-19r, %3-14i]+"},
+ {0x0e000004, 0x3e000007, "sw\t\t%20-24r, [%15-19r]+, %3-14i"},
+ {0x0000200c, 0x0000700f, "sw!\t\t%8-11r, [%4-7r]"},
+ {0x00007004, 0x00007007, "swp!\t\t%8-11r, %3-7d2"},
+ {0x00000002, 0x3e0003ff, "syscall\t\t%10-24d"},
+ {0x00000054, 0x3e007fff, "tcs"},
+ {0x00000454, 0x3e007fff, "tcc"},
+ {0x00003854, 0x3e007fff, "tcnz"},
+ {0x00000005, 0x00007f0f, "tcs!"},
+ {0x00000105, 0x00007f0f, "tcc!"},
+ {0x00000e05, 0x00007f0f, "tcnz!"},
+ {0x00001054, 0x3e007fff, "teq"},
+ {0x00000405, 0x00007f0f, "teq!"},
+ {0x00000854, 0x3e007fff, "tgtu"},
+ {0x00001854, 0x3e007fff, "tgt"},
+ {0x00002054, 0x3e007fff, "tge"},
+ {0x00000205, 0x00007f0f, "tgtu!"},
+ {0x00000605, 0x00007f0f, "tgt!"},
+ {0x00000805, 0x00007f0f, "tge!"},
+ {0x00000c54, 0x3e007fff, "tleu"},
+ {0x00001c54, 0x3e007fff, "tle"},
+ {0x00002454, 0x3e007fff, "tlt"},
+ {0x0c000004, 0x3e0003ff, "stlb"},
+ {0x0c000024, 0x3e0003ff, "mftlb"},
+ {0x0c000044, 0x3e0003ff, "mtptlb"},
+ {0x0c000064, 0x3e0003ff, "mtrtlb"},
+ {0x00000305, 0x00007f0f, "tleu!"},
+ {0x00000705, 0x00007f0f, "tle!"},
+ {0x00000905, 0x00007f0f, "tlt!"},
+ {0x00002854, 0x3e007fff, "tmi"},
+ {0x00000a05, 0x00007f0f, "tmi!"},
+ {0x00001454, 0x3e007fff, "tne"},
+ {0x00000505, 0x00007f0f, "tne!"},
+ {0x00002c54, 0x3e007fff, "tpl"},
+ {0x00000b05, 0x00007f0f, "tpl!"},
+ {0x00000004, 0x3e007fff, "trapcs\t\t%15-19d"},
+ {0x00000404, 0x3e007fff, "trapcc\t\t%15-19d"},
+ {0x00000804, 0x3e007fff, "trapgtu\t\t%15-19d"},
+ {0x00000c04, 0x3e007fff, "trapleu\t\t%15-19d"},
+ {0x00001004, 0x3e007fff, "trapeq\t\t%15-19d"},
+ {0x00001404, 0x3e007fff, "trapne\t\t%15-19d"},
+ {0x00001804, 0x3e007fff, "trapgt\t\t%15-19d"},
+ {0x00001c04, 0x3e007fff, "traple\t\t%15-19d"},
+ {0x00002004, 0x3e007fff, "trapge\t\t%15-19d"},
+ {0x00002404, 0x3e007fff, "traplt\t\t%15-19d"},
+ {0x00002804, 0x3e007fff, "trapmi\t\t%15-19d"},
+ {0x00002c04, 0x3e007fff, "trappl\t\t%15-19d"},
+ {0x00003004, 0x3e007fff, "trapvs\t\t%15-19d"},
+ {0x00003404, 0x3e007fff, "trapvc\t\t%15-19d"},
+ {0x00003c04, 0x3e007fff, "trap\t\t%15-19d"},
+ {0x00003c54, 0x3e007fff, "tset"},
+ {0x00000f05, 0x00007f0f, "tset!"},
+ {0x00003054, 0x3e007fff, "tvs"},
+ {0x00003454, 0x3e007fff, "tvc"},
+ {0x00000c05, 0x00007f0f, "tvs!"},
+ {0x00000d05, 0x00007f0f, "tvc!"},
+ {0x00000026, 0x3e0003ff, "xor\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00000027, 0x3e0003ff, "xor.c\t\t%20-24r, %15-19r, %10-14r"},
+ {0x00002007, 0x0000700f, "xor!\t\t%8-11r, %4-7r"}
+};
+
+typedef struct
+{
+ const char *name;
+ const char *description;
+ const char *reg_names[32];
+} score_regname;
+
+static score_regname regnames[] =
+{
+ {"gcc", "Select register names used by GCC",
+ {"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "r10",
+ "r11", "r12", "r13", "r14", "r15", "r16", "r17", "r18", "r19", "r20",
+ "r21", "r22", "r23", "r24", "r25", "r26", "r27", "gp", "r29", "r30", "r31"}},
+};
+
+static unsigned int regname_selected = 0;
+
+#define NUM_SCORE_REGNAMES NUM_ELEM (regnames)
+#define score_regnames regnames[regname_selected].reg_names
+
+/* s3_s7: opcodes and export prototypes. */
+int
+s7_print_insn (bfd_vma pc, struct disassemble_info *info, bfd_boolean little);
+
+/* Print one instruction from PC on INFO->STREAM.
+ Return the size of the instruction. */
+static int
+print_insn_score32 (bfd_vma pc, struct disassemble_info *info, long given)
+{
+ struct score_opcode *insn;
+ void *stream = info->stream;
+ fprintf_ftype func = info->fprintf_func;
+
+ for (insn = score_opcodes; insn->assembler; insn++)
+ {
+ if ((insn->mask & 0xffff0000) && (given & insn->mask) == insn->value)
+ {
+ char *c;
+
+ for (c = insn->assembler; *c; c++)
+ {
+ if (*c == '%')
+ {
+ switch (*++c)
+ {
+ case 'j':
+ {
+ int target;
+
+ if (info->flags & INSN_HAS_RELOC)
+ pc = 0;
+ target = (pc & 0xfe000000) | (given & 0x01fffffe);
+ (*info->print_address_func) (target, info);
+ }
+ break;
+ case 'b':
+ {
+ /* Sign-extend a 20-bit number. */
+#define SEXT20(x) ((((x) & 0xfffff) ^ (~ 0x7ffff)) + 0x80000)
+ int disp = ((given & 0x01ff8000) >> 5) | (given & 0x3fe);
+ int target = (pc + SEXT20 (disp));
+
+ (*info->print_address_func) (target, info);
+ }
+ break;
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ {
+ int bitstart = *c++ - '0';
+ int bitend = 0;
+
+ while (*c >= '0' && *c <= '9')
+ bitstart = (bitstart * 10) + *c++ - '0';
+
+ switch (*c)
+ {
+ case '-':
+ c++;
+ while (*c >= '0' && *c <= '9')
+ bitend = (bitend * 10) + *c++ - '0';
+
+ if (!bitend)
+ abort ();
+
+ switch (*c)
+ {
+ case 'r':
+ {
+ long reg;
+
+ reg = given >> bitstart;
+ reg &= (2 << (bitend - bitstart)) - 1;
+
+ func (stream, "%s", score_regnames[reg]);
+ }
+ break;
+ case 'd':
+ {
+ long reg;
+
+ reg = given >> bitstart;
+ reg &= (2 << (bitend - bitstart)) - 1;
+
+ func (stream, "%ld", reg);
+ }
+ break;
+ case 'i':
+ {
+ long reg;
+
+ reg = given >> bitstart;
+ reg &= (2 << (bitend - bitstart)) - 1;
+ reg = ((reg ^ (1 << (bitend - bitstart))) -
+ (1 << (bitend - bitstart)));
+
+ if (((given & insn->mask) == 0x0c00000a) /* ldc1 */
+ || ((given & insn->mask) == 0x0c000012) /* ldc2 */
+ || ((given & insn->mask) == 0x0c00001c) /* ldc3 */
+ || ((given & insn->mask) == 0x0c00000b) /* stc1 */
+ || ((given & insn->mask) == 0x0c000013) /* stc2 */
+ || ((given & insn->mask) == 0x0c00001b)) /* stc3 */
+ reg <<= 2;
+
+ func (stream, "%ld", reg);
+ }
+ break;
+ case 'x':
+ {
+ long reg;
+
+ reg = given >> bitstart;
+ reg &= (2 << (bitend - bitstart)) - 1;
+
+ func (stream, "%lx", reg);
+ }
+ break;
+ default:
+ abort ();
+ }
+ break;
+ case '`':
+ c++;
+ if ((given & (1 << bitstart)) == 0)
+ func (stream, "%c", *c);
+ break;
+ case '\'':
+ c++;
+ if ((given & (1 << bitstart)) != 0)
+ func (stream, "%c", *c);
+ break;
+ default:
+ abort ();
+ }
+ break;
+
+ default:
+ abort ();
+ }
+ }
+ }
+ else
+ func (stream, "%c", *c);
+ }
+ return 4;
+ }
+ }
+
+#if (SCORE_SIMULATOR_ACTIVE)
+ func (stream, _("<illegal instruction>"));
+ return 4;
+#endif
+
+ abort ();
+}
+
+static void
+print_insn_parallel_sym (struct disassemble_info *info)
+{
+ void *stream = info->stream;
+ fprintf_ftype func = info->fprintf_func;
+
+ /* 10: 0000 nop!
+ 4 space + 1 colon + 1 space + 1 tab + 8 opcode + 2 space + 1 tab.
+ FIXME: the space number is not accurate. */
+ func (stream, "%s", " ||\n \t \t");
+}
+
+/* Print one instruction from PC on INFO->STREAM.
+ Return the size of the instruction. */
+static int
+print_insn_score16 (bfd_vma pc, struct disassemble_info *info, long given)
+{
+ struct score_opcode *insn;
+ void *stream = info->stream;
+ fprintf_ftype func = info->fprintf_func;
+
+ given &= 0xffff;
+ for (insn = score_opcodes; insn->assembler; insn++)
+ {
+ if (!(insn->mask & 0xffff0000) && (given & insn->mask) == insn->value)
+ {
+ char *c = insn->assembler;
+
+ info->bytes_per_chunk = 2;
+ info->bytes_per_line = 4;
+ given &= 0xffff;
+
+ for (; *c; c++)
+ {
+ if (*c == '%')
+ {
+ switch (*++c)
+ {
+
+ case 'j':
+ {
+ int target;
+
+ if (info->flags & INSN_HAS_RELOC)
+ pc = 0;
+
+ target = (pc & 0xfffff000) | (given & 0x00000ffe);
+ (*info->print_address_func) (target, info);
+ }
+ break;
+ case 'b':
+ {
+ /* Sign-extend a 9-bit number. */
+#define SEXT9(x) ((((x) & 0x1ff) ^ (~ 0xff)) + 0x100)
+ int disp = (given & 0xff) << 1;
+ int target = (pc + SEXT9 (disp));
+
+ (*info->print_address_func) (target, info);
+ }
+ break;
+
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ {
+ int bitstart = *c++ - '0';
+ int bitend = 0;
+
+ while (*c >= '0' && *c <= '9')
+ bitstart = (bitstart * 10) + *c++ - '0';
+
+ switch (*c)
+ {
+ case '-':
+ {
+ long reg;
+
+ c++;
+ while (*c >= '0' && *c <= '9')
+ bitend = (bitend * 10) + *c++ - '0';
+ if (!bitend)
+ abort ();
+ reg = given >> bitstart;
+ reg &= (2 << (bitend - bitstart)) - 1;
+ switch (*c)
+ {
+ case 'R':
+ func (stream, "%s", score_regnames[reg + 16]);
+ break;
+ case 'r':
+ func (stream, "%s", score_regnames[reg]);
+ break;
+ case 'd':
+ if (*(c + 1) == '\0')
+ func (stream, "%ld", reg);
+ else
+ {
+ c++;
+ if (*c == '1')
+ func (stream, "%ld", reg << 1);
+ else if (*c == '2')
+ func (stream, "%ld", reg << 2);
+ }
+ break;
+
+ case 'x':
+ if (*(c + 1) == '\0')
+ func (stream, "%lx", reg);
+ else
+ {
+ c++;
+ if (*c == '1')
+ func (stream, "%lx", reg << 1);
+ else if (*c == '2')
+ func (stream, "%lx", reg << 2);
+ }
+ break;
+ case 'i':
+ reg = ((reg ^ (1 << bitend)) - (1 << bitend));
+ func (stream, "%ld", reg);
+ break;
+ default:
+ abort ();
+ }
+ }
+ break;
+
+ case '\'':
+ c++;
+ if ((given & (1 << bitstart)) != 0)
+ func (stream, "%c", *c);
+ break;
+ default:
+ abort ();
+ }
+ }
+ break;
+ default:
+ abort ();
+ }
+ }
+ else
+ func (stream, "%c", *c);
+ }
+
+ return 2;
+ }
+ }
+#if (SCORE_SIMULATOR_ACTIVE)
+ func (stream, _("<illegal instruction>"));
+ return 2;
+#endif
+ /* No match. */
+ abort ();
+}
+
+/*****************************************************************************/
+/* s3_s7: exported functions. */
+
+/* NOTE: There are no checks in these routines that
+ the relevant number of data bytes exist. */
+int
+s7_print_insn (bfd_vma pc, struct disassemble_info *info, bfd_boolean little)
+{
+ unsigned char b[4];
+ long given;
+ long ridparity;
+ int status;
+ bfd_boolean insn_pce_p = FALSE;
+ bfd_boolean insn_16_p = FALSE;
+
+ info->display_endian = little ? BFD_ENDIAN_LITTLE : BFD_ENDIAN_BIG;
+
+ if (pc & 0x2)
+ {
+ info->bytes_per_chunk = 2;
+ status = info->read_memory_func (pc, (bfd_byte *) b, 2, info);
+ b[3] = b[2] = 0;
+ insn_16_p = TRUE;
+ }
+ else
+ {
+ info->bytes_per_chunk = 4;
+ status = info->read_memory_func (pc, (bfd_byte *) & b[0], 4, info);
+ if (status != 0)
+ {
+ info->bytes_per_chunk = 2;
+ status = info->read_memory_func (pc, (bfd_byte *) b, 2, info);
+ b[3] = b[2] = 0;
+ insn_16_p = TRUE;
+ }
+ }
+
+ if (status != 0)
+ {
+ info->memory_error_func (status, pc, info);
+ return -1;
+ }
+
+ if (little)
+ {
+ given = (b[0]) | (b[1] << 8) | (b[2] << 16) | (b[3] << 24);
+ }
+ else
+ {
+ given = (b[0] << 24) | (b[1] << 16) | (b[2] << 8) | (b[3]);
+ }
+
+ if ((given & 0x80008000) == 0x80008000)
+ {
+ insn_pce_p = FALSE;
+ insn_16_p = FALSE;
+ }
+ else if ((given & 0x8000) == 0x8000)
+ {
+ insn_pce_p = TRUE;
+ }
+ else
+ {
+ insn_16_p = TRUE;
+ }
+
+ /* 16 bit instruction. */
+ if (insn_16_p)
+ {
+ if (little)
+ {
+ given = b[0] | (b[1] << 8);
+ }
+ else
+ {
+ given = (b[0] << 8) | b[1];
+ }
+
+ status = print_insn_score16 (pc, info, given);
+ }
+ /* pce instruction. */
+ else if (insn_pce_p)
+ {
+ long other;
+
+ other = given & 0xFFFF;
+ given = (given & 0xFFFF0000) >> 16;
+
+ status = print_insn_score16 (pc, info, given);
+ print_insn_parallel_sym (info);
+ status += print_insn_score16 (pc, info, other);
+ /* disassemble_bytes() will output 4 byte per chunk for pce instructio. */
+ info->bytes_per_chunk = 4;
+ }
+ /* 32 bit instruction. */
+ else
+ {
+ /* Get rid of parity. */
+ ridparity = (given & 0x7FFF);
+ ridparity |= (given & 0x7FFF0000) >> 1;
+ given = ridparity;
+ status = print_insn_score32 (pc, info, given);
+ }
+
+ return status;
+}
+
+/*****************************************************************************/