Commit Graph

98 Commits

Author SHA1 Message Date
Alan Modra 75cfe082c0 PR26103, Assertion failure with symbols defined in link-once sections
PR 26103
	* elflink.c (elf_link_add_archive_symbols): Exclude undefined
	symbols that were defined in discarded sections.
	* cofflink.c (coff_link_check_archive_element): Likewise.
	(coff_link_add_symbols): Set indx to -3 for symbols defined in
	discarded sections.
	(_bfd_coff_write_global_sym): Don't emit such symbols.
	libcoff-in.h (struct coff_link_hash_entry): Update indx comment.
	libcoff.h: Regenerate.
2020-06-15 12:10:06 +09:30
Juan Manuel Guerrero f717994fe8 [PATCH v2 2/2] coff-go32: support extended relocations
This patch extends the relocation and line number counters for
coff-go32 and coff-go32-exe to 32 bits.  As I understand it works the
same as for PE-COFF:

If the number of relocations in an object file exceeds 65534, the
NRELOC field is set to 65535 and the actual number of relocations is
stored in the VADDR field of the first relocation entry.

Executable files have no relocations, and thus the NRELOC field is
repurposed to extend NLNNO to 32-bits.

bfd	* coff-go32.c (COFF_GO32, IMAGE_SCN_LNK_NRELOC_OVFL)
	(coff_SWAP_scnhdr_in, coff_SWAP_scnhdr_out): Define.
	(_bfd_go32_swap_scnhdr_in, _bfd_go32_swap_scnhdr_out)
	(_bfd_go32_mkobject): New functions.
	* coff-stgo32.c (IMAGE_SCN_LNK_NRELOC_OVFL)
	(coff_SWAP_scnhdr_in, coff_SWAP_scnhdr_out): Define.
	(go32exe_mkobject): Call _bfd_go32_mkobject.
	* coffcode.h (COFF_WITH_EXTENDED_RELOC_COUNTER): Define.
	(coff_set_alignment_hook): Define function for COFF_GO32_EXE
	and COFF_GO32.
	(coff_write_relocs): Enable extended reloc counter code if
	COFF_WITH_EXTENDED_RELOC_COUNTER is defined.  Test for obj_go32.
	(coff_write_object_contents): Likewise.  Pad section headers
	for COFF_GO32 and COFF_GO32EXE.  Use bfd_coff_swap_scnhdr_out
	instead of coff_swap_scnhdr_out.
	* cofflink.c (_bfd_coff_final_link): Test also for obj_go32 to
	enable extended reloc counter.
	* coffswap.h: (coff_swap_scnhdr_in, coff_swap_scnhdr_out):
	Declare with ATTRIBUTE_UNUSED.
	* libcoff-in.h: (struct coff_tdata): New field go32.
	(obj_go32): Define.
	* libcoff.h: Regenerate.
2020-04-14 17:30:01 +01:00
Jan W. Jagersma 4d095f5b5e coff-go32-exe: support variable-length stubs
The stub size in GO32 executables has historically been fixed at 2048
bytes, due to hardcoded limitations in bfd.  Recent patches to djgpp by
Stas Sergeev (CC'd) have pushed the stub right up to this limit, so if
any further expansion is desired, this must first be patched in bfd.

This series includes three patches:  The first changes the meaning of
the bfd->origin field slightly, so that target code can use this to
specify an offset into the file where the actual bfd is located.
The second patch then uses this to enable support for variable-sized
stubs in the coff-go32-exe format.
The final patch is only a cleanup, it normalizes function and variable
names in coff-stgo32.c so that they all begin with the same prefix.

bfd	* bfdio.c (bfd_bread, bfd_tell, bfd_seek, bfd_mmap): Always add
	bfd->origin to file offset.
	* bfdwin.c (bfd_get_file_window): Likewise.
	* bfd.c: Clarify the use of the bfd->origin field.
	* bfd-in2.h: Regenerate.
	* coff-i386.c: Don't include go32exe.h. Allow overriding
	coff_write_object_contents via COFF_WRITE_CONTENTS.
	* coff-stgo32.c (go32exe_cleanup, go32exe_mkobject)
	(go32exe_write_object_contents): New functions.
	(go32exe_temp_stub, go32exe_temp_stub_size): New static globals.
	(COFF_WRITE_CONTENTS, GO32EXE_DEFAULT_STUB_SIZE): Define.
	(create_go32_stub): Remove check for 2k size limit.  Read stub
	from go32exe_temp_stub if present.
	(go32_stubbed_coff_bfd_copy_private_bfd_data): Allocate and
	copy variable-length stub.
	(go32_check_format): Read stub to go32exe_temp_stub, set
	origin, return go32exe_cleanup.
	(adjust_filehdr_in_post, adjust_filehdr_out_pre)
	(adjust_filehdr_out_post, adjust_scnhdr_in_post)
	(adjust_scnhdr_out_pre, adjust_scnhdr_out_post)
	(adjust_aux_in_post, adjust_aux_out_pre, adjust_aux_out_post):
	Remove functions and their associated #defines.
	* coffcode.h (coff_mkobject_hook): Remove stub copying code.
	* libcoff-in.h: (struct coff_tdata): New field stub_size.
	Rename field go32stub to stub.
	* libcoff.h: Regenerate.
	* coff-stgo32.c (go32_check_format): Rename to...
	(go32exe_check_format): ...this.
	(go32_stubbed_coff_bfd_copy_private_bfd_data): Rename to...
	(go32exe_copy_private_bfd_data): ...this.
	(stub_bytes): Rename to...
	(go32exe_default_stub): ...this.
	(create_go32_stub): Rename to...
	(go32exe_create_stub): ...this.
	* coff-stgo32.c (go32exe_copy_private_bfd_data): Avoid realloc
	when possible.

include	* coff/go32exe.h: Remove file.
	* coff/internal.h (struct internal_filehdr): Remove field
	go32stub.  Remove flag F_GO32STUB.
2020-04-02 14:31:43 +01:00
Nick Clifton 00386881a3 Fix objcopy's --preserve-dates command line option so that it will work with PE format files.
PR binutils/pr25662
bfd	* libcoff-in.h (struct pe_tdata): Rename the insert_timestamp
	field to timestamp and make it an integer.
	* libcoff.h: Regenerate.
	* peXXigen.c (_bfd_XXi_only_swap_filehdr_out): Test the timestamp
	field in the pe_data structure rather than the insert_timestamp
	field.

binutils* objcopy.c (copy_object): When copying PE format files set the
	timestamp field in the pe_data structure if the preserve_dates
	flag is set.
	* testsuite/binutils-all/objcopy.exp (objcopy_test) Use
	--preserve-dates in place of the -p option, in order to make its
	effect more obvious.

ld	* emultempl/pe.em (after_open): Replace initialisation of the
	insert_timestamp field in the pe_data structure with an
	initialisation of the timestamp field.
	* emultemp/pep.em: Likewise.
	* pe-dll.c (fill_edata): Use the timestamp field in the pe_data
	structure instead of the insert_timestamp field.
2020-03-30 16:30:02 +01:00
Alan Modra cb001c0d28 bfd_cleanup for object_p
The object_p (and archive_p, core_file_p) functions are not supposed
to have any target specific malloc'd memory attached to the bfd on
their return.  This should be obvious on a failure return, but it's
also true for a successful return.  The reason is that even though the
object_p recognises the file, that particular target may not be used
and thus the bfd won't be closed calling close_and_cleanup for the
target that allocated the memory.

It turns out that the object_p bfd_target* return value isn't needed.
In all cases except ld/plugin.c the target is abfd->xvec and with
ld/plugin.c the target isn't used.  So this patch returns a cleanup
function from object_p instead, called in bfd_check_format_matches to
tidy the bfd before trying a different target match.  The only cleanup
that does anything at this stage is the alpha-vms one.

bfd/
	* targets.c (bfd_cleanup): New typedef.
	(struct bfd <_bfd_check_format>): Return a bfd_cleanup.
	* libbfd-in.h (_bfd_no_cleanup): Define.
	* format.c (bfd_reinit): Add cleanup parameter, call it.
	(bfd_check_format_matches): Set cleanup from _bfd_check_format
	call and pass to bfd_reinit.  Delete temp, use abfd->xvec instead.
	* aout-target.h (callback, object_p): Return bfd_cleanup.
	* aout-tic30.c (tic30_aout_callback, tic30_aout_object_p): Likewise.
	* archive.c (bfd_generic_archive_p): Likewise.
	* binary.c (binary_object_p): Likewise.
	* coff-alpha.c (alpha_ecoff_object_p): Likewise.
	* coff-ia64.c (ia64coff_object_p): Likewise.
	* coff-rs6000.c (_bfd_xcoff_archive_p, rs6000coff_core_p): Likewise.
	* coff-sh.c (coff_small_object_p): Likewise.
	* coff-stgo32.c (go32_check_format): Likewise.
	* coff64-rs6000.c (xcoff64_archive_p, rs6000coff_core_p),
	(xcoff64_core_p): Likewise.
	* coffgen.c (coff_real_object_p, coff_object_p): Likewise.
	* elf-bfd.h (bfd_elf32_object_p, bfd_elf32_core_file_p),
	(bfd_elf64_object_p, bfd_elf64_core_file_p): Likewise.
	* elfcode.h (elf_object_p): Likewise.
	* elfcore.h (elf_core_file_p): Likewise.
	* i386msdos.c (msdos_object_p): Likewise.
	* ihex.c (ihex_object_p): Likewise.
	* libaout.h (some_aout_object_p): Likewise.
	* libbfd-in.h (bfd_generic_archive_p, _bfd_dummy_target),
	(_bfd_vms_lib_alpha_archive_p, _bfd_vms_lib_ia64_archive_p): Likewise.
	* libbfd.c (_bfd_dummy_target): Likewise.
	* libcoff-in.h (coff_object_p): Likewise.
	* mach-o-aarch64.c (bfd_mach_o_arm64_object_p),
	(bfd_mach_o_arm64_core_p): Likewise.
	* mach-o-arm.c (bfd_mach_o_arm_object_p),
	(bfd_mach_o_arm_core_p): Likewise.
	* mach-o-i386.c (bfd_mach_o_i386_object_p),
	(bfd_mach_o_i386_core_p): Likewise.
	* mach-o-x86-64.c (bfd_mach_o_x86_64_object_p),
	(bfd_mach_o_x86_64_core_p): Likewise.
	* mach-o.c (bfd_mach_o_header_p, bfd_mach_o_gen_object_p),
	(bfd_mach_o_gen_core_p, bfd_mach_o_fat_archive_p): Likewise.
	* mach-o.h (bfd_mach_o_object_p, bfd_mach_o_core_p),
	(bfd_mach_o_fat_archive_p, bfd_mach_o_header_p): Likewise.
	* mmo.c (mmo_object_p): Likewise.
	* pef.c (bfd_pef_object_p, bfd_pef_xlib_object_p): Likewise.
	* peicode.h (coff_real_object_p, pe_ILF_object_p),
	(pe_bfd_object_p): Likewise.
	* plugin.c (ld_plugin_object_p, bfd_plugin_object_p): Likewise.
	* ppcboot.c (ppcboot_object_p): Likewise.
	* rs6000-core.c (rs6000coff_core_p): Likewise.
	* som.c (som_object_setup, som_object_p): Likewise.
	* srec.c (srec_object_p, symbolsrec_object_p): Likewise.
	* tekhex.c (tekhex_object_p): Likewise.
	* vms-alpha.c (alpha_vms_object_p): Likewise.
	* vms-lib.c (_bfd_vms_lib_archive_p, _bfd_vms_lib_alpha_archive_p),
	(_bfd_vms_lib_ia64_archive_p, _bfd_vms_lib_txt_archive_p): Likewise.
	* wasm-module.c (wasm_object_p): Likewise.
	* xsym.c (bfd_sym_object_p): Likewise.
	* xsym.h (bfd_sym_object_p): Likewise.
	* aoutx.h (some_aout_object_p): Likewise, and callback parameter
	return type.
	* pdp11.c (some_aout_object_p): Likewise.
	* plugin.c (register_ld_plugin_object_p): Update object_p
	parameter type.
	* plugin.h (register_ld_plugin_object_p): Likewise.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
	* libcoff.h: Regenerate.
ld/
	* plugin.c (plugin_object_p): Return a bfd_cleanup.
	(plugin_cleanup): New function.
2020-03-02 19:30:48 +10:30
Alan Modra b3adc24a07 Update year range in copyright notice of binutils files 2020-01-01 18:42:54 +10:30
Alan Modra f5d35bb7a5 coff_close_and_cleanup
Fixes leaks in _bfd_coff_get_external_symbols and
_bfd_coff_read_string_table.

	* coffcode.h (coff_close_and_cleanup): Redefine to..
	* coffgen.c (_bfd_coff_close_and_cleanup): ..this.  New function.
	* libcoff-in.h (_bfd_coff_close_and_cleanup): Declare.
	* libcoff.h: Regenerate.
2019-12-29 21:26:00 +10:30
Andrew Eikum 70cf683455 When copying pe format files, copy the dos_message array, rather than re-initiialising it.
* libcoff-in.h (struct pe_tdata): Add dos_message field.
	* libcoff.h: Regenerate.
	* peXXigen.c (_bfd_XXi_only_swap_filehdr_out): Copy the
	dos_message field rather than initialising it.
	(_bfd_XX_bfd_copy_private_bfd_data_common): Copy the dos_message
	field.
	* peicode.h (pe_mkobject): Initialise the dos_message field.
	(pe_mkobject_hook): Copy the dos_message field.
	(pe_bfd_object_p): Copy the dos_message field.
2019-10-29 17:07:03 +00:00
Alan Modra cb7f4b298e Tidy ld/ldmisc.c
The idea here is to not use elf-bfd.h and coff-bfd.h in generic linker
code.

bfd/
	* targets.c (struct bfd_target): Add _bfd_group_name.
	(BFD_JUMP_TABLE): Likewise.
	* coffgen.c (bfd_coff_group_name): New function.
	* elf.c (bfd_elf_group_name): New function.
	* linker.c (_bfd_nolink_bfd_group_name): New function.
	* section.c (bfd_generic_group_name): New function.
	* elf-bfd.h (bfd_elf_group_name): Declare.
	* libbfd-in.h (_bfd_nolink_bfd_group_name): Declare.
	* libcoff-in.h (bfd_coff_group_name): Declare.
	* aout-target.h (MY_bfd_group_name): Define.
	* aout-tic30.c (MY_bfd_group_name): Define.
	* bfd.c (bfd_group_name): Define.
	* binary.c (binary_bfd_group_name): Define.
	* coff-alpha.c (_bfd_ecoff_bfd_group_name): Define.
	* coff-mips.c (_bfd_ecoff_bfd_group_name): Define.
	* coff-rs6000.c (_bfd_xcoff_bfd_group_name): Define.
	* coffcode.h (coff_bfd_group_name): Define.
	* elfxx-target.h (bfd_elfNN_bfd_group_name): Define.
	* i386msdos.c (msdos_bfd_group_name): Define.
	* ihex.c (ihex_bfd_group_name): Define.
	* mach-o-target.c (bfd_mach_o_bfd_group_name): Define.
	* mmo.c (mmo_bfd_group_name): Define.
	* pef.c (bfd_pef_bfd_group_name): Define.
	* plugin.c (bfd_plugin_bfd_group_name): Define.
	* ppcboot.c (ppcboot_bfd_group_name): Define.
	* som.c (som_bfd_group_name): Define.
	* srec.c (srec_bfd_group_name): Define.
	* tekhex.c (tekhex_bfd_group_name): Define.
	* verilog.c (verilog_bfd_group_name): Define.
	* vms-alpha.c (vms_bfd_group_name, alpha_vms_bfd_group_name): Define.
	* xsym.c (bfd_sym_bfd_group_name): Define.
	* coff64-rs6000.c (rs6000_xcoff64_vec): Init new field.
	(rs6000_xcoff64_aix_vec): Likewise.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
	* libcoff.h: Regenerate.
ld/
	* ldmisc.c: Don't #include elf-bfd.h or coff-bfd.h.
	(vfinfo): Use bfd_group_name.
2019-09-11 13:43:29 +09:30
Alan Modra 827041555a Update year range in copyright notice of binutils files 2019-01-01 22:06:53 +10:30
Alan Modra 0b43954349 libbfd.h and libcoff.h include guards
* libbfd-in.h: Add include guard.
	* libcoff-in.h: Likewise.
	* doc/Makefile.am (libbfd.h, libcoff.h): Append another #endif.
	* doc/Makefile.in: Regenerate.
	* libbfd.h: Regenerate.
	* libcoff.h: Regenerate.
2018-05-18 13:07:21 +09: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
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
Jan Beulich 270f824531 bfd: don't produce corrupt COFF symbol table due to long ELF file name symbols
The re-writing logic in _bfd_coff_final_link() overwrote the ".file"
part of the symbol table entry, due to not coping with the auxiliary
entry generated in all cases.

Note that while I would have wanted to add a test case,
(a) I didn't spot any one testing the base functionality here, and
(b) I wasn't able to figure out proper conditionals to use in e.g.
    ld-elf/elf.exp to check for the necessary PE/PE+ support (which
    varies by target).
2015-12-15 14:31:25 +01:00
Kai Tietz 0f088b2a94 Add experimental support for --gc-sections with COFF and PE based targets.
PR ld/11539
bfd	* coffcode.h (coff_bfd_gc_sections): Define default
	to bfd_coff_gc_sections function.
	* cofflink.c (init_reloc_cookie): Copy and adjust coff
	related code about gc-sections from elflink.c to here.
	(fini_reloc_cookie): Likewise.
	(init_reloc_cookie_rels): Likewise.
	(fini_reloc_cookie_rels): Likewise.
	(init_reloc_cookie_for_section): Likewise.
	(fini_reloc_cookie_for_section): Likewise.
	(_bfd_coff_gc_mark_hook): Likewise.
	(_bfd_coff_gc_mark_rsec): Likewise.
	(_bfd_coff_gc_mark_reloc): Likewise.
	(_bfd_coff_gc_mark): Likewise.
	(_bfd_coff_gc_mark_extra_sections): Likewise.
	(coff_gc_sweep_symbol_info): Likewise.
	(coff_gc_sweep_symbol): Likewise.
	(gc_sweep_hook_fn): Likewise.
	(coff_gc_sweep): Likewise.
	(bfd_coff_gc_sections): Likewise.
	(_bfd_coff_gc_keep): Likewise.
	* libcoff.h (coff_reloc_cookie): New struct.
	(bfd_coff_gc_sections): New prototype.
	(coff_gc_mark_hook_fn): New type.

ld	* scripttempl/pep.sc: Mark .idata*, .CRT*, .tls*,
	.rsrc*, .init, .ctor*, .dtor*, .fini, .jcr,
	.eh_frame, .pdata. .xdata, and .gcc_except_table sections
	as KEEP.
	* scripttempl/pe.sc: Likewise.
2015-07-03 15:50:29 +01:00
Pedro Alves 55172d69d0 Wrap BFD headers in extern "C"
These were the BFD changes needed for building a C++ GDB with
--enable-targets=all, on x86_64 Fedora 20.

For libbfd.h and libcoff.h, this does same as already done when
generating bfd.h: open extern "C" in the -in.h header, and close it
from the Makefile.

bfd/doc/ChangeLog:
2015-02-11  Pedro Alves  <palves@redhat.com>

	* Makefile.am (libbfd.h, libcoff.h): Close extern "C" scope.
	* Makefile.in: Regenerate.

bfd/ChangeLog:
2015-02-11  Pedro Alves  <palves@redhat.com>

	* libbfd-in.h [__cplusplus]: Open extern "C" scope.
	* libcoff-in.h [__cplusplus]: Open extern "C" scope.
	* libbfd.h: Regenerate.
	* libcoff.h: Regenerate.

	* elf-bfd.h [__cplusplus]: Wrap in extern "C".
	* mach-o.h [__cplusplus]: Wrap in extern "C".
	* som.h [__cplusplus]: Wrap in extern "C".
2015-02-11 10:04:47 +00:00
Alan Modra b90efa5b79 ChangeLog rotatation and copyright year update 2015-01-02 00:53:45 +10:30
Alan Modra f4943d8253 Don't always build coffgen.o
Removes a bunch of unused functions from libbfd when building ELF or
AOUT.  Split off the bits we need externally when not building a COFF
target into coff-bfd.c and coff-bfd.h.

bfd/
	* Makefile.am (BFD32_LIBS, BFD32_LIBS_CFILES): Remove dwarf2
	and coffgen.  Add coff-bfd.  Sort.
	(BFD32_BACKENDS, BFD32_BACKENDS_CFILES): Add coffgen and dwarf2.
	* bfd-in.h (bfd_coff_get_syment, bfd_coff_get_auxent): Delete.
	(struct coff_comdat_info, bfd_coff_get_comdat_section): Delete.
	* coffgen.c (coff_symbol_from): Move to coff-bfd.h as macro,
	without unused param.  Update uses.
	(bfd_coff_get_comdat_section): Move to coff-bfd.h as macro.
	(bfd_coff_get_syment, bfd_coff_get_auxent): Move to coff-bfd.c.
	* libcoff-in.h: #include "coff-bfd.h".
	(struct coff_section_tdata, coff_section_data): Move to coff-bfd.h.
	(coff_symbol_from): Delete.
	* coff-bfd.c: New file.
	* coff-bfd.h: New file.
	* coff-i386.c: Update coff_symbol_from occurrences.
	* coff-i960.c: Likewise.
	* coff-m68k.c: Likewise.
	* coff-sh.c: Likewise.
	* coff-x86_64.c: Likewise.
	* coffcode.h: Likewise.
	* pe-mips.c: Likewise.
	* configure.ac (elf): Add dwarf2.lo.
	(coffgen, coff, ecoff, xcoff): Define.  Use when mapping bfd
	target vectors to .o files.  Add dwarf2 for mach-o targets.
	Fix the sh target FIXME.
	* po/SRC-POTFILES.in: Regenerate.
	* Makefile.in: Regenerate.
	* configure: Regenerate.
	* bfd-in2.h: Regenerate.
	* libcoff.h: Regenerate.
binutils/
	* objdump.c: #include "coff-bfd.h".
ld/
	* ldmisc.c: #include "coff-bfd.h"
2014-12-10 23:13:49 +10:30
H.J. Lu 60bb06bc89 Use get_symbol_version_string in BFD_JUMP_TABLE_SYMBOLS
This patch adds get_symbol_version_string to BFD_JUMP_TABLE_SYMBOLS so
that we can use bfd_get_symbol_version_string in objdump for non-ELF
targets.

bfd/

	* targets.c (BFD_JUMP_TABLE_SYMBOLS): Use
	NAME##_get_symbol_version_string.
	(bfd_get_symbol_version_string): New.
	* aout-adobe.c (aout_32_get_symbol_version_string): Define using
	_bfd_nosymbols define.
	* aout-target.h (MY_get_symbol_version_string): Likewise.
	* aout-tic30.c (MY_get_symbol_version_string): Likewise.
	* binary.c (binary_get_symbol_version_string): Likewise.
	* bout.c (aout_32_get_symbol_version_string): Likewise.
	* coff-rs6000.c (_bfd_xcoff_get_symbol_version_string): Likewise.
	* i386msdos.c (msdos_get_symbol_version_string): Likewise.
	* i386os9k.c (aout_32_get_symbol_version_string): Likewise.
	* ieee.c (ieee_get_symbol_version_string): Likewise.
	* ihex.c (ihex_get_symbol_version_string): Likewise.
	* libecoff.h (_bfd_ecoff_get_symbol_version_string): Likewise.
	* mach-o-target.c (bfd_mach_o_get_symbol_version_string): Likewise.
	* mmo.c (mmo_get_symbol_version_string): Likewise.
	* nlm-target.h (nlm_get_symbol_version_string): Likewise.
	* oasys.c (oasys_get_symbol_version_string): Likewise.
	* pef.c (bfd_pef_get_symbol_version_string): Likewise.
	* plugin.c (bfd_plugin_get_symbol_version_string): Likewise.
	* ppcboot.c (ppcboot_get_symbol_version_string): Likewise.
	* som.c (som_get_symbol_version_string): Likewise.
	* srec.c (srec_get_symbol_version_string): Likewise.
	* tekhex.c (tekhex_get_symbol_version_string): Likewise.
	* versados.c (versados_get_symbol_version_string): Likewise.
	* vms-alpha.c (alpha_vms_get_symbol_version_string): Likewise.
	* xsym.c (bfd_sym_get_symbol_version_string): Likewise.

	* coff64-rs6000.c (rs6000_xcoff64_vec): Use
	coff_get_symbol_version_string.
	(rs6000_xcoff64_aix_vec): Likewise.

	* elf-bfd.h (bfd_elf_get_symbol_version_string): Renamed to ...
	(_bfd_elf_get_symbol_version_string): This.
	* elf.c: Likewise.
	(bfd_elf_print_symbol): Updated.
	* elfxx-target.h (bfd_elfNN_get_symbol_version_string): Define.

	* libbfd-in.h (_bfd_nosymbols_get_symbol_version_string): Define.
	* libcoff-in.h (coff_get_symbol_version_string): Likewise.
	* bfd-in2.h: Regenerated.
	* libbfd.h: Likewise.
	* libcoff.h: Likewise.

binutils/

	* objdump.c (objdump_print_symname): Replace
	bfd_elf_get_symbol_version_string with
	bfd_get_symbol_version_string.
2014-11-25 09:28:32 -08:00
Nick Clifton a5c71af8d3 More fixes for memory access violations whilst scanning corrupt binaries.
PR binutils/17512
	* config/obj-coff.c (coff_obj_symbol_new_hook): Set the is_sym
	field.

	* coffcode.h (coff_ptr_struct): Add is_sym field.
	(coff_new_section_hook): Set the is_sym field.
	(coff_pointerize_aux_hook): Check the is_sym field.
	(coff_print_aux): Likewise.
	(coff_compute_section_file_positions): Likewise.
	(coff_write_object_contents): Likewise.
	(coff_slurp_line_table): Likewise.
	(coff_slurp_symbol_table): Likewise.
	(CALC_ADDEND): Likewise.
	* coffgen.c (coff_renumber_symbols): Likewise.
	(coff_mangle_symbols): Likewise.
	(coff_fix_symbol_name): Likewise.
	(coff_write_symbol): Likewise.
	(coff_write_alien_symbol): Likewise.
	(coff_write_native_symbol): Likewise.
	(coff_write_symbols): Likewise.
	(coff_write_linenumbers): Likewise.
	(coff_pointerize_aux): Likewise.
	(coff_get_normalized_symtab): Likewise.
	(coff_get_symbol_info): Likewise.
	(bfd_coff_get_syment): Likewise.
	(bfd_coff_get_auxent): Likewise.
	(coff_print_symbol): Likewise.
	(coff_find_nearest_line_with_names): Likewise.
	(bfd_coff_set_symbol_class): Likewise.
	(coff_make_empty_symbol): Set the is_sym field.
	(coff_bfd_make_debug_symbol): Likewise.
	* peicode.h (pe_ILF_make_a_symbol): Likewise.
	* libcoff.h: Regenerate.
	* libcoff-in.h: Regenerate.
2014-11-13 17:46:11 +00:00
Nick Clifton 5a3f568b70 More fixes for buffer overruns instigated by corrupt binaries.
PR binutils/17512
	* objdump.c (slurp_symtab): Fail gracefully if the table could not
	be read.
	(dump_relocs_in_section): Likewise.

	* aoutx.h (slurp_symbol_table): Check that computed table size is
	not bigger than the file from which is it being read.
	(slurp_reloc_table): Likewise.
	* coffcode.h (coff_slurp_line_table): Remove unneeded local
	'warned'.  Do not try to print the details of a symbol with an
	invalid index.
	* coffgen.c (make_a_sectiobn_from_file): Check computed string
	index against length of string table.
	(bfd_coff_internal_syment_name): Check read in string offset
	against length of string table.
	(build_debug_section): Return a pointer to the section used.
	(_bfd_coff_read_string_table): Store the length of the string
	table in the coff_tdata structure.
	(bfd_coff_free_symbols): Set the length of the string table to
	zero when it is freed.
	(coff_get_normalized_symtab): Check offsets against string table
	or data table lengths as appropriate.
	* cofflink.c (_bfd_coff_link_input_bfd): Check offset against
	length of string table.
	* compress.c (bfd_get_full_section_contents): Check computed size
	against the size of the file.
	* libcoff-in.h (obj_coff_strings_len): Define.
	(struct coff_tdata): Add strings_len field.
	* libcoff.h: Regenerate.
	* peXXigen.c (pe_print_debugdata): Do not attempt to print the
	data if the debug section is too small.
	* xcofflink.c (xcoff_link_input_bfd):  Check offset against
	length of string table.
2014-11-03 17:44:00 +00:00
Alan Modra fb167eb272 Merge bfd_find_nearest_line variants
When bfd_find_nearest_line_discriminator was added, not enough care
was taken to ensure all targets had a proper definition of the function.
This patch cures that by merging bfd_find_nearest_line_discriminator
and bfd_find_nearest_line target implementations.

	PR 17481
	* aoutx.h (NAME (aout, find_nearest_line)): Add "discriminator_ptr"
	param, group "section" and "offset" params.  Zero discriminator.
	* bfd.c (bfd_find_nearest_line): Implement with new
	_bfd_find_nearest_line.
	(bfd_find_nearest_line_discriminator): Likewise.
	* coff-i386.c (_bfd_generic_find_nearest_line_discriminator): Don't
	define.
	* coff-rs6000.c (xcoff_find_nearest_line,
	xcoff_find_nearest_line_discriminator): Delete.
	(_bfd_xcoff_find_nearest_line): Don't define.
	(_bfd_xcoff_find_nearest_line): Define as coff_find_nearest_line.
	* coff-x86_64.c (_bfd_generic_find_nearest_line_discriminator): Don't
	define.
	* coff64-rs6000.c (rs6000_xcoff64_vec, rs6000_xcoff64_aix_vec): Adjust.
	* coffgen.c (coff_find_nearest_line_with_names): Reorder params,
	adjust _bfd_dwarf2_find_nearest_line call.
	(coff_find_nearest_line): Add "discriminator_ptr" param, reorder
	others.  Set discriminator.  Adjust call.
	(coff_find_nearest_line_discriminator): Delete.
	* dwarf1.c (_bfd_dwarf1_find_nearest_line): Reorder params.
	* dwarf2.c (find_line): Rename to..
	(_bfd_dwarf2_find_nearest_line): ..this, reordering params.
	Simplify setting of do_line.  Delete old function.
	(_bfd_dwarf2_find_line): Delete.
	* ecoff.c (_bfd_ecoff_find_nearest_line): Reorder params, add
	discriminator_ptr and set it.
	* elf-bfd.h (_bfd_elf_find_nearest_line): Update prototype.
	(_bfd_elf_find_nearest_line_discriminator): Delete.
	(_bfd_elf_find_line_discriminator): Delete.
	(_bfd_generic_find_nearest_line_discriminator): Don't define.
	* elf.c (elf_find_function): Reorder params.
	(_bfd_elf_find_nearest_line): Reorder params, add discriminator_ptr.
	Adjust calls.
	(_bfd_elf_find_nearest_line_discriminator): Delete.
	(_bfd_elf_find_line): Adjust call.
	* elf32-arm.c (arm_elf_find_function): Reorder params.
	(elf32_arm_find_nearest_line): Reorder params, add discriminator_ptr.
	Adjust calls.
	* elf64-alpha.c (elf64_alpha_find_nearest_line): Similarly.
	* elfnn-aarch64.c (aarch64_elf_find_function): Reorder params.
	(elfNN_aarch64_find_nearest_line): Reorder params, add
	discriminator_ptr.  Adjust calls.
	* elfxx-mips.c (_bfd_mips_elf_find_nearest_line): Similarly.
	* elfxx-mips.h (_bfd_mips_elf_find_nearest_line): Update prototype.
	* libaout.h (NAME (aout, find_nearest_line)): Update prototype.
	* libbfd-in.h (_bfd_nosymbols_find_nearest_line): Update.
	(_bfd_dwarf1_find_nearest_line): Likewise.
	(_bfd_dwarf2_find_nearest_line): Likewise.
	(_bfd_dwarf2_find_line): Delete.
	(_bfd_generic_find_nearest_line_discriminator): Delete.
	* libbfd.c (_bfd_generic_find_nearest_line_discriminator): Delete.
	* libcoff-in.h (coff_find_nearest_line): Update prototype.
	(coff_find_nearest_line_discriminator): Delete.
	(coff_find_nearest_line_with_names): Update prototype.
	* libecoff.h (_bfd_ecoff_find_nearest_line): Update prototype.
	* mach-o.c (bfd_mach_o_find_nearest_line): Reorder params, add
	discriminator_ptr.  Adjust calls.
	* mach-o.h (bfd_mach_o_find_nearest_line): Update prototype.
	* pdp11.c (NAME (aout, find_nearest_line)): Reorder params, add
	discriminator_ptr and set.
	* som.c (som_find_nearest_line): Similarly.
	* targets.c (BFD_JUMP_TABLE_SYMBOLS): Delete entry for
	_bfd_find_nearest_line_discriminator.
	(struct bfd_target <_bfd_find_nearest_line>): Adjust prototype.
	(struct bfd_target <_bfd_find_nearest_line_discriminator>): Delete.
	* vms-alpha.c (_bfd_vms_find_nearest_dst_line): Rename to..
	(_bfd_vms_find_nearest_line): ..this.  Reorder params, add
	"discriminator" and set.
	(_bfd_vms_find_nearest_line_discriminator): Delete.
	(_bfd_generic_find_nearest_line_discriminator): Don't define.
	(alpha_vms_find_nearest_line): Update define.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
	* libcoff.h: Regenerate.
2014-10-15 22:55:25 +10:30
Alan Modra 9c461f7dba Define bfd_find_line entry of BFD_JUMP_TABLE_SYMBOLS using NAME.
In https://www.sourceware.org/ml/binutils/2005-06/msg00082.html
HJ implemented bfd_find_line for DWARF2, but cheated a little in not
using the usual NAME##_find_line, saving quite a lot of boring
editing.  However that shortcut probably contributed to
bfd_find_nearest_line_discriminator being implemented the same way,
and missing support for some targets.

	* targets.c (BFD_JUMP_TABLE_SYMBOLS): Use NAME##_find_line.
	* aout-adobe.c (aout_32_find_line): Define.
	(aout_32_bfd_make_debug_symbol, aout_32_bfd_reloc_type_lookup,
	aout_32_bfd_reloc_name_lookup): Define using _bfd_nosymbols define.
	* aout-target.h (MY_find_line): Define.
	* aout-tic30.c (MY_find_line): Define.
	* binary.c (binary_find_line): Define.
	* bout.c (aout_32_find_line): Define.
	* coff-rs6000.c (_bfd_xcoff_find_line): Define.
	* coff64-rs6000.c (rs6000_xcoff64_vec): Use coff_find_line.
	(rs6000_xcoff64_aix_vec): Likewise.
	* elf-bfd.h (_bfd_generic_find_line): Don't define.
	* elfxx-target.h (bfd_elfNN_find_line): Define.
	* i386msdos.c (msdos_find_line): Define.
	* i386os9k.c (aout_32_find_line): Define.
	* ieee.c (ieee_find_nearest_line, ieee_find_inliner_info): Delete func.
	(ieee_find_nearest_line, ieee_find_line,
	ieee_find_inliner_info): Define.
	* ihex.c (ihex_find_line): Define.
	* libbfd-in.h (_bfd_nosymbols_find_line): Define.
	(_bfd_generic_find_line): Don't define.
	* libbfd.c (_bfd_generic_find_line): Delete.
	* libcoff-in.h (coff_find_line): Define.
	* libecoff.h (_bfd_ecoff_find_line): Define.
	* mach-o.h (bfd_mach_o_find_line): Define.
	* mmo.c (mmo_find_line): Define.
	* nlm-target.h (nlm_find_line): Define.
	* oasys.c (oasys_find_nearest_line, oasys_find_inliner_info): Delete.
	(oasys_find_nearest_line, oasys_find_line,
	oasys_find_inliner_info): Define.
	* pef.c (bfd_pef_find_line): Define.
	* plugin.c (bfd_plugin_find_line): Define.
	* ppcboot.c (ppcboot_find_line): Define.
	* som.c (som_find_line): Define.
	* srec.c (srec_find_line): Define.
	* tekhex.c (tekhex_find_line): Define.
	* versados.c (versados_find_line): Define.
	* vms-alpha.c (alpha_vms_find_line): Define.
	* xsym.c (bfd_sym_find_line): Define.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
	* libcoff.h: Regenerate.
2014-10-15 22:55:25 +10:30
Doug Evans aaffae57f3 Fix outputdots so that it doesn't errantly discard the first line of, e.g.,
CODE_FRAGMENT.  Also fix skip_past_newline to not skip past NUL.

	* bfd-in2.h: Regenerate.
	* libcoff.h: Regenerate.

	doc/
	* chew.c (skip_past_newline_1): New function.
	(outputdots): Call it.
	(skip_past_newline): Ditto.
2014-08-05 09:00:40 -07:00
Alan Modra d495ab0d84 Free linker hash table from bfd_close.
Also tidies numerous error exit paths in various link_hash_table_create
functions that failed to free memory.

include/
	* bfdlink.h (struct bfd_link_hash_table): Add hash_table_free field.
bfd/
	* archive.c: Include bfdlink.h.
	(_bfd_archive_close_and_cleanup): Call linker hash_table_free.
	* bfd.c (struct bfd): Add is_linker_output field.
	* elf-bfd.h (_bfd_elf_link_hash_table_free): Update prototype.
	* linker.c (_bfd_link_hash_table_init): Set up hash_table_free,
	link.hash and is_linker_output.
	(_bfd_generic_link_hash_table_free): Replace bfd_link_hash_table*
	param with bfd*.  Assert is_linker_output and link.hash, and
	clear them before exit.
	* elf-m10300.c (elf32_mn10300_link_hash_table_free): Replace
	bfd_link_hash_table* param with bfd*.  Hack is_linker_output
	and link.hash so we can free two linker hash tables.
	(elf32_mn10300_link_hash_table_create): Create static_hash_table
	first.  Clean up on errors.  Set hash_table_free pointer.
	* elf32-arm.c (elf32_arm_link_hash_table_free): Replace
	bfd_link_hash_table* param with bfd*.
	(elf32_arm_link_hash_table_create): Clean up on errors.  Set
	hash_table_free pointer.
	* elf32-avr.c, * elf32-hppa.c, * elf32-i386.c, * elf32-m68hc1x.c,
	* elf32-m68k.c, * elf32-metag.c, * elf32-nios2.c, * elf32-xgate.c,
	* elf64-ia64-vms.c, * elf64-ppc.c, * elf64-x86-64.c, * elflink.c,
	* elfnn-aarch64.c, * elfnn-ia64.c, * elfxx-sparc.c,
	* xcofflink.c: Similarly.
	* simple.c (bfd_simple_get_relocated_section_contents): Save and
	clear link.next before creating linker hash table.  Clean up on
	errors, and restore link.next on exit.
	* elf32-m68hc1x.h (m68hc11_elf_bfd_link_hash_table_free): Delete.
	* elf32-xgate.h (xgate_elf_bfd_link_hash_table_free): Delete.
	* elfxx-sparc.h (_bfd_sparc_elf_link_hash_table_free): Delete.
	* libcoff-in.h (_bfd_xcoff_bfd_link_hash_table_free): Delete.
	* hash.c (bfd_hash_table_init_n): Free table on error.
	* libbfd-in.h (_bfd_generic_link_hash_table_free): Update proto.
	* bfd-in2.h: Regenerate.
	* libbfd.h: Regenerate.
	* libcoff.h: Regenerate.
2014-06-13 19:11:39 +09:30
Kai Tietz bad1a9f77e * libcoff-in.h (coff_tdata): Make relocbase member unsigned.
* libcoff.h: Regenerated.
2014-06-11 09:15:19 +02:00
Alan Modra e30d16e9ec Fix fallout from splitting ldbuildid.[ch] off elf32.em.
bfd/
	* libcoff.h: Regenerate.
ld/
	* emultempl/spuelf.em: Include safe-ctype.h, remove duplicate errno.h.
	* emultempl/nds32elf.em: Include bfd_stdint.h.
	* po/POTFILES.in: Regenerate.
2014-04-09 13:49:05 +09:30
Jon TURNEY 61e2488cd8 Add support for generating and inserting build IDs into COFF binaries.
* peXXigen.c (pe_print_debugdata): New function: Displays the
	contents of the debug directory and decodes codeview entries.
	(_bfd_XXi_swap_debugdir_in, _bfd_XXi_swap_debugdir_out)
	(_bfd_XXi_slurp_codeview_record, _bfd_XXi_write_codeview_record):
	Add functions for reading and writing debugdir and codeview
	records.
	* libpei.h (_bfd_XXi_swap_debugdir_in, _bfd_XXi_swap_debugdir_out)
	(_bfd_XXi_write_codeview_record): Add prototypes and macros.
	* libcoff-in.h (pe_tdata): Add build-id data.
	* libcoff.h: Regenerate.
	* coffcode.h (coff_write_object_contents): Run build_id
	after_write_object_contents hook.

	* pe.h (external_IMAGE_DEBUG_DIRECTORY, _CV_INFO_PDB70)
	(_CV_INFO_PDB20): Add structures and constants for debug directory
	and codeview records.
	* internal.h (internal_IMAGE_DEBUG_DIRECTORY, CODEVIEW_INFO):
	Add structures and constants for internal representation of debug
	directory and codeview records.

	* emultempl/elf32.em (id_note_section_size, read_hex, write_build_id):
	Move code for parsing build-id option and calculating the build-id to...
	* ldbuildid.c: New file.
	* ldbuildid.h: New file.
	* Makefile.am (CFILES, HFILES, OFILES, ld_new_SOURCES): Add new
	files.
	* Makefile.in: Regenerate.
	* ld.texinfo: Update --build-id description to mention COFF
	support.
	* NEWS: Mention support for COFF build ids.
	* emultempl/pe.em (gld${EMULATION_NAME}_handle_option):
	(pecoff_checksum_contents, write_build_id, setup_build_id)
	(gld_${EMULATION_NAME}_after_open):  Handle and implement
	build-id option.
	* emultempl/pep.em: Likewise.
2014-04-08 10:59:43 +01:00
Tristan Gingold 167ad85bf0 Add pe/x86_64 bigobj file format.
bfd/
	* peicode.h (pe_ILF_object_p): Adjust, as the version number
	has been read.
	(pe_bfd_object_p): Also read version number to detect ILF.
	* pe-x86_64.c (COFF_WITH_PE_BIGOBJ): Define.
	(x86_64pe_bigobj_vec): Define
	* coffcode.h (bfd_coff_backend_data): Add _bfd_coff_max_nscns field.
	(bfd_coff_max_nscns): New macro.
	(coff_compute_section_file_positions): Use unsigned int for
	target_index.  Compare with bfd_coff_max_nscns.
	(bfd_coff_std_swap_table, ticoff0_swap_table, ticoff1_swap_table):
	Set a value for _bfd_coff_max_nscns.
	(header_bigobj_classid): New constant.
	(coff_bigobj_swap_filehdr_in, coff_bigobj_swap_filehdr_out)
	(coff_bigobj_swap_sym_in, coff_bigobj_swap_sym_out)
	(coff_bigobj_swap_aux_in, coff_bigobj_swap_aux_out): New
	functions.
	(bigobj_swap_table): New table.
	* libcoff.h: Regenerate.
	* coff-sh.c (bfd_coff_small_swap_table): Likewise.
	* coff-alpha.c (alpha_ecoff_backend_data): Add value for
	_bfd_coff_max_nscns.
	* coff-mips.c (mips_ecoff_backend_data): Likewise.
	* coff-rs6000.c (bfd_xcoff_backend_data)
	(bfd_pmac_xcoff_backend_data): Likewise.
	* coff64-rs6000.c (bfd_xcoff_backend_data)
	(bfd_xcoff_aix5_backend_data): Likewise.
	* targets.c (x86_64pe_bigobj_vec): Declare.
	* configure.in (x86_64pe_bigobj_vec): New vector.
	* configure: Regenerate.
	* config.bfd: Add bigobj object format for Windows targets.

gas/
	* config/tc-i386.c (use_big_obj): Declare.
	(OPTION_MBIG_OBJ): Define.
	(md_longopts): Add -mbig-obj option.
	(md_parse_option): Handle it.
	(md_show_usage): Display help for this option.
	(i386_target_format): Use bigobj for x86-64 if -mbig-obj.
	* doc/c-i386.texi: Document the option.

gas/testsuite/
	* gas/pe/big-obj.d, gas/pe/big-obj.s: Add test.
	* gas/pe/pe.exp: Add test.

include/coff/
	* pe.h (struct external_ANON_OBJECT_HEADER_BIGOBJ): Declare.
	(FILHSZ_BIGOBJ): Define.
	(struct external_SYMBOL_EX): Declare.
	(SYMENT_BIGOBJ, SYMESZ_BIGOBJ): Define.
	(union external_AUX_SYMBOL_EX): Declare.
	(AUXENT_BIGOBJ, AUXESZ_BIGOBJ): Define.
	* internal.h (struct internal_filehdr): Change type
	of f_nscns.
2014-03-13 09:33:07 +01:00
Alan Modra 4b95cf5c0c Update copyright years 2014-03-05 22:16:15 +10:30
Cory Fields 0cb112f740 * windres.c (define_resource): Use zero for timestamp, making
output deterministic. time.h include is no longer needed.
	* resres.c (res_append_resource): Likewise.

	* pe-dll.c (fill_edata): Only use a real timestamp if
	--insert-timestamp was used.
	* emultempl/pe.em: Add the --insert-timestamp option.
	* emultempl/pep.em: Likewise for 64bit.
	* ld.texinfo: Document the --insert-timestamp option.

	* libcoff-in.h: Add insert_timestamp flag to the pe_data struct.
	* libcoff.h: Regenerate.
	* peXXigen.c (_bfd_XXi_only_swap_filehdr_out): Only use a real
	timestamp if --insert-timestamp was used.
2013-11-22 14:55:56 +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
Kai Tietz a29a8af823 ChangeLog bfd
2012-10-18  Kai Tietz  <ktietz@redhat.com>

	PR binutils/14067
	* coff-i386.c (bfd_target): Add section flag SEC_EXCLUDE.
	Allow BFD_COMPRESS and BFD_DECOMPRESS flags.
	* coff-x86_64.c: Likewise.
	* coffcode.h (DOT_ZDEBUG): New define.
	(sec_to_styp_flags): Check for .zdebug.
	(styp_to_sec_flags): Likewise.
	* coffgen.c (make_a_section): Handle .debug_* section
	compression/decompression flags.
	* cofflink.c (mark_relocs): Ignore relocations
	for a section, which isn't marked as used.
	(_bfd_coff_link_input_bfd): Add support of compressed
	debug sections.
	* compress.c (decompress_contents): Loop as long
	as there is input available and there is room for
	output.
	* bfd/pe-arm.c: Add .zdebug_ partial match entry.
	* pe-i386.c: Likewise.
	* pe-x86_64.c: Likewise.
	* peXXigen.c (_bfd_XXi_swap_aouthdr_out): Don't clear all
	data-directories as this might destroy content.

        * coff-i386.c (_bfd_generic_find_nearest_line_discriminator):
        define as coff_find_nearest_line_discriminator.
        * libcoff-in.h (coff_find_nearest_line_discriminator): New
        * libcoff.h: Regenerated.
        * coff-x86_64.c: Likewise.
        * coffgen.c (coff_find_nearest_line_discriminator): New function.
        prototype.

ChangeLog binutils

2012-10-18  Kai Tietz  <ktietz@redhat.com>

	* objdump.c (dump_bfd): Call dump headers after
	call of slurp_symtab.

ChangeLog ld

2012-10-18  Kai Tietz  <ktietz@redhat.com>

	PR binutils/14067
	* NEWS: Menition new feature.
	* scripttempl/pep.sc: Add zdebug sections.
	* scripttempl/pe.sc: L
2012-10-18 17:42:29 +00:00
Jan Beulich e7ebb21483 Building EFI binaries, particularly larger ones (like e.g. Xen does), on Linux
(where relocatable objects are in ELF format) so far led to all local (aka
static) symbols to be discarded, making debugging quite a bit more difficult
(like Linux, Xen builds an internal symbol lookup table from nm output
generated on the binary produced by an earlier linking pass). Therefore, this
patch arranges to insert all (relevant) local symbols from non-COFF objects
into the final executable's symbol table between those coming from COFF input
files and the global ones.

bfd/
2011-11-02  Jan Beulich  <jbeulich@suse.com>

	* coffgen.c (coff_write_alien_symbol): Make public. Add 'struct
	internal_syment *' parameter. Extend 'dummy' to an array with two
	elements. Set n_numaux early. Handle BSF_FILE.
	(coff_write_symbols): Pass NULL as new third argument to
	coff_write_alien_symbol().
	* cofflink.c (_bfd_coff_final_link): Don't use COFF-specific
	obj_raw_syment_count() on non-COFF input BFD. Insert local symbols
	from non-COFF input BFDs.
	* libcoff-in.h (coff_write_alien_symbol): Declare.
	* libcoff.h (coff_write_alien_symbol): Re-generate.
2011-11-02 14:53:04 +00:00
Tristan Gingold fc28f9aa23 2011-09-30 Tristan Gingold <gingold@adacore.com>
* dwarf2.c (struct dwarf2_debug): Add field debug_sections.
	(read_section): Add sec argument. Adjust the code to get section
	names from it.
	(read_indirect_string): Adjust call to read_section.
	(read_abbrevs): Ditto.
	(decode_line_info): Ditto.
	(read_debug_ranges): Ditto.
	(DWARF2_DEBUG_INFO, DWARF2_COMPRESSED_DEBUG_INFO): Remove.
	(find_debug_info): Add debug_sections parameter.  Use it instead
	the above macros.
	(place_sections): Get section names from stash.
	(find_line): Add debug_sections argument.  Initialize
	debug_sections field of stash from it.
	Adjust calls to find_debug_info.
	(_bfd_dwarf2_find_nearest_line): Add debug_sections argument.
	Adjust call to find_line.
	(_bfd_dwarf2_find_line): Adjust call to find_line.
	* libcoff-in.h (struct dwarf_debug_section): New declaration.
	(coff_find_nearest_line_with_names): Likewise.
	* libcoff.h: Regenerate.
	* libbfd-in.h (struct dwarf_debug_section): Move declaration.
	(dwarf_debug_sections): Likewise.
	(_bfd_dwarf2_find_nearest_line): Add debug_sections argument.
	* libbfd.h: Regenerate.
	* elf.c (_bfd_elf_find_nearest_line): Adjust call to
	_bfd_dwarf2_find_nearest_line.
	* elfxx-mips.c (_bfd_mips_elf_find_nearest_line): Ditto.
	* elf64-alpha.c (elf64_alpha_find_nearest_line): Ditto.
	* elf32-arm.c (elf32_arm_find_nearest_line): Ditto.
	* coffgen.c (coff_find_nearest_line_with_names): New function.
	(coff_find_nearest_line): Calls coff_find_nearest_line_with_names.
	* coff-rs6000.c (xcoff_debug_sections): New constant.
	(xcoff_find_nearest_line): New function.
	(rs6000coff_vec): Use xcoff_find_nearest_line.
	(pmac_xcoff_vec): Ditto.
2011-09-30 10:39:45 +00:00
Alan Modra c77ec72614 PR ld/12762
bfd/
	* bfd-in.h (struct bfd_section_already_linked): Forward declare.
	(_bfd_handle_already_linked): Declare.
	* coff-alpha.c (_bfd_ecoff_section_already_linked): Define as
	_bfd_coff_section_already_linked.
	* coff-mips.c (_bfd_ecoff_section_already_linked): Likewise.
	* coffcode.h (coff_section_already_linked): Likewise.
	* cofflink.c (coff_link_add_symbols): Revert 2011-07-09 changes.
	* elf-bfd.h: Likewise.
	* libbfd-in.h: Likewise.
	* targets.c: Likewise.
	* linker.c (bfd_section_already_linked): Likewise.
	(bfd_section_already_linked_table_lookup): Likewise.
	(bfd_section_already_linked_table_insert): Likewise.
	(_bfd_generic_section_already_linked): Likewise.  Call
	_bfd_handle_already_linked.
	(_bfd_handle_already_linked): New function, split out from..
	* elflink.c (_bfd_elf_section_already_linked): ..here.  Revert
	2011-07-09 changes.  Avoid unnecessary strcmp when matching
	already_linked_list entries.  Match plugin linkonce section.
	(section_signature): Delete.
	* coffgen.c (_bfd_coff_section_already_linked): New function.
	* libcoff-in.h (_bfd_coff_section_already_linked): Declare.
	* libbfd.h: Regenerate.
	* libcoff.h: Regenerate.
	* bfd-in2.h: Regenerate.
ld/
	* ldlang.c (section_already_linked): Revert 2011-07-09 changes.
	* plugin.c: Likewise.
	(asymbol_from_plugin_symbol): Create linkonce section for syms
	with comdat_key.
2011-08-17 00:39:41 +00:00
Alan Modra 7686d77de3 * linker.c (bfd_link_hash_traverse): Follow warning symbol link.
(_bfd_generic_link_write_global_symbol, fix_syms): Don't handle
	warning symbols here.
	* elf-m10300.c (elf32_mn10300_finish_hash_table_entry): Likewise.
	* elf32-arm.c (allocate_dynrelocs_for_symbol,
	elf32_arm_readonly_dynrelocs): Likewise.
	* elf32-bfin.c (bfin_discard_copies): Likewise.
	* elf32-cris.c (elf_cris_adjust_gotplt_to_got,
	elf_cris_discard_excess_dso_dynamics,
	elf_cris_discard_excess_program_dynamics): Likewise.
	* elf32-hppa.c (allocate_plt_static, allocate_dynrelocs,
	clobber_millicode_symbols, readonly_dynrelocs): Likewise.
	* elf32-i370.c (i370_elf_adjust_dynindx): Likewise.
	* elf32-i386.c (elf_i386_allocate_dynrelocs,
	elf_i386_readonly_dynrelocs): Likewise.
	* elf32-lm32.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
	* elf32-m32c.c (m32c_relax_plt_check, m32c_relax_plt_realloc): Likewise.
	* elf32-m32r.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
	* elf32-m68k.c (elf_m68k_discard_copies): Likewise.
	* elf32-microblaze.c (allocate_dynrelocs): Likewise.
	* elf32-ppc.c (allocate_dynrelocs, maybe_set_textrel): Likewise.
	* elf32-s390.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
	* elf32-score.c (score_elf_sort_hash_table_f): Likewise.
	* elf32-score7.c (score_elf_sort_hash_table_f): Likewise.
	* elf32-sh.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
	* elf32-tic6x.c (elf32_tic6x_allocate_dynrelocs,
	elf32_tic6x_readonly_dynrelocs): Likewise.
	* elf32-vax.c (elf_vax_discard_copies): Likewise.
	* elf32-xstormy16.c (xstormy16_relax_plt_check,
	xstormy16_relax_plt_realloc): Likewise.
	* elf32-xtensa.c (elf_xtensa_allocate_dynrelocs): Likewise.
	* elf64-alpha.c (elf64_alpha_output_extsym,
	elf64_alpha_calc_got_offsets_for_symbol,
	elf64_alpha_calc_dynrel_sizes, elf64_alpha_size_rela_got_1): Likewise.
	* elf64-hppa.c (elf64_hppa_mark_exported_functions,
	allocate_global_data_opd, elf64_hppa_mark_milli_and_exported_functions,
	elf_hppa_unmark_useless_dynamic_symbols,
	elf_hppa_remark_useless_dynamic_symbols): Likewise.
	* elf64-ppc.c (ppc64_elf_gc_mark_dynamic_ref, func_desc_adjust,
	adjust_opd_syms, adjust_toc_syms, allocate_dynrelocs,
	readonly_dynrelocs, merge_global_got, reallocate_got,
	undo_symbol_twiddle): Likewise.
	* elf64-s390.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
	* elf64-sh64.c (sh64_elf64_discard_copies): Likewise.
	* elf64-x86-64.c (elf_x86_64_allocate_dynrelocs,
	elf_x86_64_readonly_dynrelocs): Likewise.
	* elflink.c (elf_link_renumber_hash_table_dynsyms,
	elf_link_renumber_local_hash_table_dynsyms, _bfd_elf_export_symbol,
	_bfd_elf_link_find_version_dependencies,
	_bfd_elf_link_assign_sym_version, _bfd_elf_adjust_dynamic_symbol,
	_bfd_elf_link_sec_merge_syms, elf_adjust_dynstr_offsets,
	elf_collect_hash_codes, elf_collect_gnu_hash_codes,
	elf_renumber_gnu_hash_syms, elf_gc_sweep_symbol,
	elf_gc_propagate_vtable_entries_used,
	elf_gc_smash_unused_vtentry_relocs, bfd_elf_gc_mark_dynamic_ref_symbol,
	elf_gc_allocate_got_offsets): Likewise.
	* elfnn-ia64.c (elfNN_ia64_global_dyn_info_free,
	elfNN_ia64_global_dyn_sym_thunk): Likewise.
	* elfxx-mips.c (mips_elf_check_symbols, mips_elf_output_extsym,
	mips_elf_sort_hash_table_f, allocate_dynrelocs): Likewise.
	* elfxx-sparc.c (allocate_dynrelocs, readonly_dynrelocs): Likewise.
	* i386linux.c (linux_tally_symbols): Likewise.
	* m68klinux.c (linux_tally_symbols): Likewise.
	* sparclinux.c (linux_tally_symbols): Likewise.
	* sunos.c (sunos_scan_dynamic_symbol): Likewise.
	* xcofflink.c (xcoff_post_gc_symbol): Likewise.

	* elflink.c (elf_link_output_extsym): Make it a bfd_hash_traverse
	function.  Update all callers.
	* aoutx.h (aout_link_write_other_symbol): Likewise.
	* pdp11.c (aout_link_write_other_symbol): Likewise.
	* cofflink.c (_bfd_coff_write_global_sym): Likewise.
	* ecoff.c (ecoff_link_write_external): Likewise.
	* xcofflink.c (xcoff_write_global_symbol): Likewise.
	* vms-alpha.c (alpha_vms_link_output_symbol): Likewise.  Handle
	warning symbols.
	* ecoff.c (ecoff_link_hash_traverse): Delete.
	* coff-ppc.c (ppc_bfd_coff_final_link): Use bfd_hash_traverse for
	_bfd_coff_write_global_sym.
	* libcoff-in.h (_bfd_coff_write_global_sym): Update prototype.
	* libcoff.h: Regenerate.
2011-06-13 00:59:15 +00:00
Tristan Gingold 2040cacad1 2011-03-31 Tristan Gingold <gingold@adacore.com>
* libcoff-in.h (exec_hdr): Remove.
	* libcoff.h: Regenerate.
2011-03-31 08:08:39 +00:00
H.J. Lu 441f34fa99 Don't add IMAGE_FILE_RELOCS_STRIPPED for PIE.
2010-03-18  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/11396
	* libcoff-in.h (pe_tdata): Add dont_strip_reloc.
	* libcoff.h: Regenerated.

	* peXXigen.c (_bfd_XXi_only_swap_filehdr_out): Clear F_RELFLG
	if dont_strip_reloc is set.
	(_bfd_XX_bfd_copy_private_bfd_data_common): Set
	dont_strip_reloc on output if there is no .reloc and
	IMAGE_FILE_RELOCS_STRIPPED isn't set in input.
2010-03-18 12:27:15 +00:00
Nick Clifton 96d56e9f91 * bfd/coff-arm.c (coff_arm_relocate_section)
(record_thumb_to_arm_glue, bfd_arm_process_before_allocation):
        Change member name class to symbol_class.
        * bfd/coff-i960.c (coff_i960_relocate_section) Rename variable
        class to class_val. Change member name class to symbol_class.
        * bfd/coff-rs6000.c (_bfd_xcoff_swap_aux_in)
        (_bfd_xcoff_swap_aux_out): Rename arguments class to in_class.
        * bfd/coff-stgo32.c (adjust_aux_in_post)
        (adjust_aux_out_pre, adjust_aux_out_post): Rename arguments class
        to in_class.
        * bfd/coff64-rs6000.c (_bfd_xcoff64_swap_aux_in)
        (_bfd_xcoff64_swap_aux_out): Rename arguments class to in_class.
        * bfd/coffcode.h (coff_pointerize_aux_hook): Rename variable class
        to n_sclass.
        * bfd/coffgen.c (coff_write_symbol, coff_pointerize_aux): Rename
        variables named class to n_sclass. (coff_write_symbols): Rename
        variable class to sym_class. (bfd_coff_set_symbol_class): Rename
        argument class to symbol_class.
        * bfd/cofflink.c (_bfd_coff_link_hash_newfunc)
        (coff_link_add_symbols, _bfd_coff_link_input_bfd)
        (_bfd_coff_write_global_sym, _bfd_coff_generic_relocate_section):
        Update code to use renamed members.
        * bfd/coffswap.h (coff_swap_aux_in, coff_swap_aux_out): Rename
        argument class to in_class.
        * bfd/libcoff-in.h (struct coff_link_hash_entry, struct
        coff_debug_merge_type) Renamed members class to symbol_class and
        type_class.
        * bfd/libcoff.h Regenerated.
        * bfd/peXXigen.c: (_bfd_XXi_swap_aux_in, _bfd_XXi_swap_aux_out):
        Rename argument class to in_class.
        * bfd/pef.c (bfd_pef_parse_imported_symbol): Update code to use
        renamed members.
        * bfd/pef.h (struct bfd_pef_imported_symbol): Changed name of
        member class to symbol_class.
        * binutils/ieee.c (ieee_read_cxx_misc, ieee_read_cxx_class)
        (ieee_read_reference): Rename variables named class to cxxclass.
        * gas/config/tc-arc.c (struct syntax_classes): Rename member class
        to s_class. (arc_extinst): Rename variable class to
        s_class. Update code to use renamed members.
        * gas/config/tc-mips.c (insn_uses_reg): Rename argument class to
        regclass.
        * gas/config/tc-ppc.c (ppc_csect, ppc_change_csect, ppc_function)
        (ppc_tc, ppc_is_toc_sym, ppc_symbol_new_hook, ppc_frob_label)
        (ppc_fix_adjustable, md_apply_fix): Update code to use renamed
        members.
        * gas/config/tc-ppc.h (struct ppc_tc_sy): Change name of member
        from class to symbol_class. (OBJ_COPY_SYMBOL_ATTRIBUTES): Update
        code to use renamed members.
        * gas/config/tc-score.c (s3_adjust_paritybit): Rename argument
        class to i_class.
        * gas/config/tc-score7.c (s7_adjust_paritybit): Rename argument
        class to i_class.
        * gprof/corefile.c (core_create_function_syms): Rename variable
        class to cxxclass.
        * include/coff/ti.h (GET_LNSZ_SIZE, PUT_LNSZ_SIZE): Updated name
        of class variable to in_class to match changes in function that
        use this macro.
        * include/opcode/ia64.h (struct ia64_operand): Renamed member
        class to op_class
        * ld/emultempl/elf32.em (gld${EMULATION_NAME}_load_symbols)
        (gld${EMULATION_NAME}_try_needed): Rename variable class to
        link_class
        * opcodes/ia64-dis.c (print_insn_ia64): Update code to use renamed
        member.
        * opcodes/m88k-dis.c (m88kdis): Rename variable class to in_class.
        * opcodes/tic80-opc.c (tic80_symbol_to_value)
        (tic80_value_to_symbol): Rename argument class to symbol_class.
2009-09-05 07:56:26 +00:00
Jan Kratochvil 9bf609ecf2 bfd/
Stop using bfd_usrdata in libbfd.
	* coff-stgo32.c (bfd_coff_go32stub): Remove.
	(stub_bytes, comment): Replace STUBSIZE by GO32_STUBSIZE.
	(adjust_filehdr_in_post): Declare the abfd parameter as unused.
	Replace STUBSIZE by GO32_STUBSIZE.  Save now the stub in
	filehdr_dst->u.go32.stub.  New comment with the reason.
	(adjust_filehdr_out_pre): Replace STUBSIZE by GO32_STUBSIZE.
	Substitute the removed macro bfd_coff_go32stub.
	(adjust_filehdr_out_post, adjust_scnhdr_in_post, adjust_scnhdr_out_pre)
	(adjust_scnhdr_out_post, adjust_aux_in_post, adjust_aux_out_pre)
	(adjust_aux_out_post): Replace STUBSIZE by GO32_STUBSIZE.
	(create_go32_stub, go32_stubbed_coff_bfd_copy_private_bfd_data):
	Replace STUBSIZE by GO32_STUBSIZE.  Substitute the removed macro
	bfd_coff_go32stub.
	* coffcode.h (coff_mkobject_hook): Initialize coff->go32stub.
	* libcoff-in.h (coff_data_type): New field go32stub.
	* libcoff.h: Regenerated.

include/coff/
	Stop using bfd_usrdata in libbfd.
	* go32exe.h (struct external_filehdr_go32_exe <stub>, FILHSZ): Replace
	STUBSIZE by GO32_STUBSIZE.
	(STUBSIZE): Move the definition ...
	* internal.h (GO32_STUBSIZE): ... here and rename it.
	(struct internal_filehdr <go32stub>, F_GO32STUB): New.
2009-08-10 21:56:42 +00:00
H.J. Lu 4f3607846c 2009-04-21 H.J. Lu <hongjiu.lu@intel.com>
* coff-ia64.c (COFF_PAGE_SIZE): Changed to 8K.

	* coffcode.h (coff_compute_section_file_positions): Clear
	D_PAGED if PE section alignment is smaller than COFF_PAGE_SIZE.

	* libcoff-in.h (pe_tdata): Remove force_minimum_alignment and
	force_minimum_alignment.

	* libcoff.h: Regenerated.

	* pei-ia64.c (PEI_TARGET_SUBSYSTEM): Removed.
	(PEI_FORCE_MINIMUM_ALIGNMENT): Likewise.

	* peicode.h (pe_mkobject): Don't set force_minimum_alignment
	nor target_subsystem.

	* peXXigen.c (_bfd_XXi_swap_aouthdr_out): Don't check
	force_minimum_alignment nor target_subsystem.
2009-04-21 17:08:20 +00:00
H.J. Lu 92dd451149 bfd/
2009-04-17  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/10074
	* coffcode.h (bfd_pei_p): New.

	* config.bfd: Remove bfd_efi_bsdrv_ia32_vec,
	bfd_efi_rtdrv_ia32_vec, bfd_efi_bsdrv_x86_64_vec,
	bfd_efi_rtdrv_x86_64_vec, bfd_efi_bsdrv_ia64_vec and
	bfd_efi_rtdrv_ia64_vec.  Replace bfd_efi_app_ia32_vec,
	bfd_efi_app_x86_64_vec and bfd_efi_app_ia64_vec with
	i386pei_vec, x86_64pei_vec and bfd_pei_ia64_vec, respectively.

	* configure.in: Remove bfd_efi_bsdrv_ia32_vec,
	bfd_efi_rtdrv_ia32_vec, bfd_efi_bsdrv_x86_64_vec,
	bfd_efi_rtdrv_x86_64_vec,
	bfd_efi_bsdrv_ia64_vec and bfd_efi_rtdrv_ia64_vec.  Replace
	bfd_efi_ia64_vec with bfd_pei_ia64_vec.
	* targets.c: Likewise.

	* configure: Regenerated.
	* libcoff.h: Likewise.
	* Makefile.in: Likewise.

	* efi-app-ia32.c: Removed.
	* efi-app-x86_64.c: Likewise.
	* efi-bsdrv-ia32.c: Likewise.
	* efi-bsdrv-ia64.c: Likewise.
	* efi-bsdrv-x86_64.c: Likewise.
	* efi-rtdrv-ia32.c: Likewise.
	* efi-rtdrv-ia64.c: Likewise.
	* efi-rtdrv-x86_64.c: Likewise.
	* efi-rtdrv-ia32.c: Likewise.

	* efi-app-ia64.c: Moved to ...
	* pei-ia64.c: This.
	(TARGET_SYM): Set to bfd_pei_ia64_vec.
	(TARGET_NAME): Set to pei-ia64.

	* libpei.h (bfd_target_pei_p): Removed.
	(bfd_target_pei_arch): Likewise.
	(bfd_target_efi_app_p): Likewise.
	(bfd_target_efi_app_arch): Likewise.
	(bfd_target_efi_bsdrv_p): Likewise.
	(bfd_target_efi_bsdrv_arch): Likewise.
	(bfd_target_efi_rtdrv_p): Likewise.
	(bfd_target_efi_rtdrv_arch): Likewise.
	(bfd_pe_executable_p): Likewise.

	* Makefile.am (BFD32_BACKENDS): Remove efi-app-ia32.lo,
	efi-bsdrv-ia32.lo and efi-rtdrv-ia32.lo.
	(BFD32_BACKENDS_CFILES): Remove efi-app-ia32.c, efi-bsdrv-ia32.c
	and efi-rtdrv-ia32.c.
	(BFD64_BACKENDS): Remove efi-app-ia64.lo, efi-bsdrv-ia64.lo,
	efi-rtdrv-ia64.lo, efi-app-x86_64.lo, efi-bsdrv-x86_64.lo and
	efi-rtdrv-x86_64.lo. Add pei-ia64.lo.
	(BFD64_BACKENDS_CFILES): Remove efi-app-ia64.c, efi-bsdrv-ia64.c,
	efi-rtdrv-ia64.c, efi-app-x86_64.c, efi-bsdrv-x86_64.c and
	efi-rtdrv-x86_64.c. Add pei-ia64.c.
	(efi-app-ia64.lo): Removed.
	(efi-bsdrv-ia32.lo): Likewise.
	(efi-rtdrv-ia32.lo): Likewise.
	(efi-app-ia64.lo): Likewise.
	(efi-bsdrv-ia64.lo): Likewise.
	(efi-rtdrv-ia64.lo): Likewise.
	(efi-app-x86_64.lo): Likewise.
	(efi-bsdrv-x86_64.lo): Likewise.
	(efi-rtdrv-x86_64.lo): Likewise.
	(pei-ia64.lo): New.

	* peicode.h (coff_swap_scnhdr_in): Replace bfd_pe_executable_p
	with bfd_pei_p.
	(arch_type): Removed.
	(pe_arch): Likewise.
	(pe_bfd_object_p): Just return coff_object_p.

	* peXXigen.c (_bfd_XXi_swap_scnhdr_out): Replace
	bfd_pe_executable_p with bfd_pei_p.

binutils/

2009-04-17  H.J. Lu  <hongjiu.lu@intel.com>

	PR binutils/10074
	* objcopy.c: Include coff/i386.h and coff/pe.h.
	(pe_file_alignment): New.
	(pe_heap_commit): Likewise.
	(pe_heap_reserve): Likewise.
	(pe_image_base): Likewise.
	(pe_section_alignment): Likewise.
	(pe_stack_commit): Likewise.
	(pe_stack_reserve): Likewise.
	(pe_subsystem): Likewise.
	(pe_major_subsystem_version): Likewise.
	(pe_minor_subsystem_version): Likewise.
	(set_pe_subsystem): Likewise.
	(convert_efi_target): Likewise.
	(command_line_switch): Add OPTION_FILE_ALIGNMENT,
	OPTION_HEAP, OPTION_IMAGE_BASE, OPTION_SECTION_ALIGNMENT,
	OPTION_STACK and OPTION_SUBSYSTEM.
	(copy_options): Likewise.
	(copy_usage): Add --file-alignment, --heap, --image-base,
	--section-alignment, --stack and --subsystem.
	(copy_object): Set up PE parameters.
	(copy_main): Process Add OPTION_FILE_ALIGNMENT,
	OPTION_HEAP, OPTION_IMAGE_BASE, OPTION_SECTION_ALIGNMENT,
	OPTION_STACK and OPTION_SUBSYSTEM.   Convert EFI target to
	PEI target.

	* NEWS: Mention --file-alignment, --heap, --image-base,
	--section-alignment, --stack and --subsystem command line
	options for objcopy.

	* doc/binutils.texi: Document --file-alignment, --heap,
	--image-base, --section-alignment, --stack and --subsystem
	command line options for objcopy.
2009-04-17 13:46:18 +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
Richard Sandiford 3df13c4a63 bfd/
* libcoff-in.h (xcoff_tdata): Add a lineno_counts field.
	* libcoff.h: Regenerate.
	* xcofflink.c (xcoff_link_add_symbols): Record per-symbol
	line-number counts in the bfd's lineno_counts field.
	Don't keep per-csect line-number counts.
	(xcoff_sweep): Don't update per-csect line-number counts.
	(bfd_xcoff_size_dynamic_sections): Count the number of line-number
	entries in each output section.
	(xcoff_link_input_bfd): Get the number of line numbers from
	the bfd's lineno_counts field, rather than recalculating it
	from scratch.  Fix the range check when updating C_BINCL and
	C_EINCL symbols.
	(_bfd_xcoff_bfd_final_link): Don't count the output line numbers
	here.  Don't expect csects to have line-number counts.

ld/testsuite/
	* ld-powerpc/aix-lineno-1.s, ld-powerpc/aix-lineno-1.txt,
	ld-powerpc/aix-lineno-1a.dd, ld-powerpc/aix-lineno-1a.nd,
	ld-powerpc/aix-lineno-1b.dd, ld-powerpc/aix-lineno-1b.nd: New tests.
	* ld-powerpc/aix52.exp: Run them.  Copy aix-lineno-1.txt to tmpdir.
2009-03-14 09:32:33 +00:00
Richard Sandiford e450936a6f bfd/
* libcoff-in.h (xcoff_tdata): Change debug_indices to a signed long.
	* libcoff.h: Regenerate.
	* xcofflink.c (xcoff_keep_symbol_p): New function, using the
	"skip" logic from xcoff_link_input_bfd.
	(bfd_xcoff_size_dynamic_sections): Explicitly skip dynamic
	objects in a dynamic link, rather than checking whether csectpp
	is null.  Always allocate debug_index for other objects,
	and always go through the loop.  Update the type of debug_index
	after the change above.  Read the auxillary csect information
	and use xcoff_keep_symbol_p to decide whether a symbol should
	be kept.  Set its debug_index to -2 if not.
	(xcoff_link_input_bfd): Update the type of debug_index after
	the change above and always expect it to be nonnull.  Use it to
	test whether a symbol should be stripped, rather than making the
	decision here.  Postpone all symbol creation to the second pass.
2009-03-14 09:32:06 +00:00
Richard Sandiford 4cc02a022b bfd/
* libcoff-in.h (xcoff_section_tdata): Update commentary.
	* libcoff.h: Regenerate.
	* xcofflink.c (xcoff_link_add_symbols): Set the csect of XTY_ER
	symbols to bfd_und_section_ptr or bfd_abs_section_ptr, rather than
	the previous symbol's csect.  Treat last_symndx as an inclusive value
	and simplify its handling.
	(xcoff_mark): Treat last_symndx as an inclusive value.  Only mark
	symbols with the right csect.  Don't mark rsec when processing
	relocations against undefined or absolute sections.
	(bfd_xcoff_size_dynamic_sections): Don't check the SEC_MARK flag
	of bfd_und_section_ptr.
	(xcoff_link_input_bfd): Likewise.
2009-03-14 09:17:56 +00:00
Dave Korn 8818386922 bfd/ChangeLog
* coff-alpha.c (alpha_ecoff_backend_data):  Initialise fields which
	control long section name handling with ECOFF_NO_LONG_SECTION_NAMES.
	* coff-mips.c (mips_ecoff_backend_data):  Likewise.
	* coff-rs6000.c (bfd_xcoff_backend_data):  Initialise fields which
	control long section name handling with XCOFF_NO_LONG_SECTION_NAMES.
	(bfd_pmac_xcoff_backend_data):  Likewise.
	* coff64-rs6000.c (bfd_xcoff_backend_data):  Likewise.
	(bfd_xcoff_aix5_backend_data):  Likewise.
	(xcoff64_write_object_contents):  Delete unused long_section_names
	local variable.
	* coff-sh.c (bfd_coff_small_swap_table):  Initialise long section
	name members using COFF_DEFAULT_LONG_SECTION_NAMES and make entire
	struct non-const.
	* coffcode.h (documentation):  Update to describe long section names.
	(COFFLONGSECTIONCATHELPER):  New helper macro.
	(BLANKOR1TOODD):  Likewise.
	(COFF_ENABLE_LONG_SECTION_NAMES):  Likewise.
	(COFF_LONG_SECTION_NAMES_SETTER):  Likewise.
	(COFF_DEFAULT_LONG_SECTION_NAMES):  Likewise.
	(bfd_coff_set_long_section_names_allowed):  New function.
	(bfd_coff_set_long_section_names_disallowed):  Likewise.
	(struct bfd_coff_backend_data):  Add new backend hook function
	pointer _bfd_coff_set_long_section_names.
	(bfd_coff_set_long_section_names):  New backend hook.
	(coff_write_object_contents):  Only generate long section names if
	bfd_coff_long_section_names() indicates they are currently enabled.
	(bfd_coff_std_swap_table):  Make non-const, and initialise long
	section name fields using COFF_DEFAULT_LONG_SECTION_NAMES.
	(ticoff0_swap_table):  Likewise to both.
	(ticoff1_swap_table):  Again, likewise to both.
	* coffgen.c (make_a_section_from_file):  Allow long section names
	as inputs even if not currently allowed for outputs.
	* ecoff.c (_bfd_ecoff_no_long_sections):  New function.
	* efi-app-ia32.c (COFF_LONG_SECTION_NAMES):  Define to 0, not blank.
	* efi-app-ia64.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* efi-app-x86_64.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* efi-bsdrv-ia32.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* efi-bsdrv-ia64.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* efi-bsdrv-x86_64.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* efi-rtdrv-ia32.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* efi-rtdrv-ia64.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* efi-rtdrv-x86_64.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* pei-arm.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* pei-i386.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* pei-mcore.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* pei-mips.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* pei-ppc.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* pei-sh.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* pei-x86_64.c (COFF_LONG_SECTION_NAMES):  Likewise.
	* libcoff-in.h:  Update copyright year to cause updated copyright
	year in generated libcoff.h, and fix typo.
	* libcoff.h:  Regenerated.
	* libecoff.h (ECOFF_NO_LONG_SECTION_NAMES):  New macro.
	(_bfd_ecoff_no_long_sections):  Add prototype.
	* libxcoff.h (XCOFF_NO_LONG_SECTION_NAMES):  New macro.
	* pe-mips.c (COFF_LONG_SECTION_NAMES):  Define empty if not already
	defined by an including .c file.
	* ticoff.h (ticoff0_swap_table):  Make non-const, and initialise
	long section name fields using COFF_DEFAULT_LONG_SECTION_NAMES.
	(ticoff1_swap_table):  Likewise to both.

ld/ChangeLog

	* ld.texinfo:  Update to mention long section name options.
	* NEWS:  Mention new behaviour and command-line options.
	* pe-dll.c (pe_use_coff_long_section_names):  New global variable.
	(pe_output_file_set_long_section_names):  New function.
	(pe_dll_build_sections):  Call it on output BFDs.
	(pe_exe_build_sections):  Likewise.
	(pe_dll_fill_sections):  Likewise.
	(pe_exe_fill_sections):  Likewise.
	* pe-dll.h (pe_use_coff_long_section_names):  Declare extern.
	(pe_output_file_set_long_section_names):  Add prototype.
	* pep-dll.c (pe_use_coff_long_section_names):  Define pep_ alias.
	(pe_output_file_set_long_section_names):  Likewise.
	* pep-dll.h (pep_use_coff_long_section_names):  Declare extern.
	(pep_output_file_set_long_section_names):  Add prototype.
	* pe.em (OPTION_ENABLE_LONG_SECTION_NAMES):  New getopt value macro.
	(OPTION_DISABLE_LONG_SECTION_NAMES):  Likewise.
	(gld${EMULATION_NAME}_add_options):  Add new options to xtra_long[].
	(gld_${EMULATION_NAME}_list_options):  Describe them.
	(gld${EMULATION_NAME}_handle_option):  Set or clear global
	pe_use_coff_long_section_names flag when options recognised.
	(gld_${EMULATION_NAME}_after_open):  En/disable long section names
	for main output bfd by calling pe_output_file_set_long_section_names.
	* pep.em (enum options):  Extend enum with new getopt option values.
	(gld${EMULATION_NAME}_add_options):  Add new options to xtra_long[].
	(gld_${EMULATION_NAME}_list_options):  Describe them.
	(gld${EMULATION_NAME}_handle_option):  Set or clear global
	pe_use_coff_long_section_names flag when options recognised.
	(gld_${EMULATION_NAME}_after_open):  En/disable long section names
	for main output bfd by calling pep_output_file_set_long_section_names.

ld/testsuite/ChangeLog

	* ld-pe/longsecn-1.d:  New test file.
	* ld-pe/longsecn-2.d:  Likewise.
	* ld-pe/longsecn-3.d:  Likewise.
	* ld-pe/longsecn-4.d:  Likewise.
	* ld-pe/longsecn-5.d:  Likewise.
	* ld-pe/longsecn.d:  Likewise.
	* ld-pe/longsecn.exp:  New test control script.
	* ld-pe/longsecn.s:  New test source file.
2009-02-18 18:23:08 +00:00