* elf-bfd.h (elf_backend_data): Remove use_rela_p. Add
[binutils-gdb.git] / bfd / elfcode.h
index 22f648862871a253757a3c49d6d34ff0222ab749..0426da215e71ad13d09d1a5d124aaefcf09720d3 100644 (file)
@@ -729,7 +729,7 @@ write_relocs (abfd, sec, data)
   Elf_External_Rela *outbound_relocas;
   Elf_External_Rel *outbound_relocs;
   unsigned int idx;
-  int use_rela_p = get_elf_backend_data (abfd)->use_rela_p;
+  int use_rela_p;
   asymbol *last_sym = 0;
   int last_sym_idx = 0;
 
@@ -757,6 +757,16 @@ write_relocs (abfd, sec, data)
       return;
     }
 
+  /* Figure out whether the relocations are RELA or REL relocations.  */
+  if (rela_hdr->sh_type == SHT_RELA)
+    use_rela_p = true;
+  else if (rela_hdr->sh_type == SHT_REL)
+    use_rela_p = false;
+  else
+    /* Every relocation section should be either an SHT_RELA or an
+       SHT_REL section.  */
+    abort ();
+
   /* orelocation has the data, reloc_count has the count... */
   if (use_rela_p)
     {