diff options
author | Tristan Gingold <tristan.gingold@adacore.com> | 2014-03-25 15:51:54 +0100 |
---|---|---|
committer | Tristan Gingold <tristan.gingold@adacore.com> | 2014-03-27 10:23:22 +0100 |
commit | 3cc27770cfa2080f70d44659de9d62adc80489fc (patch) | |
tree | bc8a143d3941d458aa0224b3293675bf6217af88 /bfd/mach-o.c | |
parent | b5bee914261ea82683b7da4245790465b9373131 (diff) | |
download | gdb-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/mach-o.c')
-rw-r--r-- | bfd/mach-o.c | 42 |
1 files changed, 37 insertions, 5 deletions
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; |