Commit Graph

29 Commits

Author SHA1 Message Date
Alan Modra 827041555a Update year range in copyright notice of binutils files 2019-01-01 22:06:53 +10:30
Alan Modra 2d5d5a8f0a Include bfd_stdint.h in bfd.h
This patch adds bfd_stdint.h to bfd.h, so that BFD can use size_t
where appropriate in function parameters and return values.  I also
tidy a few other cases where headers are included twice.

bfd/
	* Makefile.am (bfdinclude_HEADERS): Add bfd_stdint.h.
	(BFD_H_DEPS): Add include/diagnostics.h.
	(LOCAL_H_DEPS): Add bfd_stdint.h.
	* bfd-in.h: Include bfd_stdint.h.
	* arc-plt.h: Don't include stdint.h.
	* coff-rs6000.c: Likewise.
	* coff64-rs6000.c: Likewise.
	* elfxx-riscv.c: Likewise.
	* cache.c: Don't include bfd_stdint.h.
	* elf32-arm.c: Likewise.
	* elf32-avr.c: Likewise.
	* elf32-nds32.c: Likewise.
	* elf32-rl78.c: Likewise.
	* elf32-rx.c: Likewise.
	* elf32-wasm32.c: Likewise.
	* elf64-nfp.c: Likewise.
	* elflink.c: Likewise.
	* elfnn-aarch64.c: Likewise.
	* elfnn-ia64.c: Likewise.
	* elfxx-ia64.c: Likewise.
	* elfxx-x86.h: Likewise.
	* wasm-module.c: Likewise, and don't include sysdep.h twice.
	* elf-nacl.h: Don't include bfd.h.
	* mach-o.h: Likewise.
	* elfxx-aarch64.c: Include bfd.h and elf-bfd.h.
	* elfxx-aarch64.h: Don't include bfd.h, elf-bfd.h or stdint.h.
	* mach-o-aarch64.c: Include mach-o.h later.
	* mach-o-arm.c: Likewise.
	* mach-o-i386.c: Likewise.
	* mach-o-x86-64.c: Likewise.
	* mach-o.c: Likewise.
	* sysdep.h: Don't include ansidecl.h or sys/stat.h.
	* Makefile.in: Regenerate.
	* bfd-in2.h: Regenerate.
opcodes/
	* arm-dis.c: Include bfd.h.
	* aarch64-opc.c: Include bfd_stdint.h rather than stdint.h.
	* csky-dis.c: Likewise.
	* nds32-asm.c: Likewise.
	* riscv-dis.c: Likewise.
	* s12z-dis.c: Likewise.
	* wasm32-dis.c: Likewise.
2018-12-18 23:49:48 +10:30
Alan Modra 219d1afa89 Update year range in copyright notice of binutils files 2018-01-03 17:49:56 +10:30
Alan Modra 07d6d2b834 BFD whitespace fixes
Binutils is supposed to use tabs.  In my git config I have
whitespace = indent-with-non-tab,space-before-tab,trailing-space
and I got annoyed enough seeing red in "git diff" output to fix
the problems.

	* doc/header.sed: Trim trailing space when splitting lines.
	* aix386-core.c, * aout-adobe.c, * aout-arm.c, * aout-cris.c,
	* aout-ns32k.c, * aout-target.h, * aout-tic30.c, * aoutf1.h, * aoutx.h,
	* arc-got.h, * arc-plt.def, * arc-plt.h, * archive.c, * archive64.c,
	* archures.c, * armnetbsd.c, * bfd-in.h, * bfd.c, * bfdio.c, * binary.c,
	* bout.c, * cache.c, * cisco-core.c, * coff-alpha.c, * coff-apollo.c,
	* coff-arm.c, * coff-h8300.c, * coff-i386.c, * coff-i860.c,
	* coff-i960.c, * coff-m68k.c, * coff-m88k.c, * coff-mcore.c,
	* coff-mips.c, * coff-ppc.c, * coff-rs6000.c, * coff-sh.c,
	* coff-stgo32.c, * coff-tic4x.c, * coff-tic54x.c, * coff-tic80.c,
	* coff-we32k.c, * coff-x86_64.c, * coff-z80.c, * coff-z8k.c,
	* coff64-rs6000.c, * coffcode.h, * coffgen.c, * cofflink.c,
	* coffswap.h, * compress.c, * corefile.c, * cpu-alpha.c, * cpu-arm.c,
	* cpu-avr.c, * cpu-bfin.c, * cpu-cr16.c, * cpu-cr16c.c, * cpu-crx.c,
	* cpu-d10v.c, * cpu-frv.c, * cpu-ft32.c, * cpu-i370.c, * cpu-i960.c,
	* cpu-ia64-opc.c, * cpu-ip2k.c, * cpu-lm32.c, * cpu-m32r.c,
	* cpu-mcore.c, * cpu-microblaze.c, * cpu-mips.c, * cpu-moxie.c,
	* cpu-mt.c, * cpu-nios2.c, * cpu-ns32k.c, * cpu-or1k.c, * cpu-powerpc.c,
	* cpu-pru.c, * cpu-sh.c, * cpu-spu.c, * cpu-v850.c, * cpu-v850_rh850.c,
	* cpu-xgate.c, * cpu-z80.c, * dwarf1.c, * dwarf2.c, * ecoff.c,
	* ecofflink.c, * ecoffswap.h, * elf-bfd.h, * elf-eh-frame.c,
	* elf-hppa.h, * elf-m10200.c, * elf-m10300.c, * elf-s390-common.c,
	* elf-strtab.c, * elf-vxworks.c, * elf.c, * elf32-am33lin.c,
	* elf32-arc.c, * elf32-arm.c, * elf32-avr.c, * elf32-avr.h,
	* elf32-bfin.c, * elf32-cr16.c, * elf32-cr16c.c, * elf32-cris.c,
	* elf32-crx.c, * elf32-d10v.c, * elf32-d30v.c, * elf32-dlx.c,
	* elf32-epiphany.c, * elf32-fr30.c, * elf32-frv.c, * elf32-ft32.c,
	* elf32-h8300.c, * elf32-hppa.c, * elf32-i386.c, * elf32-i860.c,
	* elf32-i960.c, * elf32-ip2k.c, * elf32-lm32.c, * elf32-m32c.c,
	* elf32-m32r.c, * elf32-m68hc11.c, * elf32-m68hc12.c, * elf32-m68hc1x.c,
	* elf32-m68hc1x.h, * elf32-m68k.c, * elf32-m88k.c, * elf32-mcore.c,
	* elf32-mep.c, * elf32-metag.c, * elf32-microblaze.c, * elf32-mips.c,
	* elf32-moxie.c, * elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c,
	* elf32-nds32.h, * elf32-nios2.c, * elf32-or1k.c, * elf32-pj.c,
	* elf32-ppc.c, * elf32-ppc.h, * elf32-pru.c, * elf32-rl78.c,
	* elf32-rx.c, * elf32-s390.c, * elf32-score.c, * elf32-score.h,
	* elf32-score7.c, * elf32-sh-symbian.c, * elf32-sh.c, * elf32-sh64.c,
	* elf32-sparc.c, * elf32-spu.c, * elf32-tic6x.c, * elf32-tilegx.c,
	* elf32-tilegx.h, * elf32-tilepro.c, * elf32-tilepro.h, * elf32-v850.c,
	* elf32-vax.c, * elf32-wasm32.c, * elf32-xc16x.c, * elf32-xgate.c,
	* elf32-xgate.h, * elf32-xstormy16.c, * elf32-xtensa.c, * elf64-alpha.c,
	* elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mips.c, * elf64-mmix.c,
	* elf64-ppc.c, * elf64-s390.c, * elf64-sh64.c, * elf64-sparc.c,
	* elf64-tilegx.c, * elf64-tilegx.h, * elf64-x86-64.c, * elfcore.h,
	* elflink.c, * elfn32-mips.c, * elfnn-aarch64.c, * elfnn-ia64.c,
	* elfnn-riscv.c, * elfxx-aarch64.c, * elfxx-aarch64.h, * elfxx-ia64.c,
	* elfxx-ia64.h, * elfxx-mips.c, * elfxx-riscv.c, * elfxx-sparc.c,
	* elfxx-tilegx.c, * elfxx-x86.c, * elfxx-x86.h, * freebsd.h, * hash.c,
	* host-aout.c, * hp300hpux.c, * hppabsd-core.c, * hpux-core.c,
	* i386aout.c, * i386linux.c, * i386lynx.c, * i386mach3.c, * i386msdos.c,
	* i386netbsd.c, * ieee.c, * ihex.c, * irix-core.c, * libaout.h,
	* libbfd-in.h, * libbfd.c, * libcoff-in.h, * libnlm.h, * libpei.h,
	* libxcoff.h, * linker.c, * lynx-core.c, * m68k4knetbsd.c,
	* m68klinux.c, * m68knetbsd.c, * m88kmach3.c, * mach-o-aarch64.c,
	* mach-o-arm.c, * mach-o-i386.c, * mach-o-target.c, * mach-o-x86-64.c,
	* mach-o.c, * mach-o.h, * merge.c, * mipsbsd.c, * mmo.c, * netbsd.h,
	* netbsd-core.c, * newsos3.c, * nlm-target.h, * nlm32-ppc.c,
	* nlm32-sparc.c, * nlmcode.h, * ns32k.h, * ns32knetbsd.c, * oasys.c,
	* opncls.c, * pc532-mach.c, * pdp11.c, * pe-arm.c, * pe-i386.c,
	* pe-mcore.c, * pe-mips.c, * pe-x86_64.c, * peXXigen.c, * pef.c,
	* pef.h, * pei-arm.c, * pei-i386.c, * pei-mcore.c, * pei-x86_64.c,
	* peicode.h, * plugin.c, * ppcboot.c, * ptrace-core.c, * reloc.c,
	* riscix.c, * rs6000-core.c, * section.c, * som.c, * som.h,
	* sparclinux.c, * sparcnetbsd.c, * srec.c, * stabs.c, * sunos.c,
	* syms.c, * targets.c, * tekhex.c, * trad-core.c, * vax1knetbsd.c,
	* vaxnetbsd.c, * verilog.c, * versados.c, * vms-alpha.c, * vms-lib.c,
	* vms-misc.c, * wasm-module.c, * wasm-module.h, * xcofflink.c,
	* xsym.c, * xsym.h: Whitespace fixes.
	* bfd-in2.h, * libbfd.h, * libcoff.h: Regenerate.
2017-12-06 17:51:43 +10:30
Nick Clifton ca4cf9b9c6 Fix address violation errors parsing corrupt binary files.
PR 21813
binutils* rddbg.c (read_symbol_stabs_debugging_info): Check for an empty
	string whilst concatenating symbol names.

bfd	* mach-o.c (bfd_mach_o_canonicalize_relocs): Pass the base address
	of the relocs to the canonicalize_one_reloc routine.
	* mach-o.h (struct bfd_mach_o_backend_data): Update the prototype
	for the _bfd_mach_o_canonicalize_one_reloc field.
	* mach-o-arm.c (bfd_mach_o_arm_canonicalize_one_reloc): Add
	res_base parameter.  Use to check for corrupt pair relocs.
	* mach-o-aarch64.c (bfd_mach_o_arm64_canonicalize_one_reloc):
	Likewise.
	* mach-o-i386.c (bfd_mach_o_i386_canonicalize_one_reloc):
	Likewise.
	* mach-o-x86-64.c (bfd_mach_o_x86_64_canonicalize_one_reloc):
	Likewise.

	* vms-alpha.c (_bfd_vms_slurp_eihd): Make sure that there is
	enough data in the record before attempting to parse it.
	(_bfd_vms_slurp_eeom): Likewise.

	(_bfd_vms_slurp_egsd): Check for an invalid section index.
	(image_set_ptr): Likewise.
	(alpha_vms_slurp_relocs): Likewise.
2017-07-24 13:49:22 +01:00
Nick Clifton 0bae9e9ec5 Fix compile time warnings building the binutils with gcc 7.1.1.
bfd	* elf32-xtensa.c (elf_xtensa_get_plt_section): Increase length of
	plt_name buffer.
	(elf_xtensa_get_gotplt_section): Increase length of got_name
	buffer.
	* mach-o-arm.c (bfd_mach_o_arm_canonicalize_one_reloc): Add a
	default return of FALSE.
	* mach-o-i386.c (bfd_mach_o_i386_canonicalize_one_reloc): Add a
	default return of FALSE.

binutils * dwarf.c (dwarf_vmatoa_1): Do not pass a NULL string pointer to
	sprintf.
	* srconv.c (walk_tree_type): Initialise the spare field of the
	IT_dty structure.

gas	* config/tc-pru.c (md_assemble): Add continue statement after
	handling 'E' operand character.
	* config/tc-v850.c (md_assemble): Initialise the 'insn' variable.
2017-07-12 12:17:02 +01:00
Alan Modra 2571583aed Update year range in copyright notice of all files. 2017-01-02 14:08:56 +10:30
Alan Modra 6f2750feaf Copyright update for binutils 2016-01-01 23:00:01 +10:30
Tristan Gingold bcb51645d3 mach-o: use a per-target reloc canonicalize function.
bfd/
	* mach-o.h (bfd_mach_o_swap_in_non_scattered_reloc)
	(bfd_mach_o_canonicalize_non_scattered_reloc)
	(bfd_mach_o_pre_canonicalize_one_reloc): Declare.
	(bfd_mach_o_backend_data): Rename field
	_bfd_mach_o_swap_reloc_in to _bfd_mach_o_canonicalize_one_reloc.
	* mach-o.c (bfd_mach_o_swap_in_non_scattered_reloc): Now public.
	(bfd_mach_o_canonicalize_non_scattered_reloc): Renames from
	bfd_mach_o_canonicalize_one_reloc.
	(bfd_mach_o_pre_canonicalize_one_reloc): New function.
	(bfd_mach_o_canonicalize_relocs): Adjust.
	(bfd_mach_o_canonicalize_relocs): Rename define from
	bfd_mach_o_swap_reloc_in.
	* mach-o-target.c (TARGET_NAME_BACKEND): Use
	bfd_mach_o_canonicalize_one_reloc instead of
	bfd_mach_o_swap_reloc_in.
	* mach-o-i386.c (bfd_mach_o_i386_canonicalize_one_reloc): Renames
	from bfd_mach_o_i386_swap_reloc_in and adjust.
	(bfd_mach_o_canonicalize_one_reloc): Renames from
	bfd_mach_o_i386_canonicalize_one_reloc.
	* mach-o-x86_64.c (bfd_mach_o_x86_64_canonicalize_one_reloc): Renames
	from bfd_mach_o_x86_64_swap_reloc_in and adjust.
	(bfd_mach_o_canonicalize_one_reloc): Renames from
	bfd_mach_o_x86_64_canonicalize_one_reloc.
2015-11-18 15:47:56 +01:00
Tristan Gingold 47daa70fe0 mach-o cleanup: remove useless calls to bfd_seek.
Also support new commands.

bfd/
	* mach-o.h (struct mach_o_data_struct): Add hdr_offset field.
	(bfd_mach_o_fat_archive_p): Renames prototype.
	(bfd_mach_o_fat_openr_next_archived_file): Renames.
	(bfd_mach_o_header_p): Add argument.
	* mach-o.c (bfd_mach_o_read_header): Add hdr_off argument and
	use it.
	(bfd_mach_o_read_section_32, bfd_mach_o_read_section_64)
	(bfd_mach_o_read_section): Remove offset argument.
	(bfd_mach_o_read_dylinker): Remove bfd_seek call.
	(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_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_version_min)
	(bfd_mach_o_read_encryption_info): Likewise.
	(bfd_mach_o_read_encryption_info_64): New function.
	(bfd_mach_o_read_main, bfd_mach_o_read_source_version)
	(bfd_mach_o_read_segment): Remove call to bfd_seek.
	(bfd_mach_o_read_command): Use hdr_offset in bfd_seek.
	Handle BFD_MACH_O_LC_LINKER_OPTIMIZATION_HINT,
	BFD_MACH_O_LC_ENCRYPTION_INFO_64, BFD_MACH_O_LC_VERSION_MIN_WATCHOS.
	(bfd_mach_o_header_p): Add hdr_off argument.
	(bfd_mach_o_gen_object_p, bfd_mach_o_gen_core_p): Adjust calls.
	(bfd_mach_o_fat_archive_p): Renames.
	(bfd_mach_o_fat_openr_next_archived_file): Renames.
	(bfd_mach_o_close_and_cleanup): Remove useless code.
	(bfd_mach_o_close_and_cleanup): Define.
	* mach-o-x86-64.c (bfd_mach_o_x86_64_object_p)
	(bfd_mach_o_x86_64_core_p): Adjust calls.
	* mach-o-target.c: Move defines for archive from mach-o.c.
	Remove check on TARGET_ARCHIVE.
	* mach-o-i386.c (bfd_mach_o_i386_object_p)
	(bfd_mach_o_i386_core_p): Adjust calls.
2015-11-18 11:48:56 +01:00
Alan Modra b90efa5b79 ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
Alan Modra 6d00b59031 bfd target vector rationalisation
This renames the bfd targets to <cpu>_<format>_<other>_<endian>_vec.
So for example, bfd_elf32_ntradlittlemips_vec becomes
mips_elf32_ntrad_le_vec and hp300bsd_vec becomes m68k_aout_hp300bsd_vec.

bfd/
	* aix386-core.c, * aout-adobe.c, * aout-arm.c, * aout-ns32k.c,
	* aout-sparcle.c, * aout0.c, * aoutx.h, * armnetbsd.c, * bout.c,
	* cf-i386lynx.c, * cf-sparclynx.c, * cisco-core.c, * coff-alpha.c,
	* coff-apollo.c, * coff-arm.c, * coff-aux.c, * coff-go32.c,
	* coff-h8300.c, * coff-h8500.c, * coff-i386.c, * coff-i860.c,
	* coff-i960.c, * coff-m68k.c, * coff-m88k.c, * coff-mips.c,
	* coff-rs6000.c, * coff-sh.c, * coff-sparc.c, * coff-stgo32.c,
	* coff-svm68k.c, * coff-tic80.c, * coff-u68k.c, * coff-w65.c,
	* coff-we32k.c, * coff-x86_64.c, * coff-z80.c, * coff-z8k.c,
	* coff64-rs6000.c, * config.bfd, * configure.com, * configure.in,
	* demo64.c, * elf-m10200.c, * elf-m10300.c, * elf32-am33lin.c,
	* elf32-arc.c, * elf32-arm.c, * elf32-avr.c, * elf32-bfin.c,
	* elf32-cr16.c, * elf32-cr16c.c, * elf32-cris.c, * elf32-crx.c,
	* elf32-d10v.c, * elf32-d30v.c, * elf32-dlx.c, * elf32-epiphany.c,
	* elf32-fr30.c, * elf32-frv.c, * elf32-gen.c, * elf32-h8300.c,
	* elf32-hppa.c, * elf32-i370.c, * elf32-i386.c, * elf32-i860.c,
	* elf32-i960.c, * elf32-ip2k.c, * elf32-iq2000.c, * elf32-lm32.c,
	* elf32-m32c.c, * elf32-m32r.c, * elf32-m68hc11.c, * elf32-m68hc12.c,
	* elf32-m68k.c, * elf32-m88k.c, * elf32-mcore.c, * elf32-mep.c,
	* elf32-metag.c, * elf32-microblaze.c, * elf32-mips.c, * elf32-moxie.c,
	* elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c, * elf32-nios2.c,
	* elf32-or1k.c, * elf32-pj.c, * elf32-ppc.c, * elf32-rl78.c,
	* elf32-rx.c, * elf32-s390.c, * elf32-score.c, * elf32-sh-symbian.c,
	* elf32-sh.c, * elf32-sh64.c, * elf32-sparc.c, * elf32-spu.c,
	* elf32-tic6x.c, * elf32-tilegx.c, * elf32-tilepro.c, * elf32-v850.c,
	* elf32-vax.c, * elf32-xc16x.c, * elf32-xgate.c, * elf32-xstormy16.c,
	* elf32-xtensa.c, * elf64-alpha.c, * elf64-gen.c, * elf64-hppa.c,
	* elf64-ia64-vms.c, * elf64-mips.c, * elf64-mmix.c, * elf64-ppc.c,
	* elf64-s390.c, * elf64-sh64.c, * elf64-sparc.c, * elf64-tilegx.c,
	* elf64-x86-64.c, * elfn32-mips.c, * elfnn-aarch64.c, * elfnn-ia64.c,
	* epoc-pe-arm.c, * epoc-pei-arm.c, * hp300bsd.c, * hp300hpux.c,
	* hppabsd-core.c, * hpux-core.c, * i386aout.c, * i386bsd.c,
	* i386dynix.c, * i386freebsd.c, * i386linux.c, * i386lynx.c,
	* i386mach3.c, * i386msdos.c, * i386netbsd.c, * i386os9k.c,
	* irix-core.c, * m68k4knetbsd.c, * m68klinux.c, * m68knetbsd.c,
	* m88kmach3.c, * m88kopenbsd.c, * mach-o-i386.c, * mach-o-x86-64.c,
	* makefile.vms, * mipsbsd.c, * mmo.c, * netbsd-core.c, * newsos3.c,
	* nlm32-alpha.c, * nlm32-i386.c, * nlm32-ppc.c, * nlm32-sparc.c,
	* ns32knetbsd.c, * osf-core.c, * pc532-mach.c, * pe-arm-wince.c,
	* pe-arm.c, * pe-i386.c, * pe-mcore.c, * pe-mips.c, * pe-ppc.c,
	* pe-sh.c, * pe-x86_64.c, * pei-arm-wince.c, * pei-arm.c,
	* pei-i386.c, * pei-ia64.c, * pei-mcore.c, * pei-mips.c, * pei-ppc.c,
	* pei-sh.c, * pei-x86_64.c, * ppcboot.c, * ptrace-core.c, * riscix.c,
	* sco5-core.c, * som.c, * sparclinux.c, * sparclynx.c,
	* sparcnetbsd.c, * sunos.c, * targets.c, * trad-core.c,
	* vax1knetbsd.c, * vaxbsd.c, * vaxnetbsd.c, * versados.c,
	* vms-alpha.c, * vms-lib.c: Rename bfd targets to
	<cpu>_<format>_<other>_<endian>_vec.  Adjust associated MY macros
	on aout targets.
	* configure: Regenerate.
binutils/
	* emul_aix.c: Update bfd target vector naming.
	* testsuite/binutils-all/objcopy.exp: Likewise.
ld/
	* emultempl/metagelf.em: Update bfd target vector naming.
	* emultempl/nios2elf.em: Likewise.
	* emultempl/spuelf.em: Likewise.
	* emultempl/tic6xdsbt.em: Likewise.
2014-05-02 20:09:40 +09:30
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 47c5093265 mach-o: output output_section target_index to write relocs.
bfd/
	* mach-o-i386.c (bfd_mach_o_i386_swap_reloc_out): Use target index
	of output_section.
	* mach-o-x86-64.c (bfd_mach_o_x86_64_swap_reloc_out): Ditto.
2014-04-04 14:22:18 +02:00
Alan Modra 4b95cf5c0c Update copyright years 2014-03-05 22:16:15 +10:30
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
Iain Sandoe 6639d37af3 support 16 sect-diffs for mach-o
bfd:

	* mach-o-i386.c (i386_howto_table): Add support for 16 bit
	sect-diffs.
	(bfd_mach_o_i386_swap_reloc_in): Handle 16bit sect-diffs.
	(bfd_mach_o_i386_swap_reloc_out): Likewise.
2012-02-17 11:23:44 +00:00
Iain Sandoe e1e81ed3c3 add LOCAL SECDIFF relocation for m32 mach-o
bfd:

	* reloc.c (BFD_RELOC_MACH_O_LOCAL_SECTDIFF):
	* libbfd.h: Regenerated.
	* bfd-in2.h: Likewise.
	* mach-o-i386.c (i386_howto_table): Include local sectdiff.
	(bfd_mach_o_i386_swap_reloc_in): Update for local sectdiff.
	(bfd_mach_o_i386_swap_reloc_out): Likewise.
2012-02-17 10:57:33 +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
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 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 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 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 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 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