aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2018-12-05Automatic date update in version.inGDB Administrator1-1/+1
2018-12-04x86: Don't remove empty GNU_PROPERTY_X86_UINT32_OR_AND propertiesH.J. Lu9-4/+61
For GNU_PROPERTY_X86_COMPAT_ISA_1_USED and GNU_PROPERTY_X86_UINT32_OR_AND properties, a bit in the output pr_data field is set if it is set in any relocatable input pr_data fields and this property is present in all relocatable input files. A missing property implies that its bits have unknown values. When all bits in the the output pr_data field are zero, this property should not be removed from output to indicate it has zero in all bits. bfd/ PR ld/23372 * elfxx-x86.c (_bfd_x86_elf_merge_gnu_properties): Don't remove empty properties for GNU_PROPERTY_X86_COMPAT_ISA_1_USED and GNU_PROPERTY_X86_UINT32_OR_AND. (_bfd_x86_elf_link_fixup_gnu_properties): Likewise. ld/ PR ld/23372 * testsuite/ld-i386/pr23372a.d: Updated. * testsuite/ld-i386/pr23372c.d: Likewise. * testsuite/ld-x86-64/pr23372a-x32.d: Likewise. * testsuite/ld-x86-64/pr23372a.d: Likewise. * testsuite/ld-x86-64/pr23372c-x32.d: Likewise. * testsuite/ld-x86-64/pr23372c.d: Likewise.
2018-12-03Restore build on x86_64-w64-mingw32.Alexey Neyman5-4/+34
gold/ PR gold/23594 * configure.ac: Add checks for link, mkdtemp. * configure: Regenerate. * config.in: Regenerate. * plugin.cc (Plugin_recorder::init): Fall back to mktemp if mkdtemp is not available. (link_or_copy_file): Fall back to copy if link() is not available.
2018-12-04PR23939, Check frch_cfi_data before usewu.heng2-1/+15
PR 23939 * dw2gencfi.c (dot_cfi_label): Check frch_cfi_data is non-NULL before use.
2018-12-04Automatic date update in version.inGDB Administrator1-1/+1
2018-12-03RISC-V: Accept version, supervisor ext and more than one NSE for -march.Jim Wilson36-143/+720
This patch moves all -march parsing logic into bfd, because we will use this code in ELF attributes. bfd/ * elfxx-riscv.h (RISCV_DONT_CARE_VERSION): New macro. (struct riscv_subset_t): New structure. (riscv_subset_t): New typedef. (riscv_subset_list_t): New structure. (riscv_release_subset_list): New prototype. (riscv_add_subset): Likewise. (riscv_lookup_subset): Likewise. (riscv_lookup_subset_version): Likewise. (riscv_release_subset_list): Likewise. * elfxx-riscv.c: Include safe-ctype.h. (riscv_parsing_subset_version): New function. (riscv_supported_std_ext): Likewise. (riscv_parse_std_ext): Likewise. (riscv_parse_sv_or_non_std_ext): Likewise. (riscv_parse_subset): Likewise. (riscv_add_subset): Likewise. (riscv_lookup_subset): Likewise. (riscv_lookup_subset_version): Likewise. (riscv_release_subset_list): Likewise. gas/ * config/tc-riscv.c: Include elfxx-riscv.h. (struct riscv_subset): Removed. (riscv_subsets): Change type to riscv_subset_list_t. (riscv_subset_supports): Removed argument: xlen_required and move logic into libbfd. (riscv_multi_subset_supports): Removed argument: xlen_required. (riscv_clear_subsets): Removed. (riscv_add_subset): Ditto. (riscv_set_arch): Extract parsing logic into libbfd. (riscv_ip): Update argument for riscv_multi_subset_supports and riscv_subset_supports. Update riscv_subsets due to struct definition changed. (riscv_after_parse_args): Update riscv_subsets due to struct definition changed, update and argument for riscv_subset_supports. * testsuite/gas/riscv/empty.s: New. * testsuite/gas/riscv/march-fail-rv32ef.d: Likewise. * testsuite/gas/riscv/march-fail-rv32ef.l: Likewise. * testsuite/gas/riscv/march-fail-rv32i.d: Likewise. * testsuite/gas/riscv/march-fail-rv32i.l: Likewise. * testsuite/gas/riscv/march-fail-rv32iam.d: Likewise. * testsuite/gas/riscv/march-fail-rv32iam.l: Likewise. * testsuite/gas/riscv/march-fail-rv32ic.d: Likewise. * testsuite/gas/riscv/march-fail-rv32ic.l: Likewise. * testsuite/gas/riscv/march-fail-rv32icx2p.d: Likewise. * testsuite/gas/riscv/march-fail-rv32icx2p.l: Likewise. * testsuite/gas/riscv/march-fail-rv32imc.d: Likewise. * testsuite/gas/riscv/march-fail-rv32imc.l: Likewise. * testsuite/gas/riscv/march-fail-rv64I.d: Likewise. * testsuite/gas/riscv/march-fail-rv64I.l: Likewise. * testsuite/gas/riscv/march-fail-rv64e.d: Likewise. * testsuite/gas/riscv/march-fail-rv64e.l: Likewise. * testsuite/gas/riscv/march-ok-g2.d: Likewise. * testsuite/gas/riscv/march-ok-g2p0.d: Likewise. * testsuite/gas/riscv/march-ok-i2p0.d: Likewise. * testsuite/gas/riscv/march-ok-nse-with-version.: Likewise.d * testsuite/gas/riscv/march-ok-s-with-version.d: Likewise. * testsuite/gas/riscv/march-ok-s.d: Likewise. * testsuite/gas/riscv/march-ok-sx.d: Likewise. * testsuite/gas/riscv/march-ok-two-nse.d: Likewise. * testsuite/gas/riscv/march-ok-g2_p1.d: Likewise. * testsuite/gas/riscv/march-ok-i2p0m2_a2f2.d: Likewise. include/ * opcode/riscv.h (riscv_opcode): Change type of xlen_requirement to unsigned. opcodes/ * riscv-opc.c: Change the type of xlen, because type of xlen_requirement changed.
2018-12-03[aarch64] - Only use MOV for disassembly when shifter op is LSL #0Egeyar Bagcioglu5-3/+24
ARM Architecture Reference Manual for the profile ARMv8-A, Issue C.a, states that MOV (register) is an alias of the ORR (shifted register) iff shift == '00' && imm6 == '000000' && Rn == '11111'. However, mov is currently preferred for a broader range of orr instructions, which is incorrect. 2018-12-03 Egeyar Bagcioglu <egeyar.bagcioglu@oracle.com> opcodes: PR 23193 PR 19721 * aarch64-tbl.h (aarch64_opcode_table): Only disassemble an ORR encoding as MOV if the shift operation is a left shift of zero. gas: PR 23193 PR 19721 * testsuite/gas/aarch64/pr19721.s: Add new test cases. * testsuite/gas/aarch64/pr19721.d: Correct existing test cases and add new ones.
2018-12-03Update the assembler to use a version of 3 when generating the header of the ↵Nick Clifton22-21/+49
.debug_line section. PR 23941 gas * dwarf2dbg.c (DWARF2_LINE_VERSION): Change to 3. * testsuite/gas/elf/dwarf2-3.d: Update expected output. * testsuite/gas/elf/dwarf2-5.d: Likewise. * testsuite/gas/i386/debug1.d: Likewise. * testsuite/gas/i386/dw2-compress-1.d: Likewise. * testsuite/gas/i386/dw2-compress-3a.d: Likewise. * testsuite/gas/i386/dw2-compress-3b.d: Likewise. * testsuite/gas/i386/dw2-compressed-1.d: Likewise. * testsuite/gas/i386/dw2-compressed-3a.d: Likewise. * testsuite/gas/i386/dw2-compressed-3b.d: Likewise. * testsuite/gas/ia64/pr13167.d: Likewise. * testsuite/gas/mips/loc-swap-2.d: Likewise. * testsuite/gas/mips/loc-swap.d: Likewise. * testsuite/gas/mips/micromips@loc-swap-2.d: Likewise. * testsuite/gas/mips/micromips@loc-swap.d: Likewise. * testsuite/gas/mips/mips16@loc-swap-2.d: Likewise. * testsuite/gas/mips/mips16@loc-swap.d: Likewise. * testsuite/gas/mips/mips16e@loc-swap.d: Likewise. binutils* testsuite/binutils-all/i386/compressed-1a.d: Update expected output. * testsuite/binutils-all/x86-64/compressed-1a.d: Likewise.
2018-12-03Automatic date update in version.inGDB Administrator1-1/+1
2018-12-02gold: Get alignment of uncompressed section from ch_addralignH.J. Lu5-12/+42
The ELF compression header has a field (ch_addralign) that is set to the alignment of the uncompressed section. This way the section itself can have a different alignment than the decompressed section. Update decompress_input_section to get alignment of the decompressed section and use it when merging decompressed strings. PR binutils/23919 * merge.cc (Output_merge_string<Char_type>::do_add_input_section): Get addralign from decompressed_section_contents. * object.cc (build_compressed_section_map): Set info.addralign. (Object::decompressed_section_contents): Add a palign argument and store p->second.addralign in *palign if it isn't NULL. * object.h (Compressed_section_info): Add addralign. (section_is_compressed): Add a palign argument, default it to NULL, store p->second.addralign in *palign if it isn't NULL. (Object::decompressed_section_contents): Likewise. * output.cc (Output_section::add_input_section): Get addralign from section_is_compressed.
2018-12-02Automatic date update in version.inGDB Administrator1-1/+1
2018-12-01x86: Delay setting the iplt section alignmentH.J. Lu13-7/+125
Delay setting its alignment until we know it is non-empty. Otherwise an empty iplt section may change vma and lma of the following sections, which triggers moving dot of the following section backwards, resulting in a warning and section lma not being set properly. It later leads to a "File truncated" error. bfd/ PR ld/23930 * elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Update the iplt section alignment if it is non-empty. (_bfd_x86_elf_link_setup_gnu_properties): Set plt.iplt_alignment and delay setting the iplt section alignment. * elfxx-x86.h (elf_x86_plt_layout): Add iplt_alignment. ld/ PR ld/23930 * testsuite/ld-i386/i386.exp: Run pr23930. * testsuite/ld-i386/pr23930.d: New file. * testsuite/ld-x86-64/pr23930-32.t: Likewise. * testsuite/ld-x86-64/pr23930-x32.d: Likewise. * testsuite/ld-x86-64/pr23930.d: Likewise. * testsuite/ld-x86-64/pr23930.t: Likewise. * testsuite/ld-x86-64/pr23930a.s: Likewise. * testsuite/ld-x86-64/pr23930b.s: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run pr23930 and pr23930-x32.
2018-12-01PR23946, illegal memory access in readelf.c:slurp_ia64_unwind_tableAlan Modra2-2/+27
PR 23946 * readelf.c (slurp_ia64_unwind_table): Bounds check symbol index on reloc. (slurp_hppa_unwind_table): Likewise.
2018-12-01PR23945, NULL pointer dereference in readelf.c:slurp_hppa_unwind_tableAlan Modra2-5/+25
PR 23945 * readelf.c (slurp_ia64_unwind_table): Don't call elf_ia64_reloc_type needlessly. (slurp_hppa_unwind_table): Use same range checks and error messages as slurp_ia64_unwind_table.
2018-12-01[gdb/testsuite] Add gdb-caching-proc.exp testcaseTom de Vries2-0/+116
When caching a proc using gdb_caching_proc, it will become less likely to be executed, and consequently it's going to be harder to detect that the proc is racy. OTOH, in general the proc is easy to rerun. So, add a test-case to run all uncached gdb_caching_procs a number of times and detect inconsistent results. The purpose of caching is to reduce runtime, so rerunning is somewhat counter-productive in that aspect, but it's better than uncached, because the number of reruns is constant-bounded, and the increase in runtime is bound to this test-case, and can be disabled on slow targets. Tested on x86_64-linux. gdb/testsuite/ChangeLog: 2018-12-01 Tom de Vries <tdevries@suse.de> * gdb.base/gdb-caching-proc.exp: New file.
2018-12-01PR23938, should not free memory alloced in obstack by free()Alan Modra8-44/+67
This removes ineffectual and wrong code caching section names in gas/stabs.c. Code like seg = subseg_new (name, 0); ... if (seg->name == name) seg->name = xstrdup (name); with the idea of being able to unconditionally free "name" later no longer works. "name" is referenced by the section hash table as well as in the section->name field. It would be possible to use "bfd_rename_section (stdoutput, seg, xstrdup (name))", but instead I opted for a fairly straight-forward approach of adding extra parameters to two functions to indicate section name strings should be freed if possible. PR 23938 * read.h (get_stab_string_offset): Update prototype. * stabs.c (get_stab_string_offset): Add free_stabstr_secname parameter. Free stabstr_secname if unused as section name. Don't xstrdup name when used. (s_stab_generic): Remove forward declaration. Add stab_secname_obstack_end param. Reference notes obstack via macros. Delete cached_secname. Adjust get_stab_string_offset call. Free stab_secname if unused as section name. (s_stab): Adjust s_stab_generic call. (s_xstab): Likewise. Delete saved_secname and saved_strsecname. * config/obj-elf.c (obj_elf_init_stab_section): Adjust get_stab_string_offset call. * config/obj-coff.c (obj_coff_init_stab_section): Likewise. * config/obj-som.c (obj_som_init_stab_section): Likewise. * testsuite/gas/all/pr23938.s: New test. * testsuite/gas/all/gas.exp: Run it.
2018-12-01Automatic date update in version.inGDB Administrator1-1/+1
2018-11-30Use kinfo_getfile to implement fdwalk on FreeBSD.John Baldwin2-0/+29
kinfo_getfile() requires a couple of system calls to fetch the list of open file descriptors. This can be much cheaper than invoking fstat on all of the values from 0 to the open file resource limit maximum. gdb/ChangeLog: * common/filestuff.c [HAVE_KINFO_GETFILE]: Include headers. (fdwalk) [HAVE_KINFO_GETFILE]: Use kinfo_getfile.
2018-11-30Fix leak in linespec parserSimon Marchi2-23/+30
Valgrind reports this leak: ==798== VALGRIND_GDB_ERROR_BEGIN ==798== 32 (24 direct, 8 indirect) bytes in 1 blocks are definitely lost in loss record 447 of 3,143 ==798== at 0x4C2C48C: operator new(unsigned long) (vg_replace_malloc.c:334) ==798== by 0x51D401: linespec_parser_new(ls_parser*, int, language_defn const*, program_space*, symtab*, int, linespec_result*) (linespec.c:2756) ==798== by 0x524BF7: decode_line_full(event_location const*, int, program_space*, symtab*, int, linespec_result*, char const*, char const*) (linespec.c:3271) ==798== by 0x3E8893: parse_breakpoint_sals(event_location const*, linespec_result*) (breakpoint.c:9067) ==798== by 0x3E4E7F: create_breakpoint(gdbarch*, event_location const*, char const*, int, char const*, int, int, bptype, int, auto_boolean, breakpoint_ops const*, int, int, int, unsigned int) (breakpoint.c:9248) ==798== by 0x3E55F5: break_command_1(char const*, int, int) (breakpoint.c:9434) ==798== by 0x40BA68: cmd_func(cmd_list_element*, char const*, int) (cli-decode.c:1888) ==798== by 0x665300: execute_command(char const*, int) (top.c:630) ... linespec_parser_new allocates a std::vector<symtab *> at line 2756, and stores the pointer to this vector in PARSER_RESULT (parser)->file_symtabs. At 3 different places in linespec.c, another std::vector is assigned to a linespec->file_symtabs, without first deleting the current value. The leak is fixed by assigning the vector itself instead of the pointer. Everything should be moved, so there is no significant data copy involved. Tested on debian/amd64, + a bunch of tests re-run under valgrind (including the test that throws an error). gdb/ChangeLog: * linespec.c (symtab_vector_up): Remove. (symtabs_from_filename): Change return type to std::vector. (collect_symtabs_from_filename): Likewise. (create_sals_line_offset): Assign return value of collect_symtabs_from_filename to *ls->file_symtabs. (convert_explicit_location_to_linespec): Remove call to release. (parse_linespec): Likewise. (symtab_collector) <symtab_collector>: Remove initialization of m_symtabs. <release_symtabs>: Change return type to std::vector<symtab *>. <operator ()>: Adjust.
2018-11-30Update the conditionals in fbsd-nat.h so they are always honored.John Baldwin3-6/+32
Not all of the architecture-specific FreeBSD target files were including the right headers to enable conditionals in fbsd-nat.h after the C++ target conversion. As a result, certain operations like 'info auxv' and 'p $_siginfo' were not working for some native targets (noticed on RISC-V). Fix this in a couple of ways: 1) Declare fbsd_nat_target::xfer_partial unconditionally and only use conditionals in the function body for individual target objects. Originally this function was only used to read the ELF auxiliary vector, so the entire function was conditional on a macro required for that object (KERN_AUXV_PROC). However, xfer_partial has since grown support for additional objects. Making the function unconditional avoids needing to add the right header to fbsd-nat.h and allows each target object to use independent requirements. This did require using a more explicit conditional test for the $_siginfo support. Removing the "outer" KERN_PROC_AUXV test enabled $_siginfo for all kernels with PT_LWPINFO, but some older kernels (FreeBSD 6.0) exposed PT_LWPINFO with a different siginfo format. Instead use an explicit test for when the current siginfo format was adopted (shipped in FreeBSD 7.0). This actually enables $_siginfo on a wider range of kernels as KERN_PROC_AUXV wasn't introduced until FreeBSD 9.1/10.0. 2) Include <sys/proc.h> in fbsd-nat.h for the definition of TDP_RFPPWAIT that governs support for fork following. gdb/ChangeLog: * fbsd-nat.c [__FreeBSD_version >= 700009] (USE_SIGINFO): Macro defined. (union sigval32, struct siginfo32, fbsd_siginfo_size) (fbsd_convert_siginfo): Make conditional on USE_SIGINFO instead of KERN_PROC_AUXV and PT_LWPINFO. (fbsd_nat_target::xfer_partial): Define method unconditionally. Make TARGET_OBJECT_SIGNAL_INFO conditional on USE_SIGINFO. Make TARGET_OBJECT_AUXV conditional on KERN_PROC_AUXV. Make TARGET_OBJECT_FREEBSD_VMMAP and TARGET_OBJECT_FREEBSD_PS_STRINGS conditional on KERN_PROC_VMMAP and KERN_PROC_PS_STRINGS. * fbsd-nat.h: Include <sys/proc.h>. (fbsd_nat_target::xfer_partial): Declare method unconditionally.
2018-11-30GAS/MIPS: Add `-mfix-r5900' option for the R5900 short loop erratumFredrik Noring9-1/+161
`-march=r5900' already enables the R5900 short loop workaround. However, the R5900 ISA and most other MIPS ISAs are mutually exclusive since R5900-specific instructions are generated as well. The `-mfix-r5900' option can be used in combination with e.g. `-mips2' or `-mips3' to generate generic MIPS binaries that also work with the R5900 target. This change has been tested with `make RUNTESTFLAGS=mips.exp check-gas' for the targets `mipsr5900el-unknown-linux-gnu', `mipsr5900el-elf' and `mips3-unknown-linux-gnu'. gas/ * config/tc-mips.c (mips_fix_r5900, mips_fix_r5900_explicit): New variables. (options): Add OPTION_FIX_R5900 and OPTION_NO_FIX_R5900 enumeration constants. (md_longopts): Add "mfix-r5900" and "mno-fix-r5900" options. (can_swap_branch_p, md_parse_option, mips_after_parse_args): Handle the new options. (md_show_usage): Document the `-mfix-r5900' option. * doc/as.texi: Likewise. * doc/c-mips.texi: Likewise. * testsuite/gas/mips/mips.exp: Run R5900 dump tests. * testsuite/gas/mips/r5900-fix.d: Test `-mfix-r5900' option. * testsuite/gas/mips/r5900-fix.s: Likewise. * testsuite/gas/mips/r5900-no-fix.d: Test `-mno-fix-r5900'. * testsuite/gas/mips/r5900-no-fix.s: Likewise.
2018-11-30gdb/riscv: Add read_description method for riscv_linux_nat_targetAndrew Burgess2-0/+44
Adds riscv_linux_nat_target::read_description method to find a suitable target description for the native linux target we are running on. Currently this will supply a suitably sized set of x-registers, and will probe the kernel to see if the f-registers are readable. If they are readable then we currently assume that the f-registers are the same size as the x-registers as I don't know of a good way to probe the f-register length. This will obviously need fixing in future. As of Linux 4.19 there is no ptrace support for reading the f-registers, this should appear in 4.20, so right now we only return target descriptions without f-registers. gdb/ChangeLog: * riscv-linux-nat.c: Add 'inferior.h' and 'target-descriptions.h' header files. (riscv_linux_nat_target::read_description): New method.
2018-11-30gdb/riscv: Create each unique target description only onceAndrew Burgess3-0/+48
GDB relies on the fact that if two target descriptions have the same contents, then they will be the same object instance (having the same address). One place where this is a requirement is in GDBARCH_LIST_LOOKUP_BY_INFO which is used to find previously created gdbarch objects. In GDBARCH_LIST_LOOKUP_BY_INFO a pointer comparison is made on the gdbarch's target description, if the pointers are different then it is assumed the gdbarches have different, non-compatible target descriptions. Previously we would create duplicate target descriptions in the belief that RISCV_GDBARCH_INIT would spot this duplication and discard the second instance. However, this was incorrect, and instead we ended up creating duplicate gdbarch objects. With this commit every unique feature set will create one and only one target description, the feature set and resulting target description is then cached so that the same target description object can be returned later. Many other target avoid this problem by creating a small number of named target descriptions, and returning one of these. However, we currently have 8 possible target descriptions (32 vs 64 bit for x-reg and f-reg, and h/w or s/w float abi) and creating each of these just to avoid a dynamic cache seems pointless. gdb/ChangeLog: * arch/riscv.h (riscv_gdbarch_features::hash): New method. * arch/riscv.c (struct riscv_gdbarch_features_hasher): New. (riscv_tdesc_cache): New global. (riscv_create_target_description): Look in the cache before creating a new target description.
2018-11-30gdb/riscv: Add equality operators to riscv_gdb_featuresAndrew Burgess3-3/+21
Add '==' and '!=' operators for the struct riscv_gdb_features, allowing a small simplification. gdb/ChangeLog: * arch/riscv.h (riscv_gdb_features::operator==): New. (riscv_gdb_features::operator!=): New. * riscv-tdep.c (riscv_gdbarch_init): Make use of the inequality operator.
2018-11-30gdb/riscv: Make some target description functions constantAndrew Burgess4-3/+10
Makes more of the interface related to fetching target descriptions constant. gdb/ChangeLog: * arch/riscv.h (riscv_create_target_description): Make return type const. * arch/riscv.c (riscv_create_target_description): Likewise. * riscv-tdep.c (riscv_find_default_target_description): Likewise.
2018-11-30Fix dwarf2read.c:dwarf2_find_containing_comp_unit's binary searchSergio Durigan Junior2-1/+12
First of all, I would like to express my gratitude to Keith Seitz, Jan Kratochvil and Tom Tromey, who were really kind and helped a lot with this bug. The patch itself was authored by Jan. This all began with: https://bugzilla.redhat.com/show_bug.cgi?id=1639242 py-bt is broken, results in exception In summary, the error reported by the bug above is: $ gdb -args python3 GNU gdb (GDB) Fedora 8.1.1-3.fc28 (...) Reading symbols from python3...Reading symbols from /usr/lib/debug/usr/bin/python3.6-3.6.6-1.fc28.x86_64.debug...done. done. Dwarf Error: could not find partial DIE containing offset 0x316 [in module /usr/lib/debug/usr/bin/python3.6-3.6.6-1.fc28.x86_64.debug] After a long investigation, and after thinking that the problem might actually be on DWZ's side, we were able to determine that there's something wrong going on when dwarf2read.c:dwarf2_find_containing_comp_unit performs a binary search over all of the CUs belonging to an objfile in order to find the CU which contains a DIE at an specific offset. The current algorithm is: static struct dwarf2_per_cu_data * dwarf2_find_containing_comp_unit (sect_offset sect_off, unsigned int offset_in_dwz, struct dwarf2_per_objfile *dwarf2_per_objfile) { struct dwarf2_per_cu_data *this_cu; int low, high; const sect_offset *cu_off; low = 0; high = dwarf2_per_objfile->all_comp_units.size () - 1; while (high > low) { struct dwarf2_per_cu_data *mid_cu; int mid = low + (high - low) / 2; mid_cu = dwarf2_per_objfile->all_comp_units[mid]; cu_off = &mid_cu->sect_off; if (mid_cu->is_dwz > offset_in_dwz || (mid_cu->is_dwz == offset_in_dwz && *cu_off >= sect_off)) high = mid; else low = mid + 1; } For the sake of this example, let's consider that "sect_off = 0x7d". There are a few important things going on here. First, "dwarf2_per_objfile->all_comp_units ()" will be sorted first by whether the CU is a DWZ CU, and then by cu->sect_off. In this specific bug, "offset_in_dwz" is false, which means that, for the most part of the loop, we're going to do "high = mid" (i.e, we'll work with the lower part of the vector). In our particular case, when we reach the part where "mid_cu->is_dwz == offset_in_dwz" (i.e, both are false), we end up with "high = 2" and "mid = 1". I.e., there are only 2 elements in the vector who are not DWZ. The vector looks like this: #0: cu->sect_off = 0; length = 114; is_dwz = false <-- low #1: cu->sect_off = 114; length = 7796; is_dwz = false <-- mid #2: cu->sect_off = 0; length = 28; is_dwz = true <-- high ... The CU we want is #1, which is exactly where "mid" is. Also, #1 is not DWZ, which is also exactly what we want. So we perform the second comparison: (mid_cu->is_dwz == offset_in_dwz && *cu_off >= sect_off) ^^^^^^^^^^^^^^^^^^^ Because "*cu_off = 114" and "sect_off = 0x7d", this evaluates to false, so we end up with "low = mid + 1 = 2", which actually gives us the wrong CU (i.e., a CU that is DWZ). Next in the code, GDB does: gdb_assert (low == high); this_cu = dwarf2_per_objfile->all_comp_units[low]; cu_off = &this_cu->sect_off; if (this_cu->is_dwz != offset_in_dwz || *cu_off > sect_off) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ { if (low == 0 || this_cu->is_dwz != offset_in_dwz) error (_("Dwarf Error: could not find partial DIE containing " "offset %s [in module %s]"), sect_offset_str (sect_off), bfd_get_filename (dwarf2_per_objfile->objfile->obfd)); ... Triggering the error we saw in the original bug report. It's important to notice that we see the error message because the selected CU is a DWZ one, but we're looking for a non-DWZ CU here. However, even when the selected CU is *not* a DWZ (and we don't see any error message), we still end up with the wrong CU. For example, suppose that the vector had: #0: cu->sect_off = 0; length = 114; is_dwz = false #1: cu->sect_off = 114; length = 7796; is_dwz = false #2: cu->sect_off = 7910; length = 28; is_dwz = false ... I.e., #2's "is_dwz" is false instead of true. In this case, we still want #1, because that's where the DIE is located. After the loop ends up in #2, we have "is_dwz" as false, which is what we wanted, so we compare offsets. In this case, "7910 >= 0x7d", so we set "mid = high = 2". Next iteration, we have "mid = 0 + (2 - 0) / 2 = 1", and thus we examining #1. "is_dwz" is still false, but "114 >= 0x7d" also evaluates to false, so "low = mid + 1 = 2", which makes the loop stop. Therefore, we end up choosing #2 as our CU, even though #1 is the right one. The problem here is happening because we're comparing "sect_off" directly against "*cu_off", while we should actually be comparing against "*cu_off + mid_cu->length" (i.e., the end offset): ... || (mid_cu->is_dwz == offset_in_dwz && *cu_off + mid_cu->length >= sect_off)) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ... And this is what the patch does. The idea is that if GDB is searching for an offset that falls above the *end* of the CU being analyzed (i.e., "mid"), then the next iteration should try a higher-offset CU next. The previous algorithm was using the *beginning* of the CU. Unfortunately, I could not devise a testcase for this problem, so I am proposing a fix with this huge explanation attached to it in the hope that it is sufficient. After talking a bit to Keith (our testcase guru), it seems that one would have to create an objfile with both DWZ and non-DWZ sections, which may prove very hard to do, I think. I ran this patch on our BuildBot, and no regressions were detected. gdb/ChangeLog: 2018-11-30 Jan Kratochvil <jan.kratochvil@redhat.com> Keith Seitz <keiths@redhat.com> Tom Tromey <tom@tromey.com> Sergio Durigan Junior <sergiodj@redhat.com> https://bugzilla.redhat.com/show_bug.cgi?id=1613614 * dwarf2read.c (dwarf2_find_containing_comp_unit): Add 'mid_cu->length' to '*cu_off' when checking if 'sect_off' is inside the CU.
2018-11-30target_ops::to_stratum -> target_ops::stratum() virtual methodPedro Alves19-73/+122
Given that a target's stratum is a property of the type, and not of an instance of the type, get rid of to_stratum data field and replace it with a virtual method. I.e., when we have e.g., 10 target remote instances active, there's no need for each of the instances to have their own to_stratum copy. gdb/ChangeLog: 2018-11-30 Pedro Alves <palves@redhat.com> * aix-thread.c (aix_thread_target) <aix_thread_target>: Delete. <stratum>: New override. * bfd-target.c (aix_thread_target) <aix_thread_target>: Delete. <stratum>: New override. * bsd-uthread.c (bsd_uthread_target) <bsd_uthread_target>: Delete. <stratum>: New override. * exec.c (exec_target) <exec_target>: Delete. <stratum>: New override. * gdbarch-selftests.c (register_to_value_test): Adjust to use the stratum method instead of the to_stratum field. * linux-thread-db.c (thread_db_target) <thread_db_target>: Delete. <stratum>: New override. (thread_db_target::thread_db_target): Delete. * make-target-delegates (print_class): Don't print a ctor declaration. Print a stratum method override declaration. * process-stratum-target.h (process_stratum_target) <process_stratum_target>: Delete. <stratum>: New override. * ravenscar-thread.c (ravenscar_thread_target) <ravenscar_thread_target>: Delete. <stratum>: New override. * record-btrace.c (record_btrace_target) <record_btrace_target>: Delete. <stratum>: New override. * record-full.c (record_full_base_target) <record_full_base_target>: Delete. <stratum>: New override. * record.c (record_disconnect, record_detach) (record_mourn_inferior, record_kill): Adjust to use the stratum method instead of the to_stratum field. * regcache.c (cooked_read_test, cooked_write_test): Likewise. * sol-thread.c (sol_thread_target) <sol_thread_target>: Delete. <stratum>: New override. * spu-multiarch.c (spu_multiarch_target) <spu_multiarch_target>: Delete. <stratum>: New override. * target-delegates.c: Regenerate. * target.c (target_stack::push, target_stack::unpush) (pop_all_targets_above, pop_all_targets_at_and_above) (info_target_command, target_require_runnable) (target_stack::find_beneath): Adjust to use the stratum method instead of the to_stratum field. (dummy_target::dummy_target): Delete. (dummy_target::stratum): New. (debug_target::debug_target): Delete. (debug_target::stratum): New. (maintenance_print_target_stack): Adjust to use the stratum method instead of the to_stratum field. * target.h (struct target_ops) <stratum>: New method. <to_stratum>: Delete. <is_pushed>: Adjust to use the stratum method instead of the to_stratum field.
2018-11-30Add PR number to previous delta to the bfd/ directory.Nick Clifton1-0/+1
2018-11-30Convert default_child_has_foo functions to process_stratum_target methodsPedro Alves12-121/+83
This patch converts the default_child_has_foo functions to process_stratum_target methods. This simplifies "regular" non-inf_child process_stratum targets, since they no longer have to override the target_ops::has_foo methods to call the default_child_foo functions. A couple targets need to override the new defaults (corelow and tracefiles), but it still seems like a good tradeoff, since those are expected to be little different (target doesn't run). gdb/ChangeLog: 2018-11-30 Pedro Alves <palves@redhat.com> * corelow.c (core_target) <has_all_memory, has_execution>: New overrides. * inf-child.c (inf_child_target::has_all_memory) (inf_child_target::has_memory, inf_child_target::has_stack) (inf_child_target::has_registers) (inf_child_target::has_execution): Delete. * inf-child.h (inf_child_target) <has_all_memory, has_memory, has_stack, has_registers, has_execution>: Delete. * process-stratum-target.c (process_stratum_target::has_all_memory) (process_stratum_target::has_memory) (process_stratum_target::has_stack) (process_stratum_target::has_registers) (process_stratum_target::has_execution): New. * process-stratum-target.h (process_stratum_target) <has_all_memory, has_memory, has_stack, has_registers, has_execution>: New method overrides. * ravenscar-thread.c (ravenscar_thread_target) <has_all_memory, has_memory, has_stack, has_registers, has_execution>: Delete. * remote-sim.c (gdbsim_target) <has_stack, has_registers, has_execution>: Delete. * remote.c (remote_target) <has_all_memory, has_memory, has_stack, has_registers, has_execution>: Delete. * target.c (default_child_has_all_memory) (default_child_has_memory, default_child_has_stack) (default_child_has_registers, default_child_has_execution): Delete. * target.h (default_child_has_all_memory) (default_child_has_memory, default_child_has_stack) (default_child_has_registers, default_child_has_execution): Delete. * tracefile.h (tracefile_target) <has_execution>: New override.
2018-11-30Introduce process_stratum_targetPedro Alves16-82/+165
This adds a base class that all process_stratum targets inherit from. default_thread_address_space/default_thread_architecture only make sense for process_stratum targets, so they are transformed to process_stratum_target methods/overrides. gdb/ChangeLog: 2018-11-30 Pedro Alves <palves@redhat.com> * Makefile.in (COMMON_SFILES): Add process-stratum-target.c. * bsd-kvm.c: Include "process-stratum-target.h". (bsd_kvm_target): Now inherits from process_stratum_target. (bsd_kvm_target::bsd_kvm_target): Default it. * corelow.c: Include "process-stratum-target.h". (core_target): Now inherits from process_stratum_target. (core_target::core_target): Don't set to_stratum here. * inf-child.c (inf_child_target::inf_child_target): Delete. * inf-child.h: Include "process-stratum-target.h". (inf_child_target): Inherit from process_stratum_target. (inf_child_target) <inf_child_target>: Default it. <can_async_p, supports_non_stop, supports_disable_randomization>: Delete overrides. * process-stratum-target.c: New file. * process-stratum-target.h: New file. * remote-sim.c: Include "process-stratum-target.h". (gdbsim_target): Inherit from process_stratum_target. <gdbsim_target>: Default it. * remote.c: Include "process-stratum-target.h". (remote_target): Inherit from process_stratum_target. <remote_target>: Default it. * target.c (default_thread_address_space) (default_thread_architecture): Delete. * target.h (target_ops) <thread_architecture>: Now returns NULL by default. <thread_address_space>: Ditto. * test-target.h: Include "process-stratum-target.h" instead of "target.h". (test_target_ops): Inherit from process_stratum_target. <test_target_ops>: Default it. * tracefile.c (tracefile_target::tracefile_target): Delete. * tracefile.h: Include "process-stratum-target.h". (tracefile_target): Inherit from process_stratum_target. <tracefile_target>: Default it. * target-delegates.c: Regenerate.
2018-11-30Move test_target_ops to a separate filePedro Alves8-66/+121
There's no need to have all target.h users seeing this type. Also helps with a follow up patch. gdb/ChangeLog: 2018-11-30 Pedro Alves <palves@redhat.com> * Makefile.in (COMMON_SFILES): Add test-target.c. * gdbarch-selftests.c: Include "test-target.h". * regcache.c: Include "test-target.h". * target.c (test_target_info, test_target_ops::info): Move to ... * test-target.c: ... this new file. * target.h (test_target_ops): Move to ... * test-target.h: ... this new file.
2018-11-30Fix a memory exhaustion bug when attempting to allocate room for an ↵Nick Clifton2-0/+10
impossible number of program headers. * elfcode.h (elf_object_p): Check for corrupt input files with more program headers than can actually fit in the file.
2018-11-30Remove an abort in the bfd library and add a check for an integer overflow ↵Nick Clifton2-1/+18
when mapping sections to segments. PR 23932 * elf.c (IS_CONTAINED_BY_LMA): Add a check for a negative section size. (rewrite_elf_program_header): If no sections are mapped into a segment return an error.
2018-11-30PR23937, powerpc64le local ifunc IRELATIVE relocs are wrongAlan Modra6-1/+90
IFUNC resolvers must always be called via their global entry point. They will be called from ld.so rather than from the local executable. PR 23937 bfd/ * elf64-ppc.c (write_plt_relocs_for_local_syms): Don't add local entry offset for ifuncs. ld/ * testsuite/ld-powerpc/pr23937.d, * testsuite/ld-powerpc/pr23937.s: New test. * testsuite/ld-powerpc/powerpc.exp: Run it.
2018-11-30Automatic date update in version.inGDB Administrator1-1/+1
2018-11-29Fix leak in forward-searchPhilippe Waroquiers2-1/+7
Valgrind reports the below leak. Fix the leak by using xrealloc, even for the first allocation, as buf is static. ==29158== 5,888 bytes in 23 blocks are definitely lost in loss record 3,028 of 3,149 ==29158== at 0x4C2BE2D: malloc (vg_replace_malloc.c:299) ==29158== by 0x41B557: xmalloc (common-utils.c:44) ==29158== by 0x60B7D9: forward_search_command(char const*, int) (source.c:1563) ==29158== by 0x40BA68: cmd_func(cmd_list_element*, char const*, int) (cli-decode.c:1888) ==29158== by 0x665300: execute_command(char const*, int) (top.c:630) ... gdb/ChangeLog 2018-11-29 Philippe Waroquiers <philippe.waroquiers@skynet.be> * source.c (forward_search_command): Fix leak by using xrealloc even for the first allocation in the loop, as buf is static.
2018-11-29Implement the "gdb_signal_to/from_target" gdbarch methods for FreeBSD.Rajendra SY2-0/+293
This fixes failures in the gdb.base/exitsignal.exp test. gdb/ChangeLog: PR gdb/23093 * gdb/fbsd-tdep.c (fbsd_gdb_signal_from_target) (fbsd_gdb_signal_to_target): New. (fbsd_init_abi): Install gdbarch "signal_from_target" and "signal_to_target" methods.
2018-11-29RISC-V: Add missing c.unimp instruction.Jim Wilson2-1/+7
opcodes/ * riscv-opc.c (unimp): Mark compressed unimp as INSN_ALIAS. (c.unimp): New.
2018-11-29Avoid buffer overflow in value_x_unopTom Tromey2-2/+4
Commit 6b1747cd1 ("invoke_xmethod & array_view") contains this change: - argvec = (struct value **) alloca (sizeof (struct value *) * 4); + value *argvec_storage[3]; + gdb::array_view<value *> argvec = argvec_storage; However, value_x_unop still does: argvec[2] = value_from_longest (builtin_type (gdbarch)->builtin_int, 0); argvec[3] = 0; This triggers an error with -fsanitize=address from userdef.exp: ERROR: AddressSanitizer: stack-buffer-overflow on address 0x7ffdcf185068 at pc 0x000000e4f912 bp 0x7ffdcf184d80 sp 0x7ffdcf184d70 WRITE of size 8 at 0x7ffdcf185068 thread T0 #0 0xe4f911 in value_x_unop(value*, exp_opcode, noside) ../../binutils-gdb/gdb/valarith.c:557 [...] I think the two assignments to argvec[3] should just be removed, and that this was intended in the earlier patch but just missed. This passes userdef.exp with -fsanitize=address. gdb/ChangeLog 2018-11-29 Tom Tromey <tom@tromey.com> * valarith.c (value_x_unop): Don't set argvec[3].
2018-11-29Fix use-after-free in gdbserverTom Tromey7-14/+29
-fsanitize=address pointed out a use-after-free in gdbserver. In particular, handle_detach could reference "process" after it was deleted by detach_inferior. Avoiding this also necessitated changing target_ops::join to take a pid rather than a process_info*. Tested by the buildbot using a few of the gdbserver builders. gdb/gdbserver/ChangeLog 2018-11-29 Tom Tromey <tom@tromey.com> * win32-low.c (win32_join): Take pid, not process. * target.h (struct target_ops) <join>: Change argument type. (join_inferior): Change argument name. * spu-low.c (spu_join): Take pid, not process. * server.c (handle_detach): Preserve pid before destroying process. * lynx-low.c (lynx_join): Take pid, not process. * linux-low.c (linux_join): Take pid, not process.
2018-11-29Document purpose of each ld statement listsThomas Preud'homme3-7/+31
When discovering the statement lists via their header variable statement_list, file_chain and input_file_chain it can be confusing to figure out what they are for. They can point to the same initial statement and the relation between the next field they use is not obvious from the name. This commit adds comment for each of those statement list header to explain what they are for and what next field they use. It also rewrite the comment for the next fields to simply redirect the reader to the list header to avoid duplication of documentation. 2018-11-29 Thomas Preud'homme <thomas.preudhomme@linaro.org> ld/ * ldlang.c (statement_list): Document purpose and what next field it uses. (file_chain): Likewise. (input_file_chain): Likewise. * ldlang.h (lang_statement_header_type): Document statement list header the next pointer correspond to. (lang_statement_header_type): Replace comment for next and next_real_file field to refer the reader to their corresponding statement list header.
2018-11-29elf: Don't merge .note.gnu.property section in IRH.J. Lu2-1/+8
.note.gnu.property section in IR inputs should be ignored. Don't merge them. PR ld/23929 * elf-properties.c (_bfd_elf_link_setup_gnu_properties): Don't merge .note.gnu.property section in IR inputs.
2018-11-29objdump: Fix check for corrupt reloc information, to allow for the fact that ↵Nick Clifton2-2/+15
PDP11 relocs are bigger when in internal format. PR 23931 * objdump.c (dump_relocs_in_section): When checking for an unreasonable amount of relocs in a bfd, allow for the fact that the internal representation of a reloc may be bigger than the external representation.
2018-11-29Automatic date update in version.inGDB Administrator1-1/+1
2018-11-28Automatic date update in version.inGDB Administrator1-1/+1
2018-11-27RISC-V: Add .insn CA support.Jim Wilson9-15/+86
gas/ * config/tc-riscv.c (validate_riscv_insn) <'F'>: Add support for CF6 and CF2 operands. (riscv_ip) <'F'>: Likewise. * doc/c-riscv.texi (RISC-V-Formats): Add func6 abbreviation. Use rs2 instead of rs1 in CR description. Add CA docs. * gas/testsuite/riscv/insn.s: Add use of .insn ca. * gas/testsuite/riscv/insn.d: Update to match. include/ * opcode/riscv.h (OP_MASK_CFUNCT6, OP_SH_CFUNCT6): New. (OP_MASK_CFUNCT2, OP_SH_CFUNCT2): New. opcodes/ * riscv-opc.c (ciw): Fix whitespace to align columns. (ca): New.
2018-11-27[ARM] Update knowledge of bfd architecturesThomas Preud'homme152-31/+1282
Commit c0c468d562649df0f695737262b6230b7a56a4bb updated bfd's knowledge of Arm architectures to Armv5TEJ and later but missed the list of CPUs recognized by objdump -d -m<cpu>. .note.gnu.arm.ident related code is intentionally not updated as build attributes are a better mechanism to express the ISA in a file. However this patch adds tests for the existing code since no existing testcase cover those codepaths. Since I've only ever managed for bfd_arm_get_mach_from_notes () to have an effect by using objcopy on a file with a note but no Arm build attribute, the tests make use of both objcopy actions supported by run_dump_test which requires to have a ld line as well. Note that the CPU list in bfd/cpu-arm.c was simply copied over from GAS' CPU list but sorted alphabetically as already done for existing entries. 2018-11-27 Thomas Preud'homme <thomas.preudhomme@linaro.org> bfd/ * cpu-arm.c (processors): Add processors known to GAS but missing here and reindent. (bfd_arm_update_notes): Add comment explaining why the list of architectures in the switch should not be updated. (architectures): Likewise. gas/ * testsuite/gas/arm/cpu-arm1020.d: New testcase. * testsuite/gas/arm/cpu-arm1020e.d: Likewise. * testsuite/gas/arm/cpu-arm1020t.d: Likewise. * testsuite/gas/arm/cpu-arm1022e.d: Likewise. * testsuite/gas/arm/cpu-arm1026ej-s.d: Likewise. * testsuite/gas/arm/cpu-arm1026ejs.d: Likewise. * testsuite/gas/arm/cpu-arm10e.d: Likewise. * testsuite/gas/arm/cpu-arm10t.d: Likewise. * testsuite/gas/arm/cpu-arm10tdmi.d: Likewise. * testsuite/gas/arm/cpu-arm1136j-s.d: Likewise. * testsuite/gas/arm/cpu-arm1136jf-s.d: Likewise. * testsuite/gas/arm/cpu-arm1136jfs.d: Likewise. * testsuite/gas/arm/cpu-arm1136js.d: Likewise. * testsuite/gas/arm/cpu-arm1156t2-s.d: Likewise. * testsuite/gas/arm/cpu-arm1156t2f-s.d: Likewise. * testsuite/gas/arm/cpu-arm1176jz-s.d: Likewise. * testsuite/gas/arm/cpu-arm1176jzf-s.d: Likewise. * testsuite/gas/arm/cpu-arm2.d: Likewise. * testsuite/gas/arm/cpu-arm250.d: Likewise. * testsuite/gas/arm/cpu-arm3.d: Likewise. * testsuite/gas/arm/cpu-arm6.d: Likewise. * testsuite/gas/arm/cpu-arm60.d: Likewise. * testsuite/gas/arm/cpu-arm600.d: Likewise. * testsuite/gas/arm/cpu-arm610.d: Likewise. * testsuite/gas/arm/cpu-arm620.d: Likewise. * testsuite/gas/arm/cpu-arm7.d: Likewise. * testsuite/gas/arm/cpu-arm70.d: Likewise. * testsuite/gas/arm/cpu-arm700.d: Likewise. * testsuite/gas/arm/cpu-arm700i.d: Likewise. * testsuite/gas/arm/cpu-arm710.d: Likewise. * testsuite/gas/arm/cpu-arm7100.d: Likewise. * testsuite/gas/arm/cpu-arm710c.d: Likewise. * testsuite/gas/arm/cpu-arm710t.d: Likewise. * testsuite/gas/arm/cpu-arm720.d: Likewise. * testsuite/gas/arm/cpu-arm720t.d: Likewise. * testsuite/gas/arm/cpu-arm740t.d: Likewise. * testsuite/gas/arm/cpu-arm7500.d: Likewise. * testsuite/gas/arm/cpu-arm7500fe.d: Likewise. * testsuite/gas/arm/cpu-arm7d.d: Likewise. * testsuite/gas/arm/cpu-arm7di.d: Likewise. * testsuite/gas/arm/cpu-arm7dm.d: Likewise. * testsuite/gas/arm/cpu-arm7dmi.d: Likewise. * testsuite/gas/arm/cpu-arm7m.d: Likewise. * testsuite/gas/arm/cpu-arm7t.d: Likewise. * testsuite/gas/arm/cpu-arm7tdmi-s.d: Likewise. * testsuite/gas/arm/cpu-arm7tdmi.d: Likewise. * testsuite/gas/arm/cpu-arm8.d: Likewise. * testsuite/gas/arm/cpu-arm810.d: Likewise. * testsuite/gas/arm/cpu-arm9.d: Likewise. * testsuite/gas/arm/cpu-arm920.d: Likewise. * testsuite/gas/arm/cpu-arm920t.d: Likewise. * testsuite/gas/arm/cpu-arm922t.d: Likewise. * testsuite/gas/arm/cpu-arm926ej-s.d: Likewise. * testsuite/gas/arm/cpu-arm926ej.d: Likewise. * testsuite/gas/arm/cpu-arm926ejs.d: Likewise. * testsuite/gas/arm/cpu-arm940t.d: Likewise. * testsuite/gas/arm/cpu-arm946e-r0.d: Likewise. * testsuite/gas/arm/cpu-arm946e-s.d: Likewise. * testsuite/gas/arm/cpu-arm946e.d: Likewise. * testsuite/gas/arm/cpu-arm966e-r0.d: Likewise. * testsuite/gas/arm/cpu-arm966e-s.d: Likewise. * testsuite/gas/arm/cpu-arm966e.d: Likewise. * testsuite/gas/arm/cpu-arm968e-s.d: Likewise. * testsuite/gas/arm/cpu-arm9e-r0.d: Likewise. * testsuite/gas/arm/cpu-arm9e.d: Likewise. * testsuite/gas/arm/cpu-arm9tdmi.d: Likewise. * testsuite/gas/arm/cpu-arm_any.d: Likewise. * testsuite/gas/arm/cpu-cortex-a12.d: Likewise. * testsuite/gas/arm/cpu-cortex-a15.d: Likewise. * testsuite/gas/arm/cpu-cortex-a17.d: Likewise. * testsuite/gas/arm/cpu-cortex-a32.d: Likewise. * testsuite/gas/arm/cpu-cortex-a35.d: Likewise. * testsuite/gas/arm/cpu-cortex-a5.d: Likewise. * testsuite/gas/arm/cpu-cortex-a53.d: Likewise. * testsuite/gas/arm/cpu-cortex-a55.d: Likewise. * testsuite/gas/arm/cpu-cortex-a57.d: Likewise. * testsuite/gas/arm/cpu-cortex-a7.d: Likewise. * testsuite/gas/arm/cpu-cortex-a72.d: Likewise. * testsuite/gas/arm/cpu-cortex-a73.d: Likewise. * testsuite/gas/arm/cpu-cortex-a75.d: Likewise. * testsuite/gas/arm/cpu-cortex-a76.d: Likewise. * testsuite/gas/arm/cpu-cortex-a8.d: Likewise. * testsuite/gas/arm/cpu-cortex-a9.d: Likewise. * testsuite/gas/arm/cpu-cortex-m0.d: Likewise. * testsuite/gas/arm/cpu-cortex-m0plus.d: Likewise. * testsuite/gas/arm/cpu-cortex-m1.d: Likewise. * testsuite/gas/arm/cpu-cortex-m23.d: Likewise. * testsuite/gas/arm/cpu-cortex-m3.d: Likewise. * testsuite/gas/arm/cpu-cortex-m33.d: Likewise. * testsuite/gas/arm/cpu-cortex-m4.d: Likewise. * testsuite/gas/arm/cpu-cortex-m7.d: Likewise. * testsuite/gas/arm/cpu-cortex-r4.d: Likewise. * testsuite/gas/arm/cpu-cortex-r4f.d: Likewise. * testsuite/gas/arm/cpu-cortex-r5.d: Likewise. * testsuite/gas/arm/cpu-cortex-r52.d: Likewise. * testsuite/gas/arm/cpu-cortex-r7.d: Likewise. * testsuite/gas/arm/cpu-cortex-r8.d: Likewise. * testsuite/gas/arm/cpu-ep9312.d: Likewise. * testsuite/gas/arm/cpu-exynos-m1.d: Likewise. * testsuite/gas/arm/cpu-fa526.d: Likewise. * testsuite/gas/arm/cpu-fa606te.d: Likewise. * testsuite/gas/arm/cpu-fa616te.d: Likewise. * testsuite/gas/arm/cpu-fa626.d: Likewise. * testsuite/gas/arm/cpu-fa626te.d: Likewise. * testsuite/gas/arm/cpu-fa726te.d: Likewise. * testsuite/gas/arm/cpu-fmp626.d: Likewise. * testsuite/gas/arm/cpu-i80200.d: Likewise. * testsuite/gas/arm/cpu-iwmmxt.d: Likewise. * testsuite/gas/arm/cpu-iwmmxt2.d: Likewise. * testsuite/gas/arm/cpu-marvell-pj4.d: Likewise. * testsuite/gas/arm/cpu-marvell-whitney.d: Likewise. * testsuite/gas/arm/cpu-mpcore.d: Likewise. * testsuite/gas/arm/cpu-mpcorenovfp.d: Likewise. * testsuite/gas/arm/cpu-sa1.d: Likewise. * testsuite/gas/arm/cpu-strongarm.d: Likewise. * testsuite/gas/arm/cpu-strongarm1.d: Likewise. * testsuite/gas/arm/cpu-strongarm110.d: Likewise. * testsuite/gas/arm/cpu-strongarm1100.d: Likewise. * testsuite/gas/arm/cpu-strongarm1110.d: Likewise. * testsuite/gas/arm/cpu-xgene1.d: Likewise. * testsuite/gas/arm/cpu-xgene2.d: Likewise. * testsuite/gas/arm/cpu-xscale.d: Likewise. * testsuite/gas/arm/nop-asm.s: Likewise. * testsuite/gas/arm/note-march-armv2.d: Likewise. * testsuite/gas/arm/note-march-armv2.s: Likewise. * testsuite/gas/arm/note-march-armv2a.d: Likewise. * testsuite/gas/arm/note-march-armv2a.s: Likewise. * testsuite/gas/arm/note-march-armv3.d: Likewise. * testsuite/gas/arm/note-march-armv3.s: Likewise. * testsuite/gas/arm/note-march-armv3m.d: Likewise. * testsuite/gas/arm/note-march-armv3m.s: Likewise. * testsuite/gas/arm/note-march-armv4.d: Likewise. * testsuite/gas/arm/note-march-armv4.s: Likewise. * testsuite/gas/arm/note-march-armv4t.d: Likewise. * testsuite/gas/arm/note-march-armv4t.s: Likewise. * testsuite/gas/arm/note-march-armv5.d: Likewise. * testsuite/gas/arm/note-march-armv5.s: Likewise. * testsuite/gas/arm/note-march-armv5t.d: Likewise. * testsuite/gas/arm/note-march-armv5t.s: Likewise. * testsuite/gas/arm/note-march-armv5te.d: Likewise. * testsuite/gas/arm/note-march-armv5te.d: Likewise. * testsuite/gas/arm/note-march-ep9312.d: Likewise. * testsuite/gas/arm/note-march-ep9312.s: Likewise. * testsuite/gas/arm/note-march-iwmmxt.d: Likewise. * testsuite/gas/arm/note-march-iwmmxt.s: Likewise. * testsuite/gas/arm/note-march-iwmmxt2.d: Likewise. * testsuite/gas/arm/note-march-iwmmxt2.s: Likewise. * testsuite/gas/arm/note-march-xscale.d: Likewise. * testsuite/gas/arm/note-march-xscale.s: Likewise.
2018-11-27MIPS/LD: Accept high-part relocations in PIC code with absolute symbolsMaciej W. Rozycki14-0/+121
Accept R_MIPS_HI16, R_MIPS_HIGHER and R_MIPS_HIGHEST relocations and their compressed counterparts in PIC code where the symbol referred is absolute. Such an operation is meaningful, because an absolute symbol effectively is a constant the calculation of the value of which has been deferred to the static link time, and which is not going to change any further at the dynamic load time. Therefore there is no need ever to refuse the use of these relocations with such symbols, as the resulting run-time value observed by the program will be correct even in PIC code. This is not the case with R_MIPS_26 and its compressed counterparts, because the run-time value calculated by the instructions these relocations are used with depends on the address of the instruction itself, and that can change according to the base address used by the dynamic loader. Therefore these relocations have to continue being rejected in PIC code even with absolute symbols. This allows successful linking of code that relies on previous linker behavior up to commit 861fb55ab50a ("Defer allocation of R_MIPS_REL32 GOT slots"), <https://sourceware.org/ml/binutils/2008-08/msg00096.html>, which introduced the problematic check missing this special exception for absolute symbols. bfd/ * elfxx-mips.c (_bfd_mips_elf_check_relocs) <R_MIPS16_HI16> <R_MIPS_HI16, R_MIPS_HIGHER, R_MIPS_HIGHEST, R_MICROMIPS_HI16> <R_MICROMIPS_HIGHER, R_MICROMIPS_HIGHEST>: Also accept an absolute symbol in PIC code. ld/ * testsuite/ld-mips-elf/pic-reloc-0.d: New test. * testsuite/ld-mips-elf/pic-reloc-1.d: New test. * testsuite/ld-mips-elf/pic-reloc-2.d: New test. * testsuite/ld-mips-elf/pic-reloc-3.d: New test. * testsuite/ld-mips-elf/pic-reloc-4.d: New test. * testsuite/ld-mips-elf/pic-reloc-absolute-hi.ld: New test linker script. * testsuite/ld-mips-elf/pic-reloc-absolute-lo.ld: New test linker script. * testsuite/ld-mips-elf/pic-reloc-ordinary.ld: New test linker script. * testsuite/ld-mips-elf/pic-reloc-j.s: New test source. * testsuite/ld-mips-elf/pic-reloc-lui.s: New test source. * testsuite/ld-mips-elf/mips-elf.exp: Run the new tests.
2018-11-27MIPS/LD: Continue processing with refused relocations in PIC codeMaciej W. Rozycki2-6/+13
Switch from `_bfd_error_handler' to `info->callbacks->einfo' with error reporting concerning the use of position-dependent relocations such as R_MIPS_HI16 or R_MIPS_26 in PIC code and continue processing so that any subsequent link errors are also shown rather than the linker terminating right away. This can reduce user frustration where correcting one error only reveals another one; instead all are shown together making them all possible to investigate at once. The use of the `%X' specifier causes the linker to terminate unsuccessfully at the end of processing. Also fix the message to say `cannot' rather than `can not'. bfd/ * elfxx-mips.c (_bfd_mips_elf_check_relocs) <R_MIPS16_26> <R_MIPS_26, R_MICROMIPS_26_S1>: Use `info->callbacks->einfo' rather than `_bfd_error_handler' to report refused relocations in PIC code and continue processing. Fix error message: `can not' -> `cannot'.
2018-11-27LD: Convert `%P: %H:' to `%H:' in error messagesMaciej W. Rozycki2-3/+10
Similarly to commit 174d0a74a2e6 ("PowerPC/BFD: Convert `%P: %H:' to `%H:' in error messages") convert linker relocation error messages to use `%H:' rather `%P: %H:', removing inconsistent message composition like: $ cat reloc-j.s .text .globl foo .ent foo foo: j bar j bar .end foo $ cat reloc-j.ld SECTIONS { bar = 0x12345678; .text : { *(.text) } /DISCARD/ : { *(*) } } $ as -o reloc-j.o reloc-j.s $ ld -T reloc-j.ld -o reloc-j reloc-j.o ld: tmpdir/reloc-j.o: in function `foo': (.text+0x0): relocation truncated to fit: R_MIPS_26 against `bar' ld: (.text+0x8): relocation truncated to fit: R_MIPS_26 against `bar' $ where subsequent lines referring to issues within a single function have the name of the linker executable prepended, but the first one does not. As noted with the commit referred this breaks a GNU Coding Standard's requirement that error messages from compilers should look like this: source-file-name:lineno: message also quoted in `vfinfo' code handling these specifiers. Remove the linker name prefix then, making the messages now look like: $ ld -T reloc-j.ld -o reloc-j reloc-j.o tmpdir/reloc-j.o: in function `foo': (.text+0x0): relocation truncated to fit: R_MIPS_26 against `bar' (.text+0x8): relocation truncated to fit: R_MIPS_26 against `bar' $ instead. ld/ * ldmain.c (reloc_overflow): Use `%H:' rather than `%P: %H:' with `einfo'. (reloc_dangerous): Likewise. (unattached_reloc): Likewise.