aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)AuthorFilesLines
2018-02-10Automatic date update in version.inGDB Administrator1-1/+1
2018-02-09x86: Add is_solaris to elf_x86_target_osH.J. Lu5-22/+54
Add is_solaris to elf_x86_target_os since Solaris is quite different. * elf32-i386.c (elf_i386_get_synthetic_symtab): Also handle is_solaris. (i386_elf32_sol2_vec): Don't declare. (elf_i386_link_setup_gnu_properties): Also handle is_solaris. Don't set need_global_offset_table. (elf_i386_solaris_arch_bed): New. (elf_backend_arch_data): Set to elf_i386_solaris_arch_bed for Solaris. * elf64-x86-64.c (elf_x86_64_get_synthetic_symtab): Check target_os != is_nacl instead of target_os == is_normal. (x86_64_elf64_sol2_vec): Don't declare. (elf_x86_64_link_setup_gnu_properties): Check target_os != is_nacl instead of target_os == is_normal. Don't set need_global_offset_table. (elf_x86_64_solaris_arch_bed): New. (elf_backend_arch_data): Set to elf_x86_64_solaris_arch_bed for Solaris. * elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Keep _GLOBAL_OFFSET_TABLE_ for Solaris. (_bfd_x86_elf_link_setup_gnu_properties): Don't copy need_global_offset_table. * elfxx-x86.h (elf_x86_target_os): Add is_solaris. (elf_x86_link_hash_table): Remove need_global_offset_table. (elf_x86_init_table): Likewise.
2018-02-09Don't reference past the end of the vectorTom Tromey2-1/+6
An earlier change made find_source_lines read: end = &data[size]; However, since 'size' is the size of the vector, this seems fishy. More obviously ok is to compute the end of the data directly: end = data.data () + size; 2018-02-09 Tom Tromey <tom@tromey.com> * source.c (find_source_lines): Don't reference past the end of the vector.
2018-02-09btrace: reword error messagesMarkus Metzger5-7/+21
Reword some btrace error messages to align with the format discussed in https://sourceware.org/ml/gdb-patches/2018-02/msg00135.html. gdb/ * remote.c (remote_btrace_maybe_reopen): Change error message. * btrace.c (btrace_enable): Likewise. (parse_xml_btrace): Likewise. (parse_xml_btrace_conf): Likewise. testsuite/ * lib/gdb.exp (skip_btrace_pt_tests): Update expected error message. Fix test name.
2018-02-09btrace: check perf_event_paranoidMarkus Metzger2-2/+36
One recurring error on Debian systems is that the default perf_event_paranoid setting disables the perf_event interface for user-space. Check the current level and point the user to the file. gdb/ * nat/linux-btrace.c (diagnose_perf_event_open_fail): New. (linux_enable_pt, linux_enable_bts): Call diagnose_perf_event_open_fail.
2018-02-09btrace: improve enable error messagesMarkus Metzger2-40/+38
Improve the error message when GDB fails to start recording branch trace. This patch also removes a zero buffer size check for PT to align with BTS. The buffer size can not be configured to be zero. gdb/ * nat/linux-btrace.c (perf_event_pt_event_type): Improve error message. Remove parameter and change return type. Update callers. Move it. (linux_enable_bts, linux_enable_pt): Improve error message. (linux_enable_pt): Remove zero buffer size check. (linux_enable_btrace): Improve error messages. Remove NULL return check.
2018-02-09btrace, gdbserver: remove the to_supports_btrace target methodMarkus Metzger16-373/+51
Remove the to_supports_btrace target method and instead rely on detecting errors when trying to enable recording. This will also provide a suitable error message explaining why recording is not possible. For remote debugging, gdbserver will now always advertise branch tracing related packets. When talking to an older GDB, this will cause GDB to try to enable branch tracing and gdbserver to report a suitable error message every time. An older gdbserver will not advertise branch tracing related packets if the one-time check failed, so a newer GDB with this patch will fail to enable branch tracing at remote_enable_btrace() rather than at btrace_enable(). The error message is the same in both cases so there should be no user-visible change. gdb/ * btrace.c (btrace_enable): Remove target_supports_btrace call. * nat/linux-btrace.c (perf_event_pt_event_type): Move. (kernel_supports_bts, kernel_supports_pt, linux_supports_bts) (linux_supports_pt, linux_supports_btrace): Remove. (linux_enable_bts): Call cpu_supports_bts. * nat/linux-btrace.h (linux_supports_btrace): Remove. * remote.c (remote_supports_btrace): Remove. (init_remote_ops): Remove remote_supports_btrace. * target-delegates.c: Regenerated. * target.c (target_supports_btrace): Remove. * target.h (target_ops) <to_supports_btrace>: Remove (target_supports_btrace): Remove. * x86-linux-nat.c (x86_linux_create_target): Remove linux_supports_btrace. gdbserver/ * linux-low.c (linux_target_ops): Remove linux_supports_btrace. * nto-low.c (nto_target_ops): Remove NULL for supports_btrace. * spu-low.c (spu_target_ops): Likewise. * win32-low.c (win32_target_ops): Likewise. * server.c (supported_btrace_packets): Report packets unconditionally. * target.h (target_ops) <supports_btrace>: Remove. (target_supports_btrace): Remove.
2018-02-09btrace, gdbserver: use exceptions to convey btrace enable/disable errorsMarkus Metzger5-39/+53
Change error reporting to use exceptions and be prepared to catch them in gdbserver. We use the exception message in our error reply to GDB. This may remove some detail from the error message in the native case since errno is no longer printed. Later patches will improve that. We're still using error strings on the RSP level. This patch does not affect the interoperability of older/newer GDB/gdbserver. gdbserver/ * server.c (handle_btrace_enable_bts, handle_btrace_enable_pt) (handle_btrace_disable): Change return type to void. Use exceptions to report errors. (handle_btrace_general_set): Catch exception and copy message to return message. gdb/ * nat/linux-btrace.c (linux_enable_btrace): Throw exception if enabling btrace failed. * x86-linux-nat.c (x86_linux_enable_btrace): Catch btrace enabling exception and use message in own exception.
2018-02-09btrace: prepare for throwing exceptions when enabling btraceMarkus Metzger2-67/+58
We indicate success or failure for enabling branch tracing via the pointer return value. Depending on the type of error, errno may provide additional information. Prepare for using exceptions with more descriptive error messages by using smart pointers and objects with automatic destruction to hold intermediate results. gdb/ * nat/linux-btrace.c: Include scoped_fd.h and scoped_mmap.h. (perf_event_pt_event_type): Use gdb_file_up. (linux_enable_bts, linux_enable_pt): Use gdb::unique_xmalloc_ptr, scoped_fd, and scoped_mmap.
2018-02-09common: add scoped_mmapMarkus Metzger4-0/+176
Add a simple helper to automatically unmap a memory mapping. gdb/ * common/scoped_mmap.h: New. * unittests/scoped_mmap-selftest.c: New. * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add unittests/scoped_mmap-selftest.c.
2018-02-09common: add scoped_fdMarkus Metzger4-0/+158
Add a simple helper to automatically close a file descriptor. gdb/ * common/scoped_fd.h: New. * unittests/scoped_fd-selftest.c: New. * Makefile.in (SUBDIR_UNITTESTS_SRCS): Add unittests/scoped_fd-selftest.c.
2018-02-09Use gdb::unique_xmalloc_ptr in auto_load_section_scriptsTom Tromey2-4/+7
This changes auto_load_section_scripts to use gdb::unique_xmalloc_ptr, allowing the removal of a cleanup. 2018-02-09 Tom Tromey <tom@tromey.com> * auto-load.c (auto_load_section_scripts): Use gdb::unique_xmalloc_ptr.
2018-02-09Use std::string in execute_script_contentsTom Tromey2-12/+9
This changes execute_script_contents to use a std::string, allowing the removal of a cleanup. 2018-02-09 Tom Tromey <tom@tromey.com> * auto-load.c (execute_script_contents): Use std::string.
2018-02-09gdb/NEWS: Clarify the news entry for "rbreak" in GDB 8.1Joel Brobecker2-3/+8
gdb/ChangeLog: * NEWS <Changes in GDB 8.1>: Clarify that "rbreak" is a new Python function, rather than a new command.
2018-02-08x86: Set need_global_offset_table with info->output_bfd->xvecH.J. Lu3-14/+19
* elf32-i386.c (elf32_i386_copy_solaris_special_section_fields): Remove prototype. (i386_elf32_sol2_vec): Declared. (elf_i386_link_setup_gnu_properties): Set need_global_offset_table with info->output_bfd->xvec. * elf64-x86-64.c (elf64_x86_64_copy_solaris_special_section_fields): Remove prototype. (x86_64_elf64_sol2_vec): Declared. (elf_x86_64_link_setup_gnu_properties): Set need_global_offset_table with info->output_bfd->xvec.
2018-02-09Automatic date update in version.inGDB Administrator1-1/+1
2018-02-08x86: Keep the unused _GLOBAL_OFFSET_TABLE_ for SolarisH.J. Lu5-1/+45
Solaris requires to keep _GLOBAL_OFFSET_TABLE_ even if it isn't used. This patch detects Solaris target and keeps _GLOBAL_OFFSET_TABLE_ for Solaris. * elf32-i386.c (elf32_i386_copy_solaris_special_section_fields): New prototype. (elf_i386_link_setup_gnu_properties): Set need_global_offset_table for Solaris. * elf64-x86-64.c (elf64_x86_64_copy_solaris_special_section_fields): New prototype. (elf_x86_64_link_setup_gnu_properties): Set need_global_offset_table for Solaris. * elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Keep the unused _GLOBAL_OFFSET_TABLE_ for Solaris. (_bfd_x86_elf_link_setup_gnu_properties): Copy need_global_offset_table. * elfxx-x86.h (elf_x86_link_hash_table): Add need_global_offset_table. (elf_x86_init_table): Likewise.
2018-02-08RISC-V: Add comment for previous change.Jim Wilson2-0/+7
bfd/ * elfnn-riscv.c (riscv_elf_relocate_section): Add comment for previous change.
2018-02-08Remove cleanups from solib.cTom Tromey2-8/+11
This removes a couple of cleanups from solib.c, replacing one with std::string and another with unique_xmalloc_ptr. 2018-02-08 Tom Tromey <tom@tromey.com> * solib.c (solib_find_1): Use std::string. (solib_bfd_fopen): Use unique_xmalloc_ptr.
2018-02-08Use unique_xmalloc_ptr in build_id_to_debug_bfdTom Tromey2-6/+7
This changes build_id_to_debug_bfd to use a unique_xmalloc_ptr, removing a cleanup. 2018-02-08 Tom Tromey <tom@tromey.com> * build-id.c (build_id_to_debug_bfd): Use unique_xmalloc_ptr.
2018-02-08Use gdb::def_vector in find_source_linesTom Tromey2-12/+12
This replaces an explicit malloc and a cleanup with a gdb::def_vector. 2018-02-08 Tom Tromey <tom@tromey.com> * source.c (find_source_lines): Use gdb::def_vector.
2018-02-08Remove cleanups from macro_define_commandTom Tromey2-21/+28
This removes cleanups from macro_define_command, by introducing a new struct temporary_macro_definition that cleans up after itself. 2018-02-08 Tom Tromey <tom@tromey.com> * macrocmd.c (struct temporary_macro_definition): New. (macro_define_command): Use temporary_macro_definition. Remove cleanups. (free_macro_definition_ptr): Remove.
2018-02-08Use std::string in maybe_expandTom Tromey2-14/+10
This patch changes maybe_expand to use std::string rather than an explicit malloc and a cleanup. 2018-02-08 Tom Tromey <tom@tromey.com> * macroexp.c (maybe_expand): Use std::string.
2018-02-08Class-ify macro_bufferTom Tromey2-240/+185
This patch changes macro_buffer to be a bit more of a C++ class, adding constructors, a destructor, and some members. Then this is used to remove various cleanups in macroexp.c. 2018-02-08 Tom Tromey <tom@tromey.com> * macroexp.c (struct macro_buffer): Add initializers for some members. (init_buffer, init_shared_buffer, free_buffer) (free_buffer_return_text): Remove. (macro_buffer): New constructors. (~macro_buffer): New destructor. (macro_buffer::set_shared): New method. (macro_buffer::resize_buffer, macro_buffer::appendc) (macro_buffer::appendmem): Now methods, not free functions. (set_token, append_tokens_without_splicing, stringify) (macro_stringify): Update. (gather_arguments): Change return type. Remove argc_p argument, add args_ptr argument. Use std::vector. (substitute_args): Remove argc argument. Accept std::vector. (expand): Update. Use std::vector. (scan, macro_expand, macro_expand_next): Update.
2018-02-08Return unique_xmalloc_ptr from macro scope functionsTom Tromey9-75/+65
This changes the macro scope functions (sal_macro_scope, user_macro_scope, and default_macro_scope) to return a unique_xmalloc_ptr, then fixes up the users. This allowed for the removal of several cleanups. 2018-02-08 Tom Tromey <tom@tromey.com> * symtab.c (default_collect_symbol_completion_matches_break_on): Use unique_xmalloc_ptr. * macroscope.h: (sal_macro_scope, user_macro_scope) (default_macro_scope): Return unique_xmalloc_ptr. * macroscope.c (sal_macro_scope, user_macro_scope) (default_macro_scope): Return unique_xmalloc_ptr. * macroexp.h (macro_expand, macro_expand_once): Return unique_xmalloc_ptr. * macroexp.c (macro_expand, macro_expand_once): Return unique_xmalloc_ptr. * macrocmd.c (macro_expand_command, macro_expand_once_command) (info_macro_command, info_macros_command): Use unique_xmalloc_ptr. * compile/compile-c-support.c (write_macro_definitions): Use unique_xmalloc_ptr. * c-exp.y (c_parse): Use unique_xmalloc_ptr.
2018-02-08Remove make_cleanup_restore_current_thread from gdbserverTom Tromey4-18/+12
This removes make_cleanup_restore_current_thread from gdbserver, replacing it with a use of scoped_restore. 2018-02-08 Tom Tromey <tom@tromey.com> * linux-low.c (install_software_single_step_breakpoints): Use make_scoped_restore. * inferiors.c (make_cleanup_restore_current_thread): Remove. (do_restore_current_thread_cleanup): Remove. * gdbthread.h (make_cleanup_restore_current_thread): Don't declare.
2018-02-08Remove a cleanup from gdbserverTom Tromey2-5/+11
This removes a cleanup from gdbserver's set_raw_breakpoint_at, replacing it with unique_xmalloc_ptr. 2018-02-08 Tom Tromey <tom@tromey.com> * mem-break.c (set_raw_breakpoint_at): Use gdb::unique_xmalloc_ptr.
2018-02-08Speed up readelf and objdump by not looking for DWO links unless the user ↵Nick Clifton2-0/+12
has requested that they be displayed/followed. PR 22802 * dwarf.c (load_separate_debug_file): Return early if the user is not interested in debug links.
2018-02-08Fix a seg-fault in the ELF note parser when a note with an excessively large ↵Nick Clifton2-0/+8
alignment is encountered. PR 22788 * elf.c (elf_parse_notes): Reject notes with excessuively large alignments.
2018-02-08PR22819, powerpc gas "instruction address is not a multiple of 4"Alan Modra8-35/+70
Checks for insn alignment were hopelessly confused when misaligned data starts a new frag. The real-world testcase happened to run out of frag space in the middle of emitting a trace-back table via something like: .byte 0 /* VERSION=0 */ .byte 9 /* LANG=C++ */ .byte 34 /* Bits on: has_tboff, fp_present */ .byte 64 /* Bits on: name_present */ .byte 128 /* Bits on: stores_bc, FP_SAVED=0 */ .byte 0 /* Bits on: GP_SAVED=0 */ .byte 2 /* FIXEDPARMS=2 */ .byte 1 /* FLOATPARMS=0, parmsonstk */ .long 0 .long 768 /* tb_offset: 0x300 */ .hword 45 /* Function name length: 45 */ .long 0x334e5a5f .long 0x31766f70 .long 0x65744932 .long 0x69746172 .long 0x7a5f6e6f .long 0x64504533 .long 0x5f534e50 .long 0x72463431 .long 0x61746361 .long 0x74535f6c .long 0x74637572 .byte 0x45 .byte 0 The trigger being those misaligned .long's output for the function name. A most horrible way to output a string, especially considering endian issues.. PR 22819 * config/tc-ppc.c (md_assemble): Rewrite insn alignment checking. (ppc_frag_check): Likewise. * testsuite/gas/ppc/misalign.d, * testsuite/gas/ppc/misalign.l, * testsuite/gas/ppc/misalign.s: New test. * testsuite/gas/ppc/misalign2.d, * testsuite/gas/ppc/misalign2.s: New test. * testsuite/gas/ppc/ppc.exp: Run them.
2018-02-08Automatic date update in version.inGDB Administrator1-1/+1
2018-02-07Fix type of values representing optimized out static membersSimon Marchi4-5/+15
As reported here: https://sourceware.org/ml/gdb/2018-02/msg00019.html the type of values representing static members that are optimized out is wrong. It currently assigns the type of the containing class rather than the type of the field. This patch fixes that. I found a place in m-static.exp already dealing with optimized out static members, so I just added some gdb_test there. gdb/ChangeLog: * value.c (value_static_field): Assign field type instead of containing type when returning an optimized out value. gdb/testsuite/ChangeLog: * gdb.cp/m-static.exp: Check type of optimized out static member.
2018-02-07Revert "PowerPC PLT speculative execution barriers"Alan Modra16-202/+72
This reverts most of commit 1be5d8d3bb. Left in place are addition of --no-plt-align to some ppc32 ld tests and the ld.texinfo --no-plt-thread-safe fix.
2018-02-06RISC-V: Eliminate spurious error w/ reloc truncated messageJim Wilson2-0/+6
bfd/ * elfnn-riscv.c (riscv_elf_relocate_section): Return TRUE if used callback to report an error.
2018-02-07Automatic date update in version.inGDB Administrator1-1/+1
2018-02-06Remove some $ARCH_read_pc and $ARCH_write_pcYao Qi7-85/+18
Nowadays, gdbarch_read_pc is called in this way, if (gdbarch_read_pc_p (gdbarch)) pc_val = gdbarch_read_pc (gdbarch, regcache); /* Else use per-frame method on get_current_frame. */ else if (gdbarch_pc_regnum (gdbarch) >= 0) { ULONGEST raw_val; if (regcache_cooked_read_unsigned (regcache, gdbarch_pc_regnum (gdbarch), &raw_val) == REG_UNAVAILABLE) some ports don't have to define its own gdbarch read_pc method if the pc value is simply a unsigned value from "pc" register. The same rule applies to regcache_write_pc. This patch removes these $ARCH_read_pc and $ARCH_write_pc functions. gdb: 2018-02-06 Yao Qi <yao.qi@linaro.org> * ft32-tdep.c (ft32_read_pc): Remove. (ft32_write_pc): Remove. (ft32_gdbarch_init): Update. * m32r-tdep.c (m32r_read_pc): Remove. (m32r_gdbarch_init): Update. * mep-tdep.c (mep_read_pc): Remove. (mep_gdbarch_init): Update. * microblaze-tdep.c (microblaze_write_pc): Remove. (microblaze_gdbarch_init): Update. * mn10300-tdep.c (mn10300_read_pc): Remove. (mn10300_write_pc): Remove. (mn10300_gdbarch_init): Update. * moxie-tdep.c (moxie_read_pc): Remove. (moxie_write_pc): Remove. (moxie_gdbarch_init): Update.
2018-02-06Fix PR ld/22263 on SPARC.Eric Botcazou10-183/+376
This is -fpie -pie generating dynamic relocations in the text section, simply because no TLS transitions are applied in PIE mode. The meat of the patch is to turn calls to bfd_link_pic (info) in TLS-related code into !bfd_link_executable (info) and there are quite a lot of them... bfd/ * elfxx-sparc.c (sparc_elf_tls_transition): Turn call to bfd_link_pic into call to !bfd_link_executable and tidy up. (_bfd_sparc_elf_check_relocs): Fix formatting and tidy up. <R_SPARC_TLS_LE_HIX22>: Turn call to bfd_link_pic into call to !bfd_link_executable. <R_SPARC_TLS_IE_HI22>: Likewise. <GOT relocations>: Remove useless code, tidy and merge blocks. <R_SPARC_TLS_GD_CALL>: Turn call to bfd_link_pic into call to !bfd_link_executable. <R_SPARC_WPLT30>: Tidy up. (_bfd_sparc_elf_gc_mark_hook): Turn call to bfd_link_pic into call to !bfd_link_executable. (allocate_dynrelocs): Likewise. (_bfd_sparc_elf_relocate_section): Fix formatting and tidy up. <R_SPARC_TLS_GD_HI22>: Merge into... <R_SPARC_TLS_GD_LO10>: ...this. Adjust 4th argument in call to sparc_elf_tls_transition and remove redundant code. <R_SPARC_TLS_LDM_HI22>: Turn call to bfd_link_pic into call to !bfd_link_executable. <R_SPARC_TLS_LDO_HIX22>: Likewise. <R_SPARC_TLS_LE_HIX22>: Likewise. Tidy up. <R_SPARC_TLS_LDM_CALL>: Likewise. <R_SPARC_TLS_GD_CALL>: Likewise. Tidy up. <R_SPARC_TLS_GD_ADD>: Likewise. <R_SPARC_TLS_LDM_ADD>: Likewise. <R_SPARC_TLS_LDO_ADD>: Likewise. <R_SPARC_TLS_IE_LD>: Likewise. ld/ * testsuite/ld-elf/tls.exp (AFLAGS_PIC): Define on SPARC. (pr22263-1): Pass AFLAGS_PIC to the assembler. * testsuite/ld-sparc/tlspie32.s: Add test for other 3 transitions. * testsuite/ld-sparc/tlspie32.dd: Adjust to above. * testsuite/ld-sparc/tlspie64.s: Add test for other 3 transitions. * testsuite/ld-sparc/tlspie64.dd: Adjust to above.
2018-02-06Treat OP_F77_UNDETERMINED_ARGLIST as OP_FUNCALLYao Qi2-1/+8
When I debug some fortran expression parsing, I got (gdb) set debug expression 1 (gdb) p intvla(5,5,5) Dump of expression @ 0x205fa80, before conversion to prefix form: Language fortran, 19 elements, 16 bytes each. Index Opcode Hex Value String Value 0 OP_VAR_VALUE 40 (............... 1 <unknown 31863232> 31863232 .1.............. .... 14 BINOP_REM 5 ................ 15 OP_LONG 38 &............... 16 OP_F77_UNDETERMINED_ARGLIST 48 0............... 17 BINOP_MUL 3 ................ 18 OP_F77_UNDETERMINED_ARGLIST 48 0............... Dump of expression @ 0x205fa80, after conversion to prefix form: Expression: `Invalid expression ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This patch fixes this problem by handling OP_F77_UNDETERMINED_ARGLIST in the same way as handling OP_FUNCALL. With this patch applied, the output looks better, (gdb) p intvla (5,5,5) Dump of expression @ 0x2d75590, before conversion to prefix form: Language fortran, 19 elements, 16 bytes each. Index Opcode Hex Value String Value 0 OP_VAR_VALUE 40 (............... .... 16 OP_F77_UNDETERMINED_ARGLIST 48 0............... 17 BINOP_MUL 3 ................ 18 OP_F77_UNDETERMINED_ARGLIST 48 0............... Dump of expression @ 0x2d75590, after conversion to prefix form: Expression: `vla_primitives::intvla (5, 5, 5)' Language fortran, 19 elements, 16 bytes each. 0 OP_F77_UNDETERMINED_ARGLIST Number of args: 3 3 OP_VAR_VALUE Block @0x297e1c0, symbol @0x297cd50 (intvla) 7 OP_LONG Type @0x2976900 (int), value 5 (0x5) 11 OP_LONG Type @0x2976900 (int), value 5 (0x5) 15 OP_LONG Type @0x2976900 (int), value 5 (0x5) gdb: 2018-02-06 Yao Qi <yao.qi@linaro.org> * expprint.c (print_subexp_standard): Handle OP_F77_UNDETERMINED_ARGLIST. (dump_subexp_body_standard): Likewise.
2018-02-06Fix up one ChangeLog entry dateYao Qi1-2/+3
The patch was committed on 5th Feb, and the first line of ChangeLog entry is too long. The max line length is 74. https://sourceware.org/gdb/wiki/ContributionChecklist#Properly_Formatted_GNU_ChangeLog
2018-02-06Improve the find_nearest_line function for the MIPS target so that it tries ↵Nick Clifton2-6/+29
harder to find a function name. PR 22789 * elfxx-mips.c (_bfd_mips_elf_find_nearest_line): If the dwarf functions failed to find the function name, try the generic elf find function instead.
2018-02-06Fix GCC 8's -Wstringop-overflow on bfd/coff-rs6000.cSergio Durigan Junior2-1/+6
GCC 8 will bring a new warning option which will detect possible overflow and truncation on string manipulation functions. For more details, see: https://gcc.gnu.org/ml/gcc-patches/2017-08/msg00471.html While compiling BFD with it, I can see one place on bfd/coff-rs6000.c where the warning is triggered. This: (void) strncpy (fhdr.magic, XCOFFARMAG, SXCOFFARMAG); will not include the trailing NUL on fhdr.magic, but that's fine because it's a magic number. The fix is trivial: just use memcpy instead. OK to push? 2018-02-06 Sergio Durigan Junior <sergiodj@redhat.com> * coff-rs6000.c (xcoff_write_archive_contents_old): Use 'memcpy' instead of 'strncpy' when writing the magic number.
2018-02-06Replace reachable assertion with a test and return of NULL.Nick Clifton2-1/+21
PR 22793 * readelf.c (find_section): Replace assertion with test and return of NULL. (find_section_by_address): Add test of section header table existance. (find_section_by_type): Likewise. (find_section_in_set): Likewise.
2018-02-06Prevent attempts to call strncpy with a zero-length field by chacking the ↵Nick Clifton2-5/+24
size of debuglink sections. PR 22794 * opncls.c (bfd_get_debug_link_info_1): Check the size of the section before attempting to read it in. (bfd_get_alt_debug_link_info): Likewise.
2018-02-06Allow the find_abstract_instance_name() function in the BFD library to also ↵Paul Carroll2-10/+27
return file and line number information. The nm utility supports -l for using debug information to obtain file and line information for each symbol, if available. We have a tool that consumes this information and displays it. This identified a problem with the 'nm' utility. When a source is compiled with -O2, functions can be inlined. The compiler also produces an uninlined copy of the function, normally for linking to other object files. In the case of DWARF2 debug information, the compiler generates debug information to describe a function. If that function is inlined, the compiler then references that debug information from the inlined and uninlined copies of the routine through the use of the DW_AT_abstract_origin reference. When nm is used on such a file, it is not able to find file and line information because that information is present in the common debug information and not at each actual implementation of the function. The 'nm' utility only retrieves the name of the function from the abstract origin debug information and no more. What I am proposing is to modify the find_abstract_instance_name() function (which I renamed to find_abstract_instance() ) to return the name of the function as well as any file and line information. The routine is already parsing all of the debug information in the abstract instance, so it is easy to pick up the file and line information at that time. If, for some reason, the file and line information is not present, the routine behaves as before. For example, if I have a simple test case: int foo(int j) { if (j < 15) j += j << 2; else j += j << 6; return j; } int main (int argc,char **argv) { int i = argc; i += foo(i); return i; } If that test case is compiled with -O2 and then 'nm -l' reads that executable, it currently produces this symbol output (ignoring a lot of library symbols): 8048400 T foo 080482e0 T main /scratch/pcarroll/its254/test/mytest.c:12 If I modify 'nm' to return file and line information for abstract instances, it produces the following output: 08048400 T foo /scratch/pcarroll/its254/test/mytest.c:1 080482e0 T main /scratch/pcarroll/its254/test/mytest.c:12 -------------------------------------------------------------------------- bfd * bfd/dwarf2.c (find_abstract_name): Modified to return file and line information in addition to name, if they can be found.
2018-02-06Automatic date update in version.inGDB Administrator1-1/+1
2018-02-05ppc64: Fix stwux encodingJan Kratochvil1-1/+1
With gcc-8.0.1-0.9.fc28.x86_64 I get: ../../gdb/rs6000-tdep.c: In function 'CORE_ADDR skip_prologue(gdbarch*, CORE_ADDR, CORE_ADDR, rs6000_framedata*)': ../../gdb/rs6000-tdep.c:1911:34: error: bitwise comparison always evaluates to false [-Werror=tautological-compare] else if ((op & 0xfc1f016a) == 0x7c01016e) ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~ https://www.ibm.com/support/knowledgecenter/en/ssw_aix_72/com.ibm.aix.alangref/idalangref_stwux_stux_instrs.htm says bit 21 - 30 = 183 Those are bits 1..10 in normal bit order: 183<<1 = 0x16e gdb/ChangeLog 2018-02-04 Jan Kratochvil <jan.kratochvil@redhat.com> * rs6000-tdep.c (skip_prologue): Fix stwux encoding.
2018-02-05[PR22764][LD][AARCH64]Allow R_AARCH64_ABS16 and R_AARCH64_ABS32 against ↵Renlin Li8-5/+56
absolution symbol or undefine symbol in shared object. The assumption that R_AARCH64_ABS16 and R_AARCH64_ABS32 relocation in LP64 abi will be used to generate an address does not hold for absolute symbol. In this case, it is a value fixed at static linking time. The condition to check the relocations is relax to allow absolute symbol and undefined symbol case. bfd/ 2018-02-05 Renlin Li <renlin.li@arm.com> PR ld/22764 * elfnn-aarch64.c (elfNN_aarch64_check_relocs): Relax the R_AARCH64_ABS32 and R_AARCH64_ABS16 for absolute symbol. Apply the check for writeable section as well. ld/ 2018-02-05 Renlin Li <renlin.li@arm.com> PR ld/22764 * testsuite/ld-aarch64/emit-relocs-258.s: Define symbol as an address. * testsuite/ld-aarch64/emit-relocs-259.s: Likewise. * testsuite/ld-aarch64/aarch64-elf.exp: Run new test. * testsuite/ld-aarch64/pr22764.s: New. * testsuite/ld-aarch64/pr22764.d: New.
2018-02-05Remove myself as a write-after-approval GDB maintainer.Antoine Tremblay1-1/+0
Since I'll be leaving Ericsson. gdb/ * MAINTAINERS (Write After Approval): Remove Antoine Tremblay.
2018-02-05x86: Remove the unused _GLOBAL_OFFSET_TABLE_H.J. Lu21-242/+372
Since _GLOBAL_OFFSET_TABLE_ may be referenced implicitly on x86, checking ref_regular_nonweak leaves the unused _GLOBAL_OFFSET_TABLE_ in output. This patch checks explicit GOT references instead. ld-i386/discarded1.s and ld-x86-64/discarded1.s are updated to avoid linker optimization which removes GOT references. bfd/ PR ld/22782 * elf32-i386.c (elf_i386_check_relocs): Set got_referenced if _GLOBAL_OFFSET_TABLE_ is referenced or GOT is needed to resolve undefined weak symbol to 0. * elf64-x86-64.c (elf_x86_64_check_relocs): Set got_referenced if _GLOBAL_OFFSET_TABLE_ is referenced. * elfxx-x86.c (_bfd_x86_elf_size_dynamic_sections): Check got_referenced instead of ref_regular_nonweak. Remove the unused _GLOBAL_OFFSET_TABLE_ from symbol table. * elfxx-x86.h (elf_x86_link_hash_table): Add got_referenced. ld/ PR ld/22782 * testsuite/ld-i386/discarded1.s: Replace mov with div. * testsuite/ld-x86-64/discarded1.s: Likewise. * testsuite/ld-i386/i386.exp: Run pr22782. * testsuite/ld-i386/load1-nacl.d: Updated for removing _GLOBAL_OFFSET_TABLE_ from output. * testsuite/ld-i386/load1.d: Likewise. * testsuite/ld-x86-64/load1a-nacl.d: Likewise. * testsuite/ld-x86-64/load1a.d: Likewise. * testsuite/ld-x86-64/load1b-nacl.d: Likewise. * testsuite/ld-x86-64/load1b.d: Likewise. * testsuite/ld-i386/pr22782.d: New file. * testsuite/ld-i386/pr22782.s: Likewise. * testsuite/ld-x86-64/pr22782.s: Likewise. * testsuite/ld-x86-64/pr22782a.d: Likewise. * testsuite/ld-x86-64/pr22782b.d: Likewise. * testsuite/ld-x86-64/x86-64.exp: Run pr22782a and pr22782b.
2018-02-05Use visitors for make_gdb_typeAlan Hayward2-224/+272
Remove the make_gdb_type functions from the tdesc_type_ classes. Replace with a static make_gdb_type function that uses a element visitor called gdb_type_creator. gdb/ * target-descriptions.c (tdesc_element_visitor) Add empty implementations. (tdesc_type): Move make_gdb_type from here. (tdesc_type_builtin): Likewise. (tdesc_type_vector): Likewise. (tdesc_type_with_fields): Move make_gdb_type_ functions from here. (make_gdb_type_struct): Move from tdesc_type_with_fields. (make_gdb_type_union): Likewise. (make_gdb_type_flags): Likewise. (make_gdb_type_enum): Likewise. (make_gdb_type): New function. (tdesc_register_type): Use static make_gdb_type.