aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2017-06-16[AArch64] Use SYMBOL_REFERENCES_LOCAL in one symbol checkJiong Wang8-18/+44
For some pc-relative relocations we want to allow them under PIC mode while a normal global symbol defined in the same dynamic object can still bind externally through copy relocation. So, we should not allow pc-relative relocation against such symbol. SYMBOL_REFERENCES_LOCAL should be used and is more accurate than the original individual checks. bfd/ * elfnn-aarch64.c (elfNN_aarch64_final_link_relocate): Use SYMBOL_REFERENCES_LOCAL. ld/ * testsuite/ld-aarch64/aarch64-elf.exp: Update test name * testsuite/ld-aarch64/pcrel.s: Add new testcases. * testsuite/ld-aarch64/pcrel_pic_undefined.d: Update the expected warnings. * testsuite/ld-aarch64/pcrel_pic_defined_local.d: Rename ... * testsuite/ld-aarch64/pcrel_pic_defined.d: ... to this. Update expected warnings.
2017-06-16arc: Select CPU model properly before disassemblingAnton Kolesov2-6/+65
Enforce CPU model for disassembler via its options, if it was specified in XML target description, otherwise use default method of determining CPU implemented in disassembler - scanning ELF private header. The latter requires disassemble_info->section to be properly initialized. To make sure that info->section is set in all cases this patch partially reverts [1] for ARC: it reinstates arc_delayed_print_insn as a "print_insn" function for ARC, but now this function only sets disassemble_info->section and then calls default_print_insn to do the rest of the job. Support for CPU in disassembler options for ARC has been added in [2]. [1] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=39503f82427e22ed8e04d986ccdc8562091ec62e [2] https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=10045478d984f9924cb945423388ba25b7dd3ffe gdb/ChangeLog: yyyy-mm-dd Anton Kolesov <anton.kolesov@synopsys.com> * arc-tdep.c (arc_disassembler_options): New variable. (arc_gdbarch_init): Set and use it. Use arc_delayed_print_insn instead of default_print_insn. (arc_delayed_print_insn): Set info->section when needed, use default_print_insn to retrieve a disassembler.
2017-06-152017-06-15 Eric Christopher <echristo@gmail.com>Eric Christopher2-4/+9
* aarch64.cc: Fix a few typos and grammar-os.
2017-06-16Automatic date update in version.inGDB Administrator1-1/+1
2017-06-15Correct "ld --help" to display "-z stack-size=SIZE"H.J. Lu2-1/+6
ELF Linker command line option to set stack size is "-z stack-size=SIZE", not "-z stacksize=SIZE". * exsup.c (elf_shlib_list_options): Display "-z stack-size=SIZE" instead of "-z stacksize=SIZE".
2017-06-15[AArch64] Allow COPY relocation eliminationJiong Wang9-47/+220
As discussed at the PR, this patch tries to avoid COPY relocation generation and propagate the original relocation into runtime if it was relocating on writable section. The ELIMINATE_COPY_RELOCS has been set to true and it's underlying infrastructure has been improved so that the COPY reloc elimination at least working on absoluate relocations (ABS64) on AArch64. BFD linker copy relocation elimination framwork requires the backend to always allocate dynrelocs for all those relocation types that are possible to introduce copy relocations. This is for adjust_dynamic_symbol hook to be able to get all symbol reference information. Should one symbol is referenced by more than one relocations, if there is any of them needs copy relocation then linker should generate it. bfd/ PR ld/21532 * elfnn-aarch64.c (ELIMINATE_COPY_RELOCS): Set to 1. (elfNN_aarch64_final_link_relocate): Also propagate relocations to runtime for if there needs copy relocation elimination. (need_copy_relocation_p): New function. Return true for symbol with pc-relative references and if it's against read-only sections. (elfNN_aarch64_adjust_dynamic_symbol): Use need_copy_relocation_p. (elfNN_aarch64_check_relocs): Allocate dynrelocs for relocation types that are related with accessing external objects. (elfNN_aarch64_gc_sweep_hook): Sync the relocation types with the change in elfNN_aarch64_check_relocs. ld/ * testsuite/ld-aarch64/copy-reloc-exe-2.s: New test source file. * testsuite/ld-aarch64/copy-reloc-2.d: New test. * testsuite/ld-aarch64/copy-reloc-exe-eliminate.s: New test source file. * testsuite/ld-aarch64/copy-reloc-eliminate.d: New test. * testsuite/ld-aarch64/copy-reloc-so.s: Define new global objects. * testsuite/ld-aarch64/aarch64-elf.exp: Run new tests.
2017-06-15i386-dis: Add 2 tests with invalid bnd registerH.J. Lu5-0/+41
PR binutils/21594 * testsuite/gas/i386/mpx.s: Add 2 tests with invalid bnd register. * testsuite/gas/i386/x86-64-mpx.s: Likewise. * testsuite/gas/i386/mpx.d: Updated. * testsuite/gas/i386/x86-64-mpx.d: Likewise.
2017-06-15i386-dis: Check valid bnd registerH.J. Lu2-0/+16
Since there are only 4 bnd registers, return "(bad)" for register number > 3. PR binutils/21594 * i386-dis.c (OP_E_register): Check valid bnd register. (OP_G): Likewise.
2017-06-15Prevent address violation problem when disassembling corrupt aarch64 binary.Nick Clifton2-0/+9
PR binutils/21595 * aarch64-dis.c (aarch64_ext_ldst_reglist): Check for an out of range value.
2017-06-15Fix address violation parsing a corrupt ieee binary.Nick Clifton2-1/+3
PR binutils/21581 (ieee_archive_p): Use a static buffer to avoid compiler bugs.
2017-06-15Avoid a possible compiler bug by using a static buffer instead of a stack ↵Nick Clifton2-1/+7
local buffer. PR binutils/21582 * ieee.c (ieee_object_p): Use a static buffer to avoid compiler bugs.
2017-06-15Fix address violation when disassembling a corrupt RL78 binary.Nick Clifton3-411/+424
PR binutils/21588 * rl78-decode.opc (OP_BUF_LEN): Define. (GETBYTE): Check for the index exceeding OP_BUF_LEN. (rl78_decode_opcode): Use OP_BUF_LEN as the length of the op_buf array. * rl78-decode.c: Regenerate.
2017-06-15Handle EITR records in VMS Alpha binaries with overlarge command length ↵Nick Clifton2-8/+13
parameters. PR binutils/21579 * vms-alpha.c (_bfd_vms_slurp_etir): Extend check of cmd_length.
2017-06-15Prevent invalid array accesses when disassembling a corrupt bfin binary.Nick Clifton2-4/+12
PR binutils/21586 * bfin-dis.c (gregs): Clip index to prevent overflow. (regs): Likewise. (regs_lo): Likewise. (regs_hi): Likewise.
2017-06-15[GOLD] Don't install branch-to-stub for TLS relaxed ERRATUM 843419 sequences ↵Jiong Wang2-2/+35
on AArch64 TLS relaxation may change erratum 843419 sequences that those offending ADRP instructions actually transformed into other instructions in which case there is erratum 843419 risk anymore that we should avoid installing unnecessary branch-to-stub. gold/ * aarch64.cc (Insn_utilities::is_mrs_tpidr_el0): New method. (AArch64_relobj<size, big_endian>::try_fix_erratum_843419_optimized): Return ture for some TLS relaxed sequences.
2017-06-14PR gdb/21574: Mention $SHELL and startup-with-shell on "help run"Sergio Durigan Junior2-4/+13
This simple patch updates the documentation of "help run" in order to mention that the shell used to start the inferior comes from the $SHELL environment variable. It also mentions that this behaviour can be disabled by using the "set startup-with-shell off" command. gdb/ChangeLog: 2017-06-14 Sergio Durigan Junior <sergiodj@redhat.com> PR gdb/21574 * infcmd.c (_initialize_infcmd): Expand "help run" documentation to mention $SHELL and startup-with-shell.
2017-06-15Automatic date update in version.inGDB Administrator1-1/+1
2017-06-14xtensa: don't expect XCHAL_* macros to be constantMax Filippov5-37/+84
Get rid of the assumption that XCHAL_* macros are preprocessor constants: don't use them in preprocessor conditionals or in static variable initializers. 2017-06-14 Max Filippov <jcmvbkbc@gmail.com> bfd/ * elf32-xtensa.c (elf_xtensa_be_plt_entry, elf_xtensa_le_plt_entry): Add dimension for the ABI to arrays, keep both windowed and call0 ABI PLT definitions. (elf_xtensa_create_plt_entry): Use selected ABI to choose upper elf_xtensa_*_plt_entry endex. (ELF_MAXPAGESIZE): Fix at minimal supported MMU page size. gas/ * config/tc-xtensa.c (density_supported, xtensa_fetch_width, absolute_literals_supported): Leave definitions uninitialized. (directive_state): Leave entries for directive_density and directive_absolute_literals initialized to false. (xg_init_global_config, xtensa_init): New functions. * config/tc-xtensa.h (TARGET_BYTES_BIG_ENDIAN): Define as 0. (HOST_SPECIAL_INIT): New definition. (xtensa_init): New declaration.
2017-06-14Maxim Grigoriev stepping down as Xtensa maintainerMax Filippov2-1/+5
gdb/ 2017-06-14 Max Filippov <jcmvbkbc@gmail.com> * MAINTAINERS: Move Maxim Grigoriev to the Past Maintainers.
2017-06-14Fix seg-fault when trying to disassemble a corrupt score binary.Nick Clifton2-1/+7
PR binutils/21576 * score7-dis.c (score_opcodes): Add sentinel.
2017-06-14Fix address violation bug when disassembling a corrupt SH binary.Nick Clifton2-1/+7
PR binutils/21578 * elf32-sh.c (sh_elf_set_mach_from_flags): Fix check for invalid flag value.
2017-06-14Fix address violation when disassembling a corrupt binary.Nick Clifton3-15/+23
PR binutils/21580 binutils * objdump.c (disassemble_bytes): Check for buffer overrun when printing out rae insns. ld * testsuite/ld-nds32/diff.d: Adjust expected output.
2017-06-14Don't use print_insn_XXX in GDBYao Qi16-26/+57
This is a follow-up to [PATCH 0/6] Unify the disassembler selection in gdb and objdump https://sourceware.org/ml/binutils/2017-05/msg00192.html that is, opcodes is able to select the right disassembler, so gdb doesn't have to select them. Instead, gdb can just use default_print_insn. As a result, these print_insn_XXX are not used out of opcodes, so this patch also moves their declarations from include/dis-asm.h to opcodes/disassemble.h. With this change, GDB doesn't use any print_insn_XXX directly any more. gdb: 2017-06-14 Yao Qi <yao.qi@linaro.org> * aarch64-tdep.c (aarch64_gdb_print_insn): Call default_print_insn instead of print_insn_aarch64. * arm-tdep.c (gdb_print_insn_arm): Call default_print_insn instead of print_insn_big_arm and print_insn_little_arm. * i386-tdep.c (i386_print_insn): Call default_print_insn instead of print_insn_i386. * ia64-tdep.c (ia64_print_insn): Call default_print_insn instead of print_insn_ia64. * mips-tdep.c (gdb_print_insn_mips): Call default_print_insn instead of print_insn_big_mips and print_insn_little_mips. * spu-tdep.c (gdb_print_insn_spu): Call default_print_insn instead of print_insn_spu. include: 2017-06-14 Yao Qi <yao.qi@linaro.org> * dis-asm.h (print_insn_aarch64): Move it to opcodes/disassemble.h. (print_insn_big_arm, print_insn_big_mips): Likewise. (print_insn_i386, print_insn_ia64): Likewise. (print_insn_little_arm, print_insn_little_mips): Likewise. (print_insn_spu): Likewise. opcodes: 2017-06-14 Yao Qi <yao.qi@linaro.org> * aarch64-dis.c: Include disassemble.h instead of dis-asm.h. * arm-dis.c: Likewise. * ia64-dis.c: Likewise. * mips-dis.c: Likewise. * spu-dis.c: Likewise. * disassemble.h (print_insn_aarch64): New declaration, moved from include/dis-asm.h. (print_insn_big_arm, print_insn_big_mips): Likewise. (print_insn_i386, print_insn_ia64): Likewise. (print_insn_little_arm, print_insn_little_mips): Likewise.
2017-06-14xfail pr20022.d on targets without dynamic relocs in .textH.J. Lu2-0/+8
ld-gc/pr20022.d requires support for dynamic relocations in .text section. PR ld/20022 * testsuite/ld-gc/pr20022.d: Skip on targets without dynamic relocations in .text section.
2017-06-14Skip PR ld/21562 tests on targets with leading char or without --gc-sectionsH.J. Lu15-0/+105
Symbol lookup in linker will always fail on targets with leading char in symbol name since __start_SECNAME and __stop_SECNAME in C may be ___start_SECNAME and ___stop_SECNAME in assembly. Also tests with --gc-sections always fails on targets without --gc-sections support. * testsuite/ld-elf/pr21562a.d: Skip on targets with leading char in in symbol name or without --gc-sections. * testsuite/ld-elf/pr21562b.d: Likewise. * testsuite/ld-elf/pr21562c.d: Likewise. * testsuite/ld-elf/pr21562d.d: Likewise. * testsuite/ld-elf/pr21562i.d: Likewise. * testsuite/ld-elf/pr21562j.d: Likewise. * testsuite/ld-elf/pr21562k.d: Likewise. * testsuite/ld-elf/pr21562l.d: Likewise. * testsuite/ld-elf/pr21562m.d: Likewise. * testsuite/ld-elf/pr21562n.d: Likewise. * testsuite/ld-elf/pr21562e.d: Skip on targets with leading char in symbol name. * testsuite/ld-elf/pr21562f.d: Likewise. * testsuite/ld-elf/pr21562g.d: Likewise. * testsuite/ld-elf/pr21562h.d: Likewise.
2017-06-14Add size to bar in ld-gc/pr20022a.sH.J. Lu2-0/+5
Some linker backends require size info on dynamic symbols. * testsuite/ld-gc/pr20022a.s: Add size to bar.
2017-06-14Skip sizeof/startof tests on targets with leading charH.J. Lu5-0/+24
Symbol lookup in linker will always fail on targets with leading char in symbol name since __start_SECNAME and __stop_SECNAME in C may be ___start_SECNAME and ___stop_SECNAME in assembly. * testsuite/ld-elf/sizeofa.d: Skip on targets with leading char in symbol name. * testsuite/ld-elf/sizeofb.d: Likewise. * testsuite/ld-elf/startofa.d: Likewise. * testsuite/ld-elf/startofb.d: Likewise.
2017-06-14Fix address violation problems when disassembling a corrupt RX binary.Nick Clifton3-20/+37
PR binutils/21587 * rx-decode.opc: Include libiberty.h (GET_SCALE): New macro - validates access to SCALE array. (GET_PSCALE): New macro - validates access to PSCALE array. (DIs, SIs, S2Is, rx_disp): Use new macros. * rx-decode.c: Regenerate.
2017-06-14Fix register selection in var-access.expAndreas Arnez2-5/+11
The new test var-access.exp causes FAILs on i686. This is because the test chooses the wrong name for DWARF register number 1: It uses "edx" (which corresponds to DWARF register number 2), but should have used "ecx" instead. Also, the current logic in var-access.exp does not correctly distinguish between a 64-bit and a 32-bit program on an x86-64 target. It uses the 64-bit register names for both. These problems are fixed. In order to address the latter, the convenience macros is_*_target are exploited where appropriate. gdb/testsuite/ChangeLog: * gdb.dwarf2/var-access.exp: Use register name ecx instead of edx on 32-bit x86 targets. Exploit is_*_target macros where appropriate.
2017-06-14Move location of .jumptables section and add .hightext section to AVR linker ↵Georg-Johann Lay2-5/+18
script. PR ld/21583 * scripttempl/avr.sc (.jumptables): Move down in text section. (.hightext): New in text.
2017-06-14Fix potential address violations when processing a corrupt Alpha VMA binary.Nick Clifton2-10/+50
PR binutils/21589 * vms-alpha.c (_bfd_vms_get_value): Add an extra parameter - the maximum value for the ascic pointer. Check that name processing does not read beyond this value. (_bfd_vms_slurp_etir): Add checks for attempts to read beyond the end of etir record.
2017-06-14Introduce gdb::byte_vector, add allocator that default-initializesPedro Alves14-31/+230
In some cases we've been replacing heap-allocated gdb_byte buffers managed with xmalloc/make_cleanup(xfree) with gdb::vector<gdb_byte>. That usually pessimizes the code a little bit because std::vector value-initializes elements (which for gdb_byte means zero-initialization), while if you're creating a temporary buffer, you're most certaintly going to fill it in with some data. An alternative is to use unique_ptr<gdb_byte[]> buf (new gdb_byte[size]); but it looks like that's not very popular. Recently, a use of obstacks in dwarf2read.c was replaced with std::vector<gdb_byte> and that as well introduced a pessimization for always memsetting the buffer when it's garanteed that the zeros will be overwritten immediately. (see dwarf2read.c change in this patch to find it.) So here's a different take at addressing this issue "by design": #1 - Introduce default_init_allocator<T> I.e., a custom allocator that does default construction using default initialization, meaning, no more zero initialization. That's the default_init_allocation<T> class added in this patch. See "Notes" at <http://en.cppreference.com/w/cpp/container/vector/resize>. #2 - Introduce def_vector<T> I.e., a convenience typedef, because typing the allocator is annoying: using def_vector<T> = std::vector<T, gdb::default_init_allocator<T>>; #3 - Introduce byte_vector Because gdb_byte vectors will be the common thing, add a convenience "byte_vector" typedef: using byte_vector = def_vector<gdb_byte>; which is really the same as: std::vector<gdb_byte, gdb::default_init_allocator<gdb_byte>>; The intent then is to make "gdb::byte_vector" be the go-to for dynamic byte buffers. So the less friction, the better. #4 - Adjust current code to use it. To set the example going forward. Replace std::vector uses and also unique_ptr<byte[]> uses. One nice thing is that with this allocator, for changes like these: -std::unique_ptr<byte[]> buf (new gdb_byte[some_size]); +gdb::byte_vector buf (some_size); fill_with_data (buf.data (), buf.size ()); the generated code is the same as before. I.e., the compiler de-structures the vector and gets rid of the unused "reserved vs size" related fields. The other nice thing is that it's easier to write gdb::byte_vector buf (size); than std::unique_ptr<gdb_byte[]> buf (new gdb_byte[size]); or even (C++14): auto buf = std::make_unique<gdb_byte[]> (size); // zero-initializes... #5 - Suggest s/std::vector<gdb_byte>/gdb::byte_vector/ going forward. Note that this commit actually fixes a couple of bugs where the current code is incorrectly using "std::vector::reserve(new_size)" and then accessing the vector's internal buffer beyond the vector's size: see dwarf2loc.c and charset.c. That's undefined behavior and may trigger debug mode assertion failures. With default_init_allocator, "resize()" behaves like "reserve()" performance wise, in that it leaves new elements with unspecified values, but, it does that safely without triggering undefined behavior when you access those values. gdb/ChangeLog: 2017-06-14 Pedro Alves <palves@redhat.com> * ada-lang.c: Include "common/byte-vector.h". (ada_value_primitive_packed_val): Use gdb::byte_vector. * charset.c (wchar_iterator::iterate): Resize the vector instead of reserving it. * common/byte-vector.h: Include "common/def-vector.h". (wchar_iterator::m_out): Now a gdb::def_vector<gdb_wchar_t>. * cli/cli-dump.c: Include "common/byte-vector.h". (dump_memory_to_file, restore_binary_file): Use gdb::byte_vector. * common/byte-vector.h: New file. * common/def-vector.h: New file. * common/default-init-alloc.h: New file. * dwarf2loc.c: Include "common/byte-vector.h". (rw_pieced_value): Use gdb::byte_vector, and resize the vector instead of reserving it. * dwarf2read.c: Include "common/byte-vector.h". (data_buf::m_vec): Now a gdb::byte_vector. * gdb_regex.c: Include "common/def-vector.h". (compiled_regex::compiled_regex): Use gdb::def_vector<char>. * mi/mi-main.c: Include "common/byte-vector.h". (mi_cmd_data_read_memory): Use gdb::byte_vector. * printcmd.c: Include "common/byte-vector.h". (print_scalar_formatted): Use gdb::byte_vector. * valprint.c: Include "common/byte-vector.h". (maybe_negate_by_bytes, print_decimal_chars): Use gdb::byte_vector.
2017-06-14[opcodes][arm] Remove bogus entry added by accident in former patchAndre Vieira2-2/+4
2017-07-14 Andre Vieira <andre.simoesdiasvieira@arm.com> * arm-dis.c (print_insn_arm): Remove bogus entry for bx.
2017-06-14Fix seg-faults in objdump when disassembling a corrupt versados binary.Nick Clifton2-4/+14
PR binutils/21591 * versados.c (versados_mkobject): Zero the allocated tdata structure. (process_otr): Check for an invalid offset in the otr structure.
2017-06-14Accept more epiphany targetsSebastian Huber4-2/+10
In particular this adds support for the epiphany-rtems target. bfd/ * config.bfd (epiphany-*-elf): Accept epiphany-*-*. ld/ * configure.tgt (epiphany-*-elf): Accept epiphany-*-*.
2017-06-14Automatic date update in version.inGDB Administrator1-1/+1
2017-06-13ld: Don't define __start_SECNAME/__stop_SECNAME for -rH.J. Lu4-4/+41
__start_SECNAME and __stop_SECNAME shouldn't be defined for "ld -r". * ldlang.c (lang_set_startof): Skip if config.build_constructors is FALSE. * testsuite/ld-elf/sizeofc.d: New file. * testsuite/ld-elf/startofc.d: Likewise.
2017-06-13darwin-nat: Add missing includeSimon Marchi2-0/+5
I forgot this one, which is kind of related. The function trace_start_error_with_name has moved in commit "Share fork_inferior et al with gdbserver", so this additional include is needed. Fixes: darwin-nat.c:1735:5: error: use of undeclared identifier 'trace_start_error_with_name' trace_start_error_with_name ("close"); gdb/ChangeLog: * darwin-nat.c: Include "nat/fork-inferior.h".
2017-06-13darwin: Add fork-inferior.o to NATDEPFILESSimon Marchi2-3/+11
I happened to be build-testing on macOS and found this: Undefined symbols for architecture x86_64: "fork_inferior(char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char**, void (*)(), void (*)(int), void (*)(), char const*, void (*)(char const*, char* const*, char* const*))", referenced from: darwin_create_inferior(target_ops*, char const*, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, char**, int) in darwin-nat.o "startup_inferior(int, int, target_waitstatus*, ptid_t*)", referenced from: gdb_startup_inferior(int, int) in fork-child.o "trace_start_error(char const*, ...)", referenced from: darwin_ptrace_me() in darwin-nat.o "trace_start_error_with_name(char const*)", referenced from: darwin_ptrace_me() in darwin-nat.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation) Adding fork-inferior.o fixes it. I factored out the Darwin bits that are no architecture-specific in the section meant for that at the top. I only built-tested this using Travis-CI, since I don't have access to this platform. gdb/ChangeLog: * configure.nat: Factor out Darwin bits that are not architecture-specific. Add fork-inferior.o.
2017-06-13aix: Add fork-inferior.o to NATDEPFILESSimon Marchi2-1/+9
Trying to build on AIX gives: ld: 0711-317 ERROR: Undefined symbol: .trace_start_error_with_name(char const*) ld: 0711-317 ERROR: Undefined symbol: .fork_inferior(char const*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, char**, void (*)(), void (*)(int), void (*)(), char const*, void (*)(char const*, char* const*, char* const*)) ld: 0711-317 ERROR: Undefined symbol: .startup_inferior(int, int, target_waitstatus*, ptid_t*) Including fork-inferior.o in the build should help. I also factored out the AIX bits that are not architecture-specific to be consistent with the other OSes. gdb/ChangeLog: * configure.nat: Factor out AIX bits that are not architecture-specific. Add fork-inferior.o.
2017-06-13ld: Add tests for .startof.SECNAME/.sizeof.SECNAMEH.J. Lu5-0/+37
* testsuite/ld-elf/sizeof.d: Renamed to ... * testsuite/ld-elf/sizeofa.d: This. Updated. * testsuite/ld-elf/startof.d: Renamed to ... * testsuite/ld-elf/startofa.d: This. Updated. * testsuite/ld-elf/sizeofb.d: New file. * testsuite/ld-elf/startofb.d: Likewise.
2017-06-13Always define referenced __start_SECNAME/__stop_SECNAMEH.J. Lu39-182/+473
Currently, linker will define __start_SECNAME and __stop_SECNAME symbols only for orphaned sections. However, during garbage collection, ELF linker marks all sections with references to __start_SECNAME and __stop_SECNAME symbols as used even when section SECNAME isn't an orphaned section and linker won't define __start_SECNAME nor __stop_SECNAME. And ELF linker stores the first input section whose name matches __start_SECNAME or __stop_SECNAME in u.undef.section for garbage collection. If these symbols are provided in linker script, u.undef.section is set to the section where they will defined by linker script, which leads to the incorrect output. This patch changes linker to always define referenced __start_SECNAME and __stop_SECNAME if the input section name is the same as the output section name, which is always true for orphaned sections, and SECNAME is a C identifier. Also __start_SECNAME and __stop_SECNAME symbols are marked as hidden by ELF linker so that __start_SECNAME and __stop_SECNAME symbols for section SECNAME in different modules are unique. For garbage collection, ELF linker stores the first matched input section in the unused vtable field. bfd/ PR ld/20022 PR ld/21557 PR ld/21562 PR ld/21571 * elf-bfd.h (elf_link_hash_entry): Add start_stop. Change the vtable field to a union. (_bfd_elf_is_start_stop): Removed. * elf32-i386.c (elf_i386_convert_load_reloc): Also check for __start_SECNAME and __stop_SECNAME symbols. * elf64-x86-64.c (elf_x86_64_convert_load_reloc): Likewise. * elflink.c (_bfd_elf_is_start_stop): Removed. (_bfd_elf_gc_mark_rsec): Check start_stop instead of calling _bfd_elf_is_start_stop. (elf_gc_propagate_vtable_entries_used): Skip __start_SECNAME and __stop_SECNAME symbols. Updated. (elf_gc_smash_unused_vtentry_relocs): Likewise. (bfd_elf_gc_record_vtinherit): Likewise. (bfd_elf_gc_record_vtentry): Likewise. ld/ PR ld/20022 PR ld/21557 PR ld/21562 PR ld/21571 * ld.texinfo: Update __start_SECNAME/__stop_SECNAME symbols. * ldlang.c (lang_insert_orphan): Move handling of __start_SECNAME and __stop_SECNAME symbols to ... (lang_set_startof): Here. Also define __start_SECNAME and __stop_SECNAME for -Ur. * emultempl/elf32.em (gld${EMULATION_NAME}_after_open): Mark referenced __start_SECNAME and __stop_SECNAME symbols as hidden and set start_stop for garbage collection. * testsuite/ld-elf/pr21562a.d: New file. * testsuite/ld-elf/pr21562a.s: Likewise. * testsuite/ld-elf/pr21562a.t: Likewise. * testsuite/ld-elf/pr21562b.d: Likewise. * testsuite/ld-elf/pr21562b.s: Likewise. * testsuite/ld-elf/pr21562b.t: Likewise. * testsuite/ld-elf/pr21562c.d: Likewise. * testsuite/ld-elf/pr21562c.t: Likewise. * testsuite/ld-elf/pr21562d.d: Likewise. * testsuite/ld-elf/pr21562d.t: Likewise. * testsuite/ld-elf/pr21562e.d: Likewise. * testsuite/ld-elf/pr21562f.d: Likewise. * testsuite/ld-elf/pr21562g.d: Likewise. * testsuite/ld-elf/pr21562h.d: Likewise. * testsuite/ld-elf/pr21562i.d: Likewise. * testsuite/ld-elf/pr21562j.d: Likewise. * testsuite/ld-elf/pr21562k.d: Likewise. * testsuite/ld-elf/pr21562l.d: Likewise. * testsuite/ld-elf/pr21562m.d: Likewise. * testsuite/ld-elf/pr21562n.d: Likewise. * testsuite/ld-gc/pr20022.d: Likewise. * testsuite/ld-gc/pr20022a.s: Likewise. * testsuite/ld-gc/pr20022b.s: Likewise. * testsuite/ld-gc/gc.exp: Run PR ld/20022 tests. * testsuite/ld-gc/pr19161.d: Also accept local __start_SECNAME symbol. * testsuite/ld-gc/start.d: Likewise. * testsuite/ld-x86-64/lea1a.d: Updated. * testsuite/ld-x86-64/lea1b.d: Updated. * testsuite/ld-x86-64/lea1d.d: Updated. * testsuite/ld-x86-64/lea1e.d: Likewise.
2017-06-13Replace multiple AVR scripts with a single, customizable linker script.Georg-Johann Lay22-283/+181
PR ld/21569 * scripttempl/avrtiny.sc: Remove file. * Makefile.am (eavrtiny.c): Depend on avr.sc, no more on avrtiny.sc. * Makefile.in: Regenerate. * emulparams/avrtiny.sh (SCRIPT_NAME): Set var to "avr". (TEXT_ORIGIN): Remove var. (FUSE_NAME, FUSE_LENGTH, LOCK_LENGTH, SIGNATURE_LENGTH) (RODATA_PM_OFFSET): Set new vars. * emulparams/avr1.sh (FUSE_NAME, EEPROM_LENGTH, FUSE_LENGTH) (LOCK_LENGTH, SIGNATURE_LENGTH, USER_SIGNATURE_LENGTH): Set new vars. * emulparams/avr2.sh: Same. * emulparams/avr25.sh: Same. * emulparams/avr3.sh: Same. * emulparams/avr31.sh: Same. * emulparams/avr35.sh: Same. * emulparams/avr4.sh: Same. * emulparams/avr5.sh: Same. * emulparams/avr51.sh: Same. * emulparams/avr6.sh: Same. * emulparams/avrxmega1.sh: Same. * emulparams/avrxmega2.sh: Same. * emulparams/avrxmega3.sh: Same. * emulparams/avrxmega4.sh: Same. * emulparams/avrxmega5.sh: Same. * emulparams/avrxmega6.sh: Same. * emulparams/avrxmega7.sh: Same. * scripttempl/avr.sc (__EEPROM_REGION_LENGTH__): Only define if EEPROM_LENGTH is set. (MEMORY) [eeprom]: Same. (SECTIONS) [.eeprom]: Same for output section. (__USER_SIGNATURE_REGION_LENGTH__): Only define if USER_SIGNATURE_LENGTH is set. (MEMORY) [user_signatures]: Same. (SECTIONS) [.fuse]: Only define output section if FUSE_NAME = fuse. (SECTIONS) [.config]: Only define output section if FUSE_NAME = config.
2017-06-13ld: Add tests for -UrH.J. Lu5-0/+51
Test -Ur with __start_SECNAME, __stop_SECNAME, .startof.SECNAME and .sizeof.SECNAME. __start_SECNAME and __stop_SECNAME should be defined to the start and the end of section SECNAME. .startof.SECNAME and .sizeof.SECNAME should be undefined. * testsuite/ld-elf/sizeof.d: New file. * testsuite/ld-elf/sizeof.s: Likewise. * testsuite/ld-elf/startof.d: Likewise. * testsuite/ld-elf/startof.s: Likewise.
2017-06-13[LD][Testsuite] Add --no-dynamic-linker option to dynamic-1 rdynamic-1 test ↵Renlin Li2-2/+7
case. arm-none-eabi-ld supports shared libraries. However, the toolchain may be configured to generate statically linked executable by default. It is required to have --no-dynamic-linker option before adding dynamic symbol to static executable. For dynamically linked executable, the behavior won't change. ld/ChangeLog 2017-06-13 Renlin Li <renlin.li@arm.com> * testsuite/ld-elf/shared.exp (build_tests): Add --no-dynamic-linker option to rdynamic-1 and dynamic-1 tests.
2017-06-13read/write_pieced_value: Merge into one functionAndreas Arnez2-182/+184
Since read_pieced_value and write_pieced_value share significant logic, this patch merges them into a single function rw_pieced_value. gdb/ChangeLog: * dwarf2loc.c (rw_pieced_value): New. Merge logic from... (read_pieced_value, write_pieced_value): ...here. Reduce to wrappers that just call rw_pieced_value.
2017-06-13write_pieced_value: Notify memory_changed observersAndreas Arnez2-4/+11
So far write_pieced_value uses write_memory when writing memory pieces to the target. However, this is a case where GDB potentially overwrites a watchpoint value. In such a case write_memory_with_notification should be used instead, so that memory_changed observers get notified. gdb/ChangeLog: * dwarf2loc.c (write_pieced_value): When writing the data for a memory piece, use write_memory_with_notification instead of write_memory.
2017-06-13Fix bit-/byte-offset mismatch in parameter to read_value_memoryAndreas Arnez3-8/+14
The function read_value_memory accepts a parameter embedded_offset and expects it to represent the byte offset into the given value. However, the only invocation with a possibly non-zero embedded_offset happens in read_pieced_value, where a bit offset is passed instead. Adjust the implementation of read_value_memory to meet the caller's expectation. This implicitly fixes the invocation in read_pieced_value. gdb/ChangeLog: * valops.c (read_value_memory): Change embedded_offset to represent a bit offset instead of a byte offset. * value.h (read_value_memory): Adjust comment.
2017-06-13read/write_pieced_value: Remove unnecessary variable copiesAndreas Arnez2-68/+58
In read_pieced_value's main loop, the variables `dest_offset_bits' and `source_offset_bits' are basically just copies of `offset' and `bits_to_skip', respectively. In write_pieced_value the copies are reversed. This is not very helpful when trying to keep the logic between these functions in sync. Since the copies are unnecessary, this patch just removes them. gdb/ChangeLog: * dwarf2loc.c (read_pieced_value): Remove unnecessary variables dest_offset_bits and source_offset_bits. (write_pieced_value): Likewise.
2017-06-13Respect piece offset for DW_OP_bit_pieceAndreas Arnez3-6/+64
So far GDB ignores the piece offset of all kinds of DWARF bit pieces (DW_OP_bit_piece) and treats such pieces as if the offset was zero. This is fixed, and an appropriate test is added. gdb/ChangeLog: * dwarf2loc.c (read_pieced_value): Respect the piece offset, as given by DW_OP_bit_piece. (write_pieced_value): Likewise. Andreas Arnez <arnez@linux.vnet.ibm.com> * gdb.dwarf2/var-access.exp: Add test for composite location with nonzero piece offsets.