Commit Graph

180 Commits

Author SHA1 Message Date
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
Iain Sandoe ab76eeafa5 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.
2011-12-19 15:42:37 +00:00
Tristan Gingold b93a1992f4 2011-12-16 Shinichiro Hamaji <shinichiro.hamaji@gmail.com>
* mach-o-i386.c (TARGET_PRIORITY): Define as 0 (top priority)
	* mach-o-target.c (TARGET_NAME): Use TARGET_PRIORITY
	* mach-o-x86-64.c (TARGET_PRIORITY): Define as 0 (top priority)
	* mach-o.c (bfd_mach_o_header_p): Remove special handling for
	mach-o-i386.
	(TARGET_PRIORITY) Set 1 for mach-o-be and mach-o-le, and set 0 for
	mach-o-fat.
2011-12-16 13:39:03 +00:00
Tristan Gingold 4434114c64 2011-12-15 Iain Sandoe <iains@gcc.gnu.org>
* mach-o.c (bfd_mach_o_mkobject_init): Initialize dyn_reloc_cache.
	(bfd_mach_o_close_and_cleanup): Only cleanup Mach-O private data
	for object files.
2011-12-15 14:04:52 +00:00
Tristan Gingold dff55db0d2 2011-12-15 Shinichiro Hamaji <shinichiro.hamaji@gmail.com>
* mach-o.c (bfd_mach_o_canonicalize_reloc): Update relocation
	table only when there isn't the cahce.
	(bfd_mach_o_get_dynamic_reloc_upper_bound): Need one more space
	for a pointer for the watchdog.
	(bfd_mach_o_canonicalize_dynamic_reloc): Utilize cache like
	bfd_mach_o_canonicalize_reloc.
	(bfd_mach_o_close_and_cleanup): Call bfd_mach_o_free_cached_info.
	(bfd_mach_o_free_cached_info): Free up cache data.
	* mach-o.h (reloc_cache): A place to store cache of dynamic relocs.
	(bfd_mach_o_free_cached_info): Add declaration.
2011-12-15 11:01:14 +00:00
Tristan Gingold 0c9ef0f001 bfd/
2011-12-15  Iain Sandoe  <iains@gcc.gnu.org>

	* mach-o-target.c (bfd_mach_o_bfd_set_private_flags): Use
	bfd_mach_o_bfd_set_private_flags.
	* mach-o.c (bfd_mach_o_bfd_set_private_flags): New.
	* mach-o.h (bfd_mach_o_bfd_set_private_flags): Declare.

gas/
2011-12-15  Iain Sandoe  <iains@gcc.gnu.org>

	* config/obj-macho.c (obj_mach_o_subsections_by_symbols): New global.
	(obj_mach_o_file_properties): New enum.
	(obj_mach_o_subsections_via_symbols):  Generalize name to...
	... (obj_mach_o_fileprop) and use to set subsections_via_symbols.

gas/testsuite/
2011-12-15  Iain Sandoe  <iains@gcc.gnu.org>

	* gas/mach-o/subsect-via-symbols-0.d: New.
	* gas/mach-o/subsect-via-symbols-1.d: New.
	* gas/mach-o/subsect-via-symbols.s: New.
2011-12-15 10:56:48 +00:00
Tristan Gingold a455111938 bfd/
2011-12-14  Iain Sandoe  <iains@gcc.gnu.org>

	* mach-o-i386.c (text_section_names_xlat): New table.
	(data_section_names_xlat): Likewise.
	(import_section_names_xlat): Likewise.
	(mach_o_i386_segsec_names_xlat): Likewise.
	(bfd_mach_o_tgt_seg_table): Use new tables.
	* mach-o-x86-64.c (bfd_mach_o_tgt_seg_table): Set NULL.
	* mach-o.c (mach_o_section_name_xlat, mach_o_segment_name_xlat):
	Move to mach-o.h as   typedefs.
	(text_section_names_xlat): Update for current GCC usage.
	(data_section_names_xlat): Likewise.
	(dwarf_section_names_xlat): Likewise.
	(objc_section_names_xlat): New table.
	(segsec_names_xlat): Add objc table.
	(bfd_mach_o_normalize_section_name):  Replace with...
	(bfd_mach_o_section_data_for_mach_sect): New.
	(bfd_mach_o_section_data_for_bfd_name): New.
	(bfd_mach_o_section_data_for_bfd_name): Update to use additional data.
	(bfd_mach_o_convert_section_name_to_mach_o): Likewise.
	(bfd_mach_o_bfd_copy_private_section_data): Implement.
	(bfd_mach_o_write_symtab): Write a zero-length string as the first entry
	for compatibility with system tools.
	(bfd_mach_o_build_commands): Update section alignment info.
	(bfd_mach_o_new_section_hook): Use translation table data to define
	default section flags, type, attributes and alignment, when available.
	(bfd_mach_o_init_section_from_mach_o): Add TODO comment.
	(bfd_mach_o_section_type_name): Add 'symbol_stubs'.
	(bfd_mach_o_section_attribute_name): Add 'self_modifying_code'.
	(bfd_mach_o_get_section_type_from_name): Change "not-found" return
	value.
	(bfd_mach_o_tgt_seg_table): Set default NULL.
	* mach-o.h (bfd_mach_o_segment_command):  Use define for name length.
	(bfd_mach_o_backend_data): Move until after contents are defined.
	(bfd_mach_o_normalize_section_name): Remove.
	(bfd_mach_o_convert_section_name_to_bfd): Declare.
	(mach_o_section_name_xlat): Declare.
	(mach_o_segment_name_xlat): Declare.
	(bfd_mach_o_section_data_for_mach_sect): Declare.
	(bfd_mach_o_section_data_for_bfd_name): Declare.

include/
2011-12-14  Iain Sandoe  <iains@gcc.gnu.org>

	* mach-o/loader.h (bfd_mach_o_section_type): define
	BFD_MACH_O_S_ATTR_NONE to 0.


gas/
2011-12-14  Iain Sandoe  <iains@gcc.gnu.org>

	* config/obj-macho.c: Add some more top-level comments.
	(collect_16char_name): New.
	(obj_mach_o_section): Amend to allow syntax compatible with existing system
	tools.  Use section translation data when available.
	(obj_mach_o_segT_from_bfd_name): New.
	(known_sections): Update.
	(obj_mach_o_known_section): Use obj_mach_o_segT_from_bfd_name.
	(objc_sections): New.
	(obj_mach_o_objc_section): New.
	(debug_sections): New.
	(obj_mach_o_debug_section): New.
	(tgt_sections): New.
	(obj_mach_o_opt_tgt_section): New.
	(obj_mach_o_base_section): New.
	(obj_mach_o_common_parse): Update to create BSS on demand and to handle
	lcomm optional alignment param.
	(obj_mach_o_comm): Update parameter name.
	(obj_mach_o_placeholder): New.
	(mach_o_pseudo_table): Update for GCC section directives.
	* config/obj-macho.h (_OBJ_MACH_O_H): New.
	(USE_ALIGN_PTWO): Define.
	(S_SET_ALIGN) Define.
2011-12-14 10:30:09 +00:00
Tristan Gingold d9071b0c42 2011-12-13 Shinichiro Hamaji <shinichiro.hamaji@gmail.com>
* dwarf2.c (bfd_dwarf2_cleanup_debug_info): Accept stash as an
	argument like other functions to support formats other than ELF.
	* elf-bfd.h (bfd_dwarf2_cleanup_debug_info): Move to bfd-in.h.
	* elf.c (_bfd_elf_close_and_cleanup): Pass dwarf2_find_line_info
	in tdata as a parameter.
	* libbfd-in.h (bfd_dwarf2_cleanup_debug_info): Move from
	elf-bfd.h.
	* libbfd.h (bfd_dwarf2_cleanup_debug_info): Regenerate.
	* mach-o-target.c (bfd_mach_o_close_and_cleanup): Remove the
	fallback macro.
	(bfd_mach_o_find_nearest_line): Likewise.
	* mach-o.c (bfd_mach_o_find_nearest_line): Add the definition
	which calls _bfd_dwarf2_find_nearest_line.
	(bfd_mach_o_close_and_cleanup): Likewise.
	* mach-o.h (mach_o_data_struct): Add dwarf2_find_line_info.
	(bfd_mach_o_find_nearest_line): Add declaration.
	(bfd_mach_o_close_and_cleanup): Add declaration.
2011-12-13 14:02:20 +00:00
Tristan Gingold c5012cd8d5 bfd/
2011-12-13  Tristan Gingold  <gingold@adacore.com>

	* mach-o.c (bfd_mach_o_read_symtab_symbols): Make global.  Remove
	prototype.
	(bfd_mach_o_section_get_entry_size): Make global.
	(bfd_mach_o_section_get_nbr_indirect): Likewise.
	(bfd_mach_o_read_symtab_strtab): Likewise.
	(struct bfd_mach_o_xlat_name): Move to mach-o.h
	(bfd_mach_o_print_flags): Move to binutils/od-macho.c
	(bfd_mach_o_get_name_of_null, bfd_mach_o_get_name): Likewise.
	(bfd_mach_o_cpu_name, bfd_mach_o_filetype_name): Likewise.
	(bfd_mach_o_header_flags_name): Likewise.
	(bfd_mach_o_load_command_name): Likewise.
	(bfd_mach_o_print_private_header): Likewise.
	(bfd_mach_o_print_section_map, bfd_mach_o_print_section): Likwise.
	(bfd_mach_o_print_segment, bfd_mach_o_print_dysymtab): Likewise.
	(bfd_mach_o_print_dyld_info): Likewise.
	(bfd_mach_o_print_private_bfd_data): Remove.
	(bfd_mach_o_type_name): Make global.
	(bfd_mach_o_section_attribute_name): Likewise.
	* mach-o.h (bfd_mach_o_xlat_name): Added.
	(bfd_mach_o_section_get_nbr_indirect)
	(bfd_mach_o_section_get_entry_size)
	(bfd_mach_o_read_symtab_symbols)
	(bfd_mach_o_read_symtab_strtab)
	(bfd_mach_o_section_attribute_name)
	(bfd_mach_o_section_type_name): Likewise.
	* mach-o-target.c (bfd_mach_o_bfd_print_private_bfd_data): Define.

binutils/
2011-12-13  Tristan Gingold  <gingold@adacore.com>

	* od-macho.c: New file.
	* objdump.h (objdump_private_desc_mach_o): Add.
	* configure.in: Add Mach-O od_vectors.
	* Makefile.am (CFILES): Add od-macho.c
	* configure: Regenerate.
	* Makefile.in: Regenerate.
2011-12-13 09:13:15 +00:00
Tristan Gingold 69499dca19 2011-12-12 Iain Sandoe <iains@gcc.gnu.org>
* mach-o.c (bfd_mach_o_read_section_32): Null-terminate sectname.
	(bfd_mach_o_read_section_64): Likewise.
2011-12-12 13:45:47 +00:00
Tristan Gingold afbb9e17e4 2011-12-07 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_canonicalize_symtab): Fix indentation.
	Adjust the condition.
	(bfd_mach_o_read_symtab_symbol): Now returns a bfd_boolean.
	Adjust return statements.
	(bfd_mach_o_read_symtab_strtab): Likewise.
	(bfd_mach_o_read_symtab_symbols): Likewise.
	(bfd_mach_o_scan_start_address): Likewise.  Make it static.
	(bfd_mach_o_scan): Likewise.
	(bfd_mach_o_read_dysymtab_symbol): Remove unused function.
	(bfd_mach_o_header_p): Adjust call.
	(bfd_mach_o_cpu_name): Make it const.
	(bfd_mach_o_filetype_name): Likewise.
	(bfd_mach_o_header_flags_name): Likewise.
	(bfd_mach_o_section_type_name): Likewise.
	(bfd_mach_o_section_attribute_name): Likewise.
	(bfd_mach_o_load_command_name): Likewise.
	(bfd_mach_o_get_section_type_from_name): Add a const qualifier
	after above change.
	(bfd_mach_o_get_section_attribute_from_name): Likewise.
	* mach-o.h (bfd_mach_o_read_dysymtab_symbol)
	(bfd_mach_o_scan_start_address, bfd_mach_o_scan): Remove.
2011-12-07 10:09:22 +00:00
Tristan Gingold 0596a831a2 2011-12-05 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_read_symtab_symbol): Accept indirect symbols.
2011-12-05 14:42:31 +00:00
Tristan Gingold 73017762b2 2011-12-05 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_write_contents): Handle LC_LOAD_UPWARD_DYLIB.
	(bfd_mach_o_read_dylib): Likewise.
	(bfd_mach_o_read_command): Likewise.
	(bfd_mach_o_bfd_print_private_bfd_data): Likewise.
2011-12-05 14:10:11 +00:00
Tristan Gingold c0d9d05149 2011-12-05 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_read_command): Add the bfd in the error
	message.
	(bfd_mach_o_openr_next_archived_file): Use arch name as member name.
	(bfd_mach_o_fat_extract): Ditto.
2011-12-05 13:48:54 +00:00
Tristan Gingold e0ce100545 2011-11-22 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_print_symbol): Display COM for common
	symbols.  Print section name in brackets.
2011-11-22 10:47:50 +00:00
Tristan Gingold 7ba695a99c 2011-09-21 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_convert_section_name_to_bfd): Add comment.
	Deals with size limited strings.
	(bfd_mach_o_build_commands): Initialize more fields.
2011-09-21 10:10:11 +00:00
Tristan Gingold 9d4b600942 2011-08-18 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_read_segment): Initialize list.
2011-08-18 09:28:42 +00:00
Tristan Gingold 72b5104c84 2011-08-17 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_write_section_32): Fix typo.
2011-08-17 10:17:39 +00:00
Tristan Gingold 5a5cbf7230 2011-08-08 Tristan Gingold <gingold@adacore.com>
* mach-o.c (struct mach_o_segment_name_xlat): Add comments.
	(segsec_names_xlat): Reorder elements.
	(bfd_mach_o_read_section_32): Fix typo.
	(bfd_mach_o_read_section_64): Fix typo.
2011-08-08 14:53:30 +00:00
Tristan Gingold f1bde64c90 2011-08-08 Tristan Gingold <gingold@adacore.com>
* mach-o.h (BFD_MACH_O_SEGNAME_SIZE): New macro.
	(BFD_MACH_O_SECTNAME_SIZE): Ditto.
	(bfd_mach_o_section): Use them.  Add next field.
	(bfd_mach_o_segment_command): Replace sections array by
	sect_head and sect_tail.
	(bfd_mach_o_get_mach_o_section): New macro.
	(bfd_mach_o_lookup_section): Remove.
	(bfd_mach_o_new_section_hook): New function.
	* mach-o.c (bfd_mach_o_normalize_section_name): Use strncmp
	instead of strcmp.
	(bfd_mach_o_convert_section_name_to_bfd): Replaces section
	parameter with segname and sectname parameters.  Adjust.
	(bfd_mach_o_append_section_to_segment): New function.  Use a
	linked list for Mach-O sections.
	(bfd_mach_o_write_segment_32): Adjust.
	(bfd_mach_o_write_segment_64): Ditto.
	(bfd_mach_o_build_commands): Fix comment.  Adjust.
	(bfd_mach_o_flatten_sections): Adjust.
	(bfd_mach_o_print_section_map): Adjust.
	(bfd_mach_o_set_section_flags_from_bfd): Ditto.
	(bfd_mach_o_new_section_hook): New function.
	(bfd_mach_o_init_section_from_mach_o): Ditto.
	(bfd_mach_o_read_section_32): Remove section parameter.
	Return a section instead.
	(bfd_mach_o_read_section_64): Ditto.
	(bfd_mach_o_read_section): Ditto.
	(bfd_mach_o_make_bfd_section): Adjust.
	(bfd_mach_o_read_segment): Adjust for new profile of
	bfd_mach_o_read_section.
	(bfd_mach_o_lookup_section): Remove.
	* mach-o-target.c (bfd_mach_o_new_section_hook): Remove.
2011-08-08 10:56:31 +00:00
Tristan Gingold edbdea0ed7 bfd/
2011-08-08  Tristan Gingold  <gingold@adacore.com>

	* mach-o.h (bfd_mach_o_version_min_command): New structure.
	(bfd_mach_o_load_command): Add version_min.
	(mach_o_data_struct): Fix comment.
	* mach-o.c (bfd_mach_o_read_version_min): New function.
	(bfd_mach_o_read_command): Handle BFD_MACH_O_LC_FUNCTION_STARTS,
	BFD_MACH_O_LC_VERSION_MIN_MACOSX and
	BFD_MACH_O_LC_VERSION_MIN_IPHONEOS.
	(bfd_mach_o_get_name_or_null): New function.
	(bfd_mach_o_get_name): Use the above new one.
	(bfd_mach_o_load_command_name): Add the above new commands.
	(bfd_mach_o_bfd_print_private_bfd_data): Display numerically
	unknown commands.  Handle BFD_MACH_O_LC_FUNCTION_STARTS,
	BFD_MACH_O_LC_VERSION_MIN_MACOSX and
	BFD_MACH_O_LC_VERSION_MIN_IPHONEOS.

include/mach-o/
2011-08-08  Tristan Gingold  <gingold@adacore.com>

	* loader.h (bfd_mach_o_load_command_type): Add
	BFD_MACH_O_LC_LOAD_UPWARD_DYLIB, BFD_MACH_O_LC_VERSION_MIN_MACOSX,
	BFD_MACH_O_LC_VERSION_MIN_IPHONEOS, BFD_MACH_O_LC_FUNCTION_STARTS,
	and BFD_MACH_O_LC_DYLD_ENVIRONMENT.
	* external.h (mach_o_version_min_command_external): New structure.
2011-08-08 10:21:02 +00:00
Tristan Gingold 46d1c23bce bfd/
2011-08-08  Tristan Gingold  <gingold@adacore.com>

	* mach-o.h: Move size macros to external.h
	Move reloc macros to reloc.h and x86-64.h.
	* mach-o-i386.c: Includes mach-o/reloc.h
	* mach-o-x86-64.c: Ditto and includes mach-o/x86-64.h
	* mach-o.c: Add includes.
	(bfd_mach_o_write_header): Use structure from external.h to convert.
	(bfd_mach_o_write_thread): Ditto.
	(bfd_mach_o_write_relocs): Ditto.
	(bfd_mach_o_write_section_32): Ditto.
	(bfd_mach_o_write_section_64): Ditto.
	(bfd_mach_o_write_segment_32): Ditto.
	(bfd_mach_o_write_segment_64): Ditto.
	(bfd_mach_o_write_symtab): Ditto.
	(bfd_mach_o_write_contents): Ditto.
	(bfd_mach_o_read_header): Ditto.
	(bfd_mach_o_read_section_32): Ditto.
	(bfd_mach_o_read_section_64): Ditto.
	(bfd_mach_o_read_symtab_symbol): Ditto.
	(bfd_mach_o_read_dylinker): Ditto.
	(bfd_mach_o_read_dylib): Ditto.
	(bfd_mach_o_read_dysymtab): Ditto.
	(bfd_mach_o_read_symtab): Ditto.
	(bfd_mach_o_read_linkedit): Ditto.
	(bfd_mach_o_read_str): Ditto.
	(bfd_mach_o_read_dyld_info): Ditto.
	(bfd_mach_o_read_segment): Ditto.
	(bfd_mach_o_read_command): Ditto.
	(bfd_mach_o_archive_p): Ditto.
	(bfd_mach_o_canonicalize_one_reloc): Ditto. Change the BUF parameter.
	(bfd_mach_o_canonicalize_relocs): Adjust to call the above function.
	(bfd_mach_o_read_dysymtab_symbol): Rename BUF variable.
	(bfd_mach_o_read_uuid): Remove useless cast.  Use a macro instead
	of an hard-coded value.

include/mach-o
2011-08-08  Tristan Gingold  <gingold@adacore.com>

	* loader.h: Reorder declarations.
	* x86-64.h: New file.
	* external.h: New file.
	* reloc.h: New file.
2011-08-08 08:59:33 +00:00
Tristan Gingold 53d58d96a7 2011-08-08 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_normalize_section_name): New function.
	(bfd_mach_o_convert_section_name_to_bfd): Use it.
	(bfd_mach_o_get_section_type_from_name): New function.
	(bfd_mach_o_get_section_attribute_from_name): Ditto.
	* mach-o.h (bfd_mach_o_section): Move bfdsection field at the end.
	Add comments.  Add prototypes for the above new functions.
2011-08-08 07:39:44 +00:00
Tristan Gingold 092d27ff47 2011-08-03 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_canonicalize_symtab): Handle no symbols case.
	(bfd_mach_o_read_symtab_symbols): Return if no symbols.
2011-08-03 08:12:07 +00:00
Tristan Gingold 9b02d21241 2011-06-28 Fawzi Mohamed <fawzi.mohamed@nokia.com>
* mach-o.c (bfd_mach_o_read_command): Also ignore
	BFD_MACH_O_LC_ROUTINES_64.
2011-06-28 07:45:53 +00:00
Alan Modra 4a97a0e54c * bfd.c (bfd_perror): Flush stdout before and stderr after printing
error.
	(_bfd_default_error_handler): Likewise.
	* elf.c (print_segment_map): Likewise.
	* libbfd.c (warn_deprecated): Likewise.
	* som.c (som_sizeof_headers): No need to do so here.
	* coff-i860.c: Replace use of printf for error messages with
	_bfd_error_handler.
	* coff-ppc.c: Likewise.
	* coff-sh.c: Likewise.
	* elf32-bfin.c: Likewise.
	* elf32-dlx.c: Likewise.
	* elf32-mep.c: Likewise.
	* elf32-v850.c: Likewise.
	* mach-o.c: Likewise.
	* pef.c: Likewise.
2011-01-14 12:35:56 +00:00
Alan Modra c7e2358a88 fix set but unused variable warnings 2010-06-27 04:07:55 +00:00
H.J. Lu 4f608e793d Update copyright year.
2010-03-24  H.J. Lu  <hongjiu.lu@intel.com>

	* aout-target.h: Update copyright year.
	* aout-tic30.c: Likewise.
	* coff-alpha.c: Likewise.
	* coff-rs6000.c: Likewise.
	* coff64-rs6000.c: Likewise.
	* elf64-mips.c: Likewise.
	* ieee.c: Likewise.
	* libecoff.h: Likewise.
	* mach-o-target.c: Likewise.
	* mach-o.c: Likewise.
	* oasys.c: Likewise.
	* targets.c: Likewise.
2010-03-24 15:41:59 +00:00
Tristan Gingold 1523fa24f7 2010-02-09 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_canonicalize_one_reloc): Adjust addend for
	non-external relocation.
2010-02-09 13:39:22 +00:00
Tristan Gingold 06988dfc57 2010-02-08 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_canonicalize_one_reloc): Set reloc.r_extern
	for non-scattered relocations.
2010-02-08 09:13:47 +00:00
Tristan Gingold 8f95b6e449 2010-01-26 Tristan Gingold <gingold@adacore.com>
* targets.c (BFD_JUMP_TABLE_ARCHIVE): Add initializer for write_ar_hdr.
	(bfd_target): Add _bfd_write_ar_hdr_fn field.
	* archive.c (is_bsd44_extended_name): New macro.
	(_bfd_generic_read_ar_hdr_mag): Use it.  Add extra_size.
	(bfd_slurp_armap): Also check for "__.SYMDEF" as a BSD4.4 extended
	name.
	(_bfd_archive_bsd44_construct_extended_name_table): New function.
	(_bfd_generic_write_ar_hdr): Ditto.
	(_bfd_bsd44_write_ar_hdr): Ditto.
	(_bfd_write_archive_contents): Call _bfd_write_ar_hdr.
	(bsd_write_armap): Adjust firstreal computation.
	* libbfd-in.h (struct areltdata): Add extra_size field.
	(_bfd_generic_write_ar_hdr): Add prototype.
	(_bfd_bsd44_write_ar_hdr): Ditto.
	(_bfd_write_ar_hdr): Define.
	(_bfd_noarchive_write_ar_hdr): Ditto.
	(_bfd_archive_bsd_write_ar_hdr): Ditto.
	(_bfd_archive_coff_write_ar_hdr): Ditto.
	(_bfd_archive_bsd44_slurp_armap): Ditto.
	(_bfd_archive_bsd44_slurp_extended_name_table): Ditto.
	(_bfd_archive_bsd44_construct_extended_name_table): New prototype.
	(_bfd_archive_bsd44_truncate_arname): Ditto.
	(_bfd_archive_bsd44_write_armap): Ditto.
	(_bfd_archive_bsd44_read_ar_hdr): Ditto.
	(_bfd_archive_bsd44_write_ar_hdr): Ditto.
	(_bfd_archive_bsd44_openr_next_archived_file): Ditto.
	(_bfd_archive_bsd44_get_elt_at_index): Ditto.
	(_bfd_archive_bsd44_generic_stat_arch_elt): Ditto.
	(_bfd_archive_bsd44_update_armap_timestamp): Ditto.
	* libbfd.h: Regenerate.
	* oasys.c (oasys_write_ar_hdr): Define.
	* libecoff.h (_bfd_ecoff_write_ar_hdr): Define.
	* ieee.c (ieee_write_ar_hdr): Define.
	* elf64-mips.c (bfd_elf64_archive_write_ar_hdr): Define.
	* coff-rs6000.c (rs6000coff_vec): Adjust for write_ar_hdr field.
	(bfd_pmac_xcoff_backend_data): Ditto.
	* coff64-rs6000.c (rs6000coff64_vec): Ditto.
	(bfd_xcoff_aix5_backend_data): Ditto.
	* coff-alpha.c (alpha_ecoff_write_ar_hdr): Define.
	* aout-target.h (MY_write_ar_hdr): Define it if not defined.
	* aout-tic30.c (MY_write_ar_hdr): Ditto.
	* mach-o-target.c (TARGET_NAME): Use _bfd_archive_bsd44 archive.
	(bfd_mach_o_mkarchive, bfd_mach_o_read_ar_hdr)
	(bfd_mach_o_slurp_armap, bfd_mach_o_slurp_extended_name_table)
	(bfd_mach_o_construct_extended_name_table)
	(bfd_mach_o_truncate_arname, bfd_mach_o_write_armap)
	(bfd_mach_o_get_elt_at_index, bfd_mach_o_generic_stat_arch_elt)
	(bfd_mach_o_update_armap_timestamp): Moved to mach-o.c
	* mach-o.c (bfd_mach_o_mkarchive, bfd_mach_o_read_ar_hdr)
	(bfd_mach_o_slurp_armap, bfd_mach_o_slurp_extended_name_table)
	(bfd_mach_o_construct_extended_name_table)
	(bfd_mach_o_truncate_arname, bfd_mach_o_write_armap)
	(bfd_mach_o_get_elt_at_index, bfd_mach_o_generic_stat_arch_elt)
	(bfd_mach_o_update_armap_timestamp): Moved from mach-o-target.c
	* bfd-in2.h: Regenerate.
2010-01-26 13:42:26 +00:00
Tristan Gingold 42fa08916b 2010-01-11 Tristan Gingold <gingold@adacore.com>
* mach-o.h (bfd_mach_o_backend_data): Add arch field.
	(bfd_mach_o_set_arch_mach): New prototype.
	* mach-o.c (bfd_mach_o_mkobject): Define with bfd_mach_o_gen_mkobject.
	(bfd_mach_o_set_arch_mach): New function.
	(bfd_mach_o_gen_mkobject): New function.
	Set TARGET_ARCHITECTURE for the generic back-ends.
	* mach-o-target.c (bfd_mach_o_set_arch_mach): Remove define.
	Check that TARGET_ARCHITECTURE is defined.
	Add TARGET_ARCHITECTURE in TARGET_NAME_BACKEND structure.
	* mach-o-i386.c (TARGET_ARCHITECTURE): Define.
2010-01-11 15:39:41 +00:00
Tristan Gingold 7f7828f676 2009-12-15 Tristan Gingold <gingold@adacore.com>
* mach-o.h (bfd_mach_o_uuid_command): Remove section field.
        * mach-o.c (bfd_mach_o_scan_read_uuid): Do not create a section
        from this command.
2009-12-15 09:50:15 +00:00
Tristan Gingold 8462aec76d 2009-12-15 Tristan Gingold <gingold@adacore.com>
* mach-o.c (struct mach_o_section_name_xlat): Add flags field.
        (dwarf_section_names_xlat): Add section flags.
        (text_section_names_xlat): Ditto.
        (data_section_names_xlat): Ditto.
        (bfd_mach_o_convert_section_name_to_bfd): Now return name and section
        flags by reference.
        (bfd_mach_o_make_bfd_section): Use section flags when know, otherwise
        try to guess.
2009-12-15 09:28:28 +00:00
Nick Clifton 91d6fa6a03 Add -Wshadow to the gcc command line options used when compiling the binutils.
Fix up all warnings generated by the addition of this switch.
2009-12-11 13:42:17 +00:00
Tristan Gingold ef17cb22d0 2009-12-03 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_make_bfd_section): Force debug flags for
	all sections of the __DWARF segment.
2009-12-03 14:14:03 +00:00
Tristan Gingold 0c9b2b4cc6 bfd/
2009-10-09  Tristan Gingold  <gingold@adacore.com>

	* mach-o.c (bfd_mach_o_read_command): Handle BFD_MACH_O_LC_RPATH.
	(bfd_mach_o_bfd_print_private_bfd_data): Ditto.
2009-10-09 15:33:39 +00:00
Tristan Gingold ab273af8f1 2009-10-09 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_scan_read_symtab_symbols): Rename to
	bfd_mach_o_read_symtab_symbols.
	(bfd_mach_o_scan_write_thread): Rename to bfd_mach_o_write_thread.
	(bfd_mach_o_scan_write_relocs): Rename to bfd_mach_o_write_relocs.
	(bfd_mach_o_scan_write_section_32): Rename to
	bfd_mach_o_write_section_32.
	(bfd_mach_o_scan_write_section_64): Rename to
	bfd_mach_o_write_section_64.
	(bfd_mach_o_scan_write_segment_32): Rename to
	bfd_mach_o_write_segment_32.
	(bfd_mach_o_scan_write_segment_64): Rename to
	bfd_mach_o_write_segment_64.
	(bfd_mach_o_scan_write_symtab): Rename to bfd_mach_o_write_symtab.
	(bfd_mach_o_scan_read_section_32): Rename to
	bfd_mach_o_read_section_32.
	(bfd_mach_o_scan_read_section_64): Rename to
	bfd_mach_o_read_section_64.
	(bfd_mach_o_scan_read_section): Rename to bfd_mach_o_read_section.
	(bfd_mach_o_scan_read_symtab_strtab): Rename to
	bfd_mach_o_read_symtab_strtab.
	(bfd_mach_o_scan_read_symtab_symbol): Rename to
	bfd_mach_o_read_symtab_symbol.
	(bfd_mach_o_scan_read_dysymtab_symbol): Rename to
	bfd_mach_o_read_dysymtab_symbol.
	(bfd_mach_o_scan_read_dylinker): Rename to bfd_mach_o_read_dylinker.
	(bfd_mach_o_scan_read_dylib): Rename to bfd_mach_o_read_dylib.
	(bfd_mach_o_scan_read_prebound_dylib): Rename to
	bfd_mach_o_read_prebound_dylib.
	(bfd_mach_o_scan_read_thread): Rename to bfd_mach_o_read_thread.
	(bfd_mach_o_scan_read_dysymtab): Rename to bfd_mach_o_read_dysymtab.
	(bfd_mach_o_scan_read_symtab): Rename to bfd_mach_o_read_symtab.
	(bfd_mach_o_scan_read_uuid): Rename to bfd_mach_o_read_uuid.
	(bfd_mach_o_scan_read_linkedit): Rename to bfd_mach_o_read_linkedit.
	(bfd_mach_o_scan_read_str): Rename to bfd_mach_o_read_str.
	(bfd_mach_o_scan_read_dyld_info): Rename to bfd_mach_o_read_dyld_info.
	(bfd_mach_o_scan_read_segment): Rename to bfd_mach_o_read_segment.
	(bfd_mach_o_scan_read_segment_32): Rename to
	bfd_mach_o_read_segment_32.
	(bfd_mach_o_scan_read_segment_64): Rename to
	bfd_mach_o_read_segment_64.
	(bfd_mach_o_scan_read_command): Rename to bfd_mach_o_read_command.
	* mach-o.h (bfd_mach_o_scan_read_dysymtab_symbol): Rename to
	bfd_mach_o_read_dysymtab_symbol.
2009-10-09 15:14:56 +00:00
Tristan Gingold b2b620601b 2009-10-09 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_section_get_entry_size): Moved.
	(bfd_mach_o_section_get_nbr_indirect): Ditto.
	(bfd_mach_o_get_synthetic_symtab): New function.
	(bfd_mach_o_print_private_header): Print the number of commands
	in decimal.
	* mach-o.h (bfd_mach_o_get_synthetic_symtab): Add prototype.
	* mach-o-target.c: Do not defined bfd_mach_o_get_synthetic_symtab.
2009-10-09 08:18:17 +00:00
Tristan Gingold afecc97cf6 2009-09-16 Tristan Gingold <gingold@adacore.com>
* mach-o.h (bfd_mach_o_filetype): Add new constants from darwin10.
	Reindent.
	* mach-o.c (bfd_mach_o_cpu_name): Reindent.
	(bfd_mach_o_filetype_name): Complete with new constants.  Reindent.
	(bfd_mach_o_print_private_header): Use fputs instead of fprintf
	when possible to avoid warnings.
	(bfd_mach_o_print_section_map): Ditto.
	(bfd_mach_o_section_get_entry_size): New function.
	(bfd_mach_o_section_get_nbr_indirect): Simplify using the newly
	added function.
	(bfd_mach_o_print_dysymtab): Print address of indirect symbols.
2009-09-16 13:30:32 +00:00
Tristan Gingold ad86f1fb4d 2009-09-09 Tristan Gingold <gingold@adacore.com>
Handle DYLD_INFO introduced by Darwin10.
	* mach-o.h (bfd_mach_o_load_command_type): Add
	BFD_MACH_O_LC_DYLD_INFO.
	(bfd_mach_o_dyld_info_command): New type.
	(bfd_mach_o_load_command): Add dyld_info field.
	* mach-o.c (bfd_mach_o_scan_read_str): Reduce size of buf.
	(bfd_mach_o_scan_read_dyld_info): New function.
	(bfd_mach_o_scan_read_command): Handle BFD_MACH_O_LC_DYLD_INFO.
	(bfd_mach_o_bfd_print_private_bfd_data): Ditto.
	(bfd_mach_o_load_command_name): AddB FD_MACH_O_LC_DYLD_INFO.
	(bfd_mach_o_print_dyld_info): New function.
2009-09-09 14:58:12 +00:00
Nick Clifton d3ce72d070 Updated sources to avoid using the identifier name "new", which is a
keyword in c++.

        * bfd/aoutx.h (NAME (aout, make_empty_symbol)): Rename variable
        new to new_symbol.
        * bfd/coffgen.c (coff_make_empty_symbol)
        (coff_bfd_make_debug_symbol): Rename variable new to new_symbol.
        * bfd/cpu-ia64-opc.c (ext_reg, ins_imms_scaled): Rename variable
        new to new_insn.
        * bfd/doc/chew.c (newentry, add_intrinsic): Rename variable new to
        new_d.
        * bfd/ecoff.c (_bfd_ecoff_make_empty_symbol): Rename variable new
        to new_symbol.
        * bfd/elf32-m68k.c (elf_m68k_get_got_entry_type): Rename argument
        new to new_reloc.
        * bfd/hash.c (bfd_hash_lookup): Rename variable new to new_string.
        * bfd/ieee.c (ieee_make_empty_symbol): Rename variable new to
        new_symbol.
        * bfd/linker.c (bfd_new_link_order): Rename variable new to
        new_lo.
        * bfd/mach-o.c (bfd_mach_o_sizeof_headers): Rename variable new to
        symbol.
        * bfd/oasys.c (oasys_make_empty_symbol): Rename variable new to
        new_symbol_type.
        * bfd/pdp11.c (NAME (aout, make_empty_symbol)): Rename variable
        new to new_symbol_type.
        * bfd/plugin.c (bfd_plugin_make_empty_symbol): Rename variable new
        to new_symbol.
        * bfd/rs6000-core.c (CoreHdr, VmInfo): Rename union member new to
        new_dump.
        (read_hdr, rs6000coff_core_p)
        (rs6000coff_core_file_matches_executable_p)
        (rs6000coff_core_file_failing_command)
        (rs6000coff_core_file_failing_signal): Updated function to use new
        union member name.
        * bfd/som.c (som_make_empty_symbol): Rename variable new to
        new_symbol_type.
        * bfd/syms.c (_bfd_generic_make_empty_symbol): Rename variable new
        to new_symbol.
        * bfd/tekhex.c (first_phase, tekhex_make_empty_symbol): Rename
        variable new to new_symbol.
        * binutils/nlmconv.c (main): Rename variable new to new_name.
        * gas/config/tc-arm.c (insert_reg_alias): Rename variable new to
        new_reg.
        * gas/config/tc-dlx.c (parse_operand): Rename variable new to
        new_pos.
        * gas/config/tc-ia64.c (ia64_gen_real_reloc_type): Rename variable
        new to newr.
        * gas/config/tc-mcore.c (parse_exp, parse_imm): Rename variable
        new to new_pointer.
        * gas/config/tc-microblaze.c (parse_exp, parse_imm, check_got):
        Change name from new to new_pointer.
        * gas/config/tc-or32.c (parse_operand): Rename variable new to
        new_pointer.
        * gas/config/tc-pdp11.c (md_assemble): Rename variable new to
        new_pointer.
        * gas/config/tc-pj.c (alias): Change argument new to new_name.
        * gas/config/tc-score.c (s3_build_score_ops_hsh): Rename variable
        new to new_opcode. (s3_build_dependency_insn_hsh) Rename variable
        new to new_i2n. (s3_convert): Rename variables old and new to
        r_old and r_new.
        * gas/config/tc-score7.c (s7_build_score_ops_hsh): Rename variable
        new to new_opcode. (s7_build_dependency_insn_hsh): Rename variable
        new to new_i2d. (s7_b32_relax_to_b16, s7_convert_frag): Rename
        variables old and new to r_old and r_new.
        * gas/config/tc-sh.c (parse_exp): Rename variable new to
        new_pointer.
        * gas/config/tc-sh64.c (shmedia_parse_exp): Rename variable new to
        new_pointer.
        * gas/config/tc-tic4x.c (tic4x_operand_parse): Rename variable new
        to new_pointer.
        * gas/config/tc-z8k.c (parse_exp): Rename variable new to
        new_pointer.
        * gas/listing.c (listing_newline): Rename variable new to new_i.
        * ld/ldexp.c (exp_intop, exp_bigintop, exp_relop, exp_binop)
        (exp_trinop, exp_unop, exp_nameop, exp_assop): Rename variable new
        to new_e.
        * ld/ldfile.c (ldfile_add_library_path): Rename variable new to
        new_dirs. (ldfile_add_arch): Rename variable new to new_arch.
        * ld/ldlang.c (new_statement, lang_final, lang_add_wild)
        (lang_target, lang_add_fill, lang_add_data, lang_add_assignment)
        (lang_add_insert): Rename variable new to new_stmt. (new_afile):
        Added missing cast. (lang_memory_region_lookup): Rename variable
        new to new_region. (init_os): Rename variable new to
        new_userdata. (lang_add_section): Rename variable new to
        new_section. (ldlang_add_undef): Rename variable new to
        new_undef. (realsymbol): Rename variable new to new_name.
        * opcodes/z8kgen.c (internal, gas): Rename variable new to new_op.

        Updated sources to avoid using the identifier name "template",
        which is a keyword in c++.

        * bfd/elf32-arm.c (struct stub_def): Rename member template to
        template_sequence. (arm_build_one_stub,
        find_stub_size_and_template, arm_size_one_stub, arm_map_one_stub):
        Rename variable template to template_sequence.
        * bfd/elfxx-ia64.c (elfNN_ia64_relax_br, elfNN_ia64_relax_brl):
        Rename variable template to template_val.
        * gas/config/tc-arm.c (struct asm_cond, struct asm_psr, struct
        asm_barrier_opt): Change member template to
        template_name. (md_begin): Update code to reflect new member
        names.
        * gas/config/tc-i386.c (struct templates, struct _i386_insn)
        (match_template, cpu_flags_match, match_reg_size, match_mem_size)
        (operand_size_match, md_begin, i386_print_statistics, pi)
        (build_vex_prefix, md_assemble, parse_insn, optimize_imm)
        (optimize_disp): Updated code to use new names. (parse_insn):
        Added casts.
        * gas/config/tc-ia64.c (dot_template, emit_one_bundle): Updated
        code to use new names.
        * gas/config/tc-score.c (struct s3_asm_opcode): Renamed member
        template to template_name. (s3_parse_16_32_inst, s3_parse_48_inst,
        s3_do_macro_ldst_label, s3_build_score_ops_hsh): Update code to
        use new names.
        * gas/config/tc-score7.c (struct s7_asm_opcode): Renamed member
        template to template_name. (s7_parse_16_32_inst,
        s7_do_macro_ldst_label, s7_build_score_ops_hsh): Update code to
        use new names.
        * gas/config/tc-tic30.c (md_begin, struct tic30_insn)
        (md_assemble): Update code to use new names.
        * gas/config/tc-tic54x.c (struct _tic54x_insn, md_begin)
        (optimize_insn, tic54x_parse_insn, next_line_shows_parallel):
        Update code to use new names.
        * include/opcode/tic30.h (template): Rename type template to
        insn_template. Updated code to use new name.
        * include/opcode/tic54x.h (template): Rename type template to
        insn_template.
        * opcodes/cris-dis.c (bytes_to_skip): Update code to use new name.
        * opcodes/i386-dis.c (putop): Update code to use new name.
        * opcodes/i386-gen.c (process_i386_opcodes): Update code to use
        new name.
        * opcodes/i386-opc.h (struct template): Rename struct template to
        insn_template. Update code accordingly.
        * opcodes/i386-tbl.h (i386_optab): Update type to use new name.
        * opcodes/ia64-dis.c (print_insn_ia64): Rename variable template
        to template_val.
        * opcodes/tic30-dis.c (struct instruction, get_tic30_instruction):
        Update code to use new name.
        * opcodes/tic54x-dis.c (has_lkaddr, get_insn_size)
        (print_parallel_instruction, print_insn_tic54x, tic54x_get_insn):
        Update code to use new name.
        * opcodes/tic54x-opc.c (tic54x_unknown_opcode, tic54x_optab):
        Update type to new name.
2009-08-29 22:11:02 +00:00
Tristan Gingold b32e07d7d7 2009-06-25 Tristan Gingold <gingold@adacore.com>
* mach-o-target.c (bfd_mach_o_get_dynamic_symtab_upper_bound)
	(bfd_mach_o_canonicalize_dynamic_symtab)
	(bfd_mach_o_get_synthetic_symtab): Defines.
	(TARGET_NAME_BACKEND): Add bfd_mach_o_print_thread entry.
	(TARGET_NAME): Use Mach-O specific functions for dynamic.

	* mach-o-i386.c (bfd_mach_o_i386_swap_reloc_in): Fix howto indexes
	for scattered relocations.
	(bfd_mach_o_i386_print_thread): New function.
	(bfd_mach_o_print_thread): Define.

	* mach-o.c (text_section_names_xlat): Add an entry for __const.
	(bfd_mach_o_canonicalize_one_reloc, bfd_mach_o_canonicalize_relocs):
	New functions extracted from ...
	(bfd_mach_o_canonicalize_reloc): ... This.  Simplified.
	(bfd_mach_o_get_dynamic_reloc_upper_bound): New function.
	(bfd_mach_o_canonicalize_dynamic_reloc): New function.
	(bfd_mach_o_i386_flavour_string): Adjusted after enum renaming.
	(bfd_mach_o_ppc_flavour_string): Reindentation.  Add 64 bits cases.
	(bfd_mach_o_scan_read_dylinker): Do not create a section anymore.
	Set name_str field.
	(bfd_mach_o_scan_read_dylib): Ditto.
	(bfd_mach_o_scan_read_thread): Set mdata at declaration.  Add comments,
	reindent.
	(bfd_mach_o_scan_read_dysymtab): Set mdata at declaration.  Correctly
	decode isym and flags on little endian targets.  Set dysymtab field.
	(bfd_mach_o_scan_start_address): Adjust for enum names.
	(bfd_mach_o_lookup_section): Do not look for segments anymore.
	(bfd_mach_o_print_section): Display bfd section name.
	(bfd_mach_o_print_segment): Display none if no name.
	(bfd_mach_o_print_dysymtab): Display next index for local, external
	and undefined symbols.
	(bfd_mach_o_bfd_print_private_bfd_data): Adjust code by using name_str.
	Display dylinker name. Display thread and unixthread commands content.
	(bfd_mach_o_print_thread): New macro.

	* mach-o.h (bfd_mach_o_mach_header_magic): Align numbers.
	(bfd_mach_o_ppc_thread_flavour): Ditto.
	(bfd_mach_o_i386_thread_flavour): Ditto.
	(BFD_MACH_O_PPC_THREAD_STATE_NONE): New enum.
	(BFD_MACH_O_x86_THREAD_STATE_NONE): Replaces
	BFD_MACH_O_THREAD_STATE_NONE.
	(bfd_mach_o_segment_command): Remove segment field.
	(bfd_mach_o_thread_flavour): Field offset is now unsigned long.
	(bfd_mach_o_dylinker_command): Remove section field, add name_str.
	(bfd_mach_o_prebound_dylib_command): Ditto.
	(bfd_mach_o_dylib_command): Ditto.
	(bfd_mach_o_prebound_dylib_command): Remove section field.
	(mach_o_data_struct): Add dysymtab field.
	(bfd_mach_o_backend_data): Add _bfd_mach_o_print_thread field.
	(bfd_mach_o_get_reloc_upper_bound, bfd_mach_o_canonicalize_reloc)
	(bfd_mach_o_build_commands): Remove parameter names and attributes.
	(bfd_mach_o_get_dynamic_reloc_upper_bound)
	(bfd_mach_o_canonicalize_dynamic_reloc): New prototypes.
2009-06-25 12:39:06 +00:00
Tristan Gingold d297e80737 2009-06-22 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_canonicalize_reloc): Append a sentinel to
	the relocs array.
2009-06-22 08:14:52 +00:00
Tristan Gingold b8674692ae 2009-06-19 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_print_private_header): Fix format character.
2009-06-19 09:23:54 +00:00
Tristan Gingold 046b007d85 2009-06-19 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_scan_read_symtab_symbols): Add prototype.
	(bfd_mach_o_version): Use bfd_mach_o_get_data instead of direct access.
	(bfd_mach_o_valid): Ditto.
	(bfd_mach_o_wide_p): Ditto.
	(bfd_mach_o_canonicalize_reloc): Ditto.
	(bfd_mach_o_build_commands): Ditto.
	(bfd_mach_o_scan_read_thread): Ditto.
	(bfd_mach_o_flatten_sections): Ditto.
	(bfd_mach_o_scan_start_address): Ditto.
	(bfd_mach_o_lookup_section): Ditto.
	(bfd_mach_o_core_fetch_environment): Ditto.
	(bfd_mach_o_write_contents): Ditto.  Handle reexport_dylib.
	(bfd_mach_o_scan_write_relocs): Adjust for bfd_mach_o_get_data.
	(bfd_mach_o_scan_write_symtab): Ditto.
	Use macros instead of hard-coded values.
	(bfd_mach_o_scan_read_symtab_symbol): Make the function static.
	Use bfd_mach_o_get_data instead of direct access.  Use macros
	instead of hard-coded values.
	(bfd_mach_o_scan_read_symtab_strtab): Make the function static.
	Remove sym argument and get section from mdata.
	Move code into the else branch.
	(bfd_mach_o_scan_read_symtab_symbols): Make the function static.
	Remove sym argument and get section from mdata.  Adjust code.
	(bfd_mach_o_scan_read_dylib): Move assertion into the created
	switch (which replaces consecutive if statements).
	(bfd_mach_o_scan_read_dysymtab): Rename seg to cmd.  Load
	module table, table of content, indirect symbols and external
	referenced symbols.
	(bfd_mach_o_scan_read_symtab): Renames seg to symtab.  Set symtab
	field.
	(bfd_mach_o_scan_read_linkedit): New function.
	(bfd_mach_o_scan_read_str): Ditto.
	(bfd_mach_o_count_symbols): Simplify the code by using the symtab
	field of mdata.
	(bfd_mach_o_get_symtab_upper_bound): Remove check as
	bfd_mach_o_count_symbols never returns an error.
	(bfd_mach_o_canonicalize_symtab): Simplify the code by using the
	symtab field (there might be only one symtab).
	(bfd_mach_o_scan_read_command): Handle reexported dylib.
	Handle sub frameworks, sub umbrella, sub library and sub client.
	Read code signature and segment split info commands.
	(bfd_mach_o_scan): Reindent.
	(bfd_mach_o_xlat_name): New type.
	(bfd_mach_o_print_flags): New function.
	(bfd_mach_o_get_name): Ditto.
	(bfd_mach_o_cpu_name): New variable.
	(bfd_mach_o_filetype_name, bfd_mach_o_header_flags_name)
	(bfd_mach_o_section_type_name)
	(bfd_mach_o_section_attribute_name)
	(bfd_mach_o_load_command_name): New variables.
	(bfd_mach_o_print_private_header): New function.
	(bfd_mach_o_print_section_map): New function extracted from
	bfd_mach_o_print_private_bfd_data.
	(bfd_mach_o_print_section): Ditto.  Print more infos.
	(bfd_mach_o_print_segment): Ditto.
	(bfd_mach_o_print_dysymtab): Ditto.
	(bfd_mach_o_bfd_print_private_bfd_data): Reworked.  Handle
	load weak dylib, reexport dylib and id dylib.
	Handle code signature and segment_split info.
	Handle sub frameworks, sub umbrella, sub library and sub client.
	(bfd_mach_o_section_get_nbr_indirect): New function.

	* mach-o.h (BFD_MACH_O_REFERENCE_MASK): New macro.  Add comment.
	(bfd_mach_o_header_flags): New enum to define header flags.
	(bfd_mach_o_section_attribute): New enum to replace ...
	(BFD_MACH_O_S_ATTR_LOC_RELOC, BFD_MACH_O_S_ATTR_EXT_RELOC,
	BFD_MACH_O_S_ATTR_SOME_INSTRUCTIONS, BFD_MACH_O_S_ATTR_DEBUG,
	BFD_MACH_O_S_SELF_MODIFYING_CODE, BFD_MACH_O_S_ATTR_LIVE_SUPPORT,
	BFD_MACH_O_S_ATTR_NO_DEAD_STRIP, BFD_MACH_O_S_ATTR_STRIP_STATIC_SYMS,
	BFD_MACH_O_S_ATTR_NO_TOC, BFD_MACH_O_S_ATTR_PURE_INSTRUCTIONS): ...
	these removed macros.
	(BFD_MACH_O_NLIST_SIZE, BFD_MACH_O_NLIST_64_SIZE): New macros.
	(bfd_mach_o_dylib_module): New type.
	(BFD_MACH_O_DYLIB_MODULE_SIZE, BFD_MACH_O_DYLIB_MODULE_64_SIZE): New
	macros.
	(bfd_mach_o_dylib_table_of_content): New type.
	(BFD_MACH_O_TABLE_OF_CONTENT_SIZE): New macro.
	(bfd_mach_o_dylib_reference): New type.
	(BFD_MACH_O_REFERENCE_SIZE): New macro.
	(bfd_mach_o_dysymtab_command): Add fields for loaded and decoded
	modules, toc, references and indirect syms.
	(BFD_MACH_O_INDIRECT_SYMBOL_SIZE): New macro.
	(bfd_mach_o_dylinker_command): Remove cmd and cmdsize fields (were
	unused).  Add comment.
	(bfd_mach_o_dylib_command): Ditto.
	(bfd_mach_o_prebound_dylib_command): Ditto.
	(bfd_mach_o_linkedit_command): New type.
	(bfd_mach_o_str_command): New type.
	(bfd_mach_o_load_command): Add linkedit and str fields.
	(mach_o_data_struct): Add symtab field.
	(bfd_get_mach_o_data): Renamed to ...
	(bfd_mach_o_get_data): ... this new macro.
	(bfd_mach_o_scan_read_symtab_symbol,
	bfd_mach_o_scan_read_symtab_strtab,
	bfd_mach_o_scan_read_symtab_symbols): Prototypes removed.

	* mach-o-i386.c (bfd_mach_o_i386_mkobject): Use bfd_mach_o_get_data
	instead of direct access.
2009-06-19 09:12:41 +00:00
Tristan Gingold 92bc0e8020 2009-06-12 Tristan Gingold <gingold@adacore.com>
* reloc.c: Add BFD_RELOC_MACH_O_SECTDIFF and BFD_RELOC_MACH_O_PAIR.
	* bfd-in2.h: Regenerated.
	* libbfd.h: Regenerated.

	* mach-o.c (FILE_ALIGN): New macro.
	(bfd_mach_o_canonicalize_symtab): Adjust for bfd_mach_o_asymbol.
	(bfd_mach_o_print_symbol): Ditto.
	(bfd_mach_o_scan_write_thread): Adjust type of variable offset.
	(bfd_mach_o_get_reloc_upper_bound): New function.
	(bfd_mach_o_canonicalize_reloc): Ditto.
	(bfd_mach_o_scan_write_relocs): Ditto.
	(bfd_mach_o_scan_write_section_32): Remove offset argument.
	(bfd_mach_o_scan_write_section_64): Ditto.
	(bfd_mach_o_scan_write_segment_32): Write relocs.  Fix size of data
	written for load command.  Do not compute section file offset.
	(bfd_mach_o_scan_write_segment_64): Ditto.
	(bfd_mach_o_scan_write_symtab): Compute file offset first.
	Adjust for bfd_mach_o_asymbol.  Move code to convert from BFD to
	Mach-O to ...
	(bfd_mach_o_mangle_symbols): ... this new function.
	(bfd_mach_o_write_contents): Be sure to habe load commands built.
	Call bfd_mach_o_mangle_symbols.
	(bfd_mach_o_build_commands): Adjust for filelen field.
	Use FILE_ALIGN macro.  Clear section file offset if section is empty.
	Do not set symtab file offset anymore here.
	(bfd_mach_o_make_empty_symbol): Allocate a bfd_mach_o_asymbol.
	(bfd_mach_o_make_bfd_section): Set SEC_RELOC if has reloc.
	Set reloc_count and rel_filepos section fields.
	(bfd_mach_o_scan_read_section_32): Type of argument offset is now
	unsigned int.
	(bfd_mach_o_scan_read_section_64): Ditto.
	(bfd_mach_o_scan_read_section): Ditto.
	(bfd_mach_o_scan_read_symtab_symbol): Typr of argument s is now
	bfd_mach_o_asymbol.  Use unsigned int for file offset type.
	(bfd_mach_o_scan_read_symtab_symbol): Adjust for bfd_mach_o_asymbol.
	Handle weak-ref symbols.
	(bfd_mach_o_scan_read_symtab_symbols): Adjust for bfd_mach_o_asymbol.
	(bfd_mach_o_scan_read_dysymtab_symbol): Ditto.
	(bfd_mach_o_scan): Remove assignment to removed field.
	(bfd_mach_o_mkobject_init): Ditto.
	(bfd_mach_o_bfd_print_private_bfd_data): Adjust printf formatter.
	(bfd_mach_o_bfd_reloc_type_lookup): New macro.
	(bfd_mach_o_bfd_reloc_name_lookup): Ditto.
	(bfd_mach_o_swap_reloc_in): Ditto.
	(bfd_mach_o_swap_reloc_out): Ditto.

	* mach-o.h (BFD_MACH_O_REFERENCE_FLAG_UNDEFINED_NON_LAZY)
	(BFD_MACH_O_REFERENCE_FLAG_UNDEFINED_LAZY)
	(BFD_MACH_O_REFERENCE_FLAG_DEFINED)
	(BFD_MACH_O_REFERENCE_FLAG_PRIVATE_DEFINED)
	(BFD_MACH_O_REFERENCE_FLAG_PRIVATE_UNDEFINED_NON_LAZY)
	(BFD_MACH_O_REFERENCE_FLAG_PRIVATE_UNDEFINED_LAZY)
	(BFD_MACH_O_REFERENCED_DYNAMICALLY, BFD_MACH_O_N_DESC_DISCARDED)
	(BFD_MACH_O_N_NO_DEAD_STRIP, BFD_MACH_O_N_WEAK_REF)
	(BFD_MACH_O_N_WEAK_DEF): New macros.
	Add comments.
	(bfd_mach_o_section_type): Add new enumeration values.
	(BFD_MACH_O_S_SELF_MODIFYING_CODE)
	(BFD_MACH_O_S_ATTR_LIVE_SUPPORT)
	(BFD_MACH_O_S_ATTR_NO_DEAD_STRIP)
	(BFD_MACH_O_S_ATTR_STRIP_STATIC_SYMS, BFD_MACH_O_S_ATTR_NO_TOC): New
	macros.
	(BFD_MACH_O_GENERIC_RELOC_VANILLA)
	(BFD_MACH_O_GENERIC_RELOC_PAIR)
	(BFD_MACH_O_GENERIC_RELOC_SECTDIFF)
	(BFD_MACH_O_GENERIC_RELOC_PB_LA_PTR)
	(BFD_MACH_O_GENERIC_RELOC_LOCAL_SECTDIFF): Ditto.
	(BFD_MACH_O_RELENT_SIZE): Ditto.
	(BFD_MACH_O_R_PCREL, BFD_MACH_O_GET_R_LENGTH)
	(BFD_MACH_O_R_EXTERN, BFD_MACH_O_GET_R_TYPE)
	(BFD_MACH_O_GET_R_SYMBOLNUM, BFD_MACH_O_SET_R_LENGTH)
	(BFD_MACH_O_SET_R_TYPE, BFD_MACH_O_SET_R_SYMBOLNUM): Ditto.
	(BFD_MACH_O_SR_SCATTERED, BFD_MACH_O_SR_PCREL)
	(BFD_MACH_O_GET_SR_LENGTH, BFD_MACH_O_GET_SR_TYPE)
	(BFD_MACH_O_GET_SR_ADDRESS, BFD_MACH_O_SET_SR_LENGTH)
	(BFD_MACH_O_SET_SR_TYPE, BFD_MACH_O_SET_SR_ADDRESS): Ditto.
	(bfd_mach_o_reloc_info): New struct.
	(bfd_mach_o_asymbol): New struct.
	(bfd_mach_o_symtab_command): The symbols field is now of type
	bfd_mach_o_asymbol.
	(bfd_mach_o_load_command): The offset and len fields are now of type
	unsigned int.
	(mach_o_data_struct): Remove symbols, nsymbols and ibfd fields.
	Add a filelen field.  Add comments.
	(bfd_mach_o_backend_data): New struct.
	(bfd_mach_o_get_backend_data): New macro.
	(bfd_mach_o_scan_read_symtab_symbol): Parameter symbol now of type
	bfd_mach_o_asymbol.
	(bfd_mach_o_scan_read_dysymtab_symbol): Ditto.
	(bfd_mach_o_get_reloc_upper_bound): New prototype.
	(bfd_mach_o_canonicalize_reloc): Ditto.

	* mach-o-target.c (bfd_mach_o_bfd_is_local_label_name): Remove
	duplicated macro.  Now defined to _bfd_generic_is_local_label.
	(TARGET_NAME_BACKEND): New macro...
	(TARGET_NAME_BACKEND): ... used to name a new variable.
	(TARGET_NAME): Define relocs table using bfd_mach_o, reference
	Mach-O backend data.

	* mach-o-i386.c (i386_howto_table): New variable.
	(bfd_mach_o_i386_swap_reloc_in): New function.
	(bfd_mach_o_i386_swap_reloc_out): Ditto.
	(bfd_mach_o_i386_bfd_reloc_type_lookup): Ditto.
	(bfd_mach_o_i386_bfd_reloc_name_lookup): Ditto.
	(bfd_mach_o_swap_reloc_in, bfd_mach_o_swap_reloc_out): New macros.
	(bfd_mach_o_bfd_reloc_type_lookup)
	(bfd_mach_o_bfd_reloc_name_lookup): Ditto.
2009-06-12 09:15:46 +00:00
Tristan Gingold c2f09c751b 2009-06-09 Tristan Gingold <gingold@adacore.com>
* mach-o.h (bfd_mach_o_symtab_command): Remove stabs_segment
	and stabstr_segment fields.
	(mach_o_be_vec, mach_o_le_vec): Removed
	(bfd_mach_o_version): New prototype.

	* mach-o.c (bfd_mach_o_version): Make this function public.
	(mach_o_wide_p): New function.
	(bfd_mach_o_wide_p): Ditto.
	(bfd_mach_o_convert_section_name_to_bfd): Add prefix only for
	weird names.
	(bfd_mach_o_convert_section_name_to_mach_o): Fix typo in comment.
	Search in the list only if the name starts with a dot.
	(bfd_mach_o_write_header): Use mach_o_wide_p instead of hard-coded
	test.  Check bfd_seek status.
	(bfd_mach_o_scan_write_thread): Check bfd_seek status.
	(bfd_mach_o_scan_write_section_32): Ditto.
	(bfd_mach_o_scan_write_section_64): Ditto.
	(bfd_mach_o_scan_write_section): Removed.
	(bfd_mach_o_scan_write_segment): Split into ...
	(bfd_mach_o_scan_write_segment_32): ... this and ...
	(bfd_mach_o_scan_write_segment_64): ... this.  Check bfd_seek status.
	(bfd_mach_o_scan_write_symtab_symbols): Moved into ...
	(bfd_mach_o_scan_write_symtab): ... this.  Write symtab from BFD
	symbol table.  Now returns a boolean.
	(bfd_mach_o_write_contents): Set filetype.  Check bfd_seek status.
	Adjust for status type.
	(bfd_mach_o_build_commands): Use mach_o_wide_p instead of hard-coded
	test.  Write symbol table.  Numbers the sections.
	(bfd_mach_o_read_header): Check bfd_seek status.
	Use mach_o_wide_p instead of hard-coded test.
	(bfd_mach_o_scan_read_section_32): Check bfd_seek status.
	(bfd_mach_o_scan_read_section_64): Ditto.
	(bfd_mach_o_scan_read_symtab_symbol): Ditto.  Check bfd_seek status.
	Use BFD_MACH_O_N_TYPE instead of hard-coded value.  Correctly
	handled common symbols.
	(bfd_mach_o_scan_read_symtab_strtab): Check bfd_seek status.
	(bfd_mach_o_scan_read_dysymtab_symbol): Ditto.
	(bfd_mach_o_scan_read_dylinker): Ditto.
	(bfd_mach_o_scan_read_dylib): Ditto.
	(bfd_mach_o_scan_read_thread): Ditto.
	(bfd_mach_o_scan_read_symtab): Ditto.
	Do not create a section for the stabs.
	(bfd_mach_o_scan_read_uuid): Check bfd_seek status.
	(bfd_mach_o_scan_read_segment): Ditto.
	(bfd_mach_o_scan_read_command): Ditto.
	(bfd_mach_o_scan_start_address): Ditto.
	(bfd_mach_o_scan): Use mach_o_wide_p instead of hard-coded test.
	(bfd_mach_o_archive_p): Check bfd_seek status.
	(bfd_mach_o_core_fetch_environment): Ditto.

	* mach-o-i386.c (bfd_mach_o_i386_mkobject): Don't set filetype.
2009-06-09 07:37:19 +00:00
Tristan Gingold 154a1ee56c 2009-06-05 Tristan Gingold <gingold@adacore.com>
* mach-o.h: Update copyright year.
	(bfd_mach_o_mach_header_magic): New enum.
	(bfd_mach_o_cpu_subtype): Now an enum.
	(BFD_MACH_O_HEADER_SIZE, BFD_MACH_O_HEADER_64_SIZE): New macros.
	(BFD_MACH_O_SECTION_SIZE, BFD_MACH_O_SECTION_64_SIZE): Ditto.
	(BFD_MACH_O_LC_SEGMENT_SIZE, BFD_MACH_O_LC_SEGMENT_64_SIZE): Ditto.
	(bfd_mach_o_load_command): Field type_required is now a boolean.
	Reindent prototypes.
	(bfd_mach_o_object_p, bfd_mach_o_core_p): Remove.
	(bfd_mach_o_bfd_copy_private_symbol_data): Add a prototype.
	(bfd_mach_o_bfd_copy_private_section_data): Ditto.
	(bfd_mach_o_bfd_copy_private_bfd_data): Ditto.
	(bfd_mach_o_get_symtab_upper_bound): Ditto.
	(bfd_mach_o_canonicalize_symtab): Ditto.
	(bfd_mach_o_get_symbol_info): Ditto.
	(bfd_mach_o_print_symbol): Ditto.
	(bfd_mach_o_bfd_print_private_bfd_data): Ditto.
	(bfd_mach_o_make_empty_symbol): Ditto.
	(bfd_mach_o_write_contents): Ditto.

	* mach-o.c (bfd_mach_o_object_p, bfd_mach_o_core_p,
	bfd_mach_o_mkobject): Defines.
	(bfd_mach_o_valid): Returns FALSE/TRUE instead of 0/1.
	Do not check with target vector but with flavour.
	(struct mach_o_section_name_xlat): New declaration.
	(dwarf_section_names_xlat): Ditto.
	(text_section_names_xlat): Ditto.
	(data_section_names_xlat): Ditto.
	(struct mach_o_segment_name_xlat): Ditto.
	(segsec_names_xlat): Ditto.
	(bfd_mach_o_convert_section_name_to_bfd): New function.
	(bfd_mach_o_convert_section_name_to_mach_o): Ditto.
	(bfd_mach_o_bfd_copy_private_symbol_data): Make it public.
	(bfd_mach_o_bfd_copy_private_section_data): Ditto.
	(bfd_mach_o_bfd_copy_private_bfd_data): Ditto.
	Accept any input and output flavour.  Do not share private data
	anymore.
	(bfd_mach_o_count_symbols): Add a comment.
	(bfd_mach_o_get_symtab_upper_bound): Make it public.
	(bfd_mach_o_canonicalize_symtab): Ditto.
	(bfd_mach_o_get_symbol_info): Ditto.
	(bfd_mach_o_print_symbol): Ditto.
	(bfd_mach_o_write_header): Now returns a boolean instead of an int.
	Use constants instead of hard-coded values.
	(bfd_mach_o_scan_write_section_32): Use constants instead of hard-coded
	values.
	(bfd_mach_o_scan_write_section_64): Ditto.
	(bfd_mach_o_scan_write_segment): Ditto.
	Do not copy sections anymore.
	(bfd_mach_o_write_contents): Make it public.
	Remove dead code.  Rewrite typeflag assignment.
	(bfd_mach_o_build_commands): New function.
	(bfd_mach_o_set_section_contents): Ditto.
	(bfd_mach_o_make_empty_symbol): Make it public.
	(bfd_mach_o_read_header): Make it static.
	Convert to bfd_boolean.
	Use constants instead of hard-coded values.
	(bfd_mach_o_make_bfd_section): Call
	bfd_mach_o_convert_section_name_to_bfd to create name.
	(bfd_mach_o_scan_read_section_32): Use constants instead of hard-coded
	values.
	(bfd_mach_o_scan_read_section_64): Ditto.
	(bfd_mach_o_scan_read_segment): Do not create a bfd section for
	a segment anymore.  Use constants instead of hard-coded values.
	(bfd_mach_o_scan_read_command): Fix style.
	(bfd_mach_o_scan): Use constants instead of hard-coded values.
	Get rid of BFD_IO_FUNCS.
	(bfd_mach_o_mkobject_init): Renamed from bfd_mach_o_mkobject.
	(bfd_mach_o_header_p): Created from bfd_mach_o_object_p.
	(bfd_mach_o_gen_object_p): New function, replaces bfd_mach_o_object_p.
	(bfd_mach_o_object_p): Removed.
	(bfd_mach_o_gen_core_p): New function, replaces ...
	(bfd_mach_o_core_p): ... deleted.
	(bfd_mach_o_bfd_print_private_bfd_data): Make it public.

	* mach-o-i386.c: New file.
	* config.bfd: Use mach_o_i386_vec as targ_defvec for ix86-darwin.
	* configure.in (TDEFINES): Add mach_o_i386_vec.
	* configure: Regenerated.
	* targets.c: Add mach_o_i386_vec.

	* mach-o.c: Update copyright years.
	(BFD_IO_FUNCS): Remove (was not used).
	(bfd_mach_o_mkarchive, bfd_mach_o_read_ar_hdr, bfd_mach_o_slurp_armap
	bfd_mach_o_slurp_extended_name_table,
	bfd_mach_o_construct_extended_name_table,
	bfd_mach_o_truncate_arname, bfd_mach_o_write_armap,
	bfd_mach_o_get_elt_at_index, bfd_mach_o_generic_stat_arch_elt,
	bfd_mach_o_update_armap_timestamp, bfd_mach_o_close_and_cleanup,
	bfd_mach_o_bfd_free_cached_info, bfd_mach_o_new_section_hook,
	bfd_mach_o_get_section_contents_in_window,
	bfd_mach_o_bfd_is_local_label_name,
	bfd_mach_o_bfd_is_target_special_symbol,
	bfd_mach_o_bfd_is_local_label_name, bfd_mach_o_get_lineno,
	bfd_mach_o_find_nearest_line, bfd_mach_o_find_inliner_info,
	bfd_mach_o_bfd_make_debug_symbol, bfd_mach_o_read_minisymbols,
	bfd_mach_o_minisymbol_to_symbol,
	bfd_mach_o_bfd_get_relocated_section_contents,
	bfd_mach_o_bfd_relax_section, bfd_mach_o_bfd_link_hash_table_create,
	bfd_mach_o_bfd_link_hash_table_free, bfd_mach_o_bfd_link_add_symbols,
	bfd_mach_o_bfd_link_just_syms, bfd_mach_o_bfd_final_link,
	bfd_mach_o_bfd_link_split_section, bfd_mach_o_set_arch_mach,
	bfd_mach_o_bfd_merge_private_bfd_data,
	bfd_mach_o_bfd_set_private_flags, bfd_mach_o_get_section_contents,
	bfd_mach_o_bfd_gc_sections, bfd_mach_o_bfd_merge_sections,
	bfd_mach_o_bfd_is_group_section, bfd_mach_o_bfd_discard_group,
	bfd_mach_o_section_already_linked, bfd_mach_o_bfd_define_common_symbol,
	bfd_mach_o_bfd_copy_private_header_data,
	bfd_mach_o_core_file_matches_executable_p): Move these defines ...
	* mach-o-target.c: ... here.
	Update copyright years.
2009-06-05 09:19:44 +00:00
Richard Sandiford 3023e3f66a bfd/
* aout-adobe.c (aout_32_bfd_define_common_symbol): Define.
	* aout-target.h (MY_bfd_define_common_symbol): Likewise.
	* aout-tic30.c (MY_bfd_define_common_symbol): Likewise.
	* binary.c (binary_bfd_define_common_symbol): Likewise.
	* bout.c (b_out_bfd_define_common_symbol): Likewise.
	* coff-alpha.c (_bfd_ecoff_bfd_define_common_symbol): Likewise.
	* coff-mips.c (_bfd_ecoff_bfd_define_common_symbol): Likewise.
	* coffcode.h (coff_bfd_define_common_symbol): Likewise.
	* elfxx-target.h (bfd_elfNN_bfd_define_common_symbol): Likewise.
	* i386msdos.c (msdos_bfd_define_common_symbol): Likewise.
	* i386os9k.c (os9k_bfd_define_common_symbol): Likewise.
	* ieee.c (ieee_bfd_define_common_symbol): Likewise.
	* ihex.c (ihex_bfd_define_common_symbol): Likewise.
	* libbfd-in.h (_bfd_nolink_bfd_define_common_symbol): Likewise.
	* mach-o.c (bfd_mach_o_bfd_define_common_symbol): Likewise.
	* mmo.c (mmo_bfd_define_common_symbol): Likewise.
	* nlm-target.h (nlm_bfd_define_common_symbol): Likewise.
	* oasys.c (oasys_bfd_define_common_symbol): Likewise.
	* pef.c (bfd_pef_bfd_define_common_symbol): Likewise.
	* ppcboot.c (ppcboot_bfd_define_common_symbol): Likewise.
	* som.c (som_bfd_define_common_symbol): Likewise.
	* srec.c (srec_bfd_define_common_symbol): Likewise.
	* tekhex.c (tekhex_bfd_define_common_symbol): Likewise.
	* versados.c (versados_bfd_define_common_symbol): Likewise.
	* vms.c (vms_bfd_define_common_symbol): Likewise.
	* xcoff-target.h (_bfd_xcoff_bfd_define_common_symbol): Likewise.
	* xsym.c (bfd_sym_bfd_define_common_symbol): Likewise.
	* coff-rs6000.c (rs6000coff_vec): Add _bfd_xcoff_define_common_symbol.
	(pmac_xcoff_vec): Likewise.
	* coff64-rs6000.c (rs6000coff64_vec): Likewise.
	(aix5coff64_vec): Likewise.
	* linker.c (bfd_generic_define_common_symbol): New function.
	* targets.c (BFD_JUMP_TABLE_LINK): Add NAME##_bfd_define_common_symbol.
	(_bfd_define_common_symbol): New field.
	* libcoff-in.h (_bfd_xcoff_define_common_symbol): Declare.
	* xcofflink.c (_bfd_xcoff_define_common_symbol): New function.
	(xcoff_build_ldsyms): Don't set XCOFF_DEF_REGULAR for common
	symbols here.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Likewise.
	* libcoff.h: Likewise.

ld/
	* ldlang.c (lang_one_common): Use bfd_define_common_symbol.

ld/testsuite/
	* ld-powerpc/aix-export-2.s, ld-powerpc/aix-export-2.nd: New test.
	* ld-powerpc/aix52.exp: Run it.
2009-04-16 23:07:00 +00:00
Andreas Schwab 27cc28f94b * mach-o.c (bfd_mach_o_archive_p): Restrict the number of
architectures in the archive.
2009-01-27 16:37:10 +00:00
Tristan Gingold 846b9259cb 2008-12-23 Tristan Gingold <gingold@adacore.com>
* mach-o.c (bfd_mach_o_make_bfd_section): Use the standard ELF name
	.eh_frame for __TEXT.__eh_frame so that it is recognized by gdb.
	Use shorter sections name for well known sections.
	(bfd_mach_o_scan_read_dylinker): Only put dylinker name in the
	section content.
	(bfd_mach_o_scan_read_segment): Use shorter sections name for
	well known segments.
	(bfd_mach_o_scan_read_command): Ignore some new commands.
	(bfd_mach_o_openr_next_archived_file): Use more descriptive names
	for members filename.
	(bfd_mach_o_fat_extract): New function to easily extract members
	of a fat binary.
	* mach-o.h (bfd_mach_o_load_command_type): Add new constants.
	(bfd_mach_o_dylinker_command): Fix comment and reindent.
	(bfd_mach_o_fat_extract): New prototype.
2008-12-23 11:32:45 +00:00