bfd/
authorTristan Gingold <gingold@adacore.com>
Thu, 15 Dec 2011 10:56:48 +0000 (10:56 +0000)
committerTristan Gingold <gingold@adacore.com>
Thu, 15 Dec 2011 10:56:48 +0000 (10:56 +0000)
2011-12-15  Iain Sandoe  <iains@gcc.gnu.org>

* mach-o-target.c (bfd_mach_o_bfd_set_private_flags): Use
bfd_mach_o_bfd_set_private_flags.
* mach-o.c (bfd_mach_o_bfd_set_private_flags): New.
* mach-o.h (bfd_mach_o_bfd_set_private_flags): Declare.

gas/
2011-12-15  Iain Sandoe  <iains@gcc.gnu.org>

* config/obj-macho.c (obj_mach_o_subsections_by_symbols): New global.
(obj_mach_o_file_properties): New enum.
(obj_mach_o_subsections_via_symbols):  Generalize name to...
... (obj_mach_o_fileprop) and use to set subsections_via_symbols.

gas/testsuite/
2011-12-15  Iain Sandoe  <iains@gcc.gnu.org>

* gas/mach-o/subsect-via-symbols-0.d: New.
* gas/mach-o/subsect-via-symbols-1.d: New.
* gas/mach-o/subsect-via-symbols.s: New.

bfd/ChangeLog
bfd/mach-o-target.c
bfd/mach-o.c
bfd/mach-o.h
gas/ChangeLog
gas/config/obj-macho.c
gas/testsuite/ChangeLog
gas/testsuite/gas/mach-o/subsect-via-symbols-0.d [new file with mode: 0644]
gas/testsuite/gas/mach-o/subsect-via-symbols-1.d [new file with mode: 0644]
gas/testsuite/gas/mach-o/subsect-via-symbols.s [new file with mode: 0644]

index 9e995a1..e1cd2ba 100644 (file)
@@ -1,3 +1,10 @@
+2011-12-15  Iain Sandoe  <iains@gcc.gnu.org>
+
+       * mach-o-target.c (bfd_mach_o_bfd_set_private_flags): Use
+       bfd_mach_o_bfd_set_private_flags.
+       * mach-o.c (bfd_mach_o_bfd_set_private_flags): New.
+       * mach-o.h (bfd_mach_o_bfd_set_private_flags): Declare.
+
 2011-12-14  Nick Clifton  <nickc@redhat.com>
 
        PR ld/12451
index 4d5690e..c91584c 100644 (file)
@@ -46,7 +46,7 @@
 #define bfd_mach_o_bfd_final_link                     _bfd_generic_final_link
 #define bfd_mach_o_bfd_link_split_section             _bfd_generic_link_split_section
 #define bfd_mach_o_bfd_merge_private_bfd_data         _bfd_generic_bfd_merge_private_bfd_data
-#define bfd_mach_o_bfd_set_private_flags              _bfd_generic_bfd_set_private_flags
+#define bfd_mach_o_bfd_set_private_flags              bfd_mach_o_bfd_set_private_flags
 #define bfd_mach_o_get_section_contents               _bfd_generic_get_section_contents
 #define bfd_mach_o_bfd_gc_sections                    bfd_generic_gc_sections
 #define bfd_mach_o_bfd_lookup_section_flags           bfd_generic_lookup_section_flags
index c768689..0c2c2f7 100644 (file)
@@ -576,6 +576,22 @@ bfd_mach_o_bfd_copy_private_bfd_data (bfd *ibfd, bfd *obfd)
   return TRUE;
 }
 
+/* This allows us to set up to 32 bits of flags (unless we invent some
+   fiendish scheme to subdivide).  For now, we'll just set the file flags
+   without error checking - just overwrite.  */
+   
+bfd_boolean
+bfd_mach_o_bfd_set_private_flags (bfd *abfd, flagword flags)
+{
+  bfd_mach_o_data_struct *mdata = bfd_mach_o_get_data (abfd);
+
+  if (!mdata)
+    return FALSE;
+
+  mdata->header.flags = flags;
+  return TRUE;
+}
+
 /* Count the total number of symbols.  */
 
 static long
index 0c6f4fd..e22b41a 100644 (file)
@@ -555,6 +555,7 @@ bfd_boolean bfd_mach_o_bfd_copy_private_symbol_data (bfd *, asymbol *,
 bfd_boolean bfd_mach_o_bfd_copy_private_section_data (bfd *, asection *,
                                                       bfd *, asection *);
 bfd_boolean bfd_mach_o_bfd_copy_private_bfd_data (bfd *, bfd *);
+bfd_boolean bfd_mach_o_bfd_set_private_flags (bfd *, flagword);
 long bfd_mach_o_get_symtab_upper_bound (bfd *);
 long bfd_mach_o_canonicalize_symtab (bfd *, asymbol **);
 long bfd_mach_o_get_synthetic_symtab (bfd *, long, asymbol **, long, 
index b7a9a87..2a996c2 100644 (file)
@@ -1,3 +1,10 @@
+2011-12-15  Iain Sandoe  <iains@gcc.gnu.org>
+
+       * config/obj-macho.c (obj_mach_o_subsections_by_symbols): New global.
+       (obj_mach_o_file_properties): New enum.
+       (obj_mach_o_subsections_via_symbols):  Generalize name to...
+       ... (obj_mach_o_fileprop) and use to set subsections_via_symbols.
+
 2011-12-14  Stuart Henderson  <shenders@gcc.gnu.org>
 
        * config/bfin-parse.y (asm_1): set SRCx fields to all 1s for
index 018f653..7f147e3 100644 (file)
@@ -53,6 +53,10 @@ static int obj_mach_o_is_static;
 
 static int seen_objc_section;
 
+/* Remember the subsections_by_symbols state in case we need to reset
+   the file flags.  */
+static int obj_mach_o_subsections_by_symbols;
+
 static void
 obj_mach_o_weak (int ignore ATTRIBUTE_UNUSED)
 {
@@ -674,11 +678,33 @@ obj_mach_o_comm (int is_local)
   s_comm_internal (is_local, obj_mach_o_common_parse);
 }
 
-static void
-obj_mach_o_subsections_via_symbols (int arg ATTRIBUTE_UNUSED)
+/* Set properties that apply to the whole file.  At present, the only
+   one defined, is subsections_via_symbols.  */
+
+typedef enum obj_mach_o_file_properties {
+  OBJ_MACH_O_FILE_PROP_NONE = 0,
+  OBJ_MACH_O_FILE_PROP_SUBSECTS_VIA_SYMS,
+  OBJ_MACH_O_FILE_PROP_MAX
+} obj_mach_o_file_properties;
+
+static void 
+obj_mach_o_fileprop (int prop)
 {
-  /* Currently ignore it.  */
-  demand_empty_rest_of_line ();
+  if (prop < 0 || prop >= OBJ_MACH_O_FILE_PROP_MAX)
+    as_fatal (_("internal error: bad file property ID %d"), prop);
+    
+  switch ((obj_mach_o_file_properties) prop)
+    {
+      case OBJ_MACH_O_FILE_PROP_SUBSECTS_VIA_SYMS:
+        subsections_by_symbols = 1;
+       if (!bfd_set_private_flags (stdoutput, 
+                                   BFD_MACH_O_MH_SUBSECTIONS_VIA_SYMBOLS))
+         as_bad (_("failed to set subsections by symbols"));
+       demand_empty_rest_of_line ();
+       break;
+      default:
+       break;
+    }
 }
 
 /* Dummy function to allow test-code to work while we are working
@@ -776,7 +802,8 @@ const pseudo_typeS mach_o_pseudo_table[] =
   { "weak", obj_mach_o_weak, 0},   /* extension */
 
   /* File flags.  */
-  { "subsections_via_symbols", obj_mach_o_subsections_via_symbols, 0 },
+  { "subsections_via_symbols", obj_mach_o_fileprop, 
+                              OBJ_MACH_O_FILE_PROP_SUBSECTS_VIA_SYMS},
 
   {NULL, NULL, 0}
 };
index 5fa4335..c9efc90 100644 (file)
@@ -1,3 +1,9 @@
+2011-12-15  Iain Sandoe  <iains@gcc.gnu.org>
+
+       * gas/mach-o/subsect-via-symbols-0.d: New.
+       * gas/mach-o/subsect-via-symbols-1.d: New.
+       * gas/mach-o/subsect-via-symbols.s: New.
+
 2011-12-15  Nick Clifton  <nickc@redhat.com>
 
        * gas/frv/immediates.s: New test file - checks assembly of
diff --git a/gas/testsuite/gas/mach-o/subsect-via-symbols-0.d b/gas/testsuite/gas/mach-o/subsect-via-symbols-0.d
new file mode 100644 (file)
index 0000000..4dd2739
--- /dev/null
@@ -0,0 +1,6 @@
+#objdump: -P header
+#source: empty.s
+.*: +file format mach-o.*
+#...
+.*flags +: 00000000 \(-\)
+#pass
diff --git a/gas/testsuite/gas/mach-o/subsect-via-symbols-1.d b/gas/testsuite/gas/mach-o/subsect-via-symbols-1.d
new file mode 100644 (file)
index 0000000..163a9c2
--- /dev/null
@@ -0,0 +1,6 @@
+#objdump: -P header
+#source: subsect-via-symbols.s
+.*: +file format mach-o.*
+#...
+.*flags +: 00002000 \(subsections_via_symbols\)
+#pass
diff --git a/gas/testsuite/gas/mach-o/subsect-via-symbols.s b/gas/testsuite/gas/mach-o/subsect-via-symbols.s
new file mode 100644 (file)
index 0000000..b244150
--- /dev/null
@@ -0,0 +1,3 @@
+# just set subsections by symbols
+       .subsections_via_symbols
+