]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gas/config/tc-or1k.c
Update year range in copyright notice of binutils files
[thirdparty/binutils-gdb.git] / gas / config / tc-or1k.c
index e490ffc9e28386a2d951066af06c56a25afca1b6..7e52711344090698edd48dcbfdd439c2a789ec85 100644 (file)
@@ -1,5 +1,5 @@
 /* tc-or1k.c -- Assembler for the OpenRISC family.
-   Copyright (C) 2001-2015 Free Software Foundation, Inc.
+   Copyright (C) 2001-2021 Free Software Foundation, Inc.
    Contributed for OR32 by Johan Rydberg, jrydberg@opencores.org
 
    This file is part of GAS, the GNU Assembler.
@@ -67,7 +67,7 @@ size_t md_longopts_size = sizeof (md_longopts);
 unsigned long or1k_machine = 0; /* default */
 
 int
-md_parse_option (int c ATTRIBUTE_UNUSED, char * arg ATTRIBUTE_UNUSED)
+md_parse_option (int c ATTRIBUTE_UNUSED, const char * arg ATTRIBUTE_UNUSED)
 {
   return 0;
 }
@@ -165,8 +165,8 @@ md_operand (expressionS * expressionP)
 valueT
 md_section_align (segT segment, valueT size)
 {
-  int align = bfd_get_section_alignment (stdoutput, segment);
-  return ((size + (1 << align) - 1) & (-1 << align));
+  int align = bfd_section_alignment (segment);
+  return ((size + (1 << align) - 1) & -(1 << align));
 }
 
 symbolS *
@@ -275,10 +275,7 @@ md_number_to_chars (char * buf, valueT val, int n)
    type, and store the appropriate bytes in *litP.  The number of LITTLENUMS
    emitted is stored in *sizeP .  An error message is returned, or NULL on OK.  */
 
-/* Equal to MAX_PRECISION in atof-ieee.c.  */
-#define MAX_LITTLENUMS 6
-
-char *
+const char *
 md_atof (int type, char * litP, int *  sizeP)
 {
   return ieee_md_atof (type, litP, sizeP, TRUE);
@@ -298,27 +295,59 @@ or1k_fix_adjustable (fixS * fixP)
 #define GOT_NAME "_GLOBAL_OFFSET_TABLE_"
 
 arelent *
-tc_gen_reloc (asection *sec, fixS *fx)
+tc_gen_reloc (asection * section, fixS * fixp)
 {
-  bfd_reloc_code_real_type code = fx->fx_r_type;
+  arelent *reloc;
+  bfd_reloc_code_real_type code;
+
+  reloc = XNEW (arelent);
+
+  reloc->sym_ptr_ptr = XNEW (asymbol *);
+  *reloc->sym_ptr_ptr = symbol_get_bfdsym (fixp->fx_addsy);
+  reloc->address = fixp->fx_frag->fr_address + fixp->fx_where;
+
+  if (fixp->fx_pcrel)
+    {
+      if (section->use_rela_p)
+        fixp->fx_offset -= md_pcrel_from_section (fixp, section);
+      else
+        fixp->fx_offset = reloc->address;
+    }
+  reloc->addend = fixp->fx_offset;
+
+  code = fixp->fx_r_type;
+  switch (code)
+    {
+    case BFD_RELOC_16:
+      if (fixp->fx_pcrel)
+        code = BFD_RELOC_16_PCREL;
+      break;
+
+    case BFD_RELOC_32:
+      if (fixp->fx_pcrel)
+        code = BFD_RELOC_32_PCREL;
+      break;
+
+    case BFD_RELOC_64:
+      if (fixp->fx_pcrel)
+        code = BFD_RELOC_64_PCREL;
+      break;
+
+    default:
+      break;
+    }
 
-  if (fx->fx_addsy != NULL
-      && strcmp (S_GET_NAME (fx->fx_addsy), GOT_NAME) == 0
-      && (code == BFD_RELOC_OR1K_GOTPC_HI16
-          || code == BFD_RELOC_OR1K_GOTPC_LO16))
+  reloc->howto = bfd_reloc_type_lookup (stdoutput, code);
+  if (reloc->howto == NULL)
     {
-      arelent * reloc;
-
-      reloc = xmalloc (sizeof (* reloc));
-      reloc->sym_ptr_ptr = xmalloc (sizeof (asymbol *));
-      *reloc->sym_ptr_ptr = symbol_get_bfdsym (fx->fx_addsy);
-      reloc->address = fx->fx_frag->fr_address + fx->fx_where;
-      reloc->howto = bfd_reloc_type_lookup (stdoutput, fx->fx_r_type);
-      reloc->addend = fx->fx_offset;
-      return reloc;
+      as_bad_where (fixp->fx_file, fixp->fx_line,
+                    _
+                    ("cannot represent %s relocation in this object file format"),
+                    bfd_get_reloc_code_name (code));
+      return NULL;
     }
 
-  return gas_cgen_tc_gen_reloc (sec, fx);
+  return reloc;
 }
 
 void
@@ -330,12 +359,18 @@ or1k_apply_fix (struct fix *f, valueT *t, segT s)
     {
     case BFD_RELOC_OR1K_TLS_GD_HI16:
     case BFD_RELOC_OR1K_TLS_GD_LO16:
+    case BFD_RELOC_OR1K_TLS_GD_PG21:
+    case BFD_RELOC_OR1K_TLS_GD_LO13:
     case BFD_RELOC_OR1K_TLS_LDM_HI16:
     case BFD_RELOC_OR1K_TLS_LDM_LO16:
+    case BFD_RELOC_OR1K_TLS_LDM_PG21:
+    case BFD_RELOC_OR1K_TLS_LDM_LO13:
     case BFD_RELOC_OR1K_TLS_LDO_HI16:
     case BFD_RELOC_OR1K_TLS_LDO_LO16:
     case BFD_RELOC_OR1K_TLS_IE_HI16:
     case BFD_RELOC_OR1K_TLS_IE_LO16:
+    case BFD_RELOC_OR1K_TLS_IE_PG21:
+    case BFD_RELOC_OR1K_TLS_IE_LO13:
     case BFD_RELOC_OR1K_TLS_LE_HI16:
     case BFD_RELOC_OR1K_TLS_LE_LO16:
       S_SET_THREAD_LOCAL (f->fx_addsy);