Warn relocation in readonly section in a shared object.
[binutils-gdb.git] / bfd / elf32-cris.c
index 83ef984a3e58ec7875f77d9c371ddec957793ea9..9644e9b902d38bd83d6faf7467ad18a8374d34b2 100644 (file)
@@ -580,7 +580,7 @@ cris_elf_grok_prstatus (abfd, note)
        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 + 22);
+       elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 22);
 
        /* pr_reg */
        offset = 70;
@@ -599,7 +599,7 @@ cris_elf_grok_prstatus (abfd, note)
        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 + 22);
+       elf_tdata (abfd)->core_lwpid = bfd_get_32 (abfd, note->descdata + 22);
 
        /* pr_reg */
        offset = 70;
@@ -1181,15 +1181,8 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
        }
 
       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;
-       }
+       RELOC_AGAINST_DISCARDED_SECTION (info, input_bfd, input_section,
+                                        rel, relend, howto, contents);
 
       if (info->relocatable)
        continue;
@@ -1493,7 +1486,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
        case R_CRIS_16:
        case R_CRIS_32:
          if (info->shared
-             && r_symndx != 0
+             && r_symndx != STN_UNDEF
              && (input_section->flags & SEC_ALLOC) != 0
              && ((r_type != R_CRIS_8_PCREL
                   && r_type != R_CRIS_16_PCREL
@@ -1512,7 +1505,7 @@ cris_elf_relocate_section (bfd *output_bfd ATTRIBUTE_UNUSED,
              if (sreloc == NULL)
                {
                  sreloc = _bfd_elf_get_dynamic_reloc_section
-                   (input_bfd, input_section, /*rela?*/ TRUE);
+                   (dynobj, input_section, /*rela?*/ TRUE);
                  /* The section should have been created in cris_elf_check_relocs,
                     but that function will not be called for objects which fail in
                     cris_elf_merge_private_bfd_data.  */
@@ -2157,7 +2150,6 @@ elf_cris_finish_dynamic_symbol (bfd *output_bfd,
     {
       asection *splt;
       asection *sgotplt;
-      asection *sgot;
       asection *srela;
       bfd_vma got_base;
 
@@ -2197,7 +2189,6 @@ elf_cris_finish_dynamic_symbol (bfd *output_bfd,
       BFD_ASSERT (h->dynindx != -1);
 
       splt = bfd_get_section_by_name (dynobj, ".plt");
-      sgot = bfd_get_section_by_name (dynobj, ".got");
       sgotplt = bfd_get_section_by_name (dynobj, ".got.plt");
       srela = bfd_get_section_by_name (dynobj, ".rela.plt");
       BFD_ASSERT (splt != NULL && sgotplt != NULL
@@ -3978,7 +3969,8 @@ elf_cris_discard_excess_dso_dynamics (h, inf)
       for (s = h->pcrel_relocs_copied; s != NULL; s = s->next)
        {
          asection *sreloc
-           = _bfd_elf_get_dynamic_reloc_section (s->section->owner,
+           = _bfd_elf_get_dynamic_reloc_section (elf_hash_table (info)
+                                                 ->dynobj,
                                                  s->section,
                                                  /*rela?*/ TRUE);
          sreloc->size -= s->count * sizeof (Elf32_External_Rela);
@@ -4365,6 +4357,7 @@ elf_cris_got_elt_size (bfd *abfd ATTRIBUTE_UNUSED,
 }
 \f
 #define ELF_ARCH               bfd_arch_cris
+#define ELF_TARGET_ID          CRIS_ELF_DATA
 #define ELF_MACHINE_CODE       EM_CRIS
 #define ELF_MAXPAGESIZE                0x2000