Commit Graph

131 Commits

Author SHA1 Message Date
Alan Modra 93ee1e3683 PR16867, linking object with separate debug file
This teaches the DWARF2 find_line functions how to deal with separate
debug relocatable object files.  Also fixes a major bug:
When _bfd_dwarf2_slurp_debug_info was split out, place_sections ran
after .debug_info was relocated.  This defeated the whole purpose of
place_sections.  See the comment I added before place_sections.
Fixes some minor bugs too:
- place_sections didn't set VMA for alloc but non-load sections (bss).
- zero size sections can have symbols, so they need their VMA set too.
- last_vma was incorrectly adjusted.
- my last change to place_sections left VMA unchanged for .debug_info
  when the linker has mapped input to output sections, but this is
  wrong since bfd_simple_get_relocated_section_contents unmaps debug
  sections.

	PR 16867
	* dwarf2.c: Formatting.
	(struct dwarf2_debug): Make adjusted_section_count signed.
	(unset_sections): Make i signed.
	(set_debug_vma): New function.
	(place_sections): Handle separate debug object file.  Set VMA
	on debug sections, even if they have an output section.  Also
	set VMA on zero size sections, and non-load but alloc sections.
	Set adjusted_section_count to -1 when no section adjustment.
	Malloc adjusted_sections.  Don't double last_vma.  Transfer
	alloc section VMAs to separate debug file.
	(_bfd_dwarf2_cleanup_debug_info): Free adjusted_sections.
	(_bfd_dwarf2_slurp_debug_info): Add do_place parameter.  Drop
	test on symbols being the same before using old stash.  Read
	and use separate debug file symbols.  Call place_sections.
	(find_line): Don't call place_sections here.
	* libbfd-in.h (_bfd_dwarf2_slurp_debug_info): Update proto.
	* libbfd.h: Regenerate.
	* mach-o.c (bfd_mach_o_find_nearest_line): Adjust
	_bfd_dwarf2_slurp_debug_info call.
	* simple.c (simple_save_output_info): Clarify comment.
2014-04-24 22:04:05 +09:30
Tristan Gingold c9ffd2eaf8 mach-o: layout executables
bfd/
	* mach-o.h (bfd_mach_o_dyld_info_command): Add rebase_content,
	bind_content, weak_bind_content, lazy_bind_content,
	export_content.
	(bfd_mach_o_load_command): Add comments, add next field.
	(mach_o_data_struct): Replace commands field by first_command
	and last_command.
	* mach-o.c (bfd_mach_o_append_command): New function.
	(bfd_mach_o_bfd_copy_private_symbol_data): Add blank lines.
	(bfd_mach_o_bfd_copy_private_section_data): Check flavour,
	copy fields.
	(bfd_mach_o_bfd_copy_private_header_data): Copy load commands.
	(bfd_mach_o_pad4, bfd_mach_o_pad_command): New functions.
	(bfd_mach_o_write_thread): Use macro instead of literal.
	(bfd_mach_o_write_dylinker, bfd_mach_o_write_dylib)
	(bfd_mach_o_write_main, bfd_mach_o_write_dyld_info): New
	functions.
	(bfd_mach_o_write_symtab_content): New function (extracted
	from bfd_mach_o_write_symtab).
	(bfd_mach_o_write_symtab): Split.
	(bfd_mach_o_count_indirect_symbols): Move
	(bfd_mach_o_build_dysymtab): Remove layout code.
	(bfd_mach_o_write_contents): Rewritten to build commands in order.
	(bfd_mach_o_count_sections_for_seg): Remove.
	(bfd_mach_o_build_obj_seg_command): New function (extracted from
	bfd_mach_o_build_seg_command).
	(bfd_mach_o_build_exec_seg_command): New function.
	(bfd_mach_o_build_dysymtab_command): Remove.
	(bfd_mach_o_layout_commands): New function.
	(bfd_mach_o_init_segment): New function.
	(bfd_mach_o_build_commands): Major rework to handle non-object
	files.
	(bfd_mach_o_alloc_and_read, bfd_mach_o_read_dyld_content): New
	function.
	(bfd_mach_o_read_dyld_info): Clear content fields.
	(bfd_mach_o_read_segment): Adjust call.
	(bfd_mach_o_flatten_sections): Adjust as now load commands are
	chained.
	(bfd_mach_o_scan_start_address, bfd_mach_o_scan)
	(bfd_mach_o_mkobject_init, bfd_mach_o_get_base_address)
	(bfd_mach_o_lookup_command, bfd_mach_o_core_fetch_environment):
	Likewise.

binutils/
	* od-macho.c (dump_section_map): Adjust as load commands
	are now chained.
	(dump_load_command, dump_section_content): Likewise.
2014-04-18 14:32:43 +02:00
Tristan Gingold 967b2c539a mach-o: Define copy_private_header instead of copy_private_bfd.
bfd/
	* mach-o-target.c (bfd_mach_o_bfd_copy_private_header_data):
	Define instead of bfd_mach_o_bfd_copy_private_bfd_data.
	* mach-o.c (bfd_mach_o_bfd_copy_private_bfd_data): Rename.
	* mach-o.h (bfd_mach_o_bfd_copy_private_bfd_data): Likewise.
2014-04-18 12:44:58 +02:00
Tristan Gingold 4525c51ab0 mach-o: remove name_len field.
bfd/
	* mach-o.h (bfd_mach_o_dylinker_command)
	(bfd_mach_o_dylib_command, bfd_mach_o_fvmlib_command): Remove
	name_len field.
	* mach-o.c (bfd_mach_o_read_dylinker, bfd_mach_o_read_dylib)
	(bfd_mach_o_read_fvmlib): Adjust after name_len removal.
2014-04-18 12:23:31 +02:00
Tristan Gingold 4384b28422 mach-o: add page_size to backend data.
This is preliminary work to layout executables.

bfd/
	* mach-o.h (bfd_mach_o_backend_data): Add page_size field.
	* mach-o-target.c: Check TARGET_PAGESIZE is defined.
	(TARGET_NAME_BACKEND): Add TARGET_PAGESIZE.
	* mach-o.c (TARGET_PAGESIZE): Define and undefined for
	each targets declared.
	* mach-o-x86-64.c (TARGET_PAGESIZE): Define.
	* mach-o-i386.c (TARGET_PAGESIZE): Define.
2014-04-18 10:45:33 +02:00
Tristan Gingold 452216ab09 mach-o.c: use boolean instead of int to return status.
bfd/
	* mach-o.c (bfd_mach_o_write_thread)
	(bfd_mach_o_write_section_32, bfd_mach_o_write_section_64)
	(bfd_mach_o_write_segment_32, bfd_mach_o_write_segment_64)
	(bfd_mach_o_read_dylinker, bfd_mach_o_read_dylib)
	(bfd_mach_o_read_prebound_dylib, bfd_mach_o_read_prebind_cksum)
	(bfd_mach_o_read_twolevel_hints, bfd_mach_o_read_fvmlib)
	(bfd_mach_o_read_thread, bfd_mach_o_read_dysymtab)
	(bfd_mach_o_read_symtab, bfd_mach_o_read_uuid)
	(bfd_mach_o_read_linkedit, bfd_mach_o_read_str)
	(bfd_mach_o_read_dyld_info, bfd_mach_o_read_segment)
	(bfd_mach_o_read_segment_32, bfd_mach_o_read_segment_64)
	(bfd_mach_o_read_command): Now return a boolean status.
	Adjust return statements.
	(bfd_mach_o_write_contents, bfd_mach_o_scan): Adjust tests.
	(bfd_mach_o_core_file_failing_command): Remove useless initialization.
2014-04-18 09:44:01 +02:00
Tristan Gingold 26954155a6 mach-o: reject 64 bit targets when not configured for.
bfd/
	* mach-o.c (bfd_mach_o_header_p): Reject 64 bit target when not
	configured for.
2014-04-04 14:40:34 +02:00
Tristan Gingold ca148c5ad5 mach-o: fix section name conversion from bfd to mach-o.
bfd/
	* mach-o.c (bfd_mach_o_convert_section_name_to_mach_o): Fix
	thinko on names length.
2014-04-04 14:32:01 +02:00
Tristan Gingold 707e555b84 mach-o: fix section number while writing symbols.
bfd/
	* mach-o.c (bfd_mach_o_mangle_symbols): Use index from
	output_section.
	(bfd_mach_o_build_seg_command): Add comment.  Realign segment.
	Fix style.
	(bfd_mach_o_build_commands, bfd_mach_o_read_thread): Fix style.
2014-04-03 10:25:21 +02:00
Tristan Gingold 7a79c51466 mach-o: read and dump: prebound_dylib, prebind_cksum, twolevel_hints.
include/mach-o:
	* external.h (mach_o_prebound_dylib_command_external)
	(mach_o_prebind_cksum_command_external)
	(mach_o_twolevel_hints_command_external): New types.

bfd/
	* mach-o.h (bfd_mach_o_twolevel_hints_command)
	(bfd_mach_o_prebind_cksum_command): New types.
	(bfd_mach_o_prebound_dylib_command): Rewrite.
	(bfd_mach_o_load_command): Add prebind_cksum and twolevel_hints
	fields.
	* mach-o.c (bfd_mach_o_read_prebound_dylib): Read and decode the
	command.
	(bfd_mach_o_read_prebind_cksum): New function.
	(bfd_mach_o_read_twolevel_hints): Ditto.
	(bfd_mach_o_read_command): Handle prebind cksum and twolevel hints
	commands.

binutils/
	* od-macho.c (OPT_TWOLEVEL_HINTS): New macro.
	(options): Add entry for twolevel_hints.
	(dump_data_in_code): Fix error message.
	(dump_twolevel_hints): New function.
	(dump_load_command): Handle prebound dylib, prebind cksum
	and twolevel hints.
	(mach_o_dump): Handle twolevel hints.
2014-04-02 15:03:51 +02:00
Tristan Gingold 23d7293976 bfd/mach-o: avoid a crash when num == 0 in reloc.
bfd/
	* mach-o.c (bfd_mach_o_canonicalize_one_reloc): Avoid to crash
	when num == 0.
2014-04-01 14:34:04 +02:00
Tristan Gingold 10be66a491 Mach-O: disp dyld environment command in objdump -P load.
bfd/
	* mach-o.c (bfd_mach_o_read_dylinker): Remove assert.
	(bfd_mach_o_read_command): Handle BFD_MACH_O_LC_DYLD_ENVIRONMENT.
binutils/
	* od-macho.c (dump_load_command): Display value for
	BFD_MACH_O_LC_DYLD_ENVIRONMENT.  Handle BFD_MACH_O_LC_DATA_IN_CODE
	and BFD_MACH_O_LC_DYLIB_CODE_SIGN_DRS.
2014-03-27 12:01:58 +01:00
Tristan Gingold 3cc27770cf 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.
2014-03-27 10:23:22 +01:00
Tristan Gingold d80285301a Mach-O: Add BFD_MACH_O_CPU_TYPE_ARM64.
include/mach-o/
        * loader.h (bfd_mach_o_cpu_type): Add BFD_MACH_O_CPU_TYPE_ARM64.

bfd/
        * mach-o.c (bfd_mach_o_convert_architecture): Add
        BFD_MACH_O_CPU_TYPE_ARM64.

binutils/
        * od-macho.c (bfd_mach_o_cpu_name): Add BFD_MACH_O_CPU_TYPE_ARM64.
2014-03-26 16:08:14 +01:00
Tristan Gingold fbe383b9ee mach-o: handle lasz load dylib command.
bfd/
	* mach-o.c (bfd_mach_o_read_dylib): Handle lazy load dylib.
	(bfd_mach_o_read_command): Ditto.

binutils/
	* od-macho.c (dump_load_command): Handle lazy load dylib.
2014-03-17 10:14:23 +01:00
Alan Modra 4b95cf5c0c Update copyright years 2014-03-05 22:16:15 +10:30
Nick Clifton 1be5090bca PR binutils/11983
* archive.c (_bfd_get_elt_at_filepos): Store a copy of the
	filename in the bfd's filename field.
	* elfcode.h (bfd_from_remote_memory): Likewise.
	* ieee.c (ieee_object_p): Likewise.
	* mach-o.c (bfd_mach_o_fat_member_init): Likewise.
	* oasys.c (oasys_openr_next_archived_file): Likewise.
	* vms-lib.c (_bfd_vms_lib_get_module): Likewise.
	* opncls.c (bfd_fopen): Likewise.
	(bfd_openstreamr): Likewise.
	(bfd_openr_iovec): Likewise.
	(bfd_openw): Likewise.
	(bfd_create): Likewise.
	(_bfd_delete_bfd): Free filename.
2014-01-02 12:14:37 +00:00
Tristan Gingold b30a5d18b1 Clear allocated target data.
2013-12-05  Tristan Gingold  <gingold@adacore.com>

	* mach-o.c (bfd_mach_o_mkobject_init): Use bfd_zalloc.
2013-12-05 11:18:59 +01:00
Nick Clifton 671a6cbe38 * mach-o.c (mach_o_section_name_xlat dw): Add entry for
.debug_gdb_scripts
2013-07-18 11:40:37 +00:00
Nick Clifton a253d456e1 * coffcode.h: Added a cast to void when a bfd_set_section_*()
macro's return value is ignored.
	* elf32-hppa.c: Likewise.
	* elf32-tic6x.c: Likewise.
	* mach-o.c: Likewise.
	* mmo.c: Likewise.
	* opncls.c: Likewise.
	* peicode.h: Likewise.
	* elf32-m32r.c: Check return value of bfd_set_section_*().
	* elfnn-ia64.c: Likewise.
	* elfxx-mips.c: Likewise.
	* vms-alpha.c: Likewise.
2013-04-17 14:16:01 +00:00
Tristan Gingold 5ee43bc47a 2013-02-04 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_scan_start_address): Do not fail if no
	start address.
2013-02-04 14:48:20 +00:00
Tristan Gingold c0fd7846dc 2013-01-31 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_scan): Call bfd_mach_o_flatten_sections
	earlier.  Fix status checking of bfd_mach_o_scan_start_address.
	(bfd_mach_o_scan_start_address): Handle LC_MAIN.
2013-01-31 09:55:41 +00:00
Alan Modra c9ba0c87bf * bfd.c (struct bfd_preserve, bfd_preserve_save, bfd_preserve_restore,
bfd_preserve_finish): Move to..
	* format.c: ..here, splitting out..
	(bfd_reinit): ..this.  New function.
	(bfd_check_format_matches): Use bfd_preserve_save/restore to
	keep bfd state for a match.
	* elfcode.h (elf_object_p): Don't use bfd_preserve_save/restore.
	* elfcore.h (elf_core_file_p): Likewise.
	* mach-o.c (bfd_mach_o_header_p): Likewise.
	* pef.c (bfd_pef_object_p, bfd_pef_xlib_object_p): Likewise.
	* xsym.c (bfd_sym_object_p): Likewise.
	* mmo.c (mmo_scan): Clear abfd->symcount.
	* opncls.c (_bfd_new_bfd): Use a smaller section hash table.
	* section.c (bfd_section_list_clear): Clear section_htab.count.
	* bfd-in2.h: Regenerate.
2013-01-26 02:08:01 +00:00
H.J. Lu 68ffbac672 Remove trailing white spaces in bfd
* aout0.c: Remove trailing white spaces.
	* archive.c: Likewise.
	* archures.c: Likewise.
	* bfd-in.h: Likewise.
	* bfd-in2.h: Likewise.
	* coff-alpha.c: Likewise.
	* coff-i860.c: Likewise.
	* coff-mips.c: Likewise.
	* coff-ppc.c: Likewise.
	* coff-tic80.c: Likewise.
	* coff-x86_64.c: Likewise.
	* coff-z80.c: Likewise.
	* coffcode.h: Likewise.
	* coffgen.c: Likewise.
	* cofflink.c: Likewise.
	* compress.c: Likewise.
	* corefile.c: Likewise.
	* cpu-arm.c: Likewise.
	* cpu-avr.c: Likewise.
	* cpu-bfin.c: Likewise.
	* cpu-cr16.c: Likewise.
	* cpu-cr16c.c: Likewise.
	* cpu-crx.c: Likewise.
	* cpu-h8300.c: Likewise.
	* cpu-i386.c: Likewise.
	* cpu-lm32.c: Likewise.
	* cpu-m68k.c: Likewise.
	* cpu-moxie.c: Likewise.
	* cpu-msp430.c: Likewise.
	* cpu-sh.c: Likewise.
	* cpu-xc16x.c: Likewise.
	* dwarf2.c: Likewise.
	* ecofflink.c: Likewise.
	* ecoffswap.h: Likewise.
	* elf-ifunc.c: Likewise.
	* elf-m10300.c: Likewise.
	* elf-vxworks.c: Likewise.
	* elf32-avr.c: Likewise.
	* elf32-avr.h: Likewise.
	* elf32-cr16.c: Likewise.
	* elf32-cr16c.c: Likewise.
	* elf32-cris.c: Likewise.
	* elf32-crx.c: Likewise.
	* elf32-frv.c: Likewise.
	* elf32-hppa.c: Likewise.
	* elf32-i860.c: Likewise.
	* elf32-ip2k.c: Likewise.
	* elf32-iq2000.c: Likewise.
	* elf32-m32c.c: Likewise.
	* elf32-m68hc1x.c: Likewise.
	* elf32-msp430.c: Likewise.
	* elf32-mt.c: Likewise.
	* elf32-ppc.c: Likewise.
	* elf32-rl78.c: Likewise.
	* elf32-s390.c: Likewise.
	* elf32-score.h: Likewise.
	* elf32-sh-symbian.c: Likewise.
	* elf32-sh.c: Likewise.
	* elf32-spu.c: Likewise.
	* elf32-tic6x.c: Likewise.
	* elf32-v850.c: Likewise.
	* elf32-xc16x.c: Likewise.
	* elf32-xtensa.c: Likewise.
	* elf64-alpha.c: Likewise.
	* elf64-hppa.c: Likewise.
	* elf64-ppc.c: Likewise.
	* elf64-s390.c: Likewise.
	* elfcore.h: Likewise.
	* elflink.c: Likewise.
	* elfxx-mips.c: Likewise.
	* elfxx-sparc.c: Likewise.
	* elfxx-tilegx.c: Likewise.
	* ieee.c: Likewise.
	* libcoff.h: Likewise.
	* libpei.h: Likewise.
	* libxcoff.h: Likewise.
	* linker.c: Likewise.
	* mach-o-i386.c: Likewise.
	* mach-o-target.c: Likewise.
	* mach-o.c: Likewise.
	* mach-o.h: Likewise.
	* mmo.c: Likewise.
	* opncls.c: Likewise.
	* pdp11.c: Likewise.
	* pe-x86_64.c: Likewise.
	* peXXigen.c: Likewise.
	* pef-traceback.h: Likewise.
	* pei-x86_64.c: Likewise.
	* peicode.h: Likewise.
	* plugin.c: Likewise.
	* reloc.c: Likewise.
	* riscix.c: Likewise.
	* section.c: Likewise.
	* som.c: Likewise.
	* syms.c: Likewise.
	* tekhex.c: Likewise.
	* ticoff.h: Likewise.
	* vaxbsd.c: Likewise.
	* xcofflink.c: Likewise.
	* xtensa-isa.c: Likewise.
2013-01-10 20:03:55 +00:00
Tristan Gingold 1778ad74b3 bfd/
2012-11-14  Tristan Gingold  <gingold@adacore.com>

	* mach-o.c (bfd_mach_o_read_main)
	(bfd_mach_o_read_source_version): New functions.
	(bfd_mach_o_read_command): Handle BFD_MACH_O_LC_DATA_IN_CODE,
	BFD_MACH_O_LC_DYLIB_CODE_SIGN_DRS, BFD_MACH_O_LC_MAIN,
	BFD_MACH_O_LC_SOURCE_VERSION.
	* mach-o.h (bfd_mach_o_main_command)
	(bfd_mach_o_source_version_command): New types.
	(bfd_mach_o_load_command): Add fields for these new types.

binutils/
2012-11-14  Tristan Gingold  <gingold@adacore.com>

	* od-macho.c (bfd_mach_o_load_command_name): Add new definitions.
	(dump_load_command): Handle BFD_MACH_O_LC_SOURCE_VERSION
	and BFD_MACH_O_LC_MAIN.
2012-11-14 11:03:27 +00:00
Tristan Gingold f4716ee22e 2012-11-14 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_canonicalize_one_reloc): Add a special
	handling for non-scattered pairs.  Update comments.
2012-11-14 10:29:46 +00:00
Alan Modra 8c746b9642 * mach-o.c (bfd_mach_o_close_and_cleanup): Don't call
_bfd_generic_close_and_cleanup for mach_o_fat archives.
2012-11-06 06:44:01 +00:00
Tom Tromey 06e7acd76f * vms-lib.c (_bfd_vms_lib_get_module): Use bfd_zmalloc for
areltdata.
	* opncls.c (_bfd_delete_bfd): Free arelt_data.
	* mach-o.c (bfd_mach_o_fat_member_init): Use bfd_zmalloc for
	areltdata.
	* ecoff.c (_bfd_ecoff_slurp_armap): Use free for mapdata.
	* coff-rs6000.c (_bfd_xcoff_read_ar_hdr): Use bfd_zmalloc for
	areltdata.
	(xcoff_write_archive_contents_old): Likewise.
	(xcoff_write_archive_contents_big): Likewise.
	* archive64.c (bfd_elf64_archive_slurp_armap): Use free for
	areltdata.
	* archive.c (_bfd_generic_read_ar_hdr_mag): Use bfd_zmalloc and
	free for areltdata.
	(_bfd_get_elt_at_filepos): Likewise.  Clear n_nfd->arelt_data on
	failure.
	(do_slurp_bsd_armap): Use bfd_zmalloc and free for areltdata.
	(do_slurp_coff_armap): Likewise.
	(_bfd_slurp_extended_name_table): Likewise.
	(bfd_slurp_bsd_armap_f2): Likewise.  Don't leak 'mapdata'.
2012-08-20 14:32:31 +00:00
Cary Coutant 9b8d1a3603 2012-07-24 Teresa Johnson <tejohnson@google.com>
bfd/
	* bfd.c (bfd_find_nearest_line_discriminator): New macro.
	* coff-rs6000.c: Init _bfd_find_nearest_line_discriminator.
	* coff64-rs6000.c: Likewise.
	* dwarf2.c (struct line_info): Add discriminator field.
	(add_line_info): Fill in new discriminator field.
	(decode_line_info): Record discriminator information instead
        of ignoring it.
	(lookup_address_in_line_info_table): Return discriminator field if
        requested.
	(comp_unit_find_nearest_line): Add discriminator argument.
	(find_line): Likewise.
	(_bfd_dwarf2_find_nearest_line): Likewise.
	(_bfd_dwarf2_find_line): Likewise.
	* elf-bfd.h (_bfd_elf_find_nearest_line_discriminator): New.
        (_bfd_elf_find_line_discriminator): Likewise.
        (_bfd_generic_find_nearest_line_discriminator): Likewise. Defined.
	* elf.c (_bfd_elf_find_nearest_line): Change to a wrapper
        that invokes _bfd_elf_find_nearest_line_discriminator with correct
        arguments.
	(_bfd_elf_find_nearest_line_discriminator): New.
	(_bfd_elf_find_line): Change to a wrapper
        that invokes _bfd_elf_find_line_discriminator with correct
        arguments.
	(_bfd_elf_find_line_discriminator): New.
	* coffgen.c (coff_find_nearest_line_with_names): Handle
        new discriminator argument.
	* elf32-arm.c (elf32_arm_find_nearest_line): Likewise.
	* elf64-alpha.c (elf64_alpha_find_nearest_line): Likewise.
	* elfxx-mips.c (_bfd_mips_elf_find_nearest_line): Likewise.
	* mach-o.c (bfd_mach_o_find_nearest_line): Likewise.
	* libbfd-in.h (_bfd_dwarf2_find_nearest_line): Add discriminator
        argument.
        (_bfd_dwarf2_find_line): Likewise.
        (_bfd_generic_find_nearest_line_discriminator): New.
	* libbfd.c (_bfd_generic_find_nearest_line_discriminator): New.
	* bfd-in2.h: Regenerated.
	* libbfd.h: Likewise.
	* targets.c (BFD_JUMP_TABLE_SYMBOLS): Initialize
        _bfd_find_nearest_line_discriminator with
        _bfd_generic_find_nearest_line_discriminator.
        (bfd_target): Add _bfd_find_nearest_line_discriminator.

binutils/
	* addr2line.c (find_address_in_section): Invoke
        bfd_find_nearest_line_discriminator to get the discriminator.
	(find_offset_in_section): Likewise.
	(translate_addresses): Print discriminator if it is non-zero.
	* objdump.c (show_line): Invoke
        bfd_find_nearest_line_discriminator to get the discriminator,
        and keep track of prev_discriminator. Print discriminator
        if it is non-zero.
	(disassemble_data): Initialize prev_discriminator.
	(dump_reloc_set): Invoke bfd_find_nearest_line_discriminator
        to get the discriminator, and keep track of last_discriminator.
        Print discriminator if it is non-zero.
2012-07-24 21:06:58 +00:00
Iain Sandoe 19765f5229 deal with endian-ness in mach-o non-scattered relocs.
BFD:

	* mach-o.c (bfd_mach_o_swap_in_non_scattered_reloc): New.
	(bfd_mach_o_canonicalize_one_reloc):  Swap non-scattered reloc
	bit-fields when target and host differ in endian-ness.  When
	PAIRs are non-scattered	find the 'symbol' from the preceding
	reloc.  Add FIXME re. reloc symbols on section boundaries.
	(bfd_mach_o_swap_out_non_scattered_reloc): New.
	(bfd_mach_o_write_relocs): Use bfd_mach_o_encode_non_scattered_reloc.

include/mach-o:

	* external.h: Add comments about relocations fields.  Add macros
	for non-scattered relocations.  Move scattered relocation macros to here.
	* reloc.h: Remove macros related to external representation of reloc fields.
2012-02-23 16:29:56 +00:00
Iain Sandoe 09903f4b53 bfd:
* mach-o.c (bfd_mach_o_build_seg_command): Count zerofill section
	vma additions in their logical, rather than physical order.
2012-02-10 11:24:44 +00:00
Iain Sandoe 632039e0a8 correct some mach-o section specification nits.
bfd:

	* mach-o.c (mach_o_section_name_xlat): Correct eh-frame section
	parameters.
	* mach-o-x86-64.c (text_section_names_xlat): New.
	(mach_o_x86_64_segsec_names_xlat): New.
	(bfd_mach_o_tgt_seg_table): Define to mach_o_x86_64_segsec_names_xlat.
	* mach-o-i386.c (text_section_names_xlat): Correct section parameters.
2012-02-10 11:07:33 +00:00
Tristan Gingold facf03f2c3 bfd/
2012-02-02  Tristan Gingold  <gingold@adacore.com>

	* mach-o.c (bfd_mach_o_read_header): Silent uninitialized
	variable warning.

gas/
2012-02-02  Tristan Gingold  <gingold@adacore.com>

	* config/obj-macho.c (obj_mach_o_zerofill): Silent
	uninitialized variable warning.
2012-02-02 11:55:43 +00:00
Iain Sandoe 687be931eb handle absolute indirect syms in mach-o
bfd:

	* mach-o.c (bfd_mach_o_build_dysymtab_command): Handle absolute
	indirect symbols.
gas:

	* config/obj-macho.c (obj_mach_o_set_indirect_symbols): Handle
	absolute indirect symbols.

gas/testsuite:

	* gas/mach-o/dysymtab-3.d: New.
	* gas/mach-o/symbols-7.s: New.
2012-01-13 12:59:30 +00:00
Iain Sandoe bb76d9401e order relocs after segments for mach-o
bfd:

	* mach-o.c (bfd_mach_o_write_relocs): Move compuation of relocs file
	position from here... to (bfd_mach_o_build_seg_command): Here.
2012-01-13 12:08:23 +00:00
Iain Sandoe 50d10658ee add indirect_symbol to mach-o port.
bfd:

	* mach-o.c (bfd_mach_o_count_indirect_symbols): New.
	(bfd_mach_o_build_dysymtab_command): Populate indirect symbol table.
	* mach-o.h (bfd_mach_o_asymbol): Move declaration to start of the
	file. (bfd_mach_o_section): Add indirect_syms field.

gas:

	* config/obj-macho.c (obj_mach_o_set_symbol_qualifier): Switch off
	lazy when the symbol is private_extern.
	(obj_mach_o_indirect_sym): New type.
	(obj_mach_o_indirect_symbol): New.
	(mach_o_pseudo_table): Use obj_mach_o_indirect_symbol.
	(obj_macho_frob_label): Adjust to avoid adding bsyms for locals.
	(obj_macho_frob_label): Likewise.  Adjust external and comm
	symbol tests.
	(obj_mach_o_set_indirect_symbols): New.
	(obj_mach_o_frob_file_after_relocs): New.
	*config/obj-macho.h (obj_frob_file_after_relocs): Define.
	(obj_mach_o_frob_file_after_relocs): Declare.

include/mach-o:

	* loader.h (BFD_MACH_O_INDIRECT_SYM_LOCAL): New.
	(BFD_MACH_O_INDIRECT_SYM_ABS): New

gas/testsuite:

	* gas/mach-o/dysymtab-2.d: New.
	* gas/mach-o/err-syms-4.s: New.
	* gas/mach-o/err-syms-5.s: New.
	* gas/mach-o/err-syms-6.s: New.
	* gas/mach-o/symbols-6-64.d: New.
	* gas/mach-o/symbols-6-64.s: New.
	* gas/mach-o/symbols-6.d: New.
	* gas/mach-o/symbols-6.s: New.
2012-01-12 14:03:12 +00:00
Iain Sandoe e5081f2f8f bfd:
* mach-o.c (bfd_mach_o_build_seg_command): Separate computation of
	vmsize from filesize.  Don't compute offsets or file sizes for
	zerofill sections.
2012-01-11 15:24:10 +00:00
Iain Sandoe bbd561712c bfd:
* mach-o.c (bfd_mach_o_build_commands): Make the building of each
	command type independent.
2012-01-11 15:06:36 +00:00
Tristan Gingold 2a65a88eea 2012-01-10 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_build_commands): Avoid uninitialized false
	warning.
2012-01-10 11:59:28 +00:00
Iain Sandoe b22161d698 add symbol qualifiers for mach-o to bfd/gas
bfd:

	* mach-o.c (bfd_mach_o_bfd_copy_private_symbol_data): Implement.
	(bfd_mach_o_write_symtab): Remove handling for indirect syms.
	(bfd_mach_o_primary_symbol_sort_key): Likewise.
	(bfd_mach_o_cf_symbols): Likewise.
	(bfd_mach_o_sort_symbol_table): Remove.
	(bfd_mach_o_mangle_symbols): Adjust arguments, remove handling
	for indirect and dysymtab counts.  Do the symbol sorting here.
	(bfd_mach_o_build_dysymtab_command): Count the symbol types here.
	Make the indirect symbols a TODO.
	(bfd_mach_o_build_commands): Adjust call to bfd_mach_o_mangle_symbols.
	(bfd_mach_o_make_empty_symbol): Specifically flag unset symbols with
	a non-zero value.
	(bfd_mach_o_read_symtab_symbol): Record the symbol index.
	(bfd_mach_o_read_symtab_symbol): Adjust recording of global status.
	* mach-o.h (mach_o_data_struct): Remove indirect and dysymtab entries.
	(IS_MACHO_INDIRECT): Remove.
	(SYM_MACHO_FIELDS_UNSET, SYM_MACHO_FIELDS_NOT_VALIDATED): New.

gas:

	* config/obj-macho.c (obj_mach_o_weak): Remove.
	(obj_mach_o_common_parse): Set symbol qualifiers.
	(LAZY, REFE): New macros.
	(obj_mach_o_symbol_type): New enum.
	(obj_mach_o_set_symbol_qualifier): New.
	(obj_mach_o_sym_qual): New.
	(mach_o_pseudo_table): Add symbol qualifiers, set indirect_symbol to
	a dummy function.
	(obj_mach_o_type_for_symbol): New.
	(obj_macho_frob_label): New.
	(obj_macho_frob_symbol): New.
	* config/obj-macho.h (S_SET_ALIGN): Amend temorary var name.
	(obj_frob_label, obj_macho_frob_label): Declare.
	(obj_frob_symbol, obj_macho_frob_symbol): Declare.

gas/testsuite:

	* gas/mach-o/err-syms-1.s: New.
	* gas/mach-o/err-syms-2.s: New.
	* gas/mach-o/err-syms-3.s: New.
	* gas/mach-o/symbols-2.d: New.
	* gas/mach-o/symbols-2.s: New.
	* gas/mach-o/symbols-3.s: New.
	* gas/mach-o/symbols-4.s: New.
	* gas/mach-o/symbols-5.d: New.
	* gas/mach-o/symbols-5.s: New.
2012-01-09 10:47:50 +00:00
Tristan Gingold 15bbba8d0d 2012-01-04 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_fat_stat_arch_elt): New function.
	(bfd_mach_o_generic_stat_arch_elt): Adjust.
2012-01-04 13:31:27 +00:00
Tristan Gingold a4e241ca1b 2012-01-04 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_fat_member_init): New function.
	(bfd_mach_o_openr_next_archived_file): Reindent.
	Adjust to call bfd_mach_o_fat_member_init.
	(bfd_mach_o_fat_extract): Adjust to call bfd_mach_o_fat_member_init.
2012-01-04 13:22:21 +00:00
Tristan Gingold 9f4a5bd19a bfd/
2012-01-04  Tristan Gingold  <gingold@adacore.com>

	* mach-o.h (bfd_mach_o_fvmlib_command): New structure.
	(bfd_mach_o_load_command): Add fvmlib field.

	* mach-o.c (bfd_mach_o_read_fvmlib): New function.
	(bfd_mach_o_read_command): Handle fvmlib.

binutils/
2012-01-04  Tristan Gingold  <gingold@adacore.com>

	* od-macho.c (dump_load_command): Handle fvmlib.

include/mach-o/
2012-01-04  Tristan Gingold  <gingold@adacore.com>

	* external.h (mach_o_fvmlib_command_external): New structure.
2012-01-04 10:37:36 +00:00
Tristan Gingold 0b2de10705 bfd/
2012-01-04  Tristan Gingold  <gingold@adacore.com>

	* mach-o.c (bfd_mach_o_convert_architecture): Reindent.
	Decode msubtype for ARM.

include/mach-o/
2012-01-04  Tristan Gingold  <gingold@adacore.com>

	* loader.h: Update copyright year.
	(bfd_mach_o_cpu_subtype): Add ARM subtypes.
2012-01-04 10:25:14 +00:00
Tristan Gingold aeefa1c9a5 bfd/
2012-01-04  Tristan Gingold  <gingold@adacore.com>

	* mach-o.c (bfd_mach_o_get_synthetic_symtab): Add comments.
2012-01-04 10:14:25 +00:00
Tristan Gingold fc55a90257 bfd/
2012-01-04  Tristan Gingold  <gingold@adacore.com>

	* mach-o.h: Reindent header.
	(bfd_mach_o_encryption_info_command): New structure.
	(bfd_mach_o_load_command): Add encryption_info field.

	* mach-o.c (bfd_mach_o_read_encryption_info): New function.
	(bfd_mach_o_read_command): Handle BFD_MACH_O_LC_ENCRYPTION_INFO.
	(bfd_mach_o_read_command): Adjust error message.

binutils/
2012-01-04  Tristan Gingold  <gingold@adacore.com>

	* od-macho.c: Update copyright year.
	(dump_load_command): Handle BFD_MACH_O_LC_ENCRYPTION_INFO.

include/mach-o/
2012-01-04  Tristan Gingold  <gingold@adacore.com>

	* external.h: Update copyright year.
	(mach_o_symtab_command_external): Add comments.
	(mach_o_encryption_info_command_external): New structure.
2012-01-04 09:58:55 +00:00
Tristan Gingold 2ca7691a9b 2012-01-04 Shinichiro Hamaji <shinichiro.hamaji@gmail.com>
* dwarf2.c (_bfd_dwarf2_slurp_debug_info): Factor out the part
	which reads DWARF2 and stores in stash from find_line.
	(find_line) Call _bfd_dwarf2_slurp_debug_info.
	* libbfd-in.h (_bfd_dwarf2_slurp_debug_info): Add declaration.
	* libbfd.h (_bfd_dwarf2_slurp_debug_info): Regenerate.
	* mach-o.c (dsym_subdir): The name of subdir where debug
	information may be stored.
	(bfd_mach_o_lookup_uuid_command): New. Lookup a load command whose
	type is UUID.
	(bfd_mach_o_dsym_for_uuid_p): New. Check if the specified BFD is
	corresponding to the executable.
	(bfd_mach_o_find_dsym): New. Find a debug information BFD in the
	specified binary file.
	(bfd_mach_o_follow_dsym): New. Find a debug information BFD for
	the original BFD.
	(bfd_mach_o_find_nearest_line): Check dSYM files for Mach-O
	executables, dylibs, and bundles.
	(bfd_mach_o_close_and_cleanup): Clean up BFDs for the dSYM file.
	* mach-o.h (dsym_bfd): The BFD of the dSYM file.
2012-01-04 08:44:04 +00:00
Iain Sandoe 68588f9540 support stabs on mach-o GAS.
bfd:

	* mach-o.c (bfd_mach_o_mangle_symbols): Put in the section index
	for stabd symbols.
	(bfd_mach_o_primary_symbol_sort_key): Adjust for stabs.
	(bfd_mach_o_cf_symbols): Likewise.

gas:

	* config/obj-macho.c (obj_macho_process_stab): New.
	* config/obj-macho.h (OBJ_PROCESS_STAB): Define.
	(obj_macho_process_stab): Declare.
2012-01-03 13:18:48 +00:00
Iain Sandoe f2b324f1f9 correct typo in previous commit.
bfd:

	* mach-o.c (bfd_mach_o_mangle_symbols): Correct typo.
2012-01-03 12:03:10 +00:00
Iain Sandoe 7f3072381b 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.
2012-01-03 10:54:01 +00:00