1. 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
  2. 05 Aug, 2019 1 commit
  3. 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
  4. 24 Apr, 2019 1 commit
  5. 04 Mar, 2019 1 commit
  6. 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
  7. 01 Jan, 2019 1 commit
  8. 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
  9. 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
  10. 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
  11. 13 Sep, 2018 1 commit
  12. 10 Sep, 2018 1 commit
    • Alan Modra's avatar
      PR23611, objcopy is not removing executable relocatable sections · f9853190
      Alan Modra authored
      BFD handles ELF relocation sections in an executable differently to
      relocation sections in a relocatable object.  For a relocatable
      object, BFD carries the relocations as data associated with the
      section to which they apply; The relocation section doesn't appear as
      a separate section.  For an executable, dynamic relocation sections do
      appear as separate sections.  This means that objcopy needs to use
      different strategies when dealing with relocations.
      
      When --remove-relocations was added to objcopy with commit
      d3e5f6c8, objcopy lost the ability to remove dynamic relocation
      sections such as .rela.plt from executables using the option
      "--remove-section=.rela.plt".  This patch reinstates that
      functionality.
      
      I thought it best to keep --remove-relocations as is, rather than
      extending to handle dynamic relocations as per the patch in the PR,
      because executables linked with --emit-relocs may have both dynamic
      and non-dynamic relocations.  In that case --remove-relocataions=* is
      useful to remove all the non-dynamic relocations.
      
      	PR binutils/23611
      	* objcopy.c (handle_remove_section_option): Consider .rela and
      	.rel sections for stripping directly as well as attached to the
      	associated section they relocate.
      	* doc/binutils.texi (remove-relocations): Specify that this
      	option removes non-dynamic relocation sections.
      	* testsuite/binutils-all/objcopy.exp
      	(objcopy_remove_relocations_from_executable): New test.
      f9853190
  13. 03 Aug, 2018 1 commit
  14. 24 Jul, 2018 1 commit
  15. 20 Jul, 2018 1 commit
    • Nick Clifton's avatar
      Close memory and resource leaks detected by coverity in the binutils directory. · 3391569f
      Nick Clifton authored
      	* objcopy.c (add_specific_symbols): Free buffer on exit.
      	(add_redefine_syms_file): Close file handle on exit.
      	(copy_object): Close file handle on early exit.
      	Free buffer on early exit.
      	Free gaps buffers once they are no longer needed.
      	* dwarf.c (display_debug_frames): Free allocated memory on exit.
      	(load_separate_debug_info): Free allocate memory on early exit.
      3391569f
  16. 08 May, 2018 1 commit
    • Alan Modra's avatar
      PR23141, SIGSEGV in bfd_elf_set_group_contents · 886d5428
      Alan Modra authored
      Another fuzzing fix.  I think it's reasonable to simply strip out any
      group section that is too weird for objcopy to handle.
      
      	PR 23141
      	* objcopy.c (is_strip_section): Strip groups without a valid
      	signature symbol.
      886d5428
  17. 07 May, 2018 1 commit
  18. 16 Apr, 2018 1 commit
    • Alan Modra's avatar
      Remove IEEE 695 object support · fdef3943
      Alan Modra authored
      include/
      	* ieee.h: Delete.
      bfd/
      	* Makefile.am: Remove IEEE 695 support.
      	* archures.c: Likewise.
      	* bfd.c: Likewise.
      	* config.bfd: Likewise.
      	* configure.ac: Likewise.
      	* doc/bfd.texinfo: Likewise.
      	* doc/bfdint.texi: Likewise.
      	* doc/bfdsumm.texi: Likewise.
      	* section.c: Likewise.
      	* targets.c: Likewise.
      	* ieee.c: Delete.
      	* libieee.h: Delete.
      	* Makefile.in: Regenerate.
      	* bfd-in2.h: Regenerate.
      	* configure: Regenerate.
      	* po/SRC-POTFILES.in: Regenerate.
      binutils/
      	* Makefile.am: Remove IEEE 695 support.
      	* budbg.h: Likewise.
      	* doc/binutils.texi: Likewise.
      	* makefile.vms: Likewise.
      	* objcopy.c: Likewise.
      	* objdump.c: Likewise.
      	* rddbg.c: Likewise.
      	* ieee.c: Delete.
      	* Makefile.in: Regenerate.
      	* po/POTFILES.in: Regenerate.
      gas/
      	* app.c: Remove IEEE 695 support.
      	* symbols.c: Likewise.
      ld/
      	* ld.texinfo: Remove IEEE 695 support.
      	* mri.c: Likewise.
      fdef3943
  19. 27 Feb, 2018 1 commit
    • Nick Clifton's avatar
      Have info_to_howto functions return a success/fail status. Check this result.... · f3185997
      Nick Clifton authored
      Have info_to_howto functions return a success/fail status.  Check this result.  Stop strip from completeing if one of these functions fails.
      
      bfd	PR 22875
      	* elf-bfd.h (struct elf_backend_data): Change the return type of
      	the elf_info_to_howto and elf_info_to_howto_rel function pointers
      	to bfd_boolean.
      	* elfcode.h (elf_slurp_reloc_table_from_section): Check the return value from the info_to_howto function and fail if that function failed.
      	* elf32-h8300.c (elf32_h8_relocate_section): Check return value from the info_to_howto function.
      	(elf32_h8_relax_section): Likewise.
      	* elf32-lm32.c (lm32_elf_relocate_section): Likewise.
      	* elf32-m68hc1x.c (elf32_m68hc11_relocate_section): Likewise.
      	* elf32-score.c (s3_bfd_score_elf_relocate_section): Likewise.
      	* elf32-score7.c (s7_bfd_score_elf_relocate_section): Likewise.
      	* elf32-tic6x.c (elf32_tic6x_relocate_section): Likewise.
      	* elf64-ia64-vms.c (elf64_ia64_relocate_section): Likewise.
      	* elf64-sparc.c (elf64_sparc_slurp_one_reloc_table): Likewise.
      	* elf64-x86-64.c (elf_x86_64_tls_transition): Likewise.
      	* elfnn-ia64.c (elfNN_ia64_relocate_section): Likewise.
      	* elfnn-riscv.c (riscv_elf_check_relocs): Likewise.
      	(riscv_elf_relocate_section): Likewise.
      	* elf-hppa.h (elf_hppa_info_to_howto): Change return type to
      	bfd_boolean.  Issue an error message, set an error value and
      	return FALSE if the reloc is not recognized.
      	(elf_hppa_info_to_howto_rel): Likewise.
      	* elf-m10200.c (mn10200_info_to_howto): Likewise.
      	* elf-m10300.c (mn10300_info_to_howto): Likewise.
      	* elf.c (_bfd_elf_no_info_to_howto): Likewise.
      	* elf32-arc.c (arc_info_to_howto_rel): Likewise.
      	* elf32-arm.c (elf32_arm_info_to_howto): Likewise.
      	* elf32-avr.c (avr_info_to_howto_rela): Likewise.
      	* elf32-bfin.c (bfin_info_to_howto): Likewise.
      	* elf32-cr16.c (elf_cr16_info_to_howto): Likewise.
      	* elf32-cr16c.c (elf_cr16c_info_to_howto): Likewise.
      	* elf32-cris.c (elf_cr16c_info_to_howto_rel, cris_info_to_howto_rela): Likewise.
      	* elf32-crx.c (elf_crx_info_to_howto): Likewise.
      	* elf32-d10v.c (d10v_info_to_howto_rel): Likewise.
      	* elf32-d30v.c (d30v_info_to_howto_rel, d30v_info_to_howto_rela): Likewise.
      	* elf32-dlx.c (dlx_rtype_to_howto, elf32_dlx_info_to_howto, elf32_dlx_info_to_howto_rel): Likewise.
      	* elf32-epiphany.c (epiphany_info_to_howto_rela): Likewise.
      	* elf32-fr30.c (fr30_info_to_howto_rela): Likewise.
      	* elf32-frv.c (frv_info_to_howto_rela, 	frvfdpic_info_to_howto_rel): Likewise.
      	* elf32-ft32.c (ft32_info_to_howto_rela): Likewise.
      	* elf32-gen.c (elf_generic_info_to_howto, elf_generic_info_to_howto_rel): Likewise.
      	* elf32-h8300.c (elf32_h8_info_to_howto, elf32_h8_info_to_howto_rel): Likewise.
      	* elf32-i370.c (i370_elf_info_to_howto): Likewise.
      	* elf32-i386.c (elf_i386_reloc_type_lookup, elf_i386_rtype_to_howto, elf_i386_info_to_howto_rel): Likewise.
      	* elf32-i860.c (lookup_howto, elf32_i860_info_to_howto_rela): Likewise.
      	* elf32-i960.c (elf32_i960_info_to_howto_rel): Likewise.
      	* elf32-ip2k.c (ip2k_info_to_howto_rela): Likewise.
      	* elf32-iq2000.c (iq2000_info_to_howto_rela): Likewise.
      	* elf32-lm32.c (lm32_info_to_howto_rela): Likewise.
      	* elf32-m32c.c (m32c_info_to_howto_rela): Likewise.
      	* elf32-m32r.c (m32r_info_to_howto_rel, m32r_info_to_howto): Likewise.
      	* elf32-m68hc11.c (m68hc11_info_to_howto_rel): Likewise.
      	* elf32-m68hc12.c (m68hc11_info_to_howto_rel): Likewise.
      	* elf32-m68k.c (rtype_to_howto): Likewise.
      	* elf32-mcore.c (mcore_elf_info_to_howto): Likewise.
      	* elf32-mep.c (mep_info_to_howto_rela): Likewise.
      	* elf32-metag.c (metag_info_to_howto_rela): Likewise.
      	* elf32-microblaze.c (microblaze_elf_info_to_howto): Likewise.
      	* elf32-mips.c (mips_info_to_howto_rel, mips_info_to_howto_rela): Likewise.
      	* elf32-moxie.c (moxie_info_to_howto_rela): Likewise.
      	* elf32-msp430.c (msp430_info_to_howto_rela): Likewise.
      	* elf32-mt.c (mt_info_to_howto_rela): Likewise.
      	* elf32-nds32.c (nds32_info_to_howto_rel, nds32_info_to_howto): Likewise.
      	* elf32-nios2.c (nios2_elf32_info_to_howto): Likewise.
      	* elf32-or1k.c (or1k_info_to_howto_rela): Likewise.
      	* elf32-pj.c (pj_elf_info_to_howto): Likewise.
      	* elf32-ppc.c (ppc_elf_info_to_howto): Likewise.
      	* elf32-pru.c (pru_elf32_info_to_howto): Likewise.
      	* elf32-rl78.c (rl78_info_to_howto_rela): Likewise.
      	* elf32-rx.c (rx_info_to_howto_rela): Likewise.
      	* elf32-s390.c (elf_s390_info_to_howto): Likewise.
      	* elf32-score.c (s3_bfd_score_info_to_howto, _bfd_score_info_to_howto): Likewise.
      	* elf32-score7.c (s7_bfd_score_info_to_howto): Likewise.
      	* elf32-sh.c (sh_elf_info_to_howto): Likewise.
      	* elf32-spu.c (spu_elf_info_to_howto): Likewise.
      	* elf32-tic6x.c (elf32_tic6x_info_to_howto, elf32_tic6x_info_to_howto_rel): Likewise.
      	* elf32-tilepro.c (tilepro_info_to_howto_rela): Likewise.
      	* elf32-v850.c (v850_elf_info_to_howto_rel, v850_elf_info_to_howto_rela, v800_elf_info_to_howto): Likewise.
      	* elf32-vax.c (rtype_to_howto): Likewise.
      	* elf32-visium.c (visium_info_to_howto_rela): Likewise.
      	* elf32-wasm32.c (elf32_wasm32_rtype_to_howto, elf32_wasm32_info_to_howto_rela): Likewise.
      	* elf32-xc16x.c (elf32_xc16x_info_to_howto): Likewise.
      	* elf32-xgate.c (xgate_info_to_howto_rel): Likewise.
      	* elf32-xstormy16.c (xstormy16_info_to_howto_rela): Likewise.
      	* elf32-xtensa.c (elf_xtensa_info_to_howto_rela): Likewise.
      	* elf64-alpha.c (elf64_alpha_info_to_howto): Likewise.
      	* elf64-gen.c (elf_generic_info_to_howto, elf_generic_info_to_howto_rel): Likewise.
      	* elf64-ia64-vms.c (elf64_ia64_info_to_howto): Likewise.
      	* elf64-mips.c (mips_elf64_info_to_howto_rela): Likewise.
      	* elf64-mmix.c (mmix_info_to_howto_rela): Likewise.
      	* elf64-ppc.c (ppc64_elf_info_to_howto): Likewise.
      	* elf64-s390.c (elf_s390_reloc_type_lookup): Likewise.
      	* elf64-sh64.c (elf_s390_info_to_howto, sh_elf64_info_to_howto): Likewise.
      	* elf64-x86-64.c (elf_x86_64_info_to_howto): Likewise.
      	* elfn32-mips.c (mips_info_to_howto_rel, mips_info_to_howto_rela): Likewise.
      	* elfnn-aarch64.c (elfNN_aarch64_info_to_howto): Likewise.
      	* elfnn-ia64.c (elfNN_ia64_info_to_howto): Likewise.
      	* elfnn-riscv.c (riscv_info_to_howto_rela): Likewise.
      	* elfxx-ia64.c (ia64_elf_reloc_type_lookup): Likewise.
      	* elfxx-sparc.c (_bfd_sparc_elf_info_to_howto): Likewise.
      	* elfxx-tilegx.c (tilegx_info_to_howto_rela): Likewise.
      	* elf32-score.h (s7_bfd_score_info_to_howto): Update prototype.
      	* elfxx-sparc.h (_bfd_sparc_elf_info_to_howto): Update prototype.
      	* elfxx-tilegx.h (tilegx_info_to_howto_rela): Update prototype.
      	* elfxx-target.h (elf_info_to_howto, elf_info_to_howto_rel): Default to NULL.
      
      binutils PR 22875
      	* objcopy.c (copy_object): Check the error status after marking symbols used in relocations.
      	* testsuite/binutils-all/strip-13.s: New test source file.
      	* testsuite/binutils-all/strip-13.s: New test driver file.
      	* testsuite/binutils-all/objcopy.exp: Run the new test.
      f3185997
  20. 30 Jan, 2018 1 commit
  21. 03 Jan, 2018 3 commits
    • Nick Clifton's avatar
      Fix compile time warning introduced by previous delta. · f13974bd
      Nick Clifton authored
      	* objcopy.c (merge_gnu_build_notes): Add cast to maximum address
      	constants.
      f13974bd
    • Nick Clifton's avatar
      Add support for v3 binary annotation notes. · 6f156d7a
      Nick Clifton authored
        I am checking in the attached patch which updates the binutils
        support for version 3 binary annotation notes.  (Version 3 adds
        an end address to the ranges covered by the notes, so that it
        is possible to detect gaps in the coverage).
      
        This patch also stops the note merging feature of objcopy from
        executing if the notes have relocations against them.  This makes the
        code simpler, and prevents the problems with architectures which have
        unusual relocation management issues.
      
      	* objcopy.c (objcopy_internal_note): New structure.
      	(gap_exists): New function.
      	(is_open_note): New function.
      	(is_func_note): New function.
      	(is_64bit): New function.
      	(merge_gnu_build_notes): Handle v3 notes.  Do not merge
      	if there are relocations against the notes.
      	* readelf.c (get_note_type): Use short names for build attribute
      	notes.
      	(print_symbol_for_build_attribute): Rename to
      	get_symbol_for_build_attribute.  Returns the found symbol rather
      	than printing it.
      	(print_gnu_build_attribute_description): Maintain address ranges
      	for function notes as well as global notes.  Handle v3 notes.
      	(print_gnu_build_attribute_name): Use more space for printing the
      	name in wide mode.
      	* testsuite/binutils-all/note-2-32.s: Use .dc.l instead of .word.
      	Eliminate symbol references in order to remove the need for
      	relocations.
      	* testsuite/binutils-all/note-2-64.s: Likewise.
      	* testsuite/binutils-all/note-3-32.s: Add a size to the note_1
      	symbol.
      	* testsuite/binutils-all/note-3-64.s: Likewise.
      	* testsuite/binutils-all/mips/mips-note-2r-n32.d: Update expected
      	output.
      	* testsuite/binutils-all/mips/mips-note-2r-n64.d: Likewise.
      	* testsuite/binutils-all/mips/mips-note-2r.d: Likewise.
      	* testsuite/binutils-all/note-2-32.d: Likewise.
      	* testsuite/binutils-all/note-2-64.d: Likewise.
      	* testsuite/binutils-all/note-3-32.d: Likewise.
      	* testsuite/binutils-all/note-3-64.d: Likewise.
      	* testsuite/binutils-all/note-4-64.s: New test.  Checks v3 notes.
      	* testsuite/binutils-all/note-4-32.s: New test.
      	* testsuite/binutils-all/note-4-64.d: New test result file.
      	* testsuite/binutils-all/note-4-32.d: New test result file.
      6f156d7a
    • Alan Modra's avatar
      219d1afa
  22. 08 Dec, 2017 1 commit
    • Nick Clifton's avatar
      Fix stripping relocs in a file with mergeable notes. · 2d054e6b
      Nick Clifton authored
        A recent Fedora bug (1520805) exposed a problem with objcopy's reloc
        copying code, when a binary also contains mergeable notes.  The note
        merging code would delete some relocs, but then the reloc copying code
        would try to put them back again, which did not work.
      
        So I am checking in the patch below to fix the problem.  The patch
        also tweaks one of the binutils note merging tests so that it is
        skipped for the Sparc64 target, since this has funky relocs.
      
      binutils	* objcopy.c (copy_relocations_in_section): Use the orelocations
      	field of the input section, if it has been initialised.
      	* testsuite/binutils-all/note-2-64.d: Skip test on Sparc64.
      
      bfd	* elfcode.h (elf_write_relocs): Check for an empty howto field.
      2d054e6b
  23. 06 Dec, 2017 1 commit
    • Jim Wilson's avatar
      Objcopy interleave fails if section address not multiple of interleave. · 1c9c7ce0
      Jim Wilson authored
      	PR 22465
      	binutils/
      	* objcopy.c (copy_section): New local extra.  If isection->lma not
      	exactly divisible by interleave, then bias from.  Also adjust
      	osection->lma if necessary.
      
      	ld/
      	* testsuite/ld-elf/interleave-0.d, testsuite/ld-elf/interleave-4.d,
      	* testsuite/ld-elf/interleave.ld, testsuite/ld-elf/interleave.s: New.
      1c9c7ce0
  24. 15 Nov, 2017 1 commit
  25. 05 Oct, 2017 1 commit
  26. 01 Jul, 2017 1 commit
    • Alan Modra's avatar
      Use bfd_malloc_and_get_section · bae7501e
      Alan Modra authored
      It's nicer than xmalloc followed by bfd_get_section_contents, since
      xmalloc exits on failure and needs a check that its size_t arg doesn't
      lose high bits when converted from bfd_size_type.
      
      	PR binutils/21665
      	* objdump.c (strtab): Make var a bfd_byte*.
      	(disassemble_section): Don't limit malloc size.  Instead, use
      	bfd_malloc_and_get_section.
      	(read_section_stabs): Use bfd_malloc_and_get_section.  Return
      	bfd_byte*.
      	(find_stabs_section): Remove now unnecessary cast.
      	* objcopy.c (copy_object): Use bfd_malloc_and_get_section.  Free
      	contents on error return.
      	* nlmconv.c (copy_sections): Use bfd_malloc_and_get_section.
      bae7501e
  27. 28 Jun, 2017 1 commit
  28. 20 May, 2017 1 commit
    • Jose E. Marchesi's avatar
      binutils: remove sparc64/mips64 workaround in objcopy build notes merge code · b4f5b984
      Jose E. Marchesi authored
      This patch removes a workaround recently installed in objcopy that
      avoided removing duplicated notes in targets for which the number of
      internal relocations may be bigger than the number of external
      relocations.  With the recent fixes in sparc64 and mips64, this
      workaround is no longer necessary.
      
      2017-05-19  Jose E. Marchesi  <jose.marchesi@oracle.com>
      
      	* objcopy.c (merge_gnu_build_notes): Remove workaround that
      	prevented deleting relocations in duplicated notes in mips64 and
      	sparc.
      b4f5b984
  29. 02 May, 2017 2 commits
  30. 01 May, 2017 1 commit
  31. 13 Apr, 2017 1 commit
    • Nick Clifton's avatar
      Add note merging to strip and add code to merge stack size notes. · 1d15e434
      Nick Clifton authored
      	* objcopy.c: Add --no-merge-notes option to disable note merging.
      	Add --[no-]merge-notes option to strip, and enable it by default.
      	(num_bytes): New function.
      	(merge_gnu_build_notes): Add code to merge stack size notes.
      	* binutils.texi: Update strip and objcopy documentation.
      	* readelf.c (print_gnu_build_attribute_name): Use defined
      	constants for note types.
      1d15e434
  32. 06 Apr, 2017 1 commit
    • Jiong Wang's avatar
      [objcopy] Fix quadratic-time when handling --redefine-syms · 0f65a5d8
      Jiong Wang authored
      objcopy/
      	* objcopy.c (struct redefine_node): Delete the field "next".
      	(redefine_sym_list): Deleted.
      	(redefine_specific_htab): New hash table.
      	(redefine_specific_reverse_htab): Likewise.
      	(eq_string_redefnode): New function.
      	(htab_hash_redefnode): Likewise.
      	(create_symbol2redef_htab): Likewise.
      	(add_specific_symbol_node): Likewise.
      	(create_symbol_htabs): Create redefine_specific_htab and
      	redefine_specific_reverse_htab.
      	(lookup_sym_redefinition): Use hash table instead of list.
      	(redefine_list_append): Likewise, and rename to add_redefine_and_check.
      	(copy_main): Use redefine_specific_htab instead of redefine_sym_list.
      	Update comments.
      0f65a5d8
  33. 21 Mar, 2017 1 commit
    • Nick Clifton's avatar
      Update support for GNU BUILD notes so that version notes can contain extra... · 75d7d298
      Nick Clifton authored
      Update support for GNU BUILD notes so that version notes can contain extra information, and stack protection notes can contain numeric values.
      
      	* readelf.c (print_gnu_build_attribute_name): Allow stack
      	protection notes to contain numeric values.  Use a colon rather
      	than a space to separate a string name from its values.  Decode
      	the numeric value of a stack protection note.
      	* objcopy.c (merge_gnu_build_notes): Allow version notes to
      	contain extra text after the protocol version number.
      75d7d298
  34. 02 Mar, 2017 1 commit
  35. 01 Mar, 2017 1 commit
    • Nick Clifton's avatar
      Add support for displaying and merging GNU_BUILD_NOTEs. · 9ef920e9
      Nick Clifton authored
      include	* elf/common.h (SHF_GNU_BUILD_NOTE): Define.
      	(NT_GNU_PROPERTY_TYPE_0): Define.
      	(NT_GNU_BUILD_ATTRIBUTE_OPEN): Define.
      	(NT_GNU_BUILD_ATTRIBUTE_FUN): Define.
      	(GNU_BUILD_ATTRIBUTE_TYPE_NUMERIC): Define.
      	(GNU_BUILD_ATTRIBUTE_TYPE_STRING): Define.
      	(GNU_BUILD_ATTRIBUTE_TYPE_BOOL_TRUE): Define.
      	(GNU_BUILD_ATTRIBUTE_TYPE_BOOL_FALSE): Define.
      	(GNU_BUILD_ATTRIBUTE_VERSION): Define.
      	(GNU_BUILD_ATTRIBUTE_STACK_PROT): Define.
      	(GNU_BUILD_ATTRIBUTE_RELRO): Define.
      	(GNU_BUILD_ATTRIBUTE_STACK_SIZE): Define.
      	(GNU_BUILD_ATTRIBUTE_TOOL): Define.
      	(GNU_BUILD_ATTRIBUTE_ABI): Define.
      	(GNU_BUILD_ATTRIBUTE_PIC): Define.
      	(NOTE_GNU_PROPERTY_SECTION_NAME): Define.
      	(GNU_BUILD_ATTRS_SECTION_NAME): Define.
      	(GNU_PROPERTY_STACK_SIZE): Define.
      	(GNU_PROPERTY_NO_COPY_ON_PROTECTED): Define.
      	(GNU_PROPERTY_X86_ISA_1_USED): Define.
      	(GNU_PROPERTY_X86_ISA_1_NEEDED): Define.
      	(GNU_PROPERTY_X86_ISA_1_486): Define.
      	(GNU_PROPERTY_X86_ISA_1_586): Define.
      	(GNU_PROPERTY_X86_ISA_1_686): Define.
      	(GNU_PROPERTY_X86_ISA_1_SSE): Define.
      	(GNU_PROPERTY_X86_ISA_1_SSE2): Define.
      	(GNU_PROPERTY_X86_ISA_1_SSE3): Define.
      	(GNU_PROPERTY_X86_ISA_1_SSSE3): Define.
      	(GNU_PROPERTY_X86_ISA_1_SSE4_1): Define.
      	(GNU_PROPERTY_X86_ISA_1_SSE4_2): Define.
      	(GNU_PROPERTY_X86_ISA_1_AVX): Define.
      	(GNU_PROPERTY_X86_ISA_1_AVX2): Define.
      	(GNU_PROPERTY_X86_ISA_1_AVX512F): Define.
      	(GNU_PROPERTY_X86_ISA_1_AVX512CD): Define.
      	(GNU_PROPERTY_X86_ISA_1_AVX512ER): Define.
      	(GNU_PROPERTY_X86_ISA_1_AVX512PF): Define.
      	(GNU_PROPERTY_X86_ISA_1_AVX512VL): Define.
      	(GNU_PROPERTY_X86_ISA_1_AVX512DQ): Define.
      	(GNU_PROPERTY_X86_ISA_1_AVX512BW): Define.
      
      binutils* readelf.c (get_note_type): Add support for GNU_BUILD_NOTEs.
      	(get_gnu_elf_note_type): Add support for GNU_PROPERTY_NOTEs.
      	(decode_x86_isa): New function.
      	(print_gnu_property_note): New function.
      	(print_gnu_note): Handle GNU_PROPERTY_NOTEs.
      	(print_gnu_build_attribute_description): New function.
      	(print_gnu_build_attribute_name): New function.
      	(process_note): Add support for GNU_BUILD_NOTEs.
      	* objcopy.c (--merge-notes): New command line option.
      	(copy_options): Add merge-notes.
      	(copy_usage): Likewise.
      	(is_merge_note_section): New function.
      	(merge_gnu_build_notes): New function.
      	(copy_object): Merge note sections if asked to do so.
      	(skip_section): Add skip_copy parameter.  Add support for skipping
      	merged note sections.
      	(copy_relocations_in_section): Update call to skip_section.
      	(copy_section): Likewise.
      	(copy_main): Add support for merge-notes option.
      	* doc/binutils.texi: Document the new option to objcopy.
      	* NEWS: Mention the new feature.
      	* testsuite/binutils-all/note-2-32.d: New test.  Checks note
      	merging on 32-bit targets.
      	* testsuite/binutils-all/note-2-32.s: New test source file.
      	* testsuite/binutils-all/note-2-64.d: New test.  Like note-2-32.d
      	but for 64-bit targets.
      	* testsuite/binutils-all/note-2-64.s: New test source file.
      	* testsuite/binutils-all/objcopy.exp: Run the new test.
      9ef920e9
  36. 17 Feb, 2017 1 commit
    • Pedro Alves's avatar
      bfd: Rename Chunk and S3Forced · 4bc26c69
      Pedro Alves authored
      The direct references in objcopy kind of look like a hack to me, so
      I'm calling these symbols internal too.  Certainly they aren't named
      and documented as a public BFD symbol today anyway.
      
      So ... give these bfd-internal symbols with external linkage a _bfd_
      prefix to avoid collisions in the global symbol namespace.
      
      While at it, give them names that more closely match the corresponding
      option name that toggles them.
      
      Also while at it, fix a few related comment typos.
      
      gdb/ChangeLog:
      2017-02-17  Pedro Alves  <palves@redhat.com>
      
      	* srec.c (Chunk): Rename to ...
      	(_bfd_srec_len): ... this.
      	(S3Forced): Rename to ...
      	(_bfd_srec_forceS3): ... this.
      	* objcopy.c: Adjust all references.
      4bc26c69