aboutsummaryrefslogtreecommitdiff
path: root/binutils
AgeCommit message (Collapse)AuthorFilesLines
2017-04-10Prevent a bigus warning from readelf about a gdb-index table being too big.John Delsignor2-1/+7
PR binutils/21319 * dwarf.c (display_gdb_index): Correct test for a corrupt address table size.
2017-04-06[objcopy] Fix quadratic-time when handling --redefine-symsJiong Wang2-33/+88
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.
2017-04-04Support ELF SHF_GNU_MBIND and PT_GNU_MBIND_XXXH.J. Lu5-3/+61
Mark an ALLOC section, which should be placed in special memory area, with SHF_GNU_MBIND. Its sh_info field indicates the special memory type. GNU_MBIND section names start with ".mbind" so that they are placed as orphan sections by linker. All input GNU_MBIND sections with the same sh_type, sh_flags and sh_info are placed in one output GNU_MBIND section. In executable and shared object, create a GNU_MBIND segment for each GNU_MBIND section and its segment type is PT_GNU_MBIND_LO plus the sh_info value. Each GNU_MBIND segment is aligned at page boundary. The assembler syntax: .section .mbind.foo,"adx",%progbits ^ 0: Special memory type. | 'd' for SHF_GNU_MBIND. .section .mbind.foo,"adx",%progbits,0x1 ^ 1: Special memory type. | 'd' for SHF_GNU_MBIND. .section .mbind.bar,"adG",%progbits,.foo_group,comdat,0x2 ^ 2: Special memory type. | 'd' for SHF_GNU_MBIND. bfd/ * elf.c (get_program_header_size): Add a GNU_MBIND segment for each GNU_MBIND section and align GNU_MBIND section to page size. (_bfd_elf_map_sections_to_segments): Create a GNU_MBIND segment for each GNU_MBIND section. (_bfd_elf_init_private_section_data): Copy sh_info from input for GNU_MBIND section. binutils/ * NEWS: Mention support for ELF SHF_GNU_MBIND and PT_GNU_MBIND_XXX. * readelf.c (get_segment_type): Handle PT_GNU_MBIND_XXX. (get_elf_section_flags): Handle SHF_GNU_MBIND. (process_section_headers): Likewise. * testsuite/binutils-all/mbind1.s: New file. * testsuite/binutils-all/objcopy.exp: Run readelf test on mbind1.s. gas/ * NEWS: Mention support for ELF SHF_GNU_MBIND. * config/obj-elf.c (section_match): New. (get_section): Match both sh_info and group name. (obj_elf_change_section): Add argument for sh_info. Pass both sh_info and group name to get_section. Issue an error for SHF_GNU_MBIND section without SHF_ALLOC. Set sh_info. (obj_elf_parse_section_letters): Set SHF_GNU_MBIND for 'd'. (obj_elf_section): Support SHF_GNU_MBIND section info. * config/obj-elf.h (obj_elf_change_section): Add argument for sh_info. * config/tc-arm.c (start_unwind_section): Pass 0 as sh_info to obj_elf_change_section. * config/tc-ia64.c (obj_elf_vms_common): Likewise. * config/tc-microblaze.c (microblaze_s_data): Likewise. (microblaze_s_sdata): Likewise. (microblaze_s_rdata): Likewise. (microblaze_s_bss): Likewise. * config/tc-mips.c (s_change_section): Likewise. * config/tc-msp430.c (msp430_profiler): Likewise. * config/tc-rx.c (parse_rx_section): Likewise. * config/tc-tic6x.c (tic6x_start_unwind_section): Likewise. * doc/as.texinfo: Document 'd' for SHF_GNU_MBIND. * testsuite/gas/elf/elf.exp: Run section12a, section12b and section13. * testsuite/gas/elf/section10.d: Updated. * testsuite/gas/elf/section10.s: Likewise. * testsuite/gas/elf/section12.s: New file. * testsuite/gas/elf/section12a.d: Likewise. * testsuite/gas/elf/section12b.d: Likewise. * testsuite/gas/elf/section13.l: Likewise. * testsuite/gas/elf/section13.d: Likewise. * testsuite/gas/elf/section13.s: Likewise. include/ * elf/common.h (PT_GNU_MBIND_NUM): New. (PT_GNU_MBIND_LO): Likewise. (PT_GNU_MBIND_HI): Likewise. (SHF_GNU_MBIND): Likewise. ld/ * NEWS: Mention support for ELF SHF_GNU_MBIND and PT_GNU_MBIND_XXX. * emultempl/elf32.em (gld${EMULATION_NAME}_place_orphan): Place input GNU_MBIND sections with the same type, attributes and sh_info field into a single output GNU_MBIND section. * testsuite/ld-elf/elf.exp: Run mbind2a and mbind2b. * testsuite/ld-elf/mbind1.s: New file. * testsuite/ld-elf/mbind1a.d: Likewise. * testsuite/ld-elf/mbind1b.d: Likewise. * testsuite/ld-elf/mbind1c.d: Likewise. * testsuite/ld-elf/mbind2a.s: Likewise. * testsuite/ld-elf/mbind2b.c: Likewise.
2017-04-03readelf: Fix overlarge memory allocation when reading a binary with an ↵Nick Clifton2-3/+20
excessive number of program headers. PR binutils/21345 * readelf.c (get_program_headers): Check for there being too many program headers before attempting to allocate space for them.
2017-04-03Fix runtime seg-fault in readelf when parsing a corrupt MIPS binary.Nick Clifton2-8/+24
PR binutils/21344 * readelf.c (process_mips_specific): Check for an out of range GOT entry before reading the module pointer.
2017-04-03readelf: Update check for invalid word offsets in ARM unwind information.Nick Clifton2-3/+9
PR binutils/21343 * readelf.c (get_unwind_section_word): Fix snafu checking for invalid word offsets in ARM unwind information.
2017-03-31Fix minor problems with previous wasm32 binutils commit.Pip Cet3-3/+7
binutils * NEWS: Use "WebAssembly" consistently. * testsuite/binutils-all/wasm32/wasm32.exp: Fix copyright notice.
2017-03-30Add support for the WebAssembly file format and the wasm32 ELF conversion to ↵Pip Cet22-1/+244
gas and the binutils. binutils * readelf.c: Add support for wasm32 ELF format WebAssembly files. (guess_is_rela): Likewise. (dump_relocations): Likewise. (is_32bit_abs_reloc): Likewise. (is_none_reloc_): Likewise. * NEWS: Mention the new support. * testsuite/lib/binutils-common.exp (is_elf_format): Mark wasm32 as ELF target. (supports_gnu_unique): Mark wasm32 as supporting STB_GNU_UNIQUE. * testsuite/binutils-all/nm.exp: Mark wasm32 as requiring .size annotations. * testsuite/binutils-all/wasm32: New directory. * testsuite/binutils-all/wasm32/create-wasm.d: New file. * testsuite/binutils-all/wasm32/create-wasm.s: Likewise. * testsuite/binutils-all/wasm32/custom-section.d: Likewise. * testsuite/binutils-all/wasm32/custom-section.s: Likewise. * testsuite/binutils-all/wasm32/invalid-wasm-1.d: Likewise. * testsuite/binutils-all/wasm32/invalid-wasm-1.s: Likewise. * testsuite/binutils-all/wasm32/long-sections.d: Likewise. * testsuite/binutils-all/wasm32/long-sections.s: Likewise. * testsuite/binutils-all/wasm32/parse-wasm.d: Likewise. * testsuite/binutils-all/wasm32/parse-wasm.s: Likewise. * testsuite/binutils-all/wasm32/parse-wasm-2.d: Likewise. * testsuite/binutils-all/wasm32/parse-wasm-2.s: Likewise. * testsuite/binutils-all/wasm32/prepared-section.d: Likewise. * testsuite/binutils-all/wasm32/prepared-section.s: Likewise. * testsuite/binutils-all/wasm32/wasm32.exp: New file, run tests. gas * config/tc-wasm32.h: New file: Add WebAssembly assembler target. * config/tc-wasm32.c: New file: Add WebAssembly assembler target. * Makefile.am: Add WebAssembly assembler target. * configure.tgt: Add WebAssembly assembler target. * doc/c-wasm32.texi: New file: Start documenting WebAssembly assembler. * doc/all.texi: Define WASM32. * doc/as.texinfo: Add WebAssembly entries. * NEWS: Mention the new support. * Makefile.in: Regenerate. * po/gas.pot: Regenerate. * po/POTFILES.in: Regenerate. * testsuite/gas/wasm32: New directory. * testsuite/gas/wasm32/allinsn.d: New file. * testsuite/gas/wasm32/allinsn.s: New file. * testsuite/gas/wasm32/illegal.l: New file. * testsuite/gas/wasm32/illegal.s: New file. * testsuite/gas/wasm32/illegal-2.l: New file. * testsuite/gas/wasm32/illegal-2.s: New file. * testsuite/gas/wasm32/illegal-3.l: New file. * testsuite/gas/wasm32/illegal-3.s: New file. * testsuite/gas/wasm32/illegal-4.l: New file. * testsuite/gas/wasm32/illegal-4.s: New file. * testsuite/gas/wasm32/illegal-5.l: New file. * testsuite/gas/wasm32/illegal-5.s: New file. * testsuite/gas/wasm32/illegal-6.l: New file. * testsuite/gas/wasm32/illegal-6.s: New file. * testsuite/gas/wasm32/illegal-7.l: New file. * testsuite/gas/wasm32/illegal-7.s: New file. * testsuite/gas/wasm32/illegal-8.l: New file. * testsuite/gas/wasm32/illegal-8.s: New file. * testsuite/gas/wasm32/illegal-9.l: New file. * testsuite/gas/wasm32/illegal-9.s: New file. * testsuite/gas/wasm32/illegal-10.l: New file. * testsuite/gas/wasm32/illegal-10.s: New file. * testsuite/gas/wasm32/illegal-11.l: New file. * testsuite/gas/wasm32/illegal-11.s: New file. * testsuite/gas/wasm32/illegal-12.l: New file. * testsuite/gas/wasm32/illegal-12.s: New file. * testsuite/gas/wasm32/illegal-13.l: New file. * testsuite/gas/wasm32/illegal-13.s: New file. * testsuite/gas/wasm32/illegal-14.l: New file. * testsuite/gas/wasm32/illegal-14.s: New file. * testsuite/gas/wasm32/illegal-15.l: New file. * testsuite/gas/wasm32/illegal-15.s: New file. * testsuite/gas/wasm32/illegal-16.l: New file. * testsuite/gas/wasm32/illegal-16.s: New file. * testsuite/gas/wasm32/illegal-17.l: New file. * testsuite/gas/wasm32/illegal-17.s: New file. * testsuite/gas/wasm32/illegal-18.l: New file. * testsuite/gas/wasm32/illegal-18.s: New file. * testsuite/gas/wasm32/illegal-19.l: New file. * testsuite/gas/wasm32/illegal-19.s: New file. * testsuite/gas/wasm32/illegal-20.l: New file. * testsuite/gas/wasm32/illegal-20.s: New file. * testsuite/gas/wasm32/illegal-21.l: New file. * testsuite/gas/wasm32/illegal-21.s: New file. * testsuite/gas/wasm32/illegal-22.l: New file. * testsuite/gas/wasm32/illegal-22.s: New file. * testsuite/gas/wasm32/illegal-24.l: New file. * testsuite/gas/wasm32/illegal-24.s: New file. * testsuite/gas/wasm32/illegal-25.l: New file. * testsuite/gas/wasm32/illegal-25.s: New file. * testsuite/gas/wasm32/reloc.d: New file. * testsuite/gas/wasm32/reloc.s: New file. * testsuite/gas/wasm32/wasm32.exp: New tests for WebAssembly architecture. opcodes * configure.ac: Add (empty) bfd_wasm32_arch target. * configure: Regenerate * po/opcodes.pot: Regenerate. include * opcode/wasm.h: New file to support wasm32 architecture. * elf/wasm32.h: Add R_WASM32_32 relocation. bfd * elf32-wasm32.c: Add relocation code, two relocs. * reloc.c: Add wasm32 relocations. * libbfd.h: Regenerate. * bfd-in2.h: Regenerate. * bfd/po/bfd.pot: Regenerate.
2017-03-29PowerPC -Mraw disassemblyAlan Modra2-6/+32
This adds -Mraw for PowerPC objdump, a disassembler option to display the underlying machine instruction rather than aliases. For example, "rlwinm" always rather than "rotlwi" when the instruction is performing a simple rotate. binutils/ * doc/binutils.texi (objdump): Document PowerPC -M options. gas/ * config/tc-ppc.c (md_parse_option): Reject -mraw. include/ * opcode/ppc.h (PPC_OPCODE_RAW): Define. (PPC_OPCODE_*): Make them all unsigned long long constants. opcodes/ * ppc-dis.c (ppc_opts): Set PPC_OPCODE_PPC for "any" flags. Add "raw" option. (lookup_powerpc): Don't special case -1 dialect. Handle PPC_OPCODE_RAW. (print_insn_powerpc): Mask out PPC_OPCODE_ANY on first lookup_powerpc call, pass it on second.
2017-03-21Add --inlines option to objdump to include scope backtrace of inlined ↵Andi Kleen4-2/+44
functions when generating source line number information. * objdump.c (unwind_inlines): Add. (option_values): Add OPTION_INLINES. (show_line): Unwind inlines if requested. (main): Parse OPTION_INLINES. (usage): Document --inlines. * doc/binutils.texi: Document --inlines. * NEWS: Likewise.
2017-03-21Update support for GNU BUILD notes so that version notes can contain extra ↵Nick Clifton3-25/+46
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.
2017-03-20readelf: Don't error on .debug files with NOBITS .dynamic section.Mark Wielaard2-6/+15
The fix for PR binutils/17512 added a check for the dynamic segment being inside the actual ELF file. If not an error message would be produced: readelf: Error: the dynamic segment offset + size exceeds the size of the file Unfortunately for separate debuginfo files it is common for the dynamic segment not being inside the file because the .dynamic section is NOBITS. Since the check is done unconditionally in process_program_headers and process_program_headers is always called (to setup dynamic_addr in case it is needed). The error is produced on any operations done on any .debug file (even if no program headers or the dynamic segment is used). If there are section headers then a cross check is done to see if the .dynamic section is NOBITS in which case dynamic_addr is set to zero without a warning or error (which is then checked first before any operation on the dynamic segement is done). Move the check for the dynamic segment being inside the actual ELF file after the cross check with the section headers to suppress the error for .debug files. binutils/ChangeLog: * readelf.c (process_program_headers): Move dynamic_addr check after .dynamic section cross check.
2017-03-17Fix displaying the value associated a GNU BUILD note that uses an ascii name.Nick Clifton2-1/+6
* readelf.c (print_gnu_build_attribute_name): Fix off by one error printing the value for a build note with an ascii name.
2017-03-16Add support for a GNU BUILD note type to record the enum size.Nick Clifton2-0/+10
include * elf/common.h (GNU_BUILD_ATTRIBUTE_SHORT_ENUM): New GNU BUILD note type. binutils * readelf.c (print_gnu_build_attribute_name): Add support for GNU_BUILD_ATTRIBUTE_SHORT_ENUM.
2017-03-14Try harder to find the correct symbol to associate with OPEN GNU BUILD notes.Nick Clifton6-88/+157
* readelf.c (print_gnu_build_attribute_description): Move symbol printing code to... (print_symbol_for_build_attribute): New function. ...here. Add to find the best symbol to associate with an OPEN note. Add code to cache the symbol table and string table, so that they are not loaded every time a note is displayed. * testsuite/binutils-all/note-2-32.s: Add a function symbol. * testsuite/binutils-all/note-2-64.s: Likewise. * testsuite/binutils-all/note-2-32.d: Update expected note output. * testsuite/binutils-all/note-2-64.d: Likewise.
2017-03-13objdump -dS: warn if source is more recent than objectAlan Modra2-25/+45
If the source file is more recent than the object file, line number information in the object may no longer match the source. So print a warning message. * objdump.c (update_source_path): Add abfd param. Add struct stat vars. Pass to try_print_file_open. Warn if source is more recent than object. (try_print_file_open, slurp_file): Add struct stat param to return fstat. (show_line): Call update_source_path with bfd.
2017-03-10Make objdump's --wide command line option affect its output of DWARF debug ↵Chia-Hao Lo2-1/+6
information. PR binutils/21235 * objdump.c (main): Set do_wide with --wide.
2017-03-10Add basic recognition of new EM_ ELF machine numbers.Nick Clifton2-60/+97
include * elf/common.h (EM_LANAI): New machine number. (EM_BPF): Likewise. (EM_WEBASSEMBLY): Likewise. Move low value, deprecated, numbers to their numerical equivalents. binutils * readelf.c (get_machine_name): Rearrange switch table in order of increasing machine number. Add missing entries.
2017-03-08Properly dump NT_GNU_PROPERTY_TYPE_0H.J. Lu10-45/+234
Property type and datasz are always 4 bytes for both 32-bit and 64-bit objects. Property values for GNU_PROPERTY_X86_ISA_1_USED and GNU_PROPERTY_X86_ISA_1_NEEDED are 4 bytes for both i386 and x86-64 objects. We should also check GNU_PROPERTY_LOPROC and GNU_PROPERTY_LOUSER. binutils/ PR binutils/21231 * readelf.c (decode_x86_isa): Change argument to unsigned int. (print_gnu_property_note): Retrieve property type and datasz as 4-byte integer. Consolidate property datasz check. Check GNU_PROPERTY_LOPROC and GNU_PROPERTY_LOUSER. * testsuite/binutils-all/i386/pr21231a.d: New file. * testsuite/binutils-all/i386/pr21231a.s: Likewise. * testsuite/binutils-all/i386/pr21231b.d: Likewise. * testsuite/binutils-all/i386/pr21231b.s: Likewise. * testsuite/binutils-all/x86-64/pr21231a.d: Likewise. * testsuite/binutils-all/x86-64/pr21231a.s: Likewise. * testsuite/binutils-all/x86-64/pr21231b.d: Likewise. * testsuite/binutils-all/x86-64/pr21231b.s: Likewise. include/ PR binutils/21231 * elf/common.h (GNU_PROPERTY_LOPROC): New. (GNU_PROPERTY_HIPROC): Likewise. (GNU_PROPERTY_LOUSER): Likewise. (GNU_PROPERTY_HIUSER): Likewise.
2017-03-06Fix reading numeric values from GNU BUILD NOTEs.Nick Clifton2-2/+11
* readelf.c (print_gnu_build_attribute_name): Read byte values from the name string as unsigned bytes. (process_notes_at): Use memcpy to copy an unterminated name string.
2017-03-06binutils: Fix warning on platforms that don't have asprintfSam Thursfield4-1/+21
* configure.ac (AC_CHECK_DECLS): Add asprintf. * config.in: Regenerate. * configure: Regenerate.
2017-03-02Support merging build notes in sections without the SHF_GNU_BUILD_NOTE flag set.Nick Clifton2-1/+7
* objcopy.c (is_merged_note_section): Support build note sections without the SHF_GNU_BUILD_NOTE section flag set.
2017-03-02Fix snafu parsing GNU_BUILD_NOTEs on ARM and AArch64 architectures.Nick Clifton2-2/+25
* readelf.c (print_gnu_build_attribute_description): Use global symbols for OPEN attributes if at all possible.
2017-03-02New debug_displays_assertJan Kratochvil2-0/+7
binutils/ 2017-03-02 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf.c (debug_displays_assert): New static assertion.
2017-03-02Fix dwarf_section_display_enum regression by DWARF-5Jan Kratochvil2-0/+6
binutils/ 2017-03-02 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf.h (enum dwarf_section_display_enum): Add loclists and rnglists.
2017-03-01Add support for displaying and merging GNU_BUILD_NOTEs.Nick Clifton10-34/+1053
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.
2017-02-28GDB: Add support for the new set/show disassembler-options commands.Peter Bergner2-6/+14
This commit adds support to GDB so that it can modify the disassembler-options value that is passed to the disassembler, similar to objdump's -M option. Currently, the only supported targets are ARM, PowerPC and S/390, but adding support for a new target(s) is not difficult. include/ * dis-asm.h (disasm_options_t): New typedef. (parse_arm_disassembler_option): Remove prototype. (set_arm_regname_option): Likewise. (get_arm_regnames): Likewise. (get_arm_regname_num_options): Likewise. (disassemble_init_s390): New prototype. (disassembler_options_powerpc): Likewise. (disassembler_options_arm): Likewise. (disassembler_options_s390): Likewise. (remove_whitespace_and_extra_commas): Likewise. (disassembler_options_cmp): Likewise. (next_disassembler_option): New inline function. (FOR_EACH_DISASSEMBLER_OPTION): New macro. opcodes/ * disassemble.c Include "safe-ctype.h". (disassemble_init_for_target): Handle s390 init. (remove_whitespace_and_extra_commas): New function. (disassembler_options_cmp): Likewise. * arm-dis.c: Include "libiberty.h". (NUM_ELEM): Delete. (regnames): Use long disassembler style names. Add force-thumb and no-force-thumb options. (NUM_ARM_REGNAMES): Rename from this... (NUM_ARM_OPTIONS): ...to this. Use ARRAY_SIZE. (get_arm_regname_num_options): Delete. (set_arm_regname_option): Likewise. (get_arm_regnames): Likewise. (parse_disassembler_options): Likewise. (parse_arm_disassembler_option): Rename from this... (parse_arm_disassembler_options): ...to this. Make static. Use new FOR_EACH_DISASSEMBLER_OPTION macro to scan over options. (print_insn): Use parse_arm_disassembler_options. (disassembler_options_arm): New function. (print_arm_disassembler_options): Handle updated regnames. * ppc-dis.c: Include "libiberty.h". (ppc_opts): Add "32" and "64" entries. (ppc_parse_cpu): Use ARRAY_SIZE and disassembler_options_cmp. (powerpc_init_dialect): Add break to switch statement. Use new FOR_EACH_DISASSEMBLER_OPTION macro. (disassembler_options_powerpc): New function. (print_ppc_disassembler_options): Use ARRAY_SIZE. Remove printing of "32" and "64". * s390-dis.c: Include "libiberty.h". (init_flag): Remove unneeded variable. (struct s390_options_t): New structure type. (options): New structure. (init_disasm): Rename from this... (disassemble_init_s390): ...to this. Add initializations for current_arch_mask and option_use_insn_len_bits_p. Remove init_flag. (print_insn_s390): Delete call to init_disasm. (disassembler_options_s390): New function. (print_s390_disassembler_options): Print using information from struct 'options'. * po/opcodes.pot: Regenerate. binutils/ * objdump.c (main): Use remove_whitespace_and_extra_commas. gdb/ * NEWS: Mention new set/show disassembler-options commands. * doc/gdb.texinfo: Document new set/show disassembler-options commands. * disasm.c: Include "arch-utils.h", "gdbcmd.h" and "safe-ctype.h". (prospective_options): New static variable. (gdb_disassembler::gdb_disassembler): Initialize m_di.disassembler_options. (gdb_buffered_insn_length_init_dis): Initilize di->disassembler_options. (get_disassembler_options): New function. (set_disassembler_options): Likewise. (set_disassembler_options_sfunc): Likewise. (show_disassembler_options_sfunc): Likewise. (disassembler_options_completer): Likewise. (_initialize_disasm): Likewise. * disasm.h (get_disassembler_options): New prototype. (set_disassembler_options): Likewise. * gdbarch.sh (gdbarch_disassembler_options): New variable. (gdbarch_verify_disassembler_options): Likewise. * gdbarch.c: Regenerate. * gdbarch.h: Likewise. * arm-tdep.c (num_disassembly_options): Delete. (set_disassembly_style): Likewise. (arm_disassembler_options): New static variable. (set_disassembly_style_sfunc): Convert short style name into long option name. Call set_disassembler_options. (show_disassembly_style_sfunc): New function. (arm_gdbarch_init): Call set_gdbarch_disassembler_options and set_gdbarch_verify_disassembler_options. (_initialize_arm_tdep): Delete regnames variable and update callers. (arm_disassembler_options): Initialize. (disasm_options): New variable. (num_disassembly_options): Rename from this... (num_disassembly_styles): ...to this. Compute by scanning through disasm_options. (valid_disassembly_styles): Initialize using disasm_options. Remove calls to parse_arm_disassembler_option, get_arm_regnames and set_arm_regname_option. Pass show_disassembly_style_sfunc to the "disassembler" setshow command. * rs6000-tdep.c (powerpc_disassembler_options): New static variable. (rs6000_gdbarch_init): Call set_gdbarch_disassembler_options and set_gdbarch_verify_disassembler_options. * s390-tdep.c (s390_disassembler_options): New static variable. (s390_gdbarch_init):all set_gdbarch_disassembler_options and set_gdbarch_verify_disassembler_options. gdb/testsuite/ * gdb.arch/powerpc-power.exp: Delete test. * gdb.arch/powerpc-power.s: Likewise. * gdb.disasm/disassembler-options.exp: New test. * gdb.arch/powerpc-altivec.exp: Likewise. * gdb.arch/powerpc-altivec.s: Likewise. * gdb.arch/powerpc-altivec2.exp: Likewise. * gdb.arch/powerpc-altivec2.s: Likewise. * gdb.arch/powerpc-altivec3.exp: Likewise. * gdb.arch/powerpc-altivec3.s: Likewise. * gdb.arch/powerpc-power7.exp: Likewise. * gdb.arch/powerpc-power7.s: Likewise. * gdb.arch/powerpc-power8.exp: Likewise. * gdb.arch/powerpc-power8.s: Likewise. * gdb.arch/powerpc-power9.exp: Likewise. * gdb.arch/powerpc-power9.s: Likewise. * gdb.arch/powerpc-vsx.exp: Likewise. * gdb.arch/powerpc-vsx.s: Likewise. * gdb.arch/powerpc-vsx2.exp: Likewise. * gdb.arch/powerpc-vsx2.s: Likewise. * gdb.arch/powerpc-vsx3.exp: Likewise. * gdb.arch/powerpc-vsx3.s: Likewise. * gdb.arch/arm-disassembler-options.exp: Likewise. * gdb.arch/powerpc-disassembler-options.exp: Likewise. * gdb.arch/s390-disassembler-options.exp: Likewise.
2017-02-28Revert "Add symbol called __nm_<name> to exported symbols created by dlltool."Nick Clifton2-26/+1
This reverts commit 47612ae91c5f2de8960df1d96adf225d2455123f.
2017-02-27Fix compilation with GCC 4.4.7.Jan Kratochvil2-3/+11
binutils/ 2017-02-27 Jan Kratochvil <jan.kratochvil@redhat.com> Fix compilation with GCC 4.4.7. * dwarf.c (display_loclists_list, display_debug_rnglists_list): Initialize begin and end.
2017-02-27Add symbol called __nm_<name> to exported symbols created by dlltool.Rudy Y2-1/+26
PR 20881 * dlltool.c (secdata): Align .idata$6 on 2 byte boundary. (make_one_lib_file): Export a symbol called __nm_<symbol> for use with auto-importing.
2017-02-25Fixes for new dw5 testAlan Modra3-31/+47
On some targets, .string does not add a NUL string terminator. * testsuite/binutils-all/dw5.S: Replace .string with .asciz. Support hpux .comm variant. * testsuite/binutils-all/readelf.exp: Define HPUX when assembling dw5 test for hppa64-hpux.
2017-02-24Fix snafu with booleans in readelf patch - lack of a program header is not a ↵Nick Clifton2-3/+7
reason for a function to return false. (process_program_headers): Fix snafu - if the program headers are not available then this is not a cause to fail. (process_corefile_note_segments): Likewise.
2017-02-24Tidy up readelf's use of boolean values.Nick Clifton2-716/+929
* readelf.c (show_name, do_dynamic, do_syms, do_dyn_syms, (do_reloc, do_sections, do_section_groups, do_section_details, (do_segments, do_unwind, do_using_dynamic, do_header, do_dump, (do_version, do_histogram, do_debugging, do_arch, do_notes, (do_archive_index, is_32bit_elf, decompress_dumps): Use bfd_boolean type. (parse_args): Treat the do_* variables as booleans. (print_vma): Return an unsigned int. (print_symbol): Change width parameter to signed int. (is_ia64_vms): Change return type to bfd_boolean. (guess_is_rela): Likewise. (slurp_rela_relocs): Likewise. (slurp_rel_relocs): Likewise. (dump_relocations): Likewise. (process_file_header): Likewise. (get_program_headers): Likewise. (process_program_headers): Likewise. (process_section_headers): Likewise. (process_section_groups): Likewise. (dump_ia64_vms_dynamic_fixups): Likewise. (dump_ia64_vms_dynamic_relocs): Likewise. (process_ia64_vms_dynamic_relocs): Likewise. (process_relocs): Likewise. (dump_ia64_unwind): Likewise. (ia64_process_unwind): Likewise. (dump_hppa_unwind): Likewise. (slurp_hppa_unwind_table): Likewise. (hppa_process_unwind): Likewise. (decode_arm_unwind_bytecode): Likewise. (decode_tic6x_unwind_bytecode): Likewise. (decode_arm_unwind): Likewise. (dump_arm_unwind): Likewise. (arm_process_unwind): Likewise. (process_unwind): Likewise. (get_32bit_dynamic_section): Likewise. (get_64bit_dynamic_section): Likewise. (process_dynamic_section): Likewise. (process_version_sections): Likewise. (process_symbol_table): Likewise. (process_syminfo): Likewise. (apply_relocations): Likewise. (disassemble_section): Likewise. (dump_section_as_strings): Likewise. (dump_section_as_bytes): Likewise. (load_specific_debug_section): Likewise. (load_debug_section): Likewise. (display_debug_section): Likewise. (process_section_contents): Likewise. (process_attributes): Likewise. (process_nds32_specific): Likewise. (process_gnu_liblist): Likewise. (print_core_note): Likewise. (print_gnu_note): Likewise. (print_v850_note): Likewise. (process_netbsd_elf_note): Likewise. (print_stapsdt_note): Likewise. (print_ia64_vms_note): Likewise. (process_note): Likewise. (process_notes_at): Likewise. (process_corefile_note_segments): Likewise. (process_v850_notes): Likewise. (process_note_sections): Likewise. (process_notes): Likewise. (process_arch_specific): Likewise. (get_file_header): Likewise. (process_object): Likewise. (process_archive): Likewise. (process_file): Likewise. (section_subset): Make static. (get_mips_reg_size): Return a signed integer. (process_object): Reverse the logic of the return value. (process_archive): Likewise. (process_file): Likewise.
2017-02-24readelf: Correct version flag formattingMaciej W. Rozycki2-6/+16
Remove a trailing space or a leading pipe character from version flags printed with `readelf --version-info'. For example with the `mips-linux' target we get: $ cat ver_def.s .data .globl new_foo .type new_foo, %object new_foo: .symver new_foo, foo@@ver_foo $ cat ver_def.ver { global: *foo*; local: *; }; $ as -o ver_def.o ver_def.s $ ld -e 0 --export-dynamic --version-script=ver_def.ver -o ver_def ver_def.o $ readelf -V ver_def Version symbols section '.gnu.version' contains 4 entries: Addr: 000000000000007e Offset: 0x01007e Link: 2 (.dynsym) 000: 0 (*local*) 2 (ver_foo) 1 (*global*) 2 (ver_foo) Version definition section '.gnu.version_d' contains 2 entries: Addr: 0x0000000000000088 Offset: 0x010088 Link: 3 (.dynstr) 000000: Rev: 1 Flags: BASE Index: 1 Cnt: 1 Name: ver_def 0x001c: Rev: 1 Flags: none Index: 2 Cnt: 1 Name: ver_foo $ which includes an unnecessary space after `BASE'; both call sites already provide suitable separation from output that follows. Also if only unknown flags were present, then lone `| <unknown>' would be printed. binutils/ * readelf.c (get_ver_flags): Tidy the formatting of the string returned
2017-02-24readelf: Make version section index sum unsignedMaciej W. Rozycki2-2/+8
Make `isum' unsigned like data it is calculated from. binutils/ * readelf.c (process_version_sections) <SHT_GNU_verdef>: Make `isum' unsigned. <SHT_GNU_verneed>: Likewise.
2017-02-24readelf: Fix incorrect "Version definition past end of section" messageMaciej W. Rozycki2-3/+14
Fix a commit 74e1a04b9787 ("More fixes for reading corrupt ELF files.") `readelf --version-info' regression that caused "Version definition past end of section" to be always printed at the end, even with good section data. For example with the `mips-linux' target we get: $ cat ver_def.s .data .globl new_foo .type new_foo, %object new_foo: .symver new_foo, foo@@ver_foo $ cat ver_def.ver { global: *foo*; local: *; }; $ as -o ver_def.o ver_def.s $ ld -e 0 --export-dynamic --version-script=ver_def.ver -o ver_def ver_def.o $ readelf -V ver_def Version symbols section '.gnu.version' contains 4 entries: Addr: 000000000000007e Offset: 0x01007e Link: 2 (.dynsym) 000: 0 (*local*) 2 (ver_foo) 1 (*global*) 2 (ver_foo) Version definition section '.gnu.version_d' contains 2 entries: Addr: 0x0000000000000088 Offset: 0x010088 Link: 3 (.dynstr) 000000: Rev: 1 Flags: BASE Index: 1 Cnt: 1 Name: ver_def 0x001c: Rev: 1 Flags: none Index: 2 Cnt: 1 Name: ver_foo Version definition past end of section $ The cause is the `if (idx + ent.vd_next <= idx)' condition introduced to ensure forward progress, which however always triggers for good version definition section data as the last entry will have its `vd_next' value set to 0. Adjust the condition then, to say `if (idx + ent.vd_next < idx)' instead and to ensure forward progress limit the number of entries processed to the size of the version definition section, removing the problematic message from output quoted above, while ensuring the original PR 17531 test case is still handled gracefully. Add a suitable test case so that we have `readelf --version-info' coverage; due to the lack of infrastructure needed to run the linker in the `binutils' test suite and limited justification to implement it add a new `readelf.exp' script to the `ld' test suite instead, intended to gather any `readelf' test cases that require the linker to be run. If ever we decide to have linker infrastructure added to the `binutils' test suite, then the script can be moved between the test suites. binutils/ * readelf.c (process_version_sections) <SHT_GNU_verdef>: Limit the number of entries processed by the section size. Don't break out of the loop if `ent.vd_next' is 0. ld/ * testsuite/ld-elf/ver_def.d: New test. * testsuite/ld-elf/ver_def.ld: New test linker script. * testsuite/ld-elf/ver_def.ver: New test version script. * testsuite/ld-elf/ver_def.s: New test source. * testsuite/ld-elf/readelf.exp: New test script.
2017-02-23DWARF-5: testcaseJan Kratochvil4-0/+1065
binutils/ 2017-02-23 Jan Kratochvil <jan.kratochvil@redhat.com> * testsuite/binutils-all/dw5.S: New file. * testsuite/binutils-all/dw5.W: New file. * testsuite/binutils-all/readelf.exp (readelf -wiaoRlL): New test.
2017-02-23DWARF-5: DW_FORM_data16Jan Kratochvil2-0/+30
binutils/ 2017-02-23 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf.c (read_and_display_attr_value): Support DW_FORM_data16.
2017-02-23DWARF-5: MacrosJan Kratochvil2-28/+33
binutils/ 2017-02-23 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf.c (display_debug_macro): Support DWARF-5. Rename DW_MACRO_GNU_*.
2017-02-23DWARF-5: call sitesJan Kratochvil2-7/+45
binutils/ 2017-02-23 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf.c (decode_location_expression): Support DW_OP_implicit_pointer, DW_OP_const_type, DW_OP_regval_type, DW_OP_deref_type, DW_OP_convert and DW_OP_reinterpret. (read_and_display_attr_value): Support DW_AT_call_value, DW_AT_call_data_value, DW_AT_call_target and DW_AT_call_target_clobbered.
2017-02-23DWARF-5 basic functionalityJan Kratochvil4-204/+994
binutils/ 2017-02-23 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf.c (fetch_indirect_line_string): New function. (abbrev_attr): New field implicit_const. (add_abbrev_attr): New parameter implicit_const. (process_abbrev_section): Support DW_FORM_implicit_const. (decode_location_expression): Support DW_OP_entry_value. (read_and_display_attr_value): Add parameter implicit_const. Support DW_FORM_line_strp and DW_FORM_implicit_const. (read_and_display_attr): Add parameter implicit_const. (process_debug_info): Support line_str and DWARF-5. (read_debug_line_header): Support DWARF-5. (display_formatted_table): New function. (display_debug_lines_raw): New parameter file. Support DWARF-5. (display_debug_lines_decoded): New parameter fileptr. Support DWARF-5. (display_debug_lines): Pass file parameter. (display_debug_macro): Update read_and_display_attr_value caller. (display_debug_abbrev): Support DW_FORM_implicit_const. (display_loclists_list): New function. (display_loc_list): Support .debug_loclists. (display_debug_ranges_list): New function from display_debug_ranges. (display_debug_rnglists_list): New function. (display_debug_ranges): Support .debug_rnglists. (debug_displays): Add .debug_line_str, .debug_loclists and .debug_rnglists. * dwarf.h: Include dwarf2.h (DWARF2_Internal_LineInfo): Add li_offset_size. (DWARF2_Internal_CompUnit): Add cu_unit_type. (enum dwarf_section_display_enum): Add line_str. * readelf.c (process_section_headers): Add rnglists and loclists.
2017-02-23DWARF attrs: add delimiterJan Kratochvil2-25/+33
binutils/ 2017-02-23 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf.c (display_block): Add parameter delimiter. (decode_location_expression): Update display_block callers. (read_and_display_attr_value): Add parameter delimiter. (read_and_display_attr, display_debug_macro): Update read_and_display_attr_value caller.
2017-02-23dwarf.c: Use more dwarf_vmaJan Kratochvil2-23/+34
binutils/ 2017-02-23 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf.c (display_loc_list): Use dwarf_vma for offset, base_address and off. (display_loc_list_dwo): Use dwarf_vma for offset. (display_debug_loc): Use dwarf_vma for offset, base_address. (struct range_entry, range_entry_compar): Use dwarf_vma for ranges_offset. (display_debug_ranges): Use dwarf_vma for ranges_offset, offset and base_address.
2017-02-23Add support to readelf for displaying gnu attributes in architectures not ↵Nick Clifton2-76/+99
known to support them. * readelf.c (display_tag_value): Use an explicit signed type for the tag parameter. (display_gnu_attributes): Use an unsigned integer type for attribute tags. (display_power_gnu_attribute): Likewise. (display_s390_gnu_attribute): Likewise. (display_sparc_hwcaps): Likewise. (display_sparc_hwcaps2): Likewise. (display_sparc_gnu_attribute): Likewise. (display_mips_gnu_attribute): Likewise. (display_tic6x_attribute): Likewise. (display_raw_attribute): Likewise. (process_attributes): Likewise. (process_arm_specific): Delete redundant function. (process_power_specific): Likewise. (process_s390_specific): Likewise. (process_sparc_specific): Likewise. (process_tic6x_specific): Likewise. (process_msp430x_specific): Likewise. (display_public_gnu_attributes): New function. Displays known information about an unknown gnu attribute. (display_generic_attribute): New function. Calls display_tag_value for non-nul tags. (process_arch_specific): Call process_attributes even for architectures not known to specifically support gnu attributes.
2017-02-22Display user op byteJan Kratochvil2-2/+6
binutils/ 2017-02-22 Jan Kratochvil <jan.kratochvil@redhat.com> * dwarf.c (decode_location_expression): Display also OP.
2017-02-22readelf: Restore a lost new line in version informationMaciej W. Rozycki2-1/+7
Fix a commit 74e1a04b9787 ("More fixes for reading corrupt ELF files.") `readelf --version-info' output formatting regression where a dropped new line caused section header information from the `.gnu.version_d' version definition section to be printed on the same line as this section's first entry. For example with the `mips-linux' target we get: $ cat ver_def.s .data .globl new_foo .type new_foo, %object new_foo: .symver new_foo, foo@@ver_foo $ cat ver_def.ver { global: *foo*; local: *; }; $ as -o ver_def.o ver_def.s $ ld -e 0 --export-dynamic --version-script=ver_def.ver -o ver_def ver_def.o $ readelf -V ver_def Version symbols section '.gnu.version' contains 4 entries: Addr: 000000000000007e Offset: 0x01007e Link: 2 (.dynsym) 000: 0 (*local*) 2 (ver_foo) 1 (*global*) 2 (ver_foo) Version definition section '.gnu.version_d' contains 2 entries: Addr: 0x0000000000000088 Offset: 0x010088 Link: 3 (.dynstr) 000000: Rev: 1 Flags: BASE Index: 1 Cnt: 1 Name: ver_def 0x001c: Rev: 1 Flags: none Index: 2 Cnt: 1 Name: ver_foo Version definition past end of section $ Add the new line then, to get: $ readelf -V ver_def Version symbols section '.gnu.version' contains 4 entries: Addr: 000000000000007e Offset: 0x01007e Link: 2 (.dynsym) 000: 0 (*local*) 2 (ver_foo) 1 (*global*) 2 (ver_foo) Version definition section '.gnu.version_d' contains 2 entries: Addr: 0x0000000000000088 Offset: 0x010088 Link: 3 (.dynstr) 000000: Rev: 1 Flags: BASE Index: 1 Cnt: 1 Name: ver_def 0x001c: Rev: 1 Flags: none Index: 2 Cnt: 1 Name: ver_foo Version definition past end of section $ instead. binutils/ * readelf.c (process_version_sections) <SHT_GNU_verdef>: Print a new line between the heading and the first version definition entry.
2017-02-20Fix another memory access error in readelf when parsing a corrupt binary.Nick Clifton2-14/+30
PR binutils/21156 * dwarf.c (cu_tu_indexes_read): Move into... (load_cu_tu_indexes): ... here. Change the variable into tri-state. Change the function into boolean, returning false if the indicies could not be loaded. (find_cu_tu_set): Return NULL if the indicies could not be loaded.
2017-02-17Fix illegal memory accesses in readelf when parsing a corrupt binary.Nick Clifton2-2/+14
PR binutils/21156 * readelf.c (find_section_in_set): Test for invalid section indicies.
2017-02-17Add support to readelf for displaying GNU section types.Nick Clifton2-1/+17
* readelf.c (get_section_type_name): Add decoding of GNU section types.
2017-02-17bfd: Rename Chunk and S3ForcedPedro Alves1-6/+6
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.