aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorIain Sandoe <iain@codesourcery.com>2011-12-29 10:53:10 +0000
committerIain Sandoe <iain@codesourcery.com>2011-12-29 10:53:10 +0000
commitbcf0aac6f660e4ee754a93276a8601ab1e1bb42c (patch)
treed9073253ba036586d92e44bf9e8c7c98661be7cc /gas
parent3362e0d9fb6c0e34a2875295c34ca3f73cdf8892 (diff)
downloadgdb-bcf0aac6f660e4ee754a93276a8601ab1e1bb42c.zip
gdb-bcf0aac6f660e4ee754a93276a8601ab1e1bb42c.tar.gz
gdb-bcf0aac6f660e4ee754a93276a8601ab1e1bb42c.tar.bz2
adjust mach-o default GAS sections.
gas: * as.c (perform_an_assembly_pass): Do not create text, data and bss sections for MACH-O. Do not switch to the text section. * config/obj-macho.c (obj_mach_o_segT_from_bfd_name): Forward decl. (mach_o_begin): Startup with only text section unless suppressed. * config/obj-macho.h (obj_begin): define to mach_o_begin (). gas/testsuite: * gas/mach-o/sections-1.d: Amend to recognize that bss is not emitted by default. * gas/mach-o/sections-2.d: New.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog8
-rw-r--r--gas/as.c6
-rw-r--r--gas/config/obj-macho.c34
-rw-r--r--gas/config/obj-macho.h4
-rw-r--r--gas/testsuite/ChangeLog6
-rw-r--r--gas/testsuite/gas/mach-o/sections-1.d5
-rw-r--r--gas/testsuite/gas/mach-o/sections-2.d14
7 files changed, 69 insertions, 8 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 30ff4fb..26e4fc5 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,11 @@
+2011-12-29 Iain Sandoe <idsandoe@googlemail.com>
+
+ * as.c (perform_an_assembly_pass): Do not create text, data and bss
+ sections for MACH-O. Do not switch to the text section.
+ * config/obj-macho.c (obj_mach_o_segT_from_bfd_name): Forward decl.
+ (mach_o_begin): Startup with only text section unless suppressed.
+ * config/obj-macho.h (obj_begin): define to mach_o_begin ().
+
2011-12-22 DJ Delorie <dj@redhat.com>
* config/rl78-defs.h (rl78_linkrelax_addr16): Add.
diff --git a/gas/as.c b/gas/as.c
index b99ea1e..1325038 100644
--- a/gas/as.c
+++ b/gas/as.c
@@ -1037,10 +1037,13 @@ static void
perform_an_assembly_pass (int argc, char ** argv)
{
int saw_a_file = 0;
+#ifndef OBJ_MACH_O
flagword applicable;
+#endif
need_pass_2 = 0;
+#ifndef OBJ_MACH_O
/* Create the standard sections, and those the assembler uses
internally. */
text_section = subseg_new (TEXT_SECTION_NAME, 0);
@@ -1057,12 +1060,15 @@ perform_an_assembly_pass (int argc, char ** argv)
| SEC_DATA));
bfd_set_section_flags (stdoutput, bss_section, applicable & SEC_ALLOC);
seg_info (bss_section)->bss = 1;
+#endif
subseg_new (BFD_ABS_SECTION_NAME, 0);
subseg_new (BFD_UND_SECTION_NAME, 0);
reg_section = subseg_new ("*GAS `reg' section*", 0);
expr_section = subseg_new ("*GAS `expr' section*", 0);
+#ifndef OBJ_MACH_O
subseg_set (text_section, 0);
+#endif
/* This may add symbol table entries, which requires having an open BFD,
and sections already created. */
diff --git a/gas/config/obj-macho.c b/gas/config/obj-macho.c
index be1c9ff..74fb0c9 100644
--- a/gas/config/obj-macho.c
+++ b/gas/config/obj-macho.c
@@ -45,13 +45,40 @@
#include "mach-o/loader.h"
#include "obj-macho.h"
+/* Forward decl. */
+static segT obj_mach_o_segT_from_bfd_name (const char *nam, int must_succeed);
+
/* TODO: Implement "-dynamic"/"-static" command line options. */
static int obj_mach_o_is_static;
+/* TODO: Implement the "-n" command line option to suppress the initial
+ switch to the text segment. */
+static int obj_mach_o_start_with_text_section = 1;
+
/* Allow for special re-ordering on output. */
-static int seen_objc_section;
+static int obj_mach_o_seen_objc_section;
+
+/* Start-up: At present, just create the sections we want. */
+void
+mach_o_begin (void)
+{
+ /* Mach-O only defines the .text section by default, and even this can
+ be suppressed by a flag. In the latter event, the first code MUST
+ be a section definition. */
+ if (obj_mach_o_start_with_text_section)
+ {
+ text_section = obj_mach_o_segT_from_bfd_name (TEXT_SECTION_NAME, 1);
+ subseg_set (text_section, 0);
+ if (obj_mach_o_is_static)
+ {
+ bfd_mach_o_section *mo_sec
+ = bfd_mach_o_get_mach_o_section (text_section);
+ mo_sec->flags &= ~BFD_MACH_O_S_ATTR_PURE_INSTRUCTIONS;
+ }
+ }
+}
/* Remember the subsections_by_symbols state in case we need to reset
the file flags. */
@@ -473,8 +500,9 @@ obj_mach_o_objc_section (int sect_index)
section = obj_mach_o_segT_from_bfd_name (objc_sections[sect_index], 1);
if (section != NULL)
{
- seen_objc_section = 1; /* We need to ensure that certain sections are
- present and in the right order. */
+ obj_mach_o_seen_objc_section = 1; /* We need to ensure that certain
+ sections are present and in the
+ right order. */
subseg_set (section, 0);
}
diff --git a/gas/config/obj-macho.h b/gas/config/obj-macho.h
index 94c1cde..d9b0b33 100644
--- a/gas/config/obj-macho.h
+++ b/gas/config/obj-macho.h
@@ -30,6 +30,10 @@
#define OUTPUT_FLAVOR bfd_target_mach_o_flavour
+/* We want to control how the sections are pre-defined on startup. */
+#define obj_begin() mach_o_begin ()
+extern void mach_o_begin (void);
+
/* All our align expressions are power of two. */
#define USE_ALIGN_PTWO
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index 723b8c4..80f9a73 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,9 @@
+2011-12-29 Iain Sandoe <idsandoe@googlemail.com>
+
+ * gas/mach-o/sections-1.d: Amend to recognize that bss is not emitted
+ by default.
+ * gas/mach-o/sections-2.d: New.
+
2011-12-19 Iain Sandoe <idsandoe@googlemail.com>
* gas/mach-o/err-sections-1.s: New.
diff --git a/gas/testsuite/gas/mach-o/sections-1.d b/gas/testsuite/gas/mach-o/sections-1.d
index a70af9b..5b8a8fa 100644
--- a/gas/testsuite/gas/mach-o/sections-1.d
+++ b/gas/testsuite/gas/mach-o/sections-1.d
@@ -11,11 +11,6 @@
align: 0 nreloc: 0 reloff: (00000000)?00000000
flags: 00000000 \(type: regular attr: -\)
reserved1: 0x0 reserved2: 0x0 reserved3: 0x0
- Section: __bss __DATA \(bfdname: .bss\)
- addr: (00000000)?00000000 size: (00000000)?00000000 offset: (00000000)?00000000
- align: 0 nreloc: 0 reloff: (00000000)?00000000
- flags: 00000001 \(type: zerofill attr: -\)
- reserved1: 0x0 reserved2: 0x0 reserved3: 0x0
Section: __textcoal_nt __TEXT \(bfdname: __TEXT.__textcoal_nt\)
addr: (00000000)?00000000 size: (00000000)?00000000 offset: (00000000)?00000000
align: 0 nreloc: 0 reloff: (00000000)?00000000
diff --git a/gas/testsuite/gas/mach-o/sections-2.d b/gas/testsuite/gas/mach-o/sections-2.d
new file mode 100644
index 0000000..9d24f9a
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/sections-2.d
@@ -0,0 +1,14 @@
+#objdump: -h
+#source: empty.s
+# we should only see a text section by default.
+.*: +file format mach-o.*
+#...
+Idx Name.*
+ 0 .text.*
+.*
+#failif
+ 1 .data.*
+.*
+ 2 .bss.*
+.*
+