1. 07 Dec, 2020 1 commit
    • Siddhesh Poyarekar's avatar
      binutils: Use file descriptors from make_tempname · 365f5fb6
      Siddhesh Poyarekar authored
      The purpose of creating a temporary file securely using mkstemp is
      defeated if it is closed in make_tempname and reopened later for use;
      it is as good as using mktemp.  Get the file descriptor instead and
      then use it to create the BFD object.
      
      bfd/
      
      	* opncls.c (bfd_fdopenw): New function.
      	* bfd-in2.h: Regenerate.
      
      binutils/
      
      	* bucomm.c (make_tempname): Add argument to return file
      	descriptor.
      	* bucomm.h (make_tempname): Likewise.
      	* ar.c: Include libbfd.h.
      	(write_archive): Adjust for change in make_tempname.  Call
      	bfd_fdopenw instead of bfd_openw.
      	* objcopy.c: Include libbfd.h.
      	(copy_file): New argument OFD.  Use bfd_fdopenw instead of
      	bfd_openw.
      	(strip_main): Adjust for change in make_tempname and
      	copy_file.
      	(copy_main): Likewise.
      365f5fb6
  2. 29 Oct, 2020 1 commit
  3. 06 Oct, 2020 1 commit
  4. 16 Sep, 2020 1 commit
    • Alan Modra's avatar
      Tidy elf_symbol_from · c1229f84
      Alan Modra authored
      bfd/
      	* elf-bfd.h (elf_symbol_from): Remove unused ABFD parameter.
      	* elf.c (ignore_section_sym, _bfd_elf_copy_private_symbol_data),
      	(swap_out_syms): Adjust elf_symbol_from invocation.
      binutils/
      	* nm.c (print_symbol): Adjust elf_symbol_from invocation.
      	* objcopy.c (is_hidden_symbol): Likewise.
      gas/
      	* config/obj-elf.c (obj_elf_visibility, elf_frob_symbol): Adjust
      	elf_symbol_from invocation.
      	* config/tc-aarch64.c (s_variant_pcs): Likewise.
      	* config/tc-m68hc11.c (s_m68hc11_mark_symbol): Likewise.
      	* config/tc-ppc.c (ppc_elf_localentry, ppc_force_relocation),
      	(ppc_fix_adjustable): Likewise.
      	* config/tc-xgate.c (xgate_frob_symbol): Likewise.
      ld/
      	* plugin.c (asymbol_from_plugin_symbol): Adjust elf_symbol_from
      	invocation.
      opcodes/
      	* ppc-dis.c (ppc_symbol_is_valid): Adjust elf_symbol_from invocation.
      c1229f84
  5. 26 Aug, 2020 1 commit
  6. 12 Aug, 2020 1 commit
    • Alan Modra's avatar
      PR26348, Malloc error in write_zeros · 75e100a3
      Alan Modra authored
      This adds a few more sanity checks on ELF objects, and a BFD flag to
      disable objcopy and strip when fuzzed input files belong in the "too
      hard" basket.
      
      bfd/
      	PR 26348
      	* bfd.c (struct bfd): Add read_only.
      	* elfcode.h (elf_swap_shdr_in): Test both sh_offset and sh_size.
      	Set read_only on warning.
      	(elf_object_p): Sanity check program header alignment.  Set
      	read_only on warning.
      	* bfd-in2.h: Regenerate.
      binutils/
      	PR 26348
      	* objcopy.c (copy_object): Report file name with endian error.
      	Error and return on abfd->read_only.
      75e100a3
  7. 03 Jun, 2020 1 commit
  8. 04 May, 2020 1 commit
  9. 30 Mar, 2020 1 commit
    • Nick Clifton's avatar
      Fix objcopy's --preserve-dates command line option so that it will work with PE format files. · 00386881
      Nick Clifton authored
      	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.
      00386881
  10. 11 Mar, 2020 1 commit
    • Alan Modra's avatar
      PR25651, objcopy SIGSEGV in copy_object · 9cc89dc0
      Alan Modra authored
      With the right set of options, the second block of code dealing with
      padding can see a different section count.  So don't use the new count.
      Since I was editing those lines, I've also changed the code allocating
      arrays a little.
          array = malloc (n * sizeof (*array));
      for an array of ints is just better than
          array = malloc (n * sizeof (int));
      It's easier to write correctly in the first place and more robust
      against code changes that might modify the array element type.
      
      	PR 25651
      	* objcopy.c (copy_object): Test "gaps" not gap_fill_set or
      	pad_to_set on second block of code dealing with padding.
      	Replace "c" with "num_sec" and don't recalculate number of
      	sections on second block.  Size arrays using sizeof (element)
      	rather than sizeof (element type).
      9cc89dc0
  11. 06 Mar, 2020 2 commits
  12. 05 Mar, 2020 1 commit
  13. 04 Mar, 2020 1 commit
  14. 10 Feb, 2020 1 commit
  15. 27 Jan, 2020 1 commit
  16. 09 Jan, 2020 1 commit
  17. 01 Jan, 2020 1 commit
  18. 21 Nov, 2019 1 commit
  19. 19 Nov, 2019 3 commits
    • Alan Modra's avatar
      PR24499, ignore --add-gnu-debuglink for archives · f2032b67
      Alan Modra authored
      objcopy --add-gnu-debuglink=foo.a.dbg foo.a just doesn't make any
      sense.  Who puts executables in archives?
      
      	PR 24499
      	* objcopy.c (copy_file): Ignore --add-gnu-debuglink for archives.
      f2032b67
    • Alan Modra's avatar
      PR24968, make objcopy use output ELF arch if -B not given · 6765ee18
      Alan Modra authored
      This should make objcopy -B redundant for the common case of producing
      ELF output where the -O target defaults to the desired arch:mach.
      
      	PR 24968
      	* objcopy.c (copy_object): For ELF output and non-ELF input without
      	arch, take arch from output file if not given by -B.  Don't
      	bfd_get_arch_info when we already have iarch.
      6765ee18
    • Alan Modra's avatar
      PR25191, internal error in _bfd_elf_set_section_contents · dd68a12b
      Alan Modra authored
      This PR copies a fuzzed PE input file to ELF output, in the process
      confusing the ELF backend by copying COFF-only section flags to the
      output.  SEC_COFF_SHARED has the same value as SEC_ELF_COMPRESS.  One
      approach to fixing this problem is of course not to reuse flag bits,
      but we've run out.  So this patch only copies section flags that are
      in the bfd_applicable_section_flags set when changing the flavour of
      the output file.
      
      	PR 25191
      	* objcopy.c (is_nondebug_keep_contents_section): Use bfd_get_flavour.
      	(copy_object): Likewise.
      	(setup_section): Likewise.  If flavour of input and output files
      	differ, restrict section flags to the intersection of input and
      	output bfd_applicable_section_flags.
      dd68a12b
  20. 07 Nov, 2019 1 commit
  21. 04 Nov, 2019 1 commit
    • Fāng-ruì Sòng's avatar
      Implement objcopy/strip --keep-section=<sectionpattern> · 64f52b3e
      Fāng-ruì Sòng authored
      llvm-objcopy and llvm-strip support an option --keep-section that
      keeps some sections from being removed.
      
      	* objcopy.c (enum option_values): Add OPTION_KEEP_SECTION.
      	(SECTION_CONTEXT_KEEP): Define.  Adjust other SECTION_CONTEXT macros.
      	(copy_usage): Describe --keep-section.
      	(strip_usage): Likewise.
      	(copy_main): Handle SECTION_CONTEXT_KEEP.
      	(strip_main): Likewise.
      	(is_strip_section_1): Likewise.
      	* testsuite/binutils-all/objcopy.exp: Add tests.
      	* testsuite/binutils-all/keep-section-1.d: New test driver file.
      	* testsuite/binutils-all/keep-section-2.d: Likewise.
      	* doc/binutils.texi: Document the new feature.
      	* NEWS: Mention the new feature.
      64f52b3e
  22. 26 Oct, 2019 1 commit
  23. 25 Oct, 2019 1 commit
    • Nick Clifton's avatar
      Improve objcopy's note mergeing capabilities. · 5c49f2cd
      Nick Clifton authored
      	* objcopy.c (struct merged_note_section): New structure.  Used to
      	chain together details of mergeable note sections.
      	(is_merged_note_section): Rename to is_megreable_note_section and
      	return true for note sections that use GNU_BUILD_ATTRS_SECTION_NAME
      	as a prefix.
      	(num_bytes): Delete
      	(objcoopy_internal_note): Add padded_namesz field.
      	(DEBUG_MERGE): New macro.  Set to non-zero to enable debugging of
      	the note merging code.
      	(gap_exists): Rename to overlaps_or_adjoins and return TRUE for
      	overlapping notes or adjoining notes.
      	(contained_by, is_deleted_note, is_version_note)
      	(compare_gnu_build_notes, sort_gnu_build_notes): New functions.
      	(merge_gnu_build_notes):  Rework.  Sort notes into a mergeable
      	order first.  Merge them.  Then sort them into an ascending
      	address order before writing them out.
      	(copy_object): Handle more than one mergeable note section.
      	* testsuite/binutils-all/note-2-32.d: Update for new merging
      	behaviour.
      	* testsuite/binutils-all/note-2-32.s: Likewise.
      	* testsuite/binutils-all/note-2-64.d: Likewise.
      	* testsuite/binutils-all/note-2-64.s: Likewise.
      	* testsuite/binutils-all/note-3-32.d: Likewise.
      	* testsuite/binutils-all/note-3-32.s: Likewise.
      	* testsuite/binutils-all/note-3-64.d: Likewise.
      	* testsuite/binutils-all/note-3-64.s: Likewise.
      	* testsuite/binutils-all/note-4-32.d: Likewise.
      	* testsuite/binutils-all/note-4-32.s: Likewise.
      	* testsuite/binutils-all/note-4-64.d: Likewise.
      	* testsuite/binutils-all/note-4-64.s: Likewise.
      	* testsuite/binutils-all/note-6-32.s: New test source file.
      	* testsuite/binutils-all/note-6-64.s: New test source file.
      	* testsuite/binutils-all/note-6-32.d: New test driver file.
      	* testsuite/binutils-all/note-6-64.d: New test driver file.
      	* testsuite/binutils-all/objcopy.exp: Run the new test.
      5c49f2cd
  24. 14 Oct, 2019 1 commit
    • Alan Modra's avatar
      qsort: objcopy.c section sort · 6ce9ba7a
      Alan Modra authored
      	* objcopy.c (compare_section_lma): Correct comment.  Dereference
      	section pointer earlier and lose unnecessary const.  Style fixes.
      	Add final sort by id.
      6ce9ba7a
  25. 02 Oct, 2019 1 commit
    • Nick Clifton's avatar
      Change objcopy's --set-section-alignment option to take a byte alignment value... · de4859ea
      Nick Clifton authored
      Change objcopy's --set-section-alignment option to take a byte alignment value rather than a power of two alignment value.
      
      	PR 24942
      	* objcopy.c (copy_usage): Update description of
      	--set-section-alignment.
      	(copy_main): Interpret numeric argument of --set-section-alignment
      	as a byte alignment, not a power of two alignment.
      	* doc/binutils.texi: Update description of
      	--set-section-alignment.
      	* testsuite/binutils-all/set-section-alignment.d: New test.
      	* testsuite/binutils-all/objcopy.exp: Run the new test.
      de4859ea
  26. 19 Sep, 2019 1 commit
    • Alan Modra's avatar
      bfd_section_* macros · fd361982
      Alan Modra authored
      This large patch removes the unnecessary bfd parameter from various
      bfd section macros and functions.  The bfd is hardly ever used and if
      needed for the bfd_set_section_* or bfd_rename_section functions can
      be found via section->owner except for the com, und, abs, and ind
      std_section special sections.  Those sections shouldn't be modified
      anyway.
      
      The patch also removes various bfd_get_section_<field> macros,
      replacing their use with bfd_section_<field>, and adds
      bfd_set_section_lma.  I've also fixed a minor bug in gas where
      compressed section renaming was done directly rather than calling
      bfd_rename_section.  This would have broken bfd_get_section_by_name
      and similar functions, but that hardly mattered at such a late stage
      in gas processing.
      
      bfd/
      	* bfd-in.h (bfd_get_section_name, bfd_get_section_vma),
      	(bfd_get_section_lma, bfd_get_section_alignment),
      	(bfd_get_section_size, bfd_get_section_flags),
      	(bfd_get_section_userdata): Delete.
      	(bfd_section_name, bfd_section_size, bfd_section_vma),
      	(bfd_section_lma, bfd_section_alignment): Lose bfd parameter.
      	(bfd_section_flags, bfd_section_userdata): New.
      	(bfd_is_com_section): Rename parameter.
      	* section.c (bfd_set_section_userdata, bfd_set_section_vma),
      	(bfd_set_section_alignment, bfd_set_section_flags, bfd_rename_section),
      	(bfd_set_section_size): Delete bfd parameter, rename section parameter.
      	(bfd_set_section_lma): New.
      	* bfd-in2.h: Regenerate.
      	* mach-o.c (bfd_mach_o_init_section_from_mach_o): Delete bfd param,
      	update callers.
      	* aoutx.h, * bfd.c, * coff-alpha.c, * coff-arm.c, * coff-mips.c,
      	* coff64-rs6000.c, * coffcode.h, * coffgen.c, * cofflink.c,
      	* compress.c, * ecoff.c, * elf-eh-frame.c, * elf-hppa.h,
      	* elf-ifunc.c, * elf-m10200.c, * elf-m10300.c, * elf-properties.c,
      	* elf-s390-common.c, * elf-vxworks.c, * elf.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-csky.c,
      	* elf32-d10v.c, * elf32-epiphany.c, * elf32-fr30.c, * elf32-frv.c,
      	* elf32-ft32.c, * elf32-h8300.c, * elf32-hppa.c, * elf32-i386.c,
      	* elf32-ip2k.c, * elf32-iq2000.c, * elf32-lm32.c, * elf32-m32c.c,
      	* elf32-m32r.c, * elf32-m68hc1x.c, * elf32-m68k.c, * elf32-mcore.c,
      	* elf32-mep.c, * elf32-metag.c, * elf32-microblaze.c,
      	* elf32-moxie.c, * elf32-msp430.c, * elf32-mt.c, * elf32-nds32.c,
      	* elf32-nios2.c, * elf32-or1k.c, * elf32-ppc.c, * elf32-pru.c,
      	* elf32-rl78.c, * elf32-rx.c, * elf32-s390.c, * elf32-score.c,
      	* elf32-score7.c, * elf32-sh.c, * elf32-spu.c, * elf32-tic6x.c,
      	* elf32-tilepro.c, * elf32-v850.c, * elf32-vax.c, * elf32-visium.c,
      	* elf32-xstormy16.c, * elf32-xtensa.c, * elf64-alpha.c,
      	* elf64-bpf.c, * elf64-hppa.c, * elf64-ia64-vms.c, * elf64-mmix.c,
      	* elf64-ppc.c, * elf64-s390.c, * elf64-sparc.c, * elf64-x86-64.c,
      	* elflink.c, * elfnn-aarch64.c, * elfnn-ia64.c, * elfnn-riscv.c,
      	* elfxx-aarch64.c, * elfxx-mips.c, * elfxx-sparc.c,
      	* elfxx-tilegx.c, * elfxx-x86.c, * i386msdos.c, * linker.c,
      	* mach-o.c, * mmo.c, * opncls.c, * pdp11.c, * pei-x86_64.c,
      	* peicode.h, * reloc.c, * section.c, * syms.c, * vms-alpha.c,
      	* xcofflink.c: Update throughout for bfd section macro and function
      	changes.
      binutils/
      	* addr2line.c, * bucomm.c, * coffgrok.c, * dlltool.c, * nm.c,
      	* objcopy.c, * objdump.c, * od-elf32_avr.c, * od-macho.c,
      	* od-xcoff.c, * prdbg.c, * rdcoff.c, * rddbg.c, * rescoff.c,
      	* resres.c, * size.c, * srconv.c, * strings.c, * windmc.c: Update
      	throughout for bfd section macro and function changes.
      gas/
      	* as.c, * as.h, * dw2gencfi.c, * dwarf2dbg.c, * ecoff.c,
      	* read.c, * stabs.c, * subsegs.c, * subsegs.h, * write.c,
      	* config/obj-coff-seh.c, * config/obj-coff.c, * config/obj-ecoff.c,
      	* config/obj-elf.c, * config/obj-macho.c, * config/obj-som.c,
      	* config/tc-aarch64.c, * config/tc-alpha.c, * config/tc-arc.c,
      	* config/tc-arm.c, * config/tc-avr.c, * config/tc-bfin.c,
      	* config/tc-bpf.c, * config/tc-d10v.c, * config/tc-d30v.c,
      	* config/tc-epiphany.c, * config/tc-fr30.c, * config/tc-frv.c,
      	* config/tc-h8300.c, * config/tc-hppa.c, * config/tc-i386.c,
      	* config/tc-ia64.c, * config/tc-ip2k.c, * config/tc-iq2000.c,
      	* config/tc-lm32.c, * config/tc-m32c.c, * config/tc-m32r.c,
      	* config/tc-m68hc11.c, * config/tc-mep.c, * config/tc-microblaze.c,
      	* config/tc-mips.c, * config/tc-mmix.c, * config/tc-mn10200.c,
      	* config/tc-mn10300.c, * config/tc-msp430.c, * config/tc-mt.c,
      	* config/tc-nds32.c, * config/tc-or1k.c, * config/tc-ppc.c,
      	* config/tc-pru.c, * config/tc-rl78.c, * config/tc-rx.c,
      	* config/tc-s12z.c, * config/tc-s390.c, * config/tc-score.c,
      	* config/tc-score7.c, * config/tc-sh.c, * config/tc-sparc.c,
      	* config/tc-spu.c, * config/tc-tic4x.c, * config/tc-tic54x.c,
      	* config/tc-tic6x.c, * config/tc-tilegx.c, * config/tc-tilepro.c,
      	* config/tc-v850.c, * config/tc-visium.c, * config/tc-wasm32.c,
      	* config/tc-xc16x.c, * config/tc-xgate.c, * config/tc-xstormy16.c,
      	* config/tc-xtensa.c, * config/tc-z8k.c: Update throughout for
      	bfd section macro and function changes.
      	* write.c (compress_debug): Use bfd_rename_section.
      gdb/
      	* aarch64-linux-tdep.c, * arm-tdep.c, * auto-load.c,
      	* coff-pe-read.c, * coffread.c, * corelow.c, * dbxread.c,
      	* dicos-tdep.c, * dwarf2-frame.c, * dwarf2read.c, * elfread.c,
      	* exec.c, * fbsd-tdep.c, * gcore.c, * gdb_bfd.c, * gdb_bfd.h,
      	* hppa-tdep.c, * i386-cygwin-tdep.c, * i386-fbsd-tdep.c,
      	* i386-linux-tdep.c, * jit.c, * linux-tdep.c, * machoread.c,
      	* maint.c, * mdebugread.c, * minidebug.c, * mips-linux-tdep.c,
      	* mips-sde-tdep.c, * mips-tdep.c, * mipsread.c, * nto-tdep.c,
      	* objfiles.c, * objfiles.h, * osabi.c, * ppc-linux-tdep.c,
      	* ppc64-tdep.c, * record-btrace.c, * record-full.c, * remote.c,
      	* rs6000-aix-tdep.c, * rs6000-tdep.c, * s390-linux-tdep.c,
      	* s390-tdep.c, * solib-aix.c, * solib-dsbt.c, * solib-frv.c,
      	* solib-spu.c, * solib-svr4.c, * solib-target.c,
      	* spu-linux-nat.c, * spu-tdep.c, * symfile-mem.c, * symfile.c,
      	* symmisc.c, * symtab.c, * target.c, * windows-nat.c,
      	* xcoffread.c, * cli/cli-dump.c, * compile/compile-object-load.c,
      	* mi/mi-interp.c: Update throughout for bfd section macro and
      	function changes.
      	* gcore (gcore_create_callback): Use bfd_set_section_lma.
      	* spu-tdep.c (spu_overlay_new_objfile): Likewise.
      gprof/
      	* corefile.c, * symtab.c: Update throughout for bfd section
      	macro and function changes.
      ld/
      	* ldcref.c, * ldctor.c, * ldelf.c, * ldlang.c, * pe-dll.c,
      	* emultempl/aarch64elf.em, * emultempl/aix.em,
      	* emultempl/armcoff.em, * emultempl/armelf.em,
      	* emultempl/cr16elf.em, * emultempl/cskyelf.em,
      	* emultempl/m68hc1xelf.em, * emultempl/m68kelf.em,
      	* emultempl/mipself.em, * emultempl/mmix-elfnmmo.em,
      	* emultempl/mmo.em, * emultempl/msp430.em,
      	* emultempl/nios2elf.em, * emultempl/pe.em, * emultempl/pep.em,
      	* emultempl/ppc64elf.em, * emultempl/xtensaelf.em: Update
      	throughout for bfd section macro and function changes.
      libctf/
      	* ctf-open-bfd.c: Update throughout for bfd section macro changes.
      opcodes/
      	* arc-ext.c: Update throughout for bfd section macro changes.
      sim/
      	* common/sim-load.c, * common/sim-utils.c, * cris/sim-if.c,
      	* erc32/func.c, * lm32/sim-if.c, * m32c/load.c, * m32c/trace.c,
      	* m68hc11/interp.c, * ppc/hw_htab.c, * ppc/hw_init.c,
      	* rl78/load.c, * rl78/trace.c, * rx/gdb-if.c, * rx/load.c,
      	* rx/trace.c: Update throughout for bfd section macro changes.
      fd361982
  27. 18 Sep, 2019 1 commit
    • Alan Modra's avatar
      bfd_asymbol_* macros · e6f7f6d1
      Alan Modra authored
      The main point of this patch is to give bfd_get_section a better name,
      bfd_asymbol_section.
      
      bfd/
      	* bfd-in.h (bfd_asymbol_section): Rename from bfd_get_section.
      	(bfd_get_output_section): Delete.
      	(bfd_asymbol_base): Delete.
      	(bfd_asymbol_section, bfd_asymbol_value, bfd_asymbol_name),
      	(bfd_asymbol_bfd, bfd_asymbol_flavour): Tidy.
      	(bfd_set_asymbol_name): New macro.
      	* bfd-in2.h: Regenerate.
      	* aout-cris.c: Update throughout to use bfd_asymbol_section.
      	* aoutx.h: Likewise.
      	* cofflink.c: Likewise.
      	* dwarf2.c: Likewise.
      	* ecoff.c: Likewise.
      	* elf.c: Likewise.
      	* elf32-arm.c: Likewise.
      	* elf32-mips.c: Likewise.
      	* elf32-score.c: Likewise.
      	* elf32-score7.c: Likewise.
      	* elfn32-mips.c: Likewise.
      	* elfnn-aarch64.c: Likewise.
      	* elfxx-mips.c: Likewise.
      	* linker.c: Likewise.
      	* pdp11.c: Likewise.
      	* elf64-mmix.c (mmix_elf_reloc): Expand bfd_get_output_section.
      binutils/
      	* nm.c: Update bfd_get_section to bfd_asymbol_section throughout.
      	* objcopy.c: Likewise.
      	* objdump.c: Likewise.
      	* rdcoff.c: Likewise.
      	* objcopy.c (create_new_symbol): Use bfd_set_asymbol_name.
      	(filter_symbols): Likewise.
      gas/
      	* symbols.c (S_IS_LOCAL): Update bfd_get_section to
      	bfd_asymbol_section.
      gdb/
      	* arm-tdep.c (arm_record_special_symbol): Update bfd_get_section
      	to bfd_asymbol_section.
      ld/
      	* ldcref.c (check_reloc_refs): Update bfd_get_section to
      	bfd_asymbol_section.
      e6f7f6d1
  28. 11 Sep, 2019 1 commit
    • Tom Tromey's avatar
      Constify argument to make_tempname and make_tempdir · 1ff5d5c4
      Tom Tromey authored
      This constifies the argument to make_tempname and make_tempdir,
      removing some casts.
      
      I initially thought that this obsoleted the allocation in
      write_archive, but write_archive closes the BFD before using the name,
      so this appears not to be the case.
      
      binutils/ChangeLog
      2019-09-11  Tom Tromey  <tom@tromey.com>
      
      	* objcopy.c (copy_archive): Update.
      	* bucomm.h (make_tempname, make_tempdir): Make argument const.
      	* bucomm.c (make_tempname, make_tempdir): Make argument const.
      1ff5d5c4
  29. 06 Sep, 2019 1 commit
    • Alan Modra's avatar
      bfd_get_filename · b16c44de
      Alan Modra authored
      This macro says:
      /* Cast from const char * to char * so that caller can assign to
         a char * without a warning.  */
      
      I reckon that isn't such a good idea since it can result in char*
      variables where const char* is appropriate.  Not very many places
      need the char* cast.
      
      bfd/
      	* aout-target.h (object_p): Formatting.
      	* bfd-in.h (bfd_get_filename): Don't cast to char*.
      	* corefile.c (generic_core_file_matches_executable_p): Constify
      	variables and remove cast.
      	* bfd-in2.h: Regenerate.
      binutils/
      	* nm.c (print_object_filename_bsd, print_object_filename_sysv),
      	(print_object_filename_posix, print_archive_filename_bsd),
      	(print_archive_filename_sysv, print_archive_filename_posix),
      	(print_archive_member_bsd, print_archive_member_sysv),
      	(print_archive_member_posix): Constify parameter.
      	(struct output_fns <print_object_filename, print_archive_filename>),
      	(<print_archive_member>): Likewise.
      	* objcopy.c (copy_archive): Add cast for make_tempdir.
      ld/
      	* emultempl/elf32.em (gld${EMULATION_NAME}_search_needed): Constify
      	variable.
      	* emultempl/pe.em (gld_${EMULATION_NAME}_after_open): Likewise.
      	* emultempl/pep.em (gld_${EMULATION_NAME}_after_open): Likewise.
      gdb/
      	* coffread.c (coff_symfile_read): Constify filename variable.
      	* dbxread.c (dbx_symfile_init, coffstab_build_psymtabs),
      	(elfstab_build_psymtabs, stabsect_build_psymtabs): Likewise.
      	* gdb_bfd.c (gdb_bfd_close_or_warn): Likewise.
      	* solib.c (reload_shared_libraries_1): Likewise.
      	* symfile.c (reread_symbols): Likewise.
      	* solib-aix.c (solib_aix_bfd_open): Add cast for xfree of filename.
      	* solib-darwin.c (darwin_bfd_open): Likewise.
      	* symfile-mem.c (symbol_file_add_from_memory): Likewise.
      sim/cris/
      	* sim-if.c (sim_open): Constify filename variable.
      b16c44de
  30. 28 Aug, 2019 1 commit
    • Niklas G?rtler's avatar
      Add an option to objcopy to change the alignment of sections. · fa463e9f
      Niklas G?rtler authored
      	PR 24942
      	* objcopy.c (SECTION_CONTEXT_SET_ALIGNMENT): New constant.
      	(struct section_list): Add alignment field.
      	(command_line_switch): Add OPTION_SET_SECTION_ALIGNMENT.
      	(copy_options): Add --set-section-alignment.
      	(copy_usage): Describe --set-section-alignment.
      	(find_section_list): Initialise the alignment field.
      	(setup_section): Handle the alignment field.
      	(copy_main): Handle OPTION_SET_SECTION_ALIGNMENT.
      	* doc/binutils.texi: Document the new feature.
      	* NEWS: Mention the new feature.
      fa463e9f
  31. 05 Aug, 2019 1 commit
  32. 14 May, 2019 1 commit
    • Jamey Hicks's avatar
      Add new option to objcopy: --verilog-data-width. Use this option to set the... · 37d0d091
      Jamey Hicks authored
      Add new option to objcopy: --verilog-data-width.  Use this option to set the size of byte bundles generated in verilog format files.
      
      	PR 19921
      binutils* objcopy.c: Add new option --verilog-data-width.  Use it to set
      	the value of VerilogDataWidth.
      	* doc/binutils.texi: Document the new option.
      	* testsuite/binutils-all/objcopy.exp: Run tests of new option.
      	* testsuite/binutils-all/verilog-1.hex: New file.
      	* testsuite/binutils-all/verilog-2.hex: New file.
      	* testsuite/binutils-all/verilog-4.hex: New file.
      	* testsuite/binutils-all/verilog-8.hex: New file.
      	* NEWS: Mention the new feature.
      
      bfd	* verilog.c: (VerilogDataWidth): New variable.
      	(verilog_write_record): Emit bytes in VerilogDataWidth bundles.
      37d0d091
  33. 24 Apr, 2019 1 commit
  34. 04 Mar, 2019 1 commit
  35. 04 Jan, 2019 1 commit
    • Nick Clifton's avatar
      Fix ridiculously small memory leak. · cf0ad5bb
      Nick Clifton authored
      	PR 24001
      	* objcopy.c (copy_object): Free dhandle after writing out the
      	debug information.
      	* objdump.c (dump_bfd): Free dhandle after printing out the debug
      	information.
      cf0ad5bb
  36. 01 Jan, 2019 1 commit
  37. 15 Oct, 2018 1 commit
    • Alan Modra's avatar
      BFD_INIT_MAGIC · bf2dd8d7
      Alan Modra authored
      This patch performs a run-time test that a shared libbfd.so has been
      compiled with the same size bfd_vma as that of apps using the library.
      On a 32-bit host it is easily possible to have one libbfd.so compiled
      to support 64-bit targets (or configured with --enable-64-bit-bfd)
      while another only supports 32-bit targets.  The two libraries will
      have differently sized bfd_vma types, and if the wrong one is loaded
      all sorts of weird behaviour might be seen.
      
      bfd/
      	PR 23534
      	* init.c (BFD_INIT_MAGIC): Define.
      	(bfd_init): Return BFD_INIT_MAGIC.
      	bfd-in2.h: Regenerate.
      binutils/
      	PR 23534
      	* addr2line.c (main): Exit with fatal error if bfd_init
      	returns an unexpected value.
      	* ar.c (main): Likewise.
      	* dlltool.c (identify_dll_for_implib): Likewise.
      	* nm.c (main): Likewise.
      	* objcopy.c (main): Likewise.
      	* objdump.c (main): Likewise.
      	* size.c (main): Likewise.
      	* strings.c (main): Likewise.
      	* windmc.c (main): Likewise.
      	* windres.c (main): Likewise.
      gas/
      	PR 23534
      	* as.c (main): Exit with fatal error if bfd_init returns an
      	unexpected value.
      ld/
      	PR 23534
      	* ldmain.c (main): Exit with fatal error if bfd_init returns
      	an unexpected value.
      bf2dd8d7