aboutsummaryrefslogtreecommitdiff
path: root/binutils
AgeCommit message (Collapse)AuthorFilesLines
2020-05-07objcopy: Mention 'entry address' in descriptionAndrew Burgess2-4/+11
The ELF header contains a start address, which is also sometimes called the entry address. The 'objdump -x' output calls this field the 'start address', while readelf calls it 'entry point address'. The linker talks about setting the 'entry' point in its manual. I've always thought of this field as the 'entry address', and so when I recently wanted to know if objcopy could adjust this field I opened up the manual and searched for 'entry', which found no hits. I thought it would be useful (for people like me) if the description of 'set-start' and 'adjust-start' in the objcopy manual mentioned the word 'entry' to make it easier to find. binutils/ChangeLog: * doc/binutils.texi: Mention 'entry address' in the set-start and adjust-start options descriptions.
2020-05-05Restore readelf's warnings that describe real problems with the file being ↵Nick Clifton6-46/+43
examined. Fix bug displaying empty file name tables. binutils* dwarf.c (do_checks): New global variable. (display_formatted_table): Warn about an unexpected number of columns in the table, if checks are enabled. Do not complain about the lack of data following the number of entries in the table if the table is empty. (display_debug_lines_decoded): Only warn about an unexpected number of columns in a table if checks are enabled. * dwarf.h (do_checks): Add a prototype. * elfcomm.c (error): Remove weak attribute. (warn): Likewise. * readelf.c (do_checks): Delete. (warn): Delete. (process_section_headers): Only warn about empty sections if checks are enabled. gas * dwarf2dbg.c (out_dir_and_file_list): Add comments describing the construction of a DWARF-5 directory name table. * testsuite/gas/elf/pr25917.d: Update expected output.
2020-05-04[PATCH] objcopy: Allow --dump-section to dump an empty SEC_HAS_CONTENTS sectionFangrui Song3-8/+16
* objcopy.c (copy_object): Allow empty section. * testsuite/binutils-all/update-section.exp: Add test.
2020-05-04GAS: Do not create an entry for the default directory if the directory table ↵Nick Clifton2-7/+29
is empty. Improve readelf's decoding of empty directory and file name tables. PR 25917 * dwarf.c (display_debug_lines_decoded): Warn if encountering a supicious number of entries for DWARF-5 format directory and file name tables. Do not display file name table header if the table is empty. Do not allocate space for empty tables.
2020-05-04readelf: nds32 specific decodingAlan Modra2-6/+15
* readelf.c (process_nds32_specific): Check size of .nds32_e_flags section. Don't assume endian of host matches nds32 target. Free buffer.
2020-05-01objdump: long run time when using -D -zAlan Modra2-32/+42
The zero scan is silly when the result isn't used. * objdump.c (disassemble_bytes): Don't scan for zeros when disassembling zeros. Translate "resuming at file offset" message. Formatting. Replace some signed variables with unsigned.
2020-04-30AArch64: add GAS support for UDF instructionAlex Coplan3-6/+12
binutils * testsuite/binutils-all/aarch64/in-order-all.d: Update to use new disassembly. * testsuite/binutils-all/aarch64/out-of-order-all.d: Likewise. ld/ * testsuite/ld-aarch64/erratum843419_tls_ie.d: Use udf in disassembly. * testsuite/ld-aarch64/farcall-b-section.d: Likewise. * testsuite/ld-aarch64/farcall-back.d: Likewise. * testsuite/ld-aarch64/farcall-bl-section.d: Likewise. gas/ * config/tc-aarch64.c (fix_insn): Implement for AARCH64_OPND_UNDEFINED. (parse_operands): Implement for AARCH64_OPND_UNDEFINED. * testsuite/gas/aarch64/udf.s: New. * testsuite/gas/aarch64/udf.d: New. * testsuite/gas/aarch64/udf-invalid.s: New. * testsuite/gas/aarch64/udf-invalid.l: New. * testsuite/gas/aarch64/udf-invalid.d: New. include * opcode/aarch64.h (enum aarch64_opnd): Add AARCH64_OPND_UNDEFINED. opcodes * aarch64-opc.h (enum aarch64_field_kind): Add FLD_imm16_2. * aarch64-opc.c (fields): Add entry for FLD_imm16_2. (operand_general_constraint_met_p): validate AARCH64_OPND_UNDEFINED. * aarch64-tbl.h (aarch64_opcode_table): Add udf instruction, entry for FLD_imm16_2. * aarch64-asm-2.c: Regenerated. * aarch64-dis-2.c: Regenerated. * aarch64-opc-2.c: Regenerated.
2020-04-30Add generic tests for linker support of the -shared or -pie options to tests ↵Nick Clifton2-0/+22
which use them. binutils* testsuite/lib/binutils-common.exp (check_pie_support): New proc. ld * testsuite/ld-elf/compress1c.d: XFAIL if thet target linker does not support the -shared command line option. * /ld-elf/compressed1c.d: Likewise. * /ld-elf/compressed1e.d: Likewise. * /ld-elf/dynamic1.d: Likewise. * /ld-elf/dynsym1.d: Likewise. * /ld-elf/ehdr_start-shared.d: Likewise. * /ld-elf/exclude3b.d: Likewise. * /ld-elf/global1.d: Likewise. * /ld-elf/hash.d: Likewise. * /ld-elf/local1.d: Likewise. * /ld-elf/mbind1b.d: Likewise. * /ld-elf/now-1.d: Likewise. * /ld-elf/now-2.d: Likewise. * /ld-elf/now-3.d: Likewise. * /ld-elf/now-4.d: Likewise. * /ld-elf/pr12975.d: Likewise. * /ld-elf/pr13177.d: Likewise. * /ld-elf/pr13195.d: Likewise. * /ld-elf/pr16322.d: Likewise. * /ld-elf/pr16498a.d: Likewise. * /ld-elf/pr16498b.d: Likewise. * /ld-elf/pr17615.d: Likewise. * /ld-elf/pr19162.d: Likewise. * /ld-elf/pr19698.d: Likewise. * /ld-elf/pr20513c.d: Likewise. * /ld-elf/pr20513d.d: Likewise. * /ld-elf/pr21389a.d: Likewise. * /ld-elf/pr21389b.d: Likewise. * /ld-elf/pr21389c.d: Likewise. * /ld-elf/pr21562a.d: Likewise. * /ld-elf/pr21562b.d: Likewise. * /ld-elf/pr21562c.d: Likewise. * /ld-elf/pr21562d.d: Likewise. * /ld-elf/pr21562e.d: Likewise. * /ld-elf/pr21562f.d: Likewise. * /ld-elf/pr21562g.d: Likewise. * /ld-elf/pr21562h.d: Likewise. * /ld-elf/pr21562i.d: Likewise. * /ld-elf/pr21562j.d: Likewise. * /ld-elf/pr21562k.d: Likewise. * /ld-elf/pr21562l.d: Likewise. * /ld-elf/pr21562m.d: Likewise. * /ld-elf/pr21562n.d: Likewise. * /ld-elf/pr21903a.d: Likewise. * /ld-elf/pr21903b.d: Likewise. * /ld-elf/pr22269b.d: Likewise. * /ld-elf/pr22393-1a.d: Likewise. * /ld-elf/pr22393-1b.d: Likewise. * /ld-elf/pr23658-1c.d: Likewise. * /ld-elf/pr25708.d: Likewise. * /ld-elf/rpath-1.d: Likewise. * /ld-elf/rpath-2.d: Likewise. * /ld-elf/runpath-1.d: Likewise. * /ld-elf/runpath-2.d: Likewise. * /ld-elf/sizeofb.d: Likewise. * /ld-elf/startofb.d: Likewise. * /ld-elf/strtab.d: Likewise. * /ld-elf/textaddr2.d: Likewise. * /ld-elf/textaddr5.d: Likewise. * /ld-elf/textaddr6.d: Likewise. * /ld-elf/unknown2.d: Likewise. * /ld-undefined/entry-3.d: Likewise. * /ld-undefined/entry-4.d: Likewise. * /ld-elf/mbind1c.d: XFAIL if the target linker does not support the -pie option. * /ld-elf/pie.d: Likewise. * /ld-elf/pr19539.d: Likewise. * /ld-elf/pr21903d.d: Likewise. * /ld-elf/pr22269a.d: Likewise. * /ld-elf/pr22393-1c.d: Likewise. * /ld-elf/pr22393-1d.d: Likewise. * /ld-elf/pr22423.d: Likewise. * /ld-elf/loadaddr1.d: Expect to fail on the rx-linux target. * /ld-elf/loadaddr2.d: Likewise. * /ld-elf/pr22393-1e.d: Likewise. * /ld-elf/pr22393-1f.d: Likewise. * /ld-elf/textaddr1.d: Likewise. * /ld-elf/textaddr4.d: Likewise.
2020-04-29When displaying ranges, ignore duplicate offsets.Andrew Burgess2-0/+15
* dwarf.c (display_debug_ranges): Ignore duplicate entries in range_entries for the same offset.
2020-04-29Add a warning if an emtpty SHT_REL, SHT_RELA or SHT_PROGBITS section is ↵Nick Clifton10-53/+201
detected. Disable all warnings unless the (new) lint mode is enabled. * readelf.c (warn): New function - like elfcomm.c version but only produces output if warnings are enabled. (struct options): Add --lint and --enable-checks. (usage): Add entry for --lint. (parse_args): Handle -L. If checks are enabled but no dumps have been selected then enable all dumps. (process_section_headers): Replace long if-then-else sequence with a switch. Add warning messages for empty SHT_REL, SHT_RELA and SHT_PROGBITS sections. (process_file): Do not complain if the file is an archive and lint mode has been enabled. * elfcomm.c (error): Make the function weak. (warn): Likewise. * NEWS: Mention the new feature. * doc/binutils.texi: Document the new feature. * dwarf.h (report_leb_status): Add file name and line number parameters. Include them in the diagnostic output. (READ_ULEB): Pass file and line number to report_leb_status. (READ_SLEB): Likewise. * dwarf.c (read_and_print_leb128): Pass file and line number to report_leb_status. * testsuite/binutils-all/readelf.exp: Add test of new feature. * testsuite/binutils-all/zero-sec.s: New test source file. * testsuite/binutils-all/zero-sec.r: Expected output from new test.
2020-04-29Updated Serbian translation for the binutils sub-directory, and Swedish ↵Nick Clifton2-2455/+5580
translation for the opcodes sub-directory.
2020-04-26readelf: NULL dereferenceAlan Modra2-30/+16
This fixes another missing error check. * readelf.c (get_num_dynamic_syms): Check DT_MIPS_XHASH was read before dereferencing, and gracefully return. Remove gnu_hash_error variable. Free gnu hash arrays if number of syms found is zero.
2020-04-24readelf: memory leaks in process_dynamic_sectionAlan Modra2-66/+82
This fixes some code that assumed only one PT_LOAD would contain DT_SYMTAB. Which is normally the case, but fuzzers thoroughly mess with object files. * readelf.c (get_num_dynamic_syms): Check for nbuckets and nchains non-zero. (process_dynamic_section): Call get_num_dynamic_syms once rather than in segment loop. Break out of segment loop on a successful load of dynamic symbols. Formatting. (process_object): Return error status from process_dynamic_section.
2020-04-23arc: Add support for ARC HS extra registers in core filesAnton Kolesov2-0/+12
When a coredump is generated, there are a few registers in ARC HS that are put under a special section, namely ".reg-v2". It is for backward compatibility reasons with older tools that we have decided not to extend the generic ".reg" section. This patch makes it possible to display the information better regarding that section. Compare the output of "readelf" without and with these changes: $ readelf -n core # without the patch ... LINUX 0x0000000c Unknown note type: (0x00000600) description data: 78 08 00 00 2f 6c 64 2d 75 43 6c 69 $ readelf -n core # with the patch ... LINUX 0x0000000c NT_ARC_V2 (ARC HS accumulator/extra registers) description data: 78 08 00 00 2f 6c 64 2d 75 43 6c 69 In another commit (soon to be submitted), GDB will makes use of these changes to parse the extra section and its registers. bfd/ChangeLog 2020-03-26 Anton Kolesov <anton.kolesov@synopsys.com> * elf-bfd.h (elfcore_write_arc_v2): Add prototype. * elf.c (elfcore_grok_arc_v2): New function. (elfcore_grok_note): Call the new function to handle the corresponding note. (elfcore_write_arc_v2): New function. (elfcore_write_register_note): Call the new function to handle the corresponding pseudo-sections. binutils/ChangeLog 2020-03-26 Anton Kolesov <anton.kolesov@synopsys.com> * readelf.c (get_note_type): Handle NT_ARC_V2. include/elf/ChangeLog 2020-03-26 Anton Kolesov <anton.kolesov@synopsys.com> * common.h (NT_ARC_V2): New macro definitions.
2020-04-22xtensa: fix PR ld/25861Max Filippov2-1/+14
Introduce new relaxations XTENSA_PDIFF{8,16,32} for positive differences (subtracted symbol precedes diminished symbol) and XTENSA_NDIFF{8,16,32} for negative differences (subtracted symbol follows diminished symbol). Don't generate XTENSA_DIFF relocations in the assembler, generate XTENSA_PDIFF or XTENSA_NDIFF based on relative symbol position. Handle XTENSA_DIFF in BFD for compatibility with old object files. Handle XTENSA_PDIFF and XTENSA_NDIFF in BFD, treating difference value as unsigned. 2020-04-22 Max Filippov <jcmvbkbc@gmail.com> bfd/ * bfd-in2.h: Regenerated. * elf32-xtensa.c (elf_howto_table): New entries for R_XTENSA_PDIFF{8,16,32} and R_XTENSA_NDIFF{8,16,32}. (elf_xtensa_reloc_type_lookup, elf_xtensa_do_reloc) (relax_section): Add cases for R_XTENSA_PDIFF{8,16,32} and R_XTENSA_NDIFF{8,16,32}. * libbfd.h (bfd_reloc_code_real_names): Add names for BFD_RELOC_XTENSA_PDIFF{8,16,32} and BFD_RELOC_XTENSA_NDIFF{8,16,32}. * reloc.c: Add documentation for BFD_RELOC_XTENSA_PDIFF{8,16,32} and BFD_RELOC_XTENSA_NDIFF{8,16,32}. binutils/ * readelf.c (is_none_reloc): Recognize BFD_RELOC_XTENSA_PDIFF{8,16,32} and BFD_RELOC_XTENSA_NDIFF{8,16,32}. gas/ * config/tc-xtensa.c (md_apply_fix): Replace BFD_RELOC_XTENSA_DIFF{8,16,32} generation with BFD_RELOC_XTENSA_PDIFF{8,16,32} and BFD_RELOC_XTENSA_NDIFF{8,16,32} generation. * testsuite/gas/xtensa/loc.d: Replace BFD_RELOC_XTENSA_DIFF16 with BFD_RELOC_XTENSA_PDIFF16 in the expected output. include/ * elf/xtensa.h (elf_xtensa_reloc_type): New entries for R_XTENSA_PDIFF{8,16,32} and R_XTENSA_NDIFF{8,16,32}. ld/ * testsuite/ld-xtensa/relax-loc.d: New test definition. * testsuite/ld-xtensa/relax-loc.s: New test source. * testsuite/ld-xtensa/xtensa.exp (relax-loc): New test.
2020-04-22Add myself as maintainer for PDP11.Stephen Casner1-0/+1
2020-04-22Remove Chris Faylor as the ix86 PE maintainer.Nick Clifton2-1/+4
* MAINTAINERS: Remove Chris Faylor as the ix86 PE maintainer.
2020-04-22readelf: move file related static vars to filedataAlan Modra2-441/+504
The idea here is to get rid of a lot of file related static vars used to pass data around, in order to not have stale data about one object file persisting to the next one. * readelf.c (archive_file_offset, archive_file_size, dynamic_addr), (dynamic_size, dynamic_nent, dynamic_strings, dynamic_strings_length), (num_dynamic_syms, nbuckets, nchains, buckets, chains), (ngnubuckets, gnubuckets, gnuchains, mipsxlat, ngnuchains), (gnusymidx, dynamic_symbols, dynamic_syminfo, dynamic_syminfo_offset), (dynamic_syminfo_nent, program_interpreter, dynamic_info), (dynamic_info_DT_GNU_HASH, dynamic_info_DT_MIPS_XHASH, version_info), (dynamic_section, symtab_shndx_list, group_count, section_groups), (section_headers_groups): Move to struct filedata. Update use throughout file.
2020-04-22readelf: cmdline dataAlan Modra2-50/+64
Don't use a struct filedata for cmdline, which only needs two of the filedata fields. * readelf.c (struct dump_data): New, used.. (cmdline): ..here, and.. (struct filedata): ..here. Adjust all uses. (request_dump_bynumber, request_dump, parse_args): Pass in a struct dump_data* rather than Filedata*. Adjust callers. (main): Don't set cmdline.file_name.
2020-04-20fix typo last commitAlan Modra1-1/+1
2020-04-20readelf: segfault at readelf.c:12227Alan Modra2-0/+11
This is another one where not cleaning up sufficiently after processing one file can lead to errors when processing the next file. We have ngnuchains non-zero but gnuchains NULL in the following: off < ngnuchains && (gnuchains[off] & 1) == 0 * readelf.c (process_symbol_table): Clear ngnuchains, ngnubuckets and nbuckets.
2020-04-20readelf: segfaults fuzzing multiple object filesAlan Modra2-15/+19
This patch is aimed at fixing a number of oss-fuzz segfaults that don't reproduce reliably with their current infrastructure, the problem being that one invocation of readelf is effectively being run on multiple object files. I believe that these segfaults could be reliably reproduced with just two fuzzed objects being presented to readelf, but those inputs are currently not identified by oss-fuzz. So there is some guesswork involved in this patch. The idea here is to clear stashed data such as symtab_shndx_list that is processed using section header info, at the same time that header info is cleared. * readelf.c (process_section_headers): Free dynamic symbols etc. earlier.
2020-04-20readelf memory leaksAlan Modra2-5/+14
This fixes two leaks found in the new code supporting display of dynamic symbols retrieved via dynamic tags. * readelf.c (get_num_dynamic_syms): Formatting. Don't return on error without freeing. (process_dynamic_section): Don't recreate dynamic symbols from dynamic tag info when the dynamic symbols have already been read via section headers.
2020-04-17[PATCH v2] binutils: arm: Fix disassembly of conditional VDUPs.Fredrik Strupe5-0/+74
VDUP (neon) instructions can be conditional, but this is not taken into account in the current master. This commit fixes that by i) fixing the VDUP instruction masks and ii) adding logic for disassembling conditional neon instructions. opcodes * arm-dis.c (neon_opcodes): Fix VDUP instruction masks. (print_insn_neon): Support disassembly of conditional instructions. binutils* testsuite/binutils-all/arm/vdup-cond.d: New test for testing that conditional VDUP instructions are disassembled correctly. * testsuite/binutils-all/arm/vdup-cond.s: New file used by vdup-cond.d. * testsuite/binutils-all/arm/vdup-thumb.d: New test for testing that VDUP instructions (which are conditional in A32) can be disassembled in thumb mode. * testsuite/binutils-all/arm/vdup-cond.s: New file used by vdup-thumb.d.
2020-04-17PR25840, Null pointer dereference in objdumpAlan Modra2-0/+7
PR 25840 * debug.c (debug_class_type_samep): Don't segfault on NULL type.
2020-04-16Extend objdump --no-addresses infoAlan Modra2-1/+7
* doc/binutils.texi: Mention --no-show-raw-insn in objdump --no-addresses description.
2020-04-15objdump --no-addressesAlan Modra3-18/+54
I find this useful when needing to compare compiler output, where the address of the instruction and the value of symbols results in unwanted differences. * objdump.c (no_addresses): New static var. (usage): Print help for --no-addresses. (long_options): Add --no-addresses entry. (objdump_print_addr_with_sym, objdump_print_addr): Omit symbol address. (disassemble_bytes): Don't print current line address, or reloc address. * doc/binutils.texi: Document objdump --no-addresses.
2020-04-15PR25822, Invalid read in process_symbol_tableAlan Modra2-1/+9
PR 25822 * readelf.c (get_num_dynamic_syms): Don't set num_of_syms when reading buckets or chains fails.
2020-04-15readelf: zero static vars after freeingAlan Modra2-0/+13
When readelf is processing more than one file, static bss vars won't start out as zero for the second file unless they are cleared. * readelf.c (process_symbol_table): Zero gnubuckets, gnuchains etc. after freeing.
2020-04-15readelf: increase size of static buffersAlan Modra2-23/+17
Translated strings might be larger than the original. * readelf.c (get_group_flags): Translate text. (get_file_type, get_symbol_binding, get_symbol_type), (get_ppc64_symbol_other, get_symbol_other): Increase size of buffer.
2020-04-15Re: readelf: Consolidate --syms --use-dynamic with --dyn-symsAlan Modra2-1/+6
PR 25821 * readelf.c (get_num_dynamic_syms): Typo fix.
2020-04-14readelf memory leaks processing mipsAlan Modra2-3/+12
* readelf.c (process_mips_specific): Free eopt and iopt. Avoid possibility of overflow when checking number of conflicts.
2020-04-14readelf: Consolidate --syms --use-dynamic with --dyn-symsH.J. Lu2-499/+527
When reconstructing dynamic symbol table from the PT_DYNAMIC segment, compute dynamic symbol table size from hash table. For DT_HASH, the number of dynamic symbol table entries equals the number of chains. For DT_GNU_HASH/DT_MIPS_XHASH, only defined symbols with non-STB_LOCAL indings are in hash table. Since DT_GNU_HASH/DT_MIPS_XHASH place all symbols with STB_LOCAL binding before symbols with other bindings and all undefined symbols defined ones in dynamic symbol table, the highest symbol index in DT_GNU_HASH/DT_MIPS_XHASH is the highest dynamic symbol table index. Rewrite print_dynamic_symbol to dump dynamic symbol table for --dyn-syms and --syms --use-dynamic. binutils/ PR binutils/25707 * readelf.c (nbuckets): New. (nchains): Likewise. (buckets): Likewise. (chains): Likewise. (ngnubuckets): Likewise. (gnubuckets): Likewise. (gnuchains): Likewise. (mipsxlat): Likewise. (ngnuchains): Likewise. (gnusymidx): Likewise. (VALID_SYMBOL_NAME): Likewise. (VALID_DYNAMIC_NAME): Use it. (get_dynamic_data): Moved before process_dynamic_section. (get_num_dynamic_syms): New function. (process_dynamic_section): Use DT_SYMTAB, DT_SYMENT, DT_HASH, DT_GNU_HASH and DT_MIPS_XHASH to reconstruct dynamic symbol table. Use DT_STRTAB and DT_STRSZ to reconstruct dynamic string table. (get_symbol_index_type): Don't print "bad section index" when there is no section header. (print_dynamic_symbol): Rewrite. (process_symbol_table): Call print_dynamic_symbol to dump dynamic symbol table. ld/ PR binutils/25707 * testsuite/ld-arm/armthumb-lib.sym: Updated. * testsuite/ld-arm/farcall-mixed-app.sym: Likewise. * testsuite/ld-arm/farcall-mixed-app2.sym: Likewise. * testsuite/ld-arm/fdpic-main-m.sym: Likewise. * testsuite/ld-arm/fdpic-main.sym: Likewise. * testsuite/ld-arm/fdpic-shared-m.sym: Likewise. * testsuite/ld-arm/fdpic-shared.sym: Likewise. * testsuite/ld-arm/mixed-app.sym: Likewise. * testsuite/ld-arm/mixed-lib.sym: Likewise. * testsuite/ld-arm/preempt-app.sym: Likewise. * testsuite/ld-elf/hash.d: Likewise. * testsuite/ld-elf/pr13195.d: Likewise. * testsuite/ld-elfvsb/hidden2.d: Likewise. * testsuite/ld-mips-elf/hash2.d: Likewise.
2020-04-02ld: Disable ifunc tests on SolarisRainer Orth2-2/+6
A couple of ld ifunc tests currently FAIL on 64-bit Solaris/x86: FAIL: ld-ifunc/ifunc-10-x86-64 FAIL: ld-ifunc/ifunc-11-x86-64 FAIL: ld-ifunc/ifunc-12-x86-64 FAIL: ld-ifunc/ifunc-13-x86-64 FAIL: ld-ifunc/ifunc-14a-x86-64 FAIL: ld-ifunc/ifunc-14b-x86-64 FAIL: ld-ifunc/ifunc-14c-x86-64 FAIL: ld-ifunc/ifunc-14d-x86-64 FAIL: ld-ifunc/ifunc-14e-x86-64 FAIL: ld-ifunc/ifunc-14f-x86-64 FAIL: ld-ifunc/ifunc-15-x86-64 FAIL: ld-ifunc/ifunc-17a-x86-64 FAIL: ld-ifunc/ifunc-17b-x86-64 FAIL: ld-ifunc/ifunc-2-local-x86-64-now FAIL: ld-ifunc/ifunc-2-local-x86-64 FAIL: ld-ifunc/ifunc-2-x86-64-now FAIL: ld-ifunc/ifunc-2-x86-64 FAIL: ld-ifunc/ifunc-20-x86-64 FAIL: ld-ifunc/pr17154-x86-64-now FAIL: ld-ifunc/pr17154-x86-64 For one, the actual error is weird: ./ld-new: target elf64-x86-64 not found failed with: <./ld-new: target elf64-x86-64 not found>, no expected output FAIL: ld-ifunc/ifunc-10-x86-64 although ld -V does report the elf_x86_64 emulation as supported: $ ./ld/ld-new -V GNU ld (GNU Binutils) 2.34.50.20200328 Supported emulations: elf_x86_64_sol2 elf_x86_64 [...] When using ld -m elf_x86_64_sol2 instead, one of the testcases links successfully. However, there's no point in pursuing this: Solaris does not support ifunc, as can be seen in <sys/elf.h>: /* * GNU/Linux specific symbol type not used by Solaris */ #define STT_GNU_IFUNC 10 and never will, given that it has symbol capabilities as solution to effectively the same problem: http://www.linker-aliens.org/blogs/rie/entry/symbol_capabilitie/ Therefore this patch disables ifunc testing on Solaris completely by removing Solaris from binutils/testsuite/lib/binutils-common.exp (supports_gnu_osabi). The ifunc part is justified above. SHF_GNU_MBIND is in the OS-specific range and conflicts with #define SHF_SUNW_REALLOC 0x01000000 /* internal: krtld realloc */ While the comment suggests this might be relocatable without too much problems, the description of mbind (no formal spec AFAICS, just the comment in the binutils patch submission) strongly suggests that this isn't relevant to Solaris at all. Indirectly, clearing supports_gnu_osabi on Solaris disables supports_gnu_unique. Again, Solaris <sys/elf.h> has /* * GNU/Linux specific binding not used by Solaris */ #define STB_GNU_UNIQUE 10 so this seems the right thing to do. Afterwards, one can remove the explicit mentions of *-*-solaris2* in quite a number of (but not all) the ld-ifunc dump file notarget lists. There's one fallout, though: two gas tests now XPASS because they are xfail'ed for !supports_gnu_osabi: XPASS: mbind sections 12 XPASS: mbind section contents 16 XPASS: mbind sections 16 XPASS: mbind section contents 16 To fix that, I've changed #xfail: ![supports_gnu_osabi] to notarget. Tested on x86_64-pc-solaris2.11, i386-pc-solaris2.11, x86_64-pc-linux-gnu, and i686-pc-linux-gnu. ld: * testsuite/ld-ifunc/ifunc-10-i386.d: Remove *-*-solaris2* from notarget. * ifunc-11-i386.d: Likewise. * ifunc-12-i386.d: Likewise. * ifunc-13-i386.d: Likewise. * ifunc-14a-i386.d: Likewise. * ifunc-14b-i386.d: Likewise. * ifunc-14c-i386.d: Likewise. * ifunc-14d-i386.d: Likewise. * ifunc-14e-i386.d: Likewise. * ifunc-14f-i386.d: Likewise. * ifunc-15-i386.d: Likewise. * ifunc-16-i386-now.d: Likewise. * ifunc-16-i386.d: Likewise. * ifunc-17a-i386.d: Likewise. * ifunc-17b-i386.d: Likewise. * ifunc-18a-i386.d: Likewise. * ifunc-18b-i386.d: Likewise. * ifunc-19a-i386.d: Likewise. * ifunc-19b-i386.d: Likewise. * ifunc-2-i386-now.d: Likewise. * ifunc-2-i386.d: Likewise. * ifunc-2-local-i386-now.d: Likewise. * ifunc-2-local-i386.d: Likewise. * ifunc-20-i386.d: Likewise. * ifunc-21-i386.d: Likewise. * ifunc-22-i386.d: Likewise. * ifunc-5a-i386.d: Likewise. * ifunc-5a-local-i386.d: Likewise. * ifunc-5b-i386.d: Likewise. * ifunc-5b-local-i386.d: Likewise. * ifunc-5r-local-i386.d: Likewise. * ifunc-6a-i386.d: Likewise. * ifunc-6b-i386.d: Likewise. * ifunc-7a-i386.d: Likewise. * ifunc-7b-i386.d: Likewise. * ifunc-8-i386.d: Likewise. * ifunc-9-i386.d: Likewise. * pr17154-i386-now.d: Likewise. * pr17154-i386.d: Likewise. * ifunc-23a-x86.d: Remove notarget. * ifunc-24a-x86.d: Likewise. * ifunc-25a-x86.d: Likewise. gas: * testsuite/gas/elf/section12a.d: Use notarget instead of xfail. * testsuite/gas/elf/section12b.d: Likewise. * testsuite/gas/elf/section16a.d: Likewise. * testsuite/gas/elf/section16b.d: Likewise. binutils: * testsuite/lib/binutils-common.exp (supports_gnu_osabi): Don't enable on *-*-solaris*.
2020-03-30Fix objcopy's --preserve-dates command line option so that it will work with ↵Nick Clifton3-1/+16
PE format files. PR binutils/pr25662 bfd * libcoff-in.h (struct pe_tdata): Rename the insert_timestamp field to timestamp and make it an integer. * libcoff.h: Regenerate. * peXXigen.c (_bfd_XXi_only_swap_filehdr_out): Test the timestamp field in the pe_data structure rather than the insert_timestamp field. binutils* objcopy.c (copy_object): When copying PE format files set the timestamp field in the pe_data structure if the preserve_dates flag is set. * testsuite/binutils-all/objcopy.exp (objcopy_test) Use --preserve-dates in place of the -p option, in order to make its effect more obvious. ld * emultempl/pe.em (after_open): Replace initialisation of the insert_timestamp field in the pe_data structure with an initialisation of the timestamp field. * emultemp/pep.em: Likewise. * pe-dll.c (fill_edata): Use the timestamp field in the pe_data structure instead of the insert_timestamp field.
2020-03-28Re: Adjust objcopy_testAlan Modra2-4/+9
Last patch didn't manage to xfail spu due to clear_xfail *-*-*elf*. Clearing *-*-*elf* dates back to a time when we had rather a lot more setup_xfail patterns, so limiting it to hppa*-*-*elf*. Also, mips-*-irix ought to have been mips-*-irix* and I'm having second thoughts about xfailing mips and hiding what looks like a problem: If the mips target is supposed to emit names for local section symbols and does so for objcopy, why isn't it doing the same for ld? Also, lots more mips targets would be subject to this test failing. So I'm backing out those xfails and leaving it to someone more knowledgeable about mips. * testsuite/binutils-all/objcopy.exp (objcopy_test): Only clear_xfail hppa*-*-*elf*. Revert mips xfails.
2020-03-28Adjust objcopy_testAlan Modra2-14/+28
xfails spu due to a note section getting a different vma, and some mips targets that give section symbols a name string. I added -p for the executable test in an attempt to fix all the pe target fails, but that doesn't preserve the date/time for some reason. * testsuite/binutils-all/objcopy.exp (objcopy_test): Move xfails from here to calls. Remove "m8*-*-*" entry. Don't xfail tic54x but do xfail spu, mipstx39 and mips-sgi-irix for the executable test. Pass "-p" to objcopy for the executable test.
2020-03-27Add testcase for PR 25662 invalid sh_offset for sectionJozef Lawrynowicz4-19/+104
binutils/ChangeLog: 2020-03-27 Jozef Lawrynowicz <jozef.l@mittosystems.com> PR binutils/25662 * testsuite/binutils-all/objcopy.exp (objcopy_test): Add argument to specify whether an object file or executable should be built and tested. Change test names to report whether an object file or executable is being tested. * testsuite/binutils-all/pr25662.ld: New test. * testsuite/binutils-all/pr25662.s: New test.
2020-03-27Re: readelf looping in process_archiveAlan Modra2-2/+7
This patch fixes a leak of qualified_name caused by 4c83662712 and a double free introduced by fd486f32d1. Not breaking out of the loop results in an error: "failed to seek to next archive header". That's slightly better than silently preventing the possibility of endless loops. * readelf.c (process_archive): Don't double free qualified_name. Don't break out of loop with "negative" archive_file_size, just set file offset to max.
2020-03-25readelf looping in process_archiveAlan Modra2-2/+8
With a crafted "negative" ar_hdr.ar_size it is possible to make readelf loop. This patch catches the overflow in a file offset calculation. * readelf.c (process_archive): Prevent endless loop.
2020-03-24bfd: Add a bfd_boolean argument to bfd_get_symbol_version_stringH.J. Lu3-5/+14
We can't call _bfd_elf_get_symbol_version_name from nm.c since it isn't available for all target configurations. This patch add a bfd_boolean argument to bfd_get_symbol_version_string instead. bfd/ PR binutils/25708 * elf-bfd.h (_bfd_elf_get_symbol_version_name): Renamed to ... (_bfd_elf_get_symbol_version_string): This. * elf.c (_bfd_elf_get_symbol_version_name): Renamed to ... (_bfd_elf_get_symbol_version_string): This. (bfd_elf_print_symbol): Pass TRUE to _bfd_elf_get_symbol_version_string. * libbfd-in.h (_bfd_nosymbols_get_symbol_version_string): Add a bfd_boolean argument. * syms.c (_bfd_nosymbols_get_symbol_version_string): Likewise. * targets.c (_bfd_get_symbol_version_string): Likewise. (bfd_get_symbol_version_string): Likewise. * bfd-in2.h: Regenerated. binutils/ PR binutils/25708 * nm.c (print_symname): Replace _bfd_elf_get_symbol_version_name with bfd_get_symbol_version_string. (print_symbo): Pass TRUE to bfd_get_symbol_version_string. * objdump.c (objdump_print_symname): Likewise.
2020-03-24bfd: Display symbol version for nm -DH.J. Lu2-6/+32
Extend _bfd_elf_get_symbol_version_string for nm -D to display symbol version. _bfd_elf_get_symbol_version_name is added to avoid updating all XXX_get_symbol_version_string functions. bfd/ PR binutils/25708 * elf-bfd.h (_bfd_elf_get_symbol_version_name): New. * elf.c (_bfd_elf_get_symbol_version_name): New function. Based on the previous _bfd_elf_get_symbol_version_string. (_bfd_elf_get_symbol_version_string): Use it. binutils/ PR binutils/25708 * nm.c (SYM_NAME): Removed. (print_symname): Add a pointer to struct extended_symbol_info argument. Call _bfd_elf_get_symbol_version_name to get symbol version. (print_symdef_entry): Pass NULL to print_symname. (print_symbol_info_bsd): Update call to print_symname. (print_symbol_info_sysv): Likewise. (print_symbol_info_posix): Likewise. ld/ PR binutils/25708 * testsuite/ld-elf/pr25708.d: New file.
2020-03-24readelf memory leak in process_mips_specificAlan Modra2-2/+12
* readelf.c (process_mips_specific): Free iconf on error path.
2020-03-23Avoid trigger an assertion failure in the STABS parser by replacing the ↵Nick Clifton2-18/+59
abort with an error return. PR 25714 * wrstabs.c (stab_pop_type): Replace assertion with error return. * write_stabs_in_sections_debugging_info: Likewise. * stab_enum_type: Likewise. * stab_modify_type: Likewise. * stab_struct_field: Likewise. * stab_end_struct_type: Likewise. * stab_start_class_type: Likewise. * stab_class_static_member: Likewise. * stab_class_baseclass: Likewise. * stab_class_start_method: Likewise. * stab_class_method_var: Likewise. * stab_class_end_method: Likewise. * stab_end_class_type: Likewise. * stab_typedef_type: Likewise. * stab_start_function: Likewise. * stab_end_block: Likewise. * stab_lineno: Likewise.
2020-03-20Fix compile time warnings about the possibility of using uninitialised ↵Nick Clifton2-9/+34
fields in the Elf_Internal_Chdr structure when building readelf. * readelf.c (get_compression_header): Add ATTRIBUTE_WARN_UNUSED_RESULT. (process_section_headers): Check the return value from get_compression_header. (dump_section_as_strings): Likewise. (dump_section_as_bytes): Likewise. (load_specific_debug_section): Likewise.
2020-03-20plugin: Don't invoke LTO-wrapperH.J. Lu3-2/+7
Don't invoke LTO-wrapper since the LTO wrapper approach is not only slow but also unreliable. For GCC 10 or newer, LDPT_ADD_SYMBOLS_V2 will be used. bfd/ * configure.ac (HAVE_EXECUTABLE_SUFFIX): Removed. (EXECUTABLE_SUFFIX): Likewise. * config.in: Regenerated. * configure: Likewise. * plugin.c (bfd_plugin_close_and_cleanup): Defined as _bfd_generic_close_and_cleanup. (plugin_list_entry): Remove resolution_file, resolution_option, real_bfd, real_nsyms, real_syms, lto_nsyms, lto_syms, gcc, lto_wrapper, gcc_env and initialized, (need_lto_wrapper_p): Removed. (get_lto_wrapper): Likewise. (setup_lto_wrapper_env): Likewise. (register_all_symbols_read): Likewise. (egister_cleanup): Likewise. (get_symbols): Likewise. (add_input_file): Likewise. (bfd_plugin_set_program_name): Remove need_lto_wrapper. (add_symbols): Updated. (try_claim): Likewise. (try_load_plugin): Likewise. (bfd_plugin_canonicalize_symtab): Likewise. * plugin.h (bfd_plugin_set_program_name): Remove int argument. (plugin_data_struct): Remove real_bfd, real_nsyms and real_syms. binutils/ * ar.c (main): Update bfd_plugin_set_program_name call. * nm.c (main): Likewise. ld/ * testsuite/ld-plugin/lto.exp (lto_link_tests): Run PR ld/25355 test only for GCC 10 or newer.
2020-03-19Fix discrepancies in nm's --line-number output by adding support for the ↵Nick Clifton3-0/+2027
DW_AT_specification DWARF Attttribute. PR 25676 bfd * dwarf2.c (struct varinfo): Add unit_offset field to record the location of the varinfo in the unit's debug info data. Change the type of the stack field to a boolean. (lookup_var_by_offset): New function. Returns the varinfo structure for the variable described at the given offset in the unit's debug info. (scan_unit_for_symbols): Add support for variables which have the DW_AT_specification attribute. binutils* testsuite/binutils-all/dw4.s: New test source file. * testsuite/binutils-all/nm.exp: Run the new test.
2020-03-19readelf.c: Use unsigned long to iterate over num_symsH.J. Lu2-4/+7
process_symbol_table () has unsigned long num_syms; ... for (si = 0, psym = symtab; si < num_syms; si++, psym++) We should use unsigned long to iterate over num_syms. * readelf.c (process_symbol_table): Use unsigned long for si.
2020-03-19Don't use bfd.h in binutils/elfcomm.cAlan Modra3-31/+39
Better than warning about bfd types, just don't include bfd.h and warn against including the header again. * elfcomm.c: Don't include bfd.h or bucomm.h. (program_name): Declare. (process_archive_index_and_symbols): Replace bfd_boolean with int, and substitute FALSE and TRUE. (setup_archive, setup_nested_archive): Likewise. * elfcomm.h: Likewise.
2020-03-19readelf leak in process_archiveAlan Modra2-76/+95
* readelf.c (process_archive): Always return via path freeing memory. Formatting.