aboutsummaryrefslogtreecommitdiff
path: root/bfd
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 /bfd
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 'bfd')
-rw-r--r--bfd/ChangeLog15
-rw-r--r--bfd/mach-o-i386.c1
-rw-r--r--bfd/mach-o-target.c3
-rw-r--r--bfd/mach-o-x86-64.c11
-rw-r--r--bfd/mach-o.c31
-rw-r--r--bfd/mach-o.h3
6 files changed, 52 insertions, 12 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index b651abe..a2d7499 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,18 @@
+2011-12-19 Iain Sandoe <idsandoe@googlemail.com>
+
+ * 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.
+
2011-12-19 Chung-Lin Tang <cltang@codesourcery.com>
* reloc.c (BFD_RELOC_MIPS16_TLS_GD,BFD_RELOC_MIPS16_TLS_LDM,
diff --git a/bfd/mach-o-i386.c b/bfd/mach-o-i386.c
index 3dadcb8..d106710 100644
--- a/bfd/mach-o-i386.c
+++ b/bfd/mach-o-i386.c
@@ -338,6 +338,7 @@ const mach_o_segment_name_xlat mach_o_i386_segsec_names_xlat[] =
#define bfd_mach_o_print_thread bfd_mach_o_i386_print_thread
#define bfd_mach_o_tgt_seg_table mach_o_i386_segsec_names_xlat
+#define bfd_mach_o_section_type_valid_for_tgt NULL
#define bfd_mach_o_bfd_reloc_type_lookup bfd_mach_o_i386_bfd_reloc_type_lookup
#define bfd_mach_o_bfd_reloc_name_lookup bfd_mach_o_i386_bfd_reloc_name_lookup
diff --git a/bfd/mach-o-target.c b/bfd/mach-o-target.c
index 4aeb920..a2aa573 100644
--- a/bfd/mach-o-target.c
+++ b/bfd/mach-o-target.c
@@ -96,7 +96,8 @@ static const bfd_mach_o_backend_data TARGET_NAME_BACKEND =
bfd_mach_o_swap_reloc_in,
bfd_mach_o_swap_reloc_out,
bfd_mach_o_print_thread,
- bfd_mach_o_tgt_seg_table
+ bfd_mach_o_tgt_seg_table,
+ bfd_mach_o_section_type_valid_for_tgt
};
const bfd_target TARGET_NAME =
diff --git a/bfd/mach-o-x86-64.c b/bfd/mach-o-x86-64.c
index c86efb7..cc31a1c 100644
--- a/bfd/mach-o-x86-64.c
+++ b/bfd/mach-o-x86-64.c
@@ -281,6 +281,16 @@ bfd_mach_o_x86_64_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
return NULL;
}
+static bfd_boolean
+bfd_mach_o_section_type_valid_for_x86_64 (unsigned long val)
+{
+ if (val == BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS
+ || val == BFD_MACH_O_S_LAZY_SYMBOL_POINTERS
+ || val == BFD_MACH_O_S_SYMBOL_STUBS)
+ return FALSE;
+ return TRUE;
+}
+
#define bfd_mach_o_swap_reloc_in bfd_mach_o_x86_64_swap_reloc_in
#define bfd_mach_o_swap_reloc_out bfd_mach_o_x86_64_swap_reloc_out
@@ -288,6 +298,7 @@ bfd_mach_o_x86_64_bfd_reloc_name_lookup (bfd *abfd ATTRIBUTE_UNUSED,
#define bfd_mach_o_bfd_reloc_name_lookup bfd_mach_o_x86_64_bfd_reloc_name_lookup
#define bfd_mach_o_print_thread NULL
#define bfd_mach_o_tgt_seg_table NULL
+#define bfd_mach_o_section_type_valid_for_tgt bfd_mach_o_section_type_valid_for_x86_64
#define TARGET_NAME mach_o_x86_64_vec
#define TARGET_STRING "mach-o-x86-64"
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index dca8601..cc68d89 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -3550,24 +3550,26 @@ bfd_mach_o_stack_addr (enum bfd_mach_o_cpu_type type)
}
}
+/* The following two tables should be kept, as far as possible, in order of
+ most frequently used entries to optimize their use from gas. */
+
const bfd_mach_o_xlat_name bfd_mach_o_section_type_name[] =
{
{ "regular", BFD_MACH_O_S_REGULAR},
+ { "coalesced", BFD_MACH_O_S_COALESCED},
{ "zerofill", BFD_MACH_O_S_ZEROFILL},
{ "cstring_literals", BFD_MACH_O_S_CSTRING_LITERALS},
{ "4byte_literals", BFD_MACH_O_S_4BYTE_LITERALS},
{ "8byte_literals", BFD_MACH_O_S_8BYTE_LITERALS},
+ { "16byte_literals", BFD_MACH_O_S_16BYTE_LITERALS},
{ "literal_pointers", BFD_MACH_O_S_LITERAL_POINTERS},
- { "non_lazy_symbol_pointers", BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS},
- { "lazy_symbol_pointers", BFD_MACH_O_S_LAZY_SYMBOL_POINTERS},
- { "symbol_stubs", BFD_MACH_O_S_SYMBOL_STUBS},
{ "mod_init_func_pointers", BFD_MACH_O_S_MOD_INIT_FUNC_POINTERS},
{ "mod_fini_func_pointers", BFD_MACH_O_S_MOD_FINI_FUNC_POINTERS},
- { "coalesced", BFD_MACH_O_S_COALESCED},
{ "gb_zerofill", BFD_MACH_O_S_GB_ZEROFILL},
{ "interposing", BFD_MACH_O_S_INTERPOSING},
- { "16byte_literals", BFD_MACH_O_S_16BYTE_LITERALS},
{ "dtrace_dof", BFD_MACH_O_S_DTRACE_DOF},
+ { "non_lazy_symbol_pointers", BFD_MACH_O_S_NON_LAZY_SYMBOL_POINTERS},
+ { "lazy_symbol_pointers", BFD_MACH_O_S_LAZY_SYMBOL_POINTERS},
{ "symbol_stubs", BFD_MACH_O_S_SYMBOL_STUBS},
{ "lazy_dylib_symbol_pointers", BFD_MACH_O_S_LAZY_DYLIB_SYMBOL_POINTERS},
{ NULL, 0}
@@ -3575,30 +3577,38 @@ const bfd_mach_o_xlat_name bfd_mach_o_section_type_name[] =
const bfd_mach_o_xlat_name bfd_mach_o_section_attribute_name[] =
{
+ { "pure_instructions", BFD_MACH_O_S_ATTR_PURE_INSTRUCTIONS },
+ { "some_instructions", BFD_MACH_O_S_ATTR_SOME_INSTRUCTIONS },
{ "loc_reloc", BFD_MACH_O_S_ATTR_LOC_RELOC },
{ "ext_reloc", BFD_MACH_O_S_ATTR_EXT_RELOC },
- { "some_instructions", BFD_MACH_O_S_ATTR_SOME_INSTRUCTIONS },
{ "debug", BFD_MACH_O_S_ATTR_DEBUG },
- { "modifying_code", BFD_MACH_O_S_SELF_MODIFYING_CODE },
{ "live_support", BFD_MACH_O_S_ATTR_LIVE_SUPPORT },
{ "no_dead_strip", BFD_MACH_O_S_ATTR_NO_DEAD_STRIP },
{ "strip_static_syms", BFD_MACH_O_S_ATTR_STRIP_STATIC_SYMS },
{ "no_toc", BFD_MACH_O_S_ATTR_NO_TOC },
- { "pure_instructions", BFD_MACH_O_S_ATTR_PURE_INSTRUCTIONS },
{ "self_modifying_code", BFD_MACH_O_S_SELF_MODIFYING_CODE },
+ { "modifying_code", BFD_MACH_O_S_SELF_MODIFYING_CODE },
{ NULL, 0}
};
/* Get the section type from NAME. Return 256 if NAME is unknown. */
unsigned int
-bfd_mach_o_get_section_type_from_name (const char *name)
+bfd_mach_o_get_section_type_from_name (bfd *abfd, const char *name)
{
const bfd_mach_o_xlat_name *x;
+ bfd_mach_o_backend_data *bed = bfd_mach_o_get_backend_data (abfd);
for (x = bfd_mach_o_section_type_name; x->name; x++)
if (strcmp (x->name, name) == 0)
- return x->val;
+ {
+ /* We found it... does the target support it? */
+ if (bed->bfd_mach_o_section_type_valid_for_target == NULL
+ || bed->bfd_mach_o_section_type_valid_for_target (x->val))
+ return x->val; /* OK. */
+ else
+ break; /* Not supported. */
+ }
/* Maximum section ID = 0xff. */
return 256;
}
@@ -3785,6 +3795,7 @@ bfd_boolean bfd_mach_o_free_cached_info (bfd *abfd)
#define bfd_mach_o_swap_reloc_out NULL
#define bfd_mach_o_print_thread NULL
#define bfd_mach_o_tgt_seg_table NULL
+#define bfd_mach_o_section_type_valid_for_tgt NULL
#define TARGET_NAME mach_o_be_vec
#define TARGET_STRING "mach-o-be"
diff --git a/bfd/mach-o.h b/bfd/mach-o.h
index 23c3e1c..89dce1a 100644
--- a/bfd/mach-o.h
+++ b/bfd/mach-o.h
@@ -584,7 +584,7 @@ bfd_boolean bfd_mach_o_set_section_contents (bfd *, asection *, const void *,
file_ptr, bfd_size_type);
unsigned int bfd_mach_o_version (bfd *);
-unsigned int bfd_mach_o_get_section_type_from_name (const char *);
+unsigned int bfd_mach_o_get_section_type_from_name (bfd *, const char *);
unsigned int bfd_mach_o_get_section_attribute_from_name (const char *);
void bfd_mach_o_convert_section_name_to_bfd (bfd *, const char *, const char *,
@@ -636,6 +636,7 @@ typedef struct bfd_mach_o_backend_data
bfd_boolean (*_bfd_mach_o_print_thread)(bfd *, bfd_mach_o_thread_flavour *,
void *, char *);
const mach_o_segment_name_xlat *segsec_names_xlat;
+ bfd_boolean (*bfd_mach_o_section_type_valid_for_target) (unsigned long);
}
bfd_mach_o_backend_data;