1. 26 Aug, 2020 1 commit
  2. 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
  3. 03 Jun, 2020 1 commit
  4. 04 May, 2020 1 commit
  5. 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
  6. 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
  7. 06 Mar, 2020 2 commits
  8. 05 Mar, 2020 1 commit
  9. 04 Mar, 2020 1 commit
  10. 10 Feb, 2020 1 commit
  11. 27 Jan, 2020 1 commit
  12. 09 Jan, 2020 1 commit
  13. 01 Jan, 2020 1 commit
  14. 21 Nov, 2019 1 commit
  15. 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
  16. 07 Nov, 2019 1 commit
  17. 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
  18. 26 Oct, 2019 1 commit
  19. 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
  20. 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
  21. 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
  22. 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
  23. 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
  24. 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
  25. 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
  26. 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
  27. 05 Aug, 2019 1 commit
  28. 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
  29. 24 Apr, 2019 1 commit
  30. 04 Mar, 2019 1 commit
  31. 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
  32. 01 Jan, 2019 1 commit
  33. 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
  34. 11 Oct, 2018 1 commit
    • Nick Clifton's avatar
      Prevent the --keep-global-symbol and --globalize-symbol options from being used together. · de564eb5
      Nick Clifton authored
      This is the result of an email thread starting here:
        https://sourceware.org/ml/binutils/2018-09/msg00031.html
      
      The main point of the thread is this observation:
      
        * Supposing we had an object file with two globals, SomeGlobal and
        SomeOtherGlobal, if one were to do "--globalize-symbol SomeGlobal
        --keep-global-symbol SomeOtherGlobal", you might expect that both
        SomeGlobal and SomeOtherGlobal are global in the output file... but it
        isn't. Because --keep-global-symbol is set and doesn't include
        SomeGlobal, SomeGlobal will be demoted to a local symbol. And because
        the check to see if we should apply the --globalize-symbol flag checks
        "flags" (the original flag set), and not "sym->flags", it decides not
        to do anything, so SomeGlobal remains a local symbol. Although this is
        a weird edge case, should this be changed so that --keep-global-symbol
        implicitly keeps anything also specified via --globalize-symbol? (The
        code seems technically correct with respect to the documentation, but
        IMO the behavior is counter-intuitive).
      
      binutils* objcopy.c (copy_main): Issue a fata error if the
      	--keep-global-symbol(s) and the --globalize-symbol(s) options are
      	used together.
      	* doc/binutils.texi: Document that the two options are
      	incompatible.
      	* testsuite/binutils-all/copy-5.d: New test.
      	* testsuite/binutils-all/objcopy.exp: Run the new test.
      de564eb5
  35. 17 Sep, 2018 2 commits
    • H.J. Lu's avatar
      Free symbol buffers if they are no longer in use · d839b914
      H.J. Lu authored
      add_specific_symbols allocates a buffer to hold symbols.  It should be
      freed only if it is no longer in use.
      
      	PR binutils/23633
      	* objcopy.c (strip_specific_buffer): New.
      	(strip_unneeded_buffer): Likewise.
      	(keep_specific_buffer): Likewise.
      	(localize_specific_buffer): Likewise.
      	(globalize_specific_buffer): Likewise.
      	(keepglobal_specific_buffer): Likewise.
      	(weaken_specific_buffer): Likewise.
      	(add_specific_symbols): Add an argument to return pointer to
      	allocated buffer.
      	(copy_main): Update add_specific_symbols to update pointers to
      	allocated buffer.  Free pointers to allocated buffer before
      	return.
      d839b914
    • Alan Modra's avatar
      Support objcopy --remove-section=.relaFOO · c12d9fa2
      Alan Modra authored
      	* objcopy.c (handle_remove_section_option): Don't require a dot
      	after .rela and .rel to handle a possible relocation section.
      	* testsuite/binutils-all/remove-relocs-07.s,
      	* testsuite/binutils-all/remove-relocs-07.d,
      	* testsuite/binutils-all/remove-relocs-08.d: New tests.
      	* testsuite/binutils-all/remove-relocs-01.d,
      	* testsuite/binutils-all/remove-relocs-04.d,
      	* testsuite/binutils-all/remove-relocs-05.d,
      	* testsuite/binutils-all/remove-relocs-06.d: Exclude mips64-openbsd.
      c12d9fa2
  36. 13 Sep, 2018 1 commit