* [Patch mach-o/gas] implement private file flags/subsections-via-symbols.
@ 2011-12-11 16:03 Iain Sandoe
2011-12-12 8:51 ` Tristan Gingold
0 siblings, 1 reply; 8+ messages in thread
From: Iain Sandoe @ 2011-12-11 16:03 UTC (permalink / raw)
To: binutils; +Cc: Tristan Gingold
(sorry forgot to post the last patch in-line)
this makes an interface to the mach-o private file flags and uses it
to set "subsection-via-symbols" in response to the directive.
the parse routine in gas/config/obj-mach-o.c has been generalized to
deal with other flags in the future.
tests in gas/mach-o
[tests patch relative to the base test suite entry previously posted]
cheers
Iain
bfd:
* 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:
* config/obj-macho.c (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:
* gas/mach-o/empty.s: New.
* 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/mach-o-target.c | 2 +-
bfd/mach-o.c | 16 ++++++++++
bfd/mach-o.h | 1 +
gas/config/obj-macho.c | 35 +++++++++++++
+++++---
gas/testsuite/gas/mach-o/empty.s | 2 +
gas/testsuite/gas/mach-o/mach-o.exp | 5 ++-
gas/testsuite/gas/mach-o/subsect-via-symbols-0.d | 6 ++++
gas/testsuite/gas/mach-o/subsect-via-symbols-1.d | 6 ++++
gas/testsuite/gas/mach-o/subsect-via-symbols.s | 3 ++
9 files changed, 68 insertions(+), 8 deletions(-)
diff --git a/bfd/mach-o-target.c b/bfd/mach-o-target.c
index 29682c9..c6b7704 100644
--- a/bfd/mach-o-target.c
+++ b/bfd/mach-o-target.c
@@ -47,7 +47,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
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index 82aeb8d..66d275c 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -364,6 +364,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
diff --git a/bfd/mach-o.h b/bfd/mach-o.h
index f199016..6f362f2 100644
--- a/bfd/mach-o.h
+++ b/bfd/mach-o.h
@@ -554,6 +554,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,
diff --git a/gas/config/obj-macho.c b/gas/config/obj-macho.c
index 5f1255d..d568b1f 100644
--- a/gas/config/obj-macho.c
+++ b/gas/config/obj-macho.c
@@ -27,6 +27,10 @@
#include "mach-o.h"
#include "mach-o/loader.h"
+/* Remember the subsections_by_symbols state in case we need to reset
+ the file flags. */
+int subsections_by_symbols ;
+
static void
obj_mach_o_weak (int ignore ATTRIBUTE_UNUSED)
{
@@ -290,11 +294,32 @@ obj_mach_o_comm (int ignore ATTRIBUTE_UNUSED)
s_comm_internal (ignore, 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_SSBS,
+ 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_SSBS:
+ 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;
+ }
}
const pseudo_typeS mach_o_pseudo_table[] =
@@ -304,7 +329,7 @@ const pseudo_typeS mach_o_pseudo_table[] =
{ "cstring", obj_mach_o_known_section, 1},
{ "lcomm", s_lcomm, 1 },
{ "comm", obj_mach_o_comm, 0 },
- { "subsections_via_symbols", obj_mach_o_subsections_via_symbols, 0 },
+ { "subsections_via_symbols", obj_mach_o_fileprop,
OBJ_MACH_O_FILE_PROP_SSBS},
{NULL, NULL, 0}
};
diff --git a/gas/testsuite/gas/mach-o/empty.s b/gas/testsuite/gas/mach-
o/empty.s
new file mode 100644
index 0000000..b2b70f4
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/empty.s
@@ -0,0 +1,2 @@
+# nothing here
+
diff --git a/gas/testsuite/gas/mach-o/mach-o.exp b/gas/testsuite/gas/
mach-o/mach-o.exp
index 5fcd22d..5ea7f7c 100644
--- a/gas/testsuite/gas/mach-o/mach-o.exp
+++ b/gas/testsuite/gas/mach-o/mach-o.exp
@@ -6,9 +6,10 @@
if {[istarget "*-*-*darwin*"]} then {
- run_dump_test "lcomm-1"
-
load_lib gas-dg.exp
+
+run_dump_tests [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
+
dg-init
dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/
$subdir/warn-*.s]] "" ""
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
index 0000000..a5246bc
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/subsect-via-symbols-0.d
@@ -0,0 +1,6 @@
+#objdump: -p
+#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
index 0000000..d90cca1
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/subsect-via-symbols-1.d
@@ -0,0 +1,6 @@
+#objdump: -p
+#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
index 0000000..b244150
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/subsect-via-symbols.s
@@ -0,0 +1,3 @@
+# just set subsections by symbols
+ .subsections_via_symbols
+
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [Patch mach-o/gas] implement private file flags/subsections-via-symbols.
2011-12-11 16:03 [Patch mach-o/gas] implement private file flags/subsections-via-symbols Iain Sandoe
@ 2011-12-12 8:51 ` Tristan Gingold
2011-12-13 11:56 ` Rebased: " Iain Sandoe
0 siblings, 1 reply; 8+ messages in thread
From: Tristan Gingold @ 2011-12-12 8:51 UTC (permalink / raw)
To: Iain Sandoe; +Cc: binutils
On Dec 11, 2011, at 5:03 PM, Iain Sandoe wrote:
> (sorry forgot to post the last patch in-line)
>
> this makes an interface to the mach-o private file flags and uses it to set "subsection-via-symbols" in response to the directive.
>
> the parse routine in gas/config/obj-mach-o.c has been generalized to deal with other flags in the future.
> tests in gas/mach-o
Ok. Setting the subsections_via_symbols flag might be premature as I am not sure we correctly set the relocation entries for that. But because as/i386 isn't yet ready I think this is ok.
> [tests patch relative to the base test suite entry previously posted]
Please slightly postpone the tests until the previous entry has been ok'ed.
BTW, I plan to submit a patch that moves all the private dumping of mach-o to the recently added 'objdump -P' option.
Tristan.
>
>
> cheers
> Iain
>
> bfd:
>
> * 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:
>
> * config/obj-macho.c (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:
>
> * gas/mach-o/empty.s: New.
> * 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/mach-o-target.c | 2 +-
> bfd/mach-o.c | 16 ++++++++++
> bfd/mach-o.h | 1 +
> gas/config/obj-macho.c | 35 ++++++++++++++++++---
> gas/testsuite/gas/mach-o/empty.s | 2 +
> gas/testsuite/gas/mach-o/mach-o.exp | 5 ++-
> gas/testsuite/gas/mach-o/subsect-via-symbols-0.d | 6 ++++
> gas/testsuite/gas/mach-o/subsect-via-symbols-1.d | 6 ++++
> gas/testsuite/gas/mach-o/subsect-via-symbols.s | 3 ++
> 9 files changed, 68 insertions(+), 8 deletions(-)
>
> diff --git a/bfd/mach-o-target.c b/bfd/mach-o-target.c
> index 29682c9..c6b7704 100644
> --- a/bfd/mach-o-target.c
> +++ b/bfd/mach-o-target.c
> @@ -47,7 +47,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
> diff --git a/bfd/mach-o.c b/bfd/mach-o.c
> index 82aeb8d..66d275c 100644
> --- a/bfd/mach-o.c
> +++ b/bfd/mach-o.c
> @@ -364,6 +364,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
> diff --git a/bfd/mach-o.h b/bfd/mach-o.h
> index f199016..6f362f2 100644
> --- a/bfd/mach-o.h
> +++ b/bfd/mach-o.h
> @@ -554,6 +554,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,
> diff --git a/gas/config/obj-macho.c b/gas/config/obj-macho.c
> index 5f1255d..d568b1f 100644
> --- a/gas/config/obj-macho.c
> +++ b/gas/config/obj-macho.c
> @@ -27,6 +27,10 @@
> #include "mach-o.h"
> #include "mach-o/loader.h"
>
> +/* Remember the subsections_by_symbols state in case we need to reset
> + the file flags. */
> +int subsections_by_symbols ;
> +
> static void
> obj_mach_o_weak (int ignore ATTRIBUTE_UNUSED)
> {
> @@ -290,11 +294,32 @@ obj_mach_o_comm (int ignore ATTRIBUTE_UNUSED)
> s_comm_internal (ignore, 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_SSBS,
> + 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_SSBS:
> + 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;
> + }
> }
>
> const pseudo_typeS mach_o_pseudo_table[] =
> @@ -304,7 +329,7 @@ const pseudo_typeS mach_o_pseudo_table[] =
> { "cstring", obj_mach_o_known_section, 1},
> { "lcomm", s_lcomm, 1 },
> { "comm", obj_mach_o_comm, 0 },
> - { "subsections_via_symbols", obj_mach_o_subsections_via_symbols, 0 },
> + { "subsections_via_symbols", obj_mach_o_fileprop, OBJ_MACH_O_FILE_PROP_SSBS},
>
> {NULL, NULL, 0}
> };
> diff --git a/gas/testsuite/gas/mach-o/empty.s b/gas/testsuite/gas/mach-o/empty.s
> new file mode 100644
> index 0000000..b2b70f4
> --- /dev/null
> +++ b/gas/testsuite/gas/mach-o/empty.s
> @@ -0,0 +1,2 @@
> +# nothing here
> +
> diff --git a/gas/testsuite/gas/mach-o/mach-o.exp b/gas/testsuite/gas/mach-o/mach-o.exp
> index 5fcd22d..5ea7f7c 100644
> --- a/gas/testsuite/gas/mach-o/mach-o.exp
> +++ b/gas/testsuite/gas/mach-o/mach-o.exp
> @@ -6,9 +6,10 @@
>
> if {[istarget "*-*-*darwin*"]} then {
>
> - run_dump_test "lcomm-1"
> -
> load_lib gas-dg.exp
> +
> +run_dump_tests [lsort [glob -nocomplain $srcdir/$subdir/*.d]]
> +
> dg-init
>
> dg-runtest [lsort [glob -nocomplain $srcdir/$subdir/err-*.s $srcdir/$subdir/warn-*.s]] "" ""
> 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
> index 0000000..a5246bc
> --- /dev/null
> +++ b/gas/testsuite/gas/mach-o/subsect-via-symbols-0.d
> @@ -0,0 +1,6 @@
> +#objdump: -p
> +#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
> index 0000000..d90cca1
> --- /dev/null
> +++ b/gas/testsuite/gas/mach-o/subsect-via-symbols-1.d
> @@ -0,0 +1,6 @@
> +#objdump: -p
> +#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
> index 0000000..b244150
> --- /dev/null
> +++ b/gas/testsuite/gas/mach-o/subsect-via-symbols.s
> @@ -0,0 +1,3 @@
> +# just set subsections by symbols
> + .subsections_via_symbols
> +
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Rebased: [Patch mach-o/gas] implement private file flags/subsections-via-symbols.
2011-12-12 8:51 ` Tristan Gingold
@ 2011-12-13 11:56 ` Iain Sandoe
2011-12-14 15:25 ` Tristan Gingold
0 siblings, 1 reply; 8+ messages in thread
From: Iain Sandoe @ 2011-12-13 11:56 UTC (permalink / raw)
To: Tristan Gingold; +Cc: binutils
rebased and adjusted to use objdump -P header for the tests.
On 12 Dec 2011, at 08:51, Tristan Gingold wrote:
> On Dec 11, 2011, at 5:03 PM, Iain Sandoe wrote:
>
>> (sorry forgot to post the last patch in-line)
>>
>> this makes an interface to the mach-o private file flags and uses
>> it to set "subsection-via-symbols" in response to the directive.
>>
>> the parse routine in gas/config/obj-mach-o.c has been generalized
>> to deal with other flags in the future.
>> tests in gas/mach-o
>
> Ok. Setting the subsections_via_symbols flag might be premature as
> I am not sure we correctly set the relocation entries for that. But
> because as/i386 isn't yet ready I think this is ok.
>
>> [tests patch relative to the base test suite entry previously posted]
now relative to :
http://sourceware.org/ml/binutils/2011-12/msg00163.html
> Please slightly postpone the tests until the previous entry has been
> ok'ed.
>>
>> bfd:
>>
>> * 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:
>>
>> * config/obj-macho.c (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:
>>
>> * 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/mach-o-target.c | 2 +-
bfd/mach-o.c | 16 ++++++++++
bfd/mach-o.h | 1 +
gas/config/obj-macho.c | 35 +++++++++++++
+++++---
gas/testsuite/gas/mach-o/subsect-via-symbols-0.d | 6 ++++
gas/testsuite/gas/mach-o/subsect-via-symbols-1.d | 6 ++++
gas/testsuite/gas/mach-o/subsect-via-symbols.s | 3 ++
7 files changed, 63 insertions(+), 6 deletions(-)
diff --git a/bfd/mach-o-target.c b/bfd/mach-o-target.c
index 5e12f84..68a6f19 100644
--- a/bfd/mach-o-target.c
+++ b/bfd/mach-o-target.c
@@ -48,7 +48,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
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index 0a614c3..db60c85 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -362,6 +362,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
diff --git a/bfd/mach-o.h b/bfd/mach-o.h
index d85224e..9560290 100644
--- a/bfd/mach-o.h
+++ b/bfd/mach-o.h
@@ -561,6 +561,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,
diff --git a/gas/config/obj-macho.c b/gas/config/obj-macho.c
index 5f1255d..d568b1f 100644
--- a/gas/config/obj-macho.c
+++ b/gas/config/obj-macho.c
@@ -27,6 +27,10 @@
#include "mach-o.h"
#include "mach-o/loader.h"
+/* Remember the subsections_by_symbols state in case we need to reset
+ the file flags. */
+int subsections_by_symbols ;
+
static void
obj_mach_o_weak (int ignore ATTRIBUTE_UNUSED)
{
@@ -290,11 +294,32 @@ obj_mach_o_comm (int ignore ATTRIBUTE_UNUSED)
s_comm_internal (ignore, 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_SSBS,
+ 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_SSBS:
+ 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;
+ }
}
const pseudo_typeS mach_o_pseudo_table[] =
@@ -304,7 +329,7 @@ const pseudo_typeS mach_o_pseudo_table[] =
{ "cstring", obj_mach_o_known_section, 1},
{ "lcomm", s_lcomm, 1 },
{ "comm", obj_mach_o_comm, 0 },
- { "subsections_via_symbols", obj_mach_o_subsections_via_symbols, 0 },
+ { "subsections_via_symbols", obj_mach_o_fileprop,
OBJ_MACH_O_FILE_PROP_SSBS},
{NULL, NULL, 0}
};
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
index 0000000..4dd2739
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/subsect-via-symbols-0.d
@@ -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
index 0000000..163a9c2
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/subsect-via-symbols-1.d
@@ -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
index 0000000..b244150
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/subsect-via-symbols.s
@@ -0,0 +1,3 @@
+# just set subsections by symbols
+ .subsections_via_symbols
+
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Rebased: [Patch mach-o/gas] implement private file flags/subsections-via-symbols.
2011-12-13 11:56 ` Rebased: " Iain Sandoe
@ 2011-12-14 15:25 ` Tristan Gingold
2011-12-14 16:09 ` Iain Sandoe
0 siblings, 1 reply; 8+ messages in thread
From: Tristan Gingold @ 2011-12-14 15:25 UTC (permalink / raw)
To: Iain Sandoe; +Cc: binutils
On Dec 13, 2011, at 12:55 PM, Iain Sandoe wrote:
> rebased and adjusted to use objdump -P header for the tests.
Iain,
I was about to commit this one when I found two minors points to improve. See comments below.
Sorry for not having noticed that before.
> diff --git a/bfd/mach-o-target.c b/bfd/mach-o-target.c
> index 5e12f84..68a6f19 100644
> --- a/bfd/mach-o-target.c
> +++ b/bfd/mach-o-target.c
> @@ -48,7 +48,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
> diff --git a/bfd/mach-o.c b/bfd/mach-o.c
> index 0a614c3..db60c85 100644
> --- a/bfd/mach-o.c
> +++ b/bfd/mach-o.c
> @@ -362,6 +362,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
> diff --git a/bfd/mach-o.h b/bfd/mach-o.h
> index d85224e..9560290 100644
> --- a/bfd/mach-o.h
> +++ b/bfd/mach-o.h
> @@ -561,6 +561,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,
> diff --git a/gas/config/obj-macho.c b/gas/config/obj-macho.c
> index 5f1255d..d568b1f 100644
> --- a/gas/config/obj-macho.c
> +++ b/gas/config/obj-macho.c
> @@ -27,6 +27,10 @@
> #include "mach-o.h"
> #include "mach-o/loader.h"
>
> +/* Remember the subsections_by_symbols state in case we need to reset
> + the file flags. */
> +int subsections_by_symbols ;
Please, make it static and event better add the 'obj_mach_o' prefix. Also, no blanks before the ';'.
> +
> static void
> obj_mach_o_weak (int ignore ATTRIBUTE_UNUSED)
> {
> @@ -290,11 +294,32 @@ obj_mach_o_comm (int ignore ATTRIBUTE_UNUSED)
> s_comm_internal (ignore, 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_SSBS,
Honestly, SSBS is not very readable. I am not able to find the origin of this acronym. Why not simply _PROP_SUBSECTIONS ?
Ok with these two changes.
Tristan.
> + 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_SSBS:
> + 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;
> + }
> }
>
> const pseudo_typeS mach_o_pseudo_table[] =
> @@ -304,7 +329,7 @@ const pseudo_typeS mach_o_pseudo_table[] =
> { "cstring", obj_mach_o_known_section, 1},
> { "lcomm", s_lcomm, 1 },
> { "comm", obj_mach_o_comm, 0 },
> - { "subsections_via_symbols", obj_mach_o_subsections_via_symbols, 0 },
> + { "subsections_via_symbols", obj_mach_o_fileprop, OBJ_MACH_O_FILE_PROP_SSBS},
>
> {NULL, NULL, 0}
> };
> 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
> index 0000000..4dd2739
> --- /dev/null
> +++ b/gas/testsuite/gas/mach-o/subsect-via-symbols-0.d
> @@ -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
> index 0000000..163a9c2
> --- /dev/null
> +++ b/gas/testsuite/gas/mach-o/subsect-via-symbols-1.d
> @@ -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
> index 0000000..b244150
> --- /dev/null
> +++ b/gas/testsuite/gas/mach-o/subsect-via-symbols.s
> @@ -0,0 +1,3 @@
> +# just set subsections by symbols
> + .subsections_via_symbols
> +
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Rebased: [Patch mach-o/gas] implement private file flags/subsections-via-symbols.
2011-12-14 15:25 ` Tristan Gingold
@ 2011-12-14 16:09 ` Iain Sandoe
2011-12-15 10:57 ` Tristan Gingold
0 siblings, 1 reply; 8+ messages in thread
From: Iain Sandoe @ 2011-12-14 16:09 UTC (permalink / raw)
To: Tristan Gingold; +Cc: binutils
On 14 Dec 2011, at 15:24, Tristan Gingold wrote:
>
> On Dec 13, 2011, at 12:55 PM, Iain Sandoe wrote:
>
>> rebased and adjusted to use objdump -P header for the tests.
>
> Iain,
>
> I was about to commit this one when I found two minors points to
> improve. See comments below.
>> +
>> +typedef enum obj_mach_o_file_properties {
>> + OBJ_MACH_O_FILE_PROP_NONE = 0,
>> + OBJ_MACH_O_FILE_PROP_SSBS,
>
> Honestly, SSBS is not very readable. I am not able to find the
> origin of this acronym. Why not simply _PROP_SUBSECTIONS ?
concise and readable are always tricky - can we compromise on :
OBJ_MACH_O_FILE_PROP_SUBSECTS_VIA_SYMS
I am concerned that someone readin g the code might get mixed up
between this property and the subsections (which we don't use).
... if you have an alternative - then just go ahead with that - in the
end the functionality is what matters ;-)
thanks again,
Iain
bfd/mach-o-target.c | 2 +-
bfd/mach-o.c | 16 +++++++++
bfd/mach-o.h | 1 +
gas/config/obj-macho.c | 37 +++++++++++++
++++++---
gas/testsuite/gas/mach-o/subsect-via-symbols-0.d | 6 +++
gas/testsuite/gas/mach-o/subsect-via-symbols-1.d | 6 +++
gas/testsuite/gas/mach-o/subsect-via-symbols.s | 3 ++
7 files changed, 65 insertions(+), 6 deletions(-)
diff --git a/bfd/mach-o-target.c b/bfd/mach-o-target.c
index 4d5690e..c91584c 100644
--- a/bfd/mach-o-target.c
+++ b/bfd/mach-o-target.c
@@ -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
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index c768689..0c2c2f7 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -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
diff --git a/bfd/mach-o.h b/bfd/mach-o.h
index 0c6f4fd..e22b41a 100644
--- a/bfd/mach-o.h
+++ b/bfd/mach-o.h
@@ -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,
diff --git a/gas/config/obj-macho.c b/gas/config/obj-macho.c
index 018f653..7f147e3 100644
--- a/gas/config/obj-macho.c
+++ b/gas/config/obj-macho.c
@@ -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}
};
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
index 0000000..4dd2739
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/subsect-via-symbols-0.d
@@ -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
index 0000000..163a9c2
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/subsect-via-symbols-1.d
@@ -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
index 0000000..b244150
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/subsect-via-symbols.s
@@ -0,0 +1,3 @@
+# just set subsections by symbols
+ .subsections_via_symbols
+
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Rebased: [Patch mach-o/gas] implement private file flags/subsections-via-symbols.
2011-12-14 16:09 ` Iain Sandoe
@ 2011-12-15 10:57 ` Tristan Gingold
2011-12-15 11:34 ` Iain Sandoe
0 siblings, 1 reply; 8+ messages in thread
From: Tristan Gingold @ 2011-12-15 10:57 UTC (permalink / raw)
To: Iain Sandoe; +Cc: binutils
On Dec 14, 2011, at 5:09 PM, Iain Sandoe wrote:
>
> On 14 Dec 2011, at 15:24, Tristan Gingold wrote:
>
>>
>> On Dec 13, 2011, at 12:55 PM, Iain Sandoe wrote:
>>
>>> rebased and adjusted to use objdump -P header for the tests.
>>
>> Iain,
>>
>> I was about to commit this one when I found two minors points to improve. See comments below.
>
>>> +
>>> +typedef enum obj_mach_o_file_properties {
>>> + OBJ_MACH_O_FILE_PROP_NONE = 0,
>>> + OBJ_MACH_O_FILE_PROP_SSBS,
>>
>> Honestly, SSBS is not very readable. I am not able to find the origin of this acronym. Why not simply _PROP_SUBSECTIONS ?
>
> concise and readable are always tricky - can we compromise on : OBJ_MACH_O_FILE_PROP_SUBSECTS_VIA_SYMS
>
> I am concerned that someone readin g the code might get mixed up between this property and the subsections (which we don't use).
>
> ... if you have an alternative - then just go ahead with that - in the end the functionality is what matters ;-)
Fine with me.
I have just committed it.
Thanks,
Tristan.
>
> thanks again,
> Iain
>
>
>
> bfd/mach-o-target.c | 2 +-
> bfd/mach-o.c | 16 +++++++++
> bfd/mach-o.h | 1 +
> gas/config/obj-macho.c | 37 +++++++++++++++++++---
> gas/testsuite/gas/mach-o/subsect-via-symbols-0.d | 6 +++
> gas/testsuite/gas/mach-o/subsect-via-symbols-1.d | 6 +++
> gas/testsuite/gas/mach-o/subsect-via-symbols.s | 3 ++
> 7 files changed, 65 insertions(+), 6 deletions(-)
>
> diff --git a/bfd/mach-o-target.c b/bfd/mach-o-target.c
> index 4d5690e..c91584c 100644
> --- a/bfd/mach-o-target.c
> +++ b/bfd/mach-o-target.c
> @@ -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
> diff --git a/bfd/mach-o.c b/bfd/mach-o.c
> index c768689..0c2c2f7 100644
> --- a/bfd/mach-o.c
> +++ b/bfd/mach-o.c
> @@ -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
> diff --git a/bfd/mach-o.h b/bfd/mach-o.h
> index 0c6f4fd..e22b41a 100644
> --- a/bfd/mach-o.h
> +++ b/bfd/mach-o.h
> @@ -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,
> diff --git a/gas/config/obj-macho.c b/gas/config/obj-macho.c
> index 018f653..7f147e3 100644
> --- a/gas/config/obj-macho.c
> +++ b/gas/config/obj-macho.c
> @@ -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}
> };
> 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
> index 0000000..4dd2739
> --- /dev/null
> +++ b/gas/testsuite/gas/mach-o/subsect-via-symbols-0.d
> @@ -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
> index 0000000..163a9c2
> --- /dev/null
> +++ b/gas/testsuite/gas/mach-o/subsect-via-symbols-1.d
> @@ -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
> index 0000000..b244150
> --- /dev/null
> +++ b/gas/testsuite/gas/mach-o/subsect-via-symbols.s
> @@ -0,0 +1,3 @@
> +# just set subsections by symbols
> + .subsections_via_symbols
> +
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Rebased: [Patch mach-o/gas] implement private file flags/subsections-via-symbols.
2011-12-15 10:57 ` Tristan Gingold
@ 2011-12-15 11:34 ` Iain Sandoe
2011-12-15 11:44 ` Tristan Gingold
0 siblings, 1 reply; 8+ messages in thread
From: Iain Sandoe @ 2011-12-15 11:34 UTC (permalink / raw)
To: Tristan Gingold; +Cc: binutils
On 15 Dec 2011, at 10:57, Tristan Gingold wrote:
>
> I have just committed it.
well, between our iterations I seem to have messed up with a patch.
the patch I posted was wrong - I must have diffed a wrong dependent
tree, very sorry (I do build each time).
Iain
this is needed ...
Index: gas/config/obj-macho.c
===================================================================
RCS file: /cvs/src/src/gas/config/obj-macho.c,v
retrieving revision 1.4
diff -u -p -r1.4 obj-macho.c
--- gas/config/obj-macho.c 15 Dec 2011 10:56:47 -0000 1.4
+++ gas/config/obj-macho.c 15 Dec 2011 11:29:47 -0000
@@ -696,7 +696,7 @@ obj_mach_o_fileprop (int prop)
switch ((obj_mach_o_file_properties) prop)
{
case OBJ_MACH_O_FILE_PROP_SUBSECTS_VIA_SYMS:
- subsections_by_symbols = 1;
+ obj_mach_o_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"));
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Rebased: [Patch mach-o/gas] implement private file flags/subsections-via-symbols.
2011-12-15 11:34 ` Iain Sandoe
@ 2011-12-15 11:44 ` Tristan Gingold
0 siblings, 0 replies; 8+ messages in thread
From: Tristan Gingold @ 2011-12-15 11:44 UTC (permalink / raw)
To: Iain Sandoe; +Cc: binutils
On Dec 15, 2011, at 12:34 PM, Iain Sandoe wrote:
>
> On 15 Dec 2011, at 10:57, Tristan Gingold wrote:
>>
>> I have just committed it.
>
> well, between our iterations I seem to have messed up with a patch.
> the patch I posted was wrong - I must have diffed a wrong dependent tree, very sorry (I do build each time).
> Iain
>
> this is needed …
Oh right. I compiled for x86_64 which doesn't (yet) enable gas…
Committed with a CL entry.
Thank you for the head-up.
Tristan.
>
> Index: gas/config/obj-macho.c
> ===================================================================
> RCS file: /cvs/src/src/gas/config/obj-macho.c,v
> retrieving revision 1.4
> diff -u -p -r1.4 obj-macho.c
> --- gas/config/obj-macho.c 15 Dec 2011 10:56:47 -0000 1.4
> +++ gas/config/obj-macho.c 15 Dec 2011 11:29:47 -0000
> @@ -696,7 +696,7 @@ obj_mach_o_fileprop (int prop)
> switch ((obj_mach_o_file_properties) prop)
> {
> case OBJ_MACH_O_FILE_PROP_SUBSECTS_VIA_SYMS:
> - subsections_by_symbols = 1;
> + obj_mach_o_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"));
>
>
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2011-12-15 11:44 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-12-11 16:03 [Patch mach-o/gas] implement private file flags/subsections-via-symbols Iain Sandoe
2011-12-12 8:51 ` Tristan Gingold
2011-12-13 11:56 ` Rebased: " Iain Sandoe
2011-12-14 15:25 ` Tristan Gingold
2011-12-14 16:09 ` Iain Sandoe
2011-12-15 10:57 ` Tristan Gingold
2011-12-15 11:34 ` Iain Sandoe
2011-12-15 11:44 ` Tristan Gingold
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).