aboutsummaryrefslogtreecommitdiff
path: root/gas
diff options
context:
space:
mode:
authorIain Sandoe <iain@codesourcery.com>2011-12-19 15:42:37 +0000
committerIain Sandoe <iain@codesourcery.com>2011-12-19 15:42:37 +0000
commitab76eeafa578ca7e301e3aa014e4ed643e32ec2e (patch)
tree617c8c1e0b565e6331bc0200dbec3e1eb6149dd1 /gas
parent72225e1798fce2f36c4eb021338707ed69517abe (diff)
downloadgdb-ab76eeafa578ca7e301e3aa014e4ed643e32ec2e.zip
gdb-ab76eeafa578ca7e301e3aa014e4ed643e32ec2e.tar.gz
gdb-ab76eeafa578ca7e301e3aa014e4ed643e32ec2e.tar.bz2
bfd:
* mach-o-i386.c (bfd_mach_o_section_type_valid_for_tgt): Define NULL. * mach-o-target.c (bfd_mach_o_backend_data): Initialize bfd_mach_o_section_type_valid_for_tgt * mach-o-x86-64.c (bfd_mach_o_section_type_valid_for_x86_64): New. (bfd_mach_o_section_type_valid_for_tgt): Set to bfd_mach_o_section_type_valid_for_x86_64. * mach-o.c (bfd_mach_o_section_type_name): Reorder and eliminate dup. (bfd_mach_o_section_attribute_name): Reorder. (bfd_mach_o_get_section_type_from_name): If the target has defined a validator for section types, then use it. * mach-o.h (bfd_mach_o_get_section_type_from_name): Alter declaration to include the bfd. gas: * config/obj-macho.c (obj_mach_o_section): Account for target-dependent section types. Improve error handling when wrong section types/attributes are specified. gas/testsuite: * gas/mach-o/err-sections-1.s: New. * gas/mach-o/err-sections-2.s: New. * gas/mach-o/sections-3.d: New. * gas/mach-o/sections-3.s: New.
Diffstat (limited to 'gas')
-rw-r--r--gas/ChangeLog6
-rw-r--r--gas/config/obj-macho.c41
-rw-r--r--gas/testsuite/ChangeLog7
-rw-r--r--gas/testsuite/gas/mach-o/err-sections-1.s9
-rw-r--r--gas/testsuite/gas/mach-o/err-sections-2.s9
-rw-r--r--gas/testsuite/gas/mach-o/sections-3.d19
-rw-r--r--gas/testsuite/gas/mach-o/sections-3.s7
7 files changed, 85 insertions, 13 deletions
diff --git a/gas/ChangeLog b/gas/ChangeLog
index 9707060..6cfd3db 100644
--- a/gas/ChangeLog
+++ b/gas/ChangeLog
@@ -1,3 +1,9 @@
+2011-12-19 Iain Sandoe <idsandoe@googlemail.com>
+
+ * config/obj-macho.c (obj_mach_o_section): Account for target-
+ dependent section types. Improve error handling when wrong section
+ types/attributes are specified.
+
2011-12-19 Chung-Lin Tang <cltang@codesourcery.com>
* config/tc-mips.c (mips_pseudo_table): Add tprelword/tpreldword
diff --git a/gas/config/obj-macho.c b/gas/config/obj-macho.c
index 0852cde..be1c9ff 100644
--- a/gas/config/obj-macho.c
+++ b/gas/config/obj-macho.c
@@ -169,6 +169,10 @@ obj_mach_o_section (int ignore ATTRIBUTE_UNUSED)
char segname[17];
char sectname[17];
+#ifdef md_flush_pending_output
+ md_flush_pending_output ();
+#endif
+
/* Zero-length segment and section names are allowed. */
/* Parse segment name. */
memset (segname, 0, sizeof(segname));
@@ -203,16 +207,18 @@ obj_mach_o_section (int ignore ATTRIBUTE_UNUSED)
/* Temporarily make a string from the token. */
p[len] = 0;
- sectype = bfd_mach_o_get_section_type_from_name (p);
+ sectype = bfd_mach_o_get_section_type_from_name (stdoutput, p);
if (sectype > 255) /* Max Section ID == 255. */
{
as_bad (_("unknown or invalid section type '%s'"), p);
- sectype = BFD_MACH_O_S_REGULAR;
+ p[len] = tmpc;
+ ignore_rest_of_line ();
+ return;
}
else
sectype_given = 1;
/* Restore. */
- tmpc = p[len];
+ p[len] = tmpc;
/* Parse attributes.
TODO: check validity of attributes for section type. */
@@ -241,7 +247,12 @@ obj_mach_o_section (int ignore ATTRIBUTE_UNUSED)
p[len] ='\0';
attr = bfd_mach_o_get_section_attribute_from_name (p);
if (attr == -1)
- as_bad (_("unknown or invalid section attribute '%s'"), p);
+ {
+ as_bad (_("unknown or invalid section attribute '%s'"), p);
+ p[len] = tmpc;
+ ignore_rest_of_line ();
+ return;
+ }
else
{
secattr_given = 1;
@@ -253,19 +264,26 @@ obj_mach_o_section (int ignore ATTRIBUTE_UNUSED)
while (*input_line_pointer == '+');
/* Parse sizeof_stub. */
- if (*input_line_pointer == ',')
+ if (secattr_given && *input_line_pointer == ',')
{
if (sectype != BFD_MACH_O_S_SYMBOL_STUBS)
- as_bad (_("unexpected sizeof_stub expression"));
+ {
+ as_bad (_("unexpected section size information"));
+ ignore_rest_of_line ();
+ return;
+ }
input_line_pointer++;
sizeof_stub = get_absolute_expression ();
}
- else if (sectype == BFD_MACH_O_S_SYMBOL_STUBS)
- as_bad (_("missing sizeof_stub expression"));
+ else if (secattr_given && sectype == BFD_MACH_O_S_SYMBOL_STUBS)
+ {
+ as_bad (_("missing sizeof_stub expression"));
+ ignore_rest_of_line ();
+ return;
+ }
}
}
- demand_empty_rest_of_line ();
flags = SEC_NO_FLAGS;
/* This provides default bfd flags and default mach-o section type and
@@ -296,10 +314,6 @@ obj_mach_o_section (int ignore ATTRIBUTE_UNUSED)
name = n;
}
-#ifdef md_flush_pending_output
- md_flush_pending_output ();
-#endif
-
/* Sub-segments don't exists as is on Mach-O. */
sec = subseg_new (name, 0);
@@ -334,6 +348,7 @@ obj_mach_o_section (int ignore ATTRIBUTE_UNUSED)
|| msect->flags != (secattr | sectype))
as_warn (_("Ignoring changed section attributes for %s"), name);
}
+ demand_empty_rest_of_line ();
}
static segT
diff --git a/gas/testsuite/ChangeLog b/gas/testsuite/ChangeLog
index c9efc90..723b8c4 100644
--- a/gas/testsuite/ChangeLog
+++ b/gas/testsuite/ChangeLog
@@ -1,3 +1,10 @@
+2011-12-19 Iain Sandoe <idsandoe@googlemail.com>
+
+ * gas/mach-o/err-sections-1.s: New.
+ * gas/mach-o/err-sections-2.s: New.
+ * gas/mach-o/sections-3.d: New.
+ * gas/mach-o/sections-3.s: New.
+
2011-12-15 Iain Sandoe <iains@gcc.gnu.org>
* gas/mach-o/subsect-via-symbols-0.d: New.
diff --git a/gas/testsuite/gas/mach-o/err-sections-1.s b/gas/testsuite/gas/mach-o/err-sections-1.s
new file mode 100644
index 0000000..99447a7
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/err-sections-1.s
@@ -0,0 +1,9 @@
+# { dg-do assemble { target x86_64-*-darwin* } }
+
+ .section __a,__b,symbol_stubs,strip_static_syms,4
+ .section __a,__c,lazy_symbol_pointers,strip_static_syms,4
+ .section __a,__d,non_lazy_symbol_pointers,strip_static_syms,4
+
+# { dg-error "unknown or invalid section type .symbol_stubs." "" { target x86_64-*-darwin* } 3 }
+# { dg-error "unknown or invalid section type .lazy_symbol_pointers." "" { target x86_64-*-darwin* } 4 }
+# { dg-error "unknown or invalid section type .non_lazy_symbol_pointers." "" { target x86_64-*-darwin* } 5 }
diff --git a/gas/testsuite/gas/mach-o/err-sections-2.s b/gas/testsuite/gas/mach-o/err-sections-2.s
new file mode 100644
index 0000000..3343066
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/err-sections-2.s
@@ -0,0 +1,9 @@
+# { dg-do assemble { target x86_64-*-darwin* } }
+
+ .symbol_stub
+ .lazy_symbol_pointer
+ .non_lazy_symbol_pointer
+
+# { dg-error ".symbol_stub is not used for the selected target" "" { target x86_64-*-darwin* } 3 }
+# { dg-error ".lazy_symbol_pointer is not used for the selected target" "" { target x86_64-*-darwin* } 4 }
+# { dg-error ".non_lazy_symbol_pointer is not used for the selected target" "" { target x86_64-*-darwin* } 5 }
diff --git a/gas/testsuite/gas/mach-o/sections-3.d b/gas/testsuite/gas/mach-o/sections-3.d
new file mode 100644
index 0000000..9d1daf4
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/sections-3.d
@@ -0,0 +1,19 @@
+#objdump: -P section
+#not-target: x86_64-*-darwin*
+.*: +file format mach-o.*
+#...
+ Section: __symbol_stub __TEXT.*\(bfdname: .symbol_stub\)
+ addr: (00000000)?00000000 size: (00000000)?00000000 offset: (00000000)?00000000
+ align: 0 nreloc: 0 reloff: (00000000)?00000000
+ flags: 80000008 \(type: symbol_stubs attr: pure_instructions\)
+ first indirect sym: 0 \(0 entries\) stub size: (16|20) reserved3: 0x0
+ Section: __la_symbol_ptr __DATA.*\(bfdname: .lazy_symbol_pointer\)
+ addr: (00000000)?00000000 size: (00000000)?00000000 offset: (00000000)?00000000
+ align: 2 nreloc: 0 reloff: (00000000)?00000000
+ flags: 00000007 \(type: lazy_symbol_pointers attr: -\)
+ first indirect sym: 0 \(0 entries\) reserved2: 0x0 reserved3: 0x0
+ Section: __nl_symbol_ptr __DATA.*\(bfdname: .non_lazy_symbol_pointer\)
+ addr: (00000000)?00000000 size: (00000000)?00000000 offset: (00000000)?00000000
+ align: 2 nreloc: 0 reloff: (00000000)?00000000
+ flags: 00000006 \(type: non_lazy_symbol_pointers attr: -\)
+ first indirect sym: 0 \(0 entries\) reserved2: 0x0 reserved3: 0x0
diff --git a/gas/testsuite/gas/mach-o/sections-3.s b/gas/testsuite/gas/mach-o/sections-3.s
new file mode 100644
index 0000000..17fae52
--- /dev/null
+++ b/gas/testsuite/gas/mach-o/sections-3.s
@@ -0,0 +1,7 @@
+
+ .symbol_stub
+
+ .lazy_symbol_pointer
+
+ .non_lazy_symbol_pointer
+