Fix score bugs
authorNick Clifton <nickc@redhat.com>
Thu, 19 Oct 2006 15:47:34 +0000 (15:47 +0000)
committerNick Clifton <nickc@redhat.com>
Thu, 19 Oct 2006 15:47:34 +0000 (15:47 +0000)
bfd/ChangeLog
bfd/elf32-score.c
gas/ChangeLog
gas/config/tc-mn10300.c
gas/config/tc-score.c
include/elf/ChangeLog
include/elf/score.h
ld/ld.texinfo

index 14cc5cbeed74b17622eecaf684180fd2e375e424..b8eced61acdcb2c14fd4961e7ca93d46758ca8d2 100644 (file)
@@ -1,3 +1,12 @@
+2006-10-19  Mei Ligang  <ligang@sunnorth.com.cn>
+
+       * elf32-score.c (score_elf_rel_dyn_section): Replace
+       bfd_make_section with bfd_make_section_with_flags.
+       (_bfd_score_elf_create_dynamic_sections): Ditto.
+       (score_elf_create_got_section): Ditto.
+       (score_elf_final_link_relocate): Delete referrence to
+       EF_SCORE_HASENTRY.
+
 2006-10-19  Richard Sandiford  <richard@codesourcery.com>
 
        * elfxx-mips.c (sort_dynamic_relocs): Sort relocations against the
index 60a1a200274850bca19402cc9237fad76fb59708..ab697ff3b3bdc91490de244eea45a85fc7487d92 100644 (file)
@@ -1141,20 +1141,19 @@ score_elf_rel_dyn_section (bfd *dynobj, bfd_boolean create_p)
   sreloc = bfd_get_section_by_name (dynobj, dname);
   if (sreloc == NULL && create_p)
     {
-      sreloc = bfd_make_section (dynobj, dname);
+      sreloc = bfd_make_section_with_flags (dynobj, dname,
+                                            (SEC_ALLOC
+                                             | SEC_LOAD
+                                             | SEC_HAS_CONTENTS
+                                             | SEC_IN_MEMORY
+                                             | SEC_LINKER_CREATED
+                                             | SEC_READONLY));
       if (sreloc == NULL
-         || ! bfd_set_section_flags (dynobj, sreloc,
-                                     (SEC_ALLOC
-                                      | SEC_LOAD
-                                      | SEC_HAS_CONTENTS
-                                      | SEC_IN_MEMORY
-                                      | SEC_LINKER_CREATED
-                                      | SEC_READONLY))
-         || ! bfd_set_section_alignment (dynobj, sreloc, SCORE_ELF_LOG_FILE_ALIGN (dynobj)))
+         || ! bfd_set_section_alignment (dynobj, sreloc,
+                                         SCORE_ELF_LOG_FILE_ALIGN (dynobj)))
        return NULL;
     }
-
-  return sreloc;
+  return sreloc; 
 }
 
 static void
@@ -1350,9 +1349,8 @@ score_elf_create_got_section (bfd *abfd,
 
   /* We have to use an alignment of 2**4 here because this is hardcoded
      in the function stub generation and in the linker script.  */
-  s = bfd_make_section (abfd, ".got");
-  if (s == NULL
-      || ! bfd_set_section_flags (abfd, s, flags)
+  s = bfd_make_section_with_flags (abfd, ".got", flags);
+   if (s == NULL
       || ! bfd_set_section_alignment (abfd, s, 4))
     return FALSE;
 
@@ -1929,15 +1927,6 @@ score_elf_final_link_relocate (reloc_howto_type *howto,
   r_type = ELF32_R_TYPE (rel->r_info);
   rel_addr = (input_section->output_section->vma + input_section->output_offset + rel->r_offset);
 
-  /* If the start address has been set, then set the EF_SCORE_HASENTRY
-     flag.  Setting this more than once is redundant, but the cost is
-     not too high, and it keeps the code simple.
-     The test is done  here, rather than somewhere else, because the
-     start address is only set just before the final link commences.
-     Note - if the user deliberately sets a start address of 0, the flag will not be set.  */
-  if (bfd_get_start_address (output_bfd) != 0)
-    elf_elfheader (output_bfd)->e_flags |= EF_SCORE_HASENTRY;
-
   if (r_type == R_SCORE_GOT15)
     {
       const Elf_Internal_Rela *relend;
@@ -3173,9 +3162,9 @@ _bfd_score_elf_create_dynamic_sections (bfd *abfd, struct bfd_link_info *info)
   /* Create .stub section.  */
   if (bfd_get_section_by_name (abfd, SCORE_ELF_STUB_SECTION_NAME) == NULL)
     {
-      s = bfd_make_section (abfd, SCORE_ELF_STUB_SECTION_NAME);
+      s = bfd_make_section_with_flags (abfd, SCORE_ELF_STUB_SECTION_NAME,
+                                       flags | SEC_CODE);
       if (s == NULL
-          || !bfd_set_section_flags (abfd, s, flags | SEC_CODE)
           || !bfd_set_section_alignment (abfd, s, 2))
 
         return FALSE;
index 22262e3791863eca7da7b6dd3cda78e06e7440d2..2d40bdf96fbeb6b027e80490bafcee44794b1257 100644 (file)
@@ -1,3 +1,8 @@
+2006-10-19  Mei Ligang  <ligang@sunnorth.com.cn>
+
+       * config/tc-score.c (build_relax_frag): Compute correct
+       tc_frag_data.fixp.
+
 2006-10-18  Roy Marples  <uberlord@gentoo.org>
 
        * config/tc-sparc.c (md_parse_option): Treat any target starting with
index a1cacf104882baac8e4fada890b965e337f32455..41358f35e54f838ddb6ca4bfeae0c1f3c3110d26 100644 (file)
@@ -691,7 +691,7 @@ void
 md_show_usage (stream)
      FILE *stream;
 {
-  fprintf (stream, _("MN10300 options:\n\
+  fprintf (stream, _("MN10300 assembler options:\n\
 none yet\n"));
 }
 
index 15fec2af1f4667270fddca86d62907532f88498c..6097d80c1c0a858b43a68f93cc88ca1a09037f25 100644 (file)
@@ -3602,7 +3602,7 @@ build_relax_frag (struct score_it fix_insts[RELAX_INST_NUM], int fix_num ATTRIBU
   int i;
   char *p;
   fixS *fixp = NULL;
-  fixS *head_fixp = NULL;
+  fixS *cur_fixp = NULL;
   long where;
   struct score_it inst_main;
 
@@ -3638,19 +3638,11 @@ build_relax_frag (struct score_it fix_insts[RELAX_INST_NUM], int fix_num ATTRIBU
   md_number_to_chars (p, inst_main.instruction, inst_main.size);
 
   if (inst_main.reloc.type != BFD_RELOC_NONE)
-    {
-      fixp = fix_new_score (frag_now, p - frag_now->fr_literal, inst_main.size,
-                            &inst_main.reloc.exp, inst_main.reloc.pc_rel, inst_main.reloc.type);
-    }
-
-  head_fixp = xmalloc (sizeof (fixS *));
-  frag_now->tc_frag_data.fixp = head_fixp;
+    fixp = fix_new_score (frag_now, p - frag_now->fr_literal, inst_main.size,
+                         &inst_main.reloc.exp, inst_main.reloc.pc_rel, inst_main.reloc.type);
 
-  if (fixp)
-    {
-      head_fixp->fx_next = fixp;
-      head_fixp = head_fixp->fx_next;
-    }
+  frag_now->tc_frag_data.fixp = fixp;
+  cur_fixp = frag_now->tc_frag_data.fixp;
 
 #ifdef OBJ_ELF
   dwarf2_emit_insn (inst_main.size);
@@ -3669,16 +3661,20 @@ build_relax_frag (struct score_it fix_insts[RELAX_INST_NUM], int fix_num ATTRIBU
                                 var_insts[i].reloc.type);
           if (fixp)
             {
-              head_fixp->fx_next = fixp;
-              head_fixp = head_fixp->fx_next;
+              if (cur_fixp)
+                {
+                  cur_fixp->fx_next = fixp;
+                  cur_fixp = cur_fixp->fx_next;
+                }
+              else
+                {
+                  frag_now->tc_frag_data.fixp = fixp;
+                  cur_fixp = frag_now->tc_frag_data.fixp;
+                }
            }
         }
     }
 
-  head_fixp = frag_now->tc_frag_data.fixp;
-  frag_now->tc_frag_data.fixp = head_fixp->fx_next;
-  free (head_fixp);
-
   p = frag_var (rs_machine_dependent, inst_main.relax_size + RELAX_PAD_BYTE, 0,
                 RELAX_ENCODE (inst_main.size, inst_main.relax_size, inst_main.type,
                 0, inst_main.size, 0), add_symbol, 0, NULL);
index c9914d9349d8a2824bc75e490e9e7432b02b17dc..c737b67dd5e73bcd4b453b065163195781a911f5 100644 (file)
@@ -1,3 +1,9 @@
+2006-10-19  Mei Ligang  <ligang@sunnorth.com.cn>
+
+       * score.h (EF_SCORE_PIC): Redefine EF_SCORE_PIC as 0x80000000.
+       (EF_SCORE_FIXDEP): Redefine EF_SCORE_FIXDEP as 0x40000000.
+       (EF_SCORE_HASENTRY): Delete.
+
 2006-09-17  Mei Ligang  <ligang@sunnorth.com.cn>
 
        * score.h: New file.
index 8eb69a788b94c425293e94f8221a79c60cd0caf2..ec3b32f16c46cb4548cb8559437328e8d579c01c 100644 (file)
 #include "elf/reloc-macros.h"
 
 #define SCORE_SIMULATOR_ACTIVE  1
-#define OPC_PTMASK              0xc0000000      /* Parity-bit Mask */
+#define OPC_PTMASK              0xc0000000      /* Parity-bit Mask */
 #define OPC16_PTMASK           0x00008000
 /* The parity-bit denotes.  */
-#define OPC_32                  0xc0000000      /* denotes 32b instruction, (default) */
-#define OPC_16                  0x00000000      /* denotes 16b instruction  */
-#define OPC_PE                  0x8000          /* denotes parallel-execution instructions  */
-#define EF_SCORE_HASENTRY       0x02
+#define OPC_32                  0xc0000000      /* Denotes 32b instruction, (default).  */
+#define OPC_16                  0x00000000      /* Denotes 16b instruction.  */
+#define OPC_PE                  0x8000          /* Denotes parallel-execution instructions.  */
 #define GP_DISP_LABEL           "_gp_disp"
 
-/* Processor specific flags for the ELF header e_flags field.  */
-
-/* Fix data dependency.  */
-#define EF_SCORE_FIXDEP         0x00000001
+/* Processor specific flags for the ELF header e_flags field:  */
 
 /* File contains position independent code.  */
-#define EF_SCORE_PIC           0x00000002
+#define EF_SCORE_PIC            0x80000000
+
+/* Fix data dependency.  */
+#define EF_SCORE_FIXDEP         0x40000000 
 
 /* Defined and allocated common symbol.  Value is virtual address.  If
    relocated, alignment must be preserved.  */
index 1fbd6ef72ce935d4f56468cf96ce319c24c5931d..067f1f6436a3d39fe6eb2a49a8d76b3b102a2a16 100644 (file)
@@ -1251,9 +1251,9 @@ it ends in a @code{.exe} suffix.
 @itemx --no-gc-sections
 Enable garbage collection of unused input sections.  It is ignored on
 targets that do not support this option.  This option is not compatible
-with @samp{-r}. The default behaviour (of not performing this garbage
-collection) can be restored by specifying @samp{--no-gc-sections} on
-the command line.
+with @samp{-r} or @samp{--emit-relocs}. The default behaviour (of not
+performing this garbage collection) can be restored by specifying
+@samp{--no-gc-sections} on the command line.
 
 @kindex --print-gc-sections
 @kindex --no-print-gc-sections