Correct the generation of OR1K pc-relative relocations.
authorPeter Zotov <whitequark@whitequark.org>
Fri, 25 Sep 2015 14:21:14 +0000 (15:21 +0100)
committerNick Clifton <nickc@redhat.com>
Fri, 25 Sep 2015 14:21:14 +0000 (15:21 +0100)
gas PR ld/18759
* config/tc-or1k.c (tc_gen_reloc): Correct computation of PC
relative relocs.
* config/tc-or1k.h (GAS_CGEN_PRCEL_R_TYPE): Delete.

bfd * elf32-or1k.c (R_OR1K_32_PCREL): Set pcrel_offset to TRUE.
(R_OR1K_16_PCREL): Likewise.
(R_OR1K_8_PCREL): Likewise.

ld/tests * ld-elf/eh-frame-hdr: Expect to pass on the or1k-linux target.

bfd/ChangeLog
bfd/elf32-or1k.c
gas/ChangeLog
gas/config/tc-or1k.c
gas/config/tc-or1k.h
ld/testsuite/ChangeLog
ld/testsuite/ld-elf/eh-frame-hdr.d

index c0672115d22d8831a7ceb613c4a341e74f2f30c8..d8068c48c0f2891bc48bb7e2f8ff9e8d33ff33e7 100644 (file)
@@ -1,3 +1,10 @@
+2015-08-11  Peter Zotov  <whitequark@whitequark.org>
+
+       PR ld/18759
+       * elf32-or1k.c (R_OR1K_32_PCREL): Set pcrel_offset to TRUE.
+       (R_OR1K_16_PCREL): Likewise.
+       (R_OR1K_8_PCREL): Likewise.
+
 2015-09-23  Nick Clifton  <nickc@redhat.com>
 
        * bout.c (b_out_slurp_reloc_table): Cast constant to unsigned in
index a1eba0956e459653a4867d60d9a262c9cd51a60e..556a9ac606f2d4d388091d319bd6b587ed16f9de 100644 (file)
@@ -199,7 +199,7 @@ static reloc_howto_type or1k_elf_howto_table[] =
          FALSE,                 /* partial_inplace */
          0,                     /* src_mask */
          0xffffffff,            /* dst_mask */
-         FALSE),                /* pcrel_offset */
+         TRUE),                 /* pcrel_offset */
 
   HOWTO (R_OR1K_16_PCREL,
          0,                     /* rightshift */
@@ -213,7 +213,7 @@ static reloc_howto_type or1k_elf_howto_table[] =
          FALSE,                 /* partial_inplace */
          0,                     /* src_mask */
          0xffff,                /* dst_mask */
-         FALSE),                /* pcrel_offset */
+         TRUE),                 /* pcrel_offset */
 
   HOWTO (R_OR1K_8_PCREL,
          0,                     /* rightshift */
@@ -227,7 +227,7 @@ static reloc_howto_type or1k_elf_howto_table[] =
          FALSE,                 /* partial_inplace */
          0,                     /* src_mask */
          0xff,                  /* dst_mask */
-         FALSE),                /* pcrel_offset */
+         TRUE),                 /* pcrel_offset */
 
    HOWTO (R_OR1K_GOTPC_HI16,    /* Type.  */
          16,                    /* Rightshift.  */
index a324f034297d4de4e12259716aed64f93a5ab275..af99b9620651ef14c5e3c02670653e0c6f05363d 100644 (file)
@@ -1,3 +1,10 @@
+2015-08-11  Peter Zotov  <whitequark@whitequark.org>
+
+       PR ld/18759
+       * config/tc-or1k.c (tc_gen_reloc): Correct computation of PC
+       relative relocs.
+       * config/tc-or1k.h (GAS_CGEN_PRCEL_R_TYPE): Delete.
+
 2015-09-25  Ryo ONODERA  <ryo_on@yk.rim.or.jp>
 
        PR 18994
index e490ffc9e28386a2d951066af06c56a25afca1b6..dba2dde581bd9267e8754b3dd9e285cfc3acac4c 100644 (file)
@@ -298,27 +298,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;
 
-  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 = xmalloc (sizeof (arelent));
+
+  reloc->sym_ptr_ptr = xmalloc (sizeof (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;
+    }
+
+  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
index cc04b3aaba349134207531273a2c2bf1ac5fc7c7..d0528342edfccc5526598a72af888f9fded6264f 100644 (file)
@@ -57,8 +57,6 @@ extern long md_pcrel_from_section (struct fix *, segT);
 extern const struct relax_type md_relax_table[];
 #define TC_GENERIC_RELAX_TABLE md_relax_table
 
-#define GAS_CGEN_PCREL_R_TYPE(r_type) gas_cgen_pcrel_r_type(r_type)
-
 #define elf_tc_final_processing or1k_elf_final_processing
 void or1k_elf_final_processing (void);
 
index 8a1eef2705d9b975bce667127055e0e151a6ab3b..3a6a5094b85e3cb4db393a0c18d4801f079521f5 100644 (file)
@@ -1,3 +1,8 @@
+2015-08-11  Peter Zotov  <whitequark@whitequark.org>
+
+       PR ld/18759
+       * ld-elf/eh-frame-hdr: Expect to pass on the or1k-linux target.
+
 2015-09-22  H.J. Lu  <hongjiu.lu@intel.com>
 
        * ld-mips-elf/pie-n32.d: Updated.
index 4214ed5fa51a666d3901fe0323a53f169283de0d..e981dffb388ec8d44ffd36f75740831e256001e0 100644 (file)
@@ -2,7 +2,7 @@
 #ld: -e _start --eh-frame-hdr
 #objdump: -hw
 #target: cfi
-#xfail: avr*-*-* or1k-*-* visium-*-*
+#xfail: avr*-*-* or1k*-*-elf or1k*-*-rtems* visium-*-*
 # avr doesn't support shared libraries.
 #...
   [0-9] .eh_frame_hdr 0*[12][048c] .*
This page took 0.043684 seconds and 4 git commands to generate.