* config/tc-h8300.c (h8300_elf_section): New function - issue a
authorNick Clifton <nickc@redhat.com>
Wed, 13 Jan 2010 14:08:54 +0000 (14:08 +0000)
committerNick Clifton <nickc@redhat.com>
Wed, 13 Jan 2010 14:08:54 +0000 (14:08 +0000)
        warning message if a new section is created without setting any
        attributes for it.
        (md_pseudo_table): Intercept section creation pseudos.
        (md_pcrel_from): Replace abort with an error message.
        * config/obj-elf.c (obj_elf_section_name): Export this function.
        * config/obj-elf.h (obj_elf_section_name): Prototype.

        * gas/elf/section0.d: Skip this test for the h8300.
        * gas/elf/section1.d: Likewise.
        * gas/elf/section6.d: Likewise.
        * gas/elf/elf.exp: Skip section2 and section5 tests when the
        target is the h8300.

        * ld-scrips/sort.exp: Skip these tests when the target is the
        h8300.

gas/ChangeLog
gas/config/obj-elf.c
gas/config/obj-elf.h
gas/config/tc-h8300.c
gas/testsuite/ChangeLog
gas/testsuite/gas/elf/elf.exp
gas/testsuite/gas/elf/section0.d
gas/testsuite/gas/elf/section1.d
gas/testsuite/gas/elf/section6.d
ld/testsuite/ChangeLog
ld/testsuite/ld-scripts/sort.exp

index e93a30cbcbf42d2becd15b231d5ca752955e4f79..f899ae98e57869cc05190dd046479332a078e3ba 100644 (file)
@@ -1,3 +1,13 @@
+2010-01-13  Nick Clifton  <nickc@redhat.com>
+
+       * config/tc-h8300.c (h8300_elf_section): New function - issue a
+       warning message if a new section is created without setting any
+       attributes for it.
+       (md_pseudo_table): Intercept section creation pseudos.
+       (md_pcrel_from): Replace abort with an error message.
+       * config/obj-elf.c (obj_elf_section_name): Export this function.
+       * config/obj-elf.h (obj_elf_section_name): Prototype.
+
 2010-01-12  Alan Modra  <amodra@gmail.com>
 
        PR 11122
index 09487025e592bb690fd6a42c9459acc18cd73077..4bd4514d1407954e7fb11afb09d0c0e513de3908 100644 (file)
@@ -855,7 +855,7 @@ obj_elf_section_word (char *str, size_t len, int *type)
 }
 
 /* Get name of section.  */
-static char *
+char *
 obj_elf_section_name (void)
 {
   char *name;
index dc8284fb991f2cba2fffb74da0f93ff3259531af..c734aab757bbb0937197461ae03d47f2ddee714d 100644 (file)
@@ -164,6 +164,7 @@ extern void elf_file_symbol (const char *, int);
 extern void obj_elf_section_change_hook (void);
 
 extern void obj_elf_section (int);
+extern char * obj_elf_section_name (void);
 extern void obj_elf_previous (int);
 extern void obj_elf_version (int);
 extern void obj_elf_common (int);
index 92c0d576027bf956121194d8d829a6903ea584ec..62af18033944089562a331e8e146dd9e19013a49 100644 (file)
@@ -139,6 +139,48 @@ pint (int arg ATTRIBUTE_UNUSED)
   cons (Hmode ? 4 : 2);
 }
 
+/* Like obj_elf_section, but issues a warning for new
+   sections which do not have an attribute specification.  */
+
+static void
+h8300_elf_section (int push)
+{
+  static const char * known_data_sections [] = { ".rodata", ".tdata", ".tbss" };
+  static const char * known_data_prefixes [] = { ".debug", ".gnu.warning" };
+  char * saved_ilp = input_line_pointer;
+  char * name;
+
+  name = obj_elf_section_name ();
+  if (name == NULL)
+    return;
+
+  if (* input_line_pointer != ','
+      && bfd_get_section_by_name (stdoutput, name) == NULL)
+    {
+      signed int i;
+
+      /* Ignore this warning for well known data sections.  */
+      for (i = ARRAY_SIZE (known_data_sections); i--;)
+       if (strcmp (name, known_data_sections[i]) == 0)
+         break;
+
+      if (i < 0)
+       for (i = ARRAY_SIZE (known_data_prefixes); i--;)
+         if (strncmp (name, known_data_prefixes[i],
+                      strlen (known_data_prefixes[i])) == 0)
+           break;
+
+      if (i < 0)
+       as_warn (_("new section '%s' defined without attributes - this might cause problems"), name);
+    }
+
+  /* FIXME: We ought to free the memory allocated by obj_elf_section_name()
+     for 'name', but we do not know if it was taken from the obstack, via
+     demand_copy_C_string(), or xmalloc()ed.  */
+  input_line_pointer = saved_ilp;
+  obj_elf_section (push);
+}
+
 /* This table describes all the machine specific pseudo-ops the assembler
    has to support.  The fields are:
    pseudo-op name without dot
@@ -165,6 +207,14 @@ const pseudo_typeS md_pseudo_table[] =
   {"import",  s_ignore, 0},
   {"page",    listing_eject, 0},
   {"program", s_ignore, 0},
+
+#ifdef OBJ_ELF
+  {"section",   h8300_elf_section, 0},
+  {"section.s", h8300_elf_section, 0},
+  {"sect",      h8300_elf_section, 0},
+  {"sect.s",    h8300_elf_section, 0},
+#endif
+
   {0, 0, 0}
 };
 
@@ -2139,9 +2189,11 @@ md_number_to_chars (char *ptr, valueT use, int nbytes)
 }
 
 long
-md_pcrel_from (fixS *fixP ATTRIBUTE_UNUSED)
+md_pcrel_from (fixS *fixp)
 {
-  abort ();
+  as_bad_where (fixp->fx_file, fixp->fx_line,
+               _("Unexpected reference to a symbol in a non-code section"));
+  return 0;
 }
 
 arelent *
index ad7eb576756de5e761a1d154d7ecf41c2cae423f..2fafd115df95d671565629d48f652a72d3490ed6 100644 (file)
@@ -1,3 +1,11 @@
+2010-01-13  Nick Clifton  <nickc@redhat.com>
+
+       * gas/elf/section0.d: Skip this test for the h8300.
+       * gas/elf/section1.d: Likewise.
+       * gas/elf/section6.d: Likewise.
+       * gas/elf/elf.exp: Skip section2 and section5 tests when the
+       target is the h8300.
+
 2010-01-06  Quentin Neill  <quentin.neill@amd.com>
 
        * gas/i386/i386.exp: Add new amdfam15 test cases.
index e65d2cfa10519dfeccd3f1b3cfb890dbeaf88084..05b5a4b98f1539fb72357d4267b61cf8cf9e98d4 100644 (file)
@@ -126,10 +126,18 @@ if { ([istarget "*-*-*elf*"]
     }
     run_dump_test "section0" 
     run_dump_test "section1" 
-    run_elf_list_test "section2" "$target_machine" "-al" "-s" ""
+    if {! [istarget "h8300-*-*"]} then {
+       # The h8300 port issues a warning message for
+       # new sections created without atrributes.
+       run_elf_list_test "section2" "$target_machine" "-al" "-s" ""
+    }
     run_dump_test "section3" 
     run_dump_test "section4"
-    run_elf_list_test "section5" "" "-al" "-SW" "| grep \" \\\\.test\\\[0-9\\\]\""
+    if {! [istarget "h8300-*-*"]} then {
+       # The h8300 port issues a warning message for
+       # new sections created without atrributes.
+       run_elf_list_test "section5" "" "-al" "-SW" "| grep \" \\\\.test\\\[0-9\\\]\""
+    }
     run_dump_test "struct" 
     run_dump_test "symtab"
     run_dump_test "symver"
index 6978d0a23d19be933fea897bc76810488dc3755f..be1d547d5ed66e73df9417b53afdf2f1991472a9 100644 (file)
@@ -1,5 +1,8 @@
 #objdump: -s
 #name: elf section0
+# The h8300 port issues a warning message for
+# new sections created without atrributes.
+#skip: h8300-*
 
 .*: +file format .*
 
index c6b7fd4827664fda6e84c342367eae3cfde8268b..b02a9e427e9d05c0c6a4b6fa889ecd40e226d7ca 100644 (file)
@@ -1,5 +1,8 @@
 #objdump: -s
 #name: elf section1
+# The h8300 port issues a warning message for
+# new sections created without atrributes.
+#skip: h8300-*
 
 .*: +file format .*
 
index e8e0a66a166fc2f43d736beac03d4ca5207d8e87..c42d95c2aa3b69eb7d86e425a91bf61bfcd9e74f 100644 (file)
@@ -1,5 +1,8 @@
 #objdump: -s
 #name: elf section6
+# The h8300 port issues a warning message for
+# new sections created without atrributes.
+#skip: h8300-*
 
 .*: +file format .*
 
index 51783a6103d7388e391095a653dac6f15f7fbec8..dbd6fc143f30a90c5143e069fbd94730d0a941de 100644 (file)
@@ -1,3 +1,8 @@
+2010-01-13  Nick Clifton  <nickc@redhat.com>
+
+       * ld-scrips/sort.exp: Skip these tests when the target is the
+       h8300.
+
 2010-01-11  H.J. Lu  <hongjiu.lu@intel.com>
 
        PR ld/11146
index 412f1072a8573a148535a1ec4f406248fa1b4696..47950a747eeeaa0a93dd7b4d11600110649f5f80 100644 (file)
@@ -25,6 +25,12 @@ if ![is_elf_format] {
     return
 }
 
+# The h8300 port issues a warning message for
+# new sections created without atrributes.
+if [istarget "h8300-*-*"] {
+  return
+}
+
 load_lib ld-lib.exp
 
 set sort_test_list [lsort [glob -nocomplain $srcdir/$subdir/sort*.d]]
This page took 0.032915 seconds and 4 git commands to generate.