daily update
[deliverable/binutils-gdb.git] / bfd / elf32-m32c.c
index 8004795e3b1d9d9be13c0c755e76ef4a33f452d8..69e617f54b8fe92decd88bd8049a8296a997f1f2 100644 (file)
@@ -40,7 +40,8 @@ static bfd_boolean m32c_elf_check_relocs
   (bfd *, struct bfd_link_info *, asection *, const Elf_Internal_Rela *);
 static bfd_boolean m32c_elf_relax_delete_bytes (bfd *, asection *, bfd_vma, int);
 #ifdef DEBUG
-static char * m32c_get_reloc (long reloc);
+char * m32c_get_reloc (long reloc);
+void dump_symtab (bfd *, void *, void *);
 #endif
 static bfd_boolean m32c_elf_relax_section
 (bfd *abfd, asection *sec, struct bfd_link_info *link_info, bfd_boolean *again);
@@ -482,6 +483,22 @@ m32c_elf_relocate_section
                relocation = (splt->output_section->vma
                              + splt->output_offset
                              + (*plt_offset & -2));
+               if (name)
+               {
+                 char *newname = bfd_malloc (strlen(name)+5);
+                 strcpy (newname, name);
+                 strcat(newname, ".plt");
+                 _bfd_generic_link_add_one_symbol (info,
+                                                   input_bfd,
+                                                   newname,
+                                                   BSF_FUNCTION | BSF_WEAK,
+                                                   splt,
+                                                   (*plt_offset & -2),
+                                                   0,
+                                                   1,
+                                                   0,
+                                                   0);
+               }
              }
          }
          break;
@@ -493,14 +510,15 @@ m32c_elf_relocate_section
        }
 
 #if 0
-      printf("relocate %s at %06lx relocation %06lx addend %ld  ",
-            m32c_elf_howto_table[ELF32_R_TYPE(rel->r_info)].name,
-            rel->r_offset, relocation, rel->r_addend);
+      printf ("relocate %s at %06lx relocation %06lx addend %ld  ",
+             m32c_elf_howto_table[ELF32_R_TYPE(rel->r_info)].name,
+             rel->r_offset + input_section->output_section->vma + input_section->output_offset,
+             relocation, rel->r_addend);
       {
        int i;
        for (i=0; i<4; i++)
-         printf(" %02x", contents[rel->r_offset+i]);
-       printf("\n");
+         printf (" %02x", contents[rel->r_offset+i]);
+       printf ("\n");
       }
 #endif
       r = _bfd_final_link_relocate (howto, input_bfd, input_section,
@@ -673,16 +691,11 @@ m32c_elf_check_relocs
              splt = bfd_get_section_by_name (dynobj, ".plt");
              if (splt == NULL)
                {
-                 splt = bfd_make_section (dynobj, ".plt");
+                 flagword flags = (SEC_ALLOC | SEC_LOAD | SEC_HAS_CONTENTS
+                                   | SEC_IN_MEMORY | SEC_LINKER_CREATED
+                                   | SEC_READONLY | SEC_CODE);
+                 splt = bfd_make_section_with_flags (dynobj, ".plt", flags);
                  if (splt == NULL
-                     || ! bfd_set_section_flags (dynobj, splt,
-                                                 (SEC_ALLOC
-                                                  | SEC_LOAD
-                                                  | SEC_HAS_CONTENTS
-                                                  | SEC_IN_MEMORY
-                                                  | SEC_LINKER_CREATED
-                                                  | SEC_READONLY
-                                                  | SEC_CODE))
                      || ! bfd_set_section_alignment (dynobj, splt, 1))
                    return FALSE;
                }
@@ -919,7 +932,7 @@ m32c_elf_object_p (bfd *abfd)
  \f
 
 #ifdef DEBUG
-static void
+void
 dump_symtab (bfd * abfd, void *internal_syms, void *external_syms)
 {
   size_t locsymcount;
@@ -960,7 +973,6 @@ dump_symtab (bfd * abfd, void *internal_syms, void *external_syms)
        {
        case STT_FUNC: st_info_str = "STT_FUNC";
        case STT_SECTION: st_info_str = "STT_SECTION";
-       case STT_SRELC: st_info_str = "STT_SRELC";
        case STT_FILE: st_info_str = "STT_FILE";
        case STT_OBJECT: st_info_str = "STT_OBJECT";
        case STT_TLS: st_info_str = "STT_TLS";
@@ -1005,7 +1017,7 @@ dump_symtab (bfd * abfd, void *internal_syms, void *external_syms)
     free (external_syms);
 }
 
-static char *
+char *
 m32c_get_reloc (long reloc)
 {
   if (0 <= reloc && reloc < R_M32C_max)
@@ -1219,10 +1231,9 @@ compare_reloc (const void *e1, const void *e2)
     return i1->r_offset < i2->r_offset ? -1 : 1;
 }
 
-#define OFFSET_FOR_RELOC(rel) m32c_offset_for_reloc (abfd, sec, rel, symtab_hdr, shndx_buf, intsyms)
+#define OFFSET_FOR_RELOC(rel) m32c_offset_for_reloc (abfd, rel, symtab_hdr, shndx_buf, intsyms)
 static bfd_vma
 m32c_offset_for_reloc (bfd *abfd,
-                      asection * sec,
                       Elf_Internal_Rela *rel,
                       Elf_Internal_Shdr *symtab_hdr,
                       Elf_External_Sym_Shndx *shndx_buf,
@@ -1236,13 +1247,17 @@ m32c_offset_for_reloc (bfd *abfd,
       /* A local symbol.  */
       Elf_Internal_Sym *isym;
       Elf_External_Sym_Shndx *shndx;
+      asection *ssec;
+
 
       isym = intsyms + ELF32_R_SYM (rel->r_info);
+      ssec = bfd_section_from_elf_index (abfd, isym->st_shndx);
       shndx = shndx_buf + (shndx_buf ? ELF32_R_SYM (rel->r_info) : 0);
 
-      symval = (isym->st_value
-               + sec->output_section->vma
-               + sec->output_offset);
+      symval = isym->st_value;
+      if (ssec)
+       symval += ssec->output_section->vma
+         + ssec->output_offset;
     }
   else
     {
@@ -1532,6 +1547,7 @@ m32c_elf_relax_section
       /* Setting gap_size nonzero is the flag which means "something
         shrunk".  */
       gap_size = 0;
+      gap = NULL;
       new_type = ELF32_R_TYPE(srel->r_info);
 
       pc = sec->output_section->vma + sec->output_offset
This page took 0.029514 seconds and 4 git commands to generate.