aboutsummaryrefslogtreecommitdiff
path: root/bfd
diff options
context:
space:
mode:
authorTristan Gingold <tristan.gingold@adacore.com>2014-03-25 15:51:54 +0100
committerTristan Gingold <tristan.gingold@adacore.com>2014-03-27 10:23:22 +0100
commit3cc27770cfa2080f70d44659de9d62adc80489fc (patch)
treebc8a143d3941d458aa0224b3293675bf6217af88 /bfd
parentb5bee914261ea82683b7da4245790465b9373131 (diff)
downloadgdb-3cc27770cfa2080f70d44659de9d62adc80489fc.zip
gdb-3cc27770cfa2080f70d44659de9d62adc80489fc.tar.gz
gdb-3cc27770cfa2080f70d44659de9d62adc80489fc.tar.bz2
Mach-O: add objdump -P function_starts to display function starts.
bfd/ * mach-o.h (bfd_mach_o_get_base_address): New prototype. * mach-o.c (bfd_mach_o_write_symtab) (bfd_mach_o_write_contents) (bfd_mach_o_set_section_flags_from_bfd) (bfd_mach_o_build_seg_command): Fix indentation. (bfd_mach_o_get_base_address): New function. binutils/ * od-macho.c (OPT_FUNCTION_STARTS): New macro. (options): Add entry for function_starts. (mach_o_help): Ditto. (disp_segment_prot): New function. (dump_section_map): Call disp_segment_prot. (dump_function_starts): New function. (dump_obj_compact_unwind): Fix ouput indentation. (dump_exe_compact_unwind): Fix ouput indentation. (mach_o_dump): Handle function_starts.
Diffstat (limited to 'bfd')
-rw-r--r--bfd/ChangeLog9
-rw-r--r--bfd/mach-o.c42
-rw-r--r--bfd/mach-o.h2
3 files changed, 48 insertions, 5 deletions
diff --git a/bfd/ChangeLog b/bfd/ChangeLog
index f2b5f9c..54b7834 100644
--- a/bfd/ChangeLog
+++ b/bfd/ChangeLog
@@ -1,3 +1,12 @@
+2014-03-27 Tristan Gingold <gingold@adacore.com>
+
+ * mach-o.h (bfd_mach_o_get_base_address): New prototype.
+ * mach-o.c (bfd_mach_o_write_symtab)
+ (bfd_mach_o_write_contents)
+ (bfd_mach_o_set_section_flags_from_bfd)
+ (bfd_mach_o_build_seg_command): Fix indentation.
+ (bfd_mach_o_get_base_address): New function.
+
2014-03-26 Nick Clifton <nickc@redhat.com>
* cofflink.c (_bfd_coff_generic_relocate_section): Skip
diff --git a/bfd/mach-o.c b/bfd/mach-o.c
index 6237602..8e8842b 100644
--- a/bfd/mach-o.c
+++ b/bfd/mach-o.c
@@ -1478,7 +1478,7 @@ bfd_mach_o_write_symtab (bfd *abfd, bfd_mach_o_load_command *command)
BFD_ASSERT (command->type == BFD_MACH_O_LC_SYMTAB);
/* Write the symbols first. */
- mdata->filelen = FILE_ALIGN(mdata->filelen, wide ? 3 : 2);
+ mdata->filelen = FILE_ALIGN (mdata->filelen, wide ? 3 : 2);
sym->symoff = mdata->filelen;
if (bfd_seek (abfd, sym->symoff, SEEK_SET) != 0)
return FALSE;
@@ -2018,8 +2018,9 @@ bfd_mach_o_write_contents (bfd *abfd)
case BFD_MACH_O_LC_SUB_FRAMEWORK:
break;
default:
- (*_bfd_error_handler) (_("unable to write unknown load command 0x%lx"),
- (unsigned long) cur->type);
+ (*_bfd_error_handler)
+ (_("unable to write unknown load command 0x%lx"),
+ (unsigned long) cur->type);
return FALSE;
}
}
@@ -2042,7 +2043,8 @@ bfd_mach_o_append_section_to_segment (bfd_mach_o_segment_command *seg,
/* Create section Mach-O flags from BFD flags. */
static void
-bfd_mach_o_set_section_flags_from_bfd (bfd *abfd ATTRIBUTE_UNUSED, asection *sec)
+bfd_mach_o_set_section_flags_from_bfd (bfd *abfd ATTRIBUTE_UNUSED,
+ asection *sec)
{
flagword bfd_flags;
bfd_mach_o_section *s = bfd_mach_o_get_mach_o_section (sec);
@@ -2173,7 +2175,8 @@ bfd_mach_o_build_seg_command (const char *segment,
mdata->filelen += s->size;
}
- /* Now pass through again, for zerofill, only now we just update the vmsize. */
+ /* Now pass through again, for zerofill, only now we just update the
+ vmsize. */
for (i = 0; i < mdata->nsects; ++i)
{
bfd_mach_o_section *s = mdata->sections[i];
@@ -4274,6 +4277,35 @@ bfd_mach_o_gen_core_p (bfd *abfd)
return bfd_mach_o_header_p (abfd, BFD_MACH_O_MH_CORE, 0);
}
+/* Return the base address of ABFD, ie the address at which the image is
+ mapped. The possible initial pagezero is ignored. */
+
+bfd_vma
+bfd_mach_o_get_base_address (bfd *abfd)
+{
+ bfd_mach_o_data_struct *mdata;
+ unsigned int i;
+
+ /* Check for Mach-O. */
+ if (!bfd_mach_o_valid (abfd))
+ return 0;
+ mdata = bfd_mach_o_get_data (abfd);
+
+ for (i = 0; i < mdata->header.ncmds; i++)
+ {
+ bfd_mach_o_load_command *cmd = &mdata->commands[i];
+ if ((cmd->type == BFD_MACH_O_LC_SEGMENT
+ || cmd->type == BFD_MACH_O_LC_SEGMENT_64))
+ {
+ struct bfd_mach_o_segment_command *segcmd = &cmd->command.segment;
+
+ if (segcmd->initprot != 0)
+ return segcmd->vmaddr;
+ }
+ }
+ return 0;
+}
+
typedef struct mach_o_fat_archentry
{
unsigned long cputype;
diff --git a/bfd/mach-o.h b/bfd/mach-o.h
index 6f695c5..4418b92 100644
--- a/bfd/mach-o.h
+++ b/bfd/mach-o.h
@@ -656,6 +656,8 @@ 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);
+bfd_vma bfd_mach_o_get_base_address (bfd *);
+
/* 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