aboutsummaryrefslogtreecommitdiff
path: root/bfd/mach-o.h
diff options
context:
space:
mode:
authorIain Sandoe <iain@codesourcery.com>2012-01-03 10:54:01 +0000
committerIain Sandoe <iain@codesourcery.com>2012-01-03 10:54:01 +0000
commit7f3072381b852817638295d676689b211af03c50 (patch)
tree7e0b9316807305c1a6851fffa3d564e0576ab597 /bfd/mach-o.h
parent3c2d6aff67c0d33ed51d588bd7780f2fc0cfad1b (diff)
downloadgdb-7f3072381b852817638295d676689b211af03c50.zip
gdb-7f3072381b852817638295d676689b211af03c50.tar.gz
gdb-7f3072381b852817638295d676689b211af03c50.tar.bz2
add dysymtab write support to bfd/mach-o.
bfd: * mach-o.c (bfd_mach_o_write_symtab): Fill in the string table index as the value of an indirect symbol. Keep the string table index in non-indirect syms for reference. (bfd_mach_o_write_dysymtab): New. (bfd_mach_o_primary_symbol_sort_key): New. (bfd_mach_o_cf_symbols): New. (bfd_mach_o_sort_symbol_table): New. (bfd_mach_o_mangle_symbols): Return early if no symbols. Sort symbols. If we are emitting a dysymtab, process indirect symbols and count the number of each other kind. (bfd_mach_o_mangle_sections): New. (bfd_mach_o_write_contents): Split out some pre-requisite code into the command builder. Write dysymtab if the command is present. (bfd_mach_o_count_sections_for_seg): New. (bfd_mach_o_build_seg_command): New. (bfd_mach_o_build_dysymtab_command): New. (bfd_mach_o_build_commands): Reorganize to support the fact that some commands are optional and should not be emitted if there are no sections or symbols. (bfd_mach_o_set_section_contents): Amend comment. * mach-o.h: Amend and add to comments. (mach_o_data_struct): Add fields for dysymtab symbols counts and a pointer to the indirects, when present. (bfd_mach_o_should_emit_dysymtab): New macro. (IS_MACHO_INDIRECT): Likewise. gas/testsuite: * gas/mach-o/dysymtab-1-64.d: New. * gas/mach-o/dysymtab-1.d: New. * gas/mach-o/symbols-1-64.d: New. * gas/mach-o/symbols-1.d: New. * gas/mach-o/symbols-base-64.s: New. * gas/mach-o/symbols-base.s: New.
Diffstat (limited to 'bfd/mach-o.h')
-rw-r--r--bfd/mach-o.h39
1 files changed, 35 insertions, 4 deletions
diff --git a/bfd/mach-o.h b/bfd/mach-o.h
index 89dce1a..24a1645 100644
--- a/bfd/mach-o.h
+++ b/bfd/mach-o.h
@@ -1,6 +1,6 @@
/* Mach-O support for BFD.
- Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008, 2009, 2011
- Free Software Foundation, Inc.
+ Copyright 1999, 2000, 2001, 2002, 2003, 2005, 2007, 2008, 2009, 2011,
+ 2012 Free Software Foundation, Inc.
This file is part of BFD, the Binary File Descriptor library.
@@ -109,13 +109,24 @@ typedef struct bfd_mach_o_asymbol
/* The actual symbol which the rest of BFD works with. */
asymbol symbol;
- /* Fields from Mach-O symbol. */
+ /* Mach-O symbol fields. */
unsigned char n_type;
unsigned char n_sect;
unsigned short n_desc;
}
bfd_mach_o_asymbol;
+/* The symbol table is sorted like this:
+ (1) local.
+ (otherwise in order of generation)
+ (2) external defined
+ (sorted by name)
+ (3) external undefined
+ (sorted by name)
+ (4) common
+ (sorted by name)
+*/
+
typedef struct bfd_mach_o_symtab_command
{
unsigned int symoff;
@@ -507,7 +518,7 @@ typedef struct mach_o_data_struct
unsigned long nsects;
bfd_mach_o_section **sections;
- /* Used while writting: current length of the output file. This is used
+ /* Used while writing: current length of the output file. This is used
to allocate space in the file. */
ufile_ptr filelen;
@@ -517,6 +528,18 @@ typedef struct mach_o_data_struct
bfd_mach_o_symtab_command *symtab;
bfd_mach_o_dysymtab_command *dysymtab;
+ /* Base values used for building the dysymtab for a single-module object. */
+ unsigned long nlocal;
+ unsigned long ndefext;
+ unsigned long nundefext;
+
+ /* If this is non-zero, then the pointer below is populated. */
+ unsigned long nindirect;
+ /* A set of synthetic symbols representing the 'indirect' ones in the file.
+ These should be sorted (a) by the section they represent and (b) by the
+ order that they appear within each section. */
+ asymbol **indirect_syms;
+
/* A place to stash dwarf2 info for this bfd. */
void *dwarf2_find_line_info;
@@ -600,6 +623,10 @@ unsigned int bfd_mach_o_section_get_entry_size (bfd *, bfd_mach_o_section *);
bfd_boolean bfd_mach_o_read_symtab_symbols (bfd *);
bfd_boolean bfd_mach_o_read_symtab_strtab (bfd *abfd);
+/* A placeholder in case we need to suppress emitting the dysymtab for some
+ reason (e.g. compatibility with older system versions). */
+#define bfd_mach_o_should_emit_dysymtab(x) TRUE
+
extern const bfd_mach_o_xlat_name bfd_mach_o_section_attribute_name[];
extern const bfd_mach_o_xlat_name bfd_mach_o_section_type_name[];
@@ -640,4 +667,8 @@ typedef struct bfd_mach_o_backend_data
}
bfd_mach_o_backend_data;
+/* Symbol type tests. */
+
+#define IS_MACHO_INDIRECT(x) (((x) & BFD_MACH_O_N_TYPE) == BFD_MACH_O_N_INDR)
+
#endif /* _BFD_MACH_O_H_ */