Commit Graph

19 Commits

Author SHA1 Message Date
Joel Brobecker 42a4f53d2b Update copyright year range in all GDB files.
This commit applies all changes made after running the gdb/copyright.py
script.

Note that one file was flagged by the script, due to an invalid
copyright header
(gdb/unittests/basic_string_view/element_access/char/empty.cc).
As the file was copied from GCC's libstdc++-v3 testsuite, this commit
leaves this file untouched for the time being; a patch to fix the header
was sent to gcc-patches first.

gdb/ChangeLog:

	Update copyright year range in all GDB files.
2019-01-01 10:01:51 +04:00
Tom Tromey 8406672eca Avoid -Wnarrowing warnings in ppc64-tdep.c
This avoids -Wnarrowing warnings in ppc64-tdep.c, by adding a few
casts to unsigned.

gdb/ChangeLog
2018-08-27  Tom Tromey  <tom@tromey.com>

	* ppc64-tdep.c (insn_d, insn_ds, insn_xfx): Add casts to
	unsigned.
	(ppc64_standard_linkage1, ppc64_standard_linkage2)
	(ppc64_standard_linkage3, ppc64_standard_linkage4)
	(ppc64_standard_linkage5, ppc64_standard_linkage6)
	(ppc64_standard_linkage7, ppc64_standard_linkage8): Add casts to
	unsigned.
2018-08-27 12:00:11 -06:00
Alan Modra 7433498b7f PowerPC PLT stub matching
This patch fixes a number of bugs in ppc32 plt stub matching code.
1) The 4-insn stubs for shared libs and PIEs weren't matched.
2) The executable stub miscalculated PLT entry address (by oring a
   sign-extended quantity rather than adding).
3) Comments were not accurate.

In addition, the insn arrays are made const.

	* ppc-linux-tdep.c (powerpc32_plt_stub): Make const.
	(powerpc32_plt_stub_so_1): Rename from powerpc32_plt_stub_so.
	Remove nop.  Make const.  Comment.
	(powerpc32_plt_stub_so_2): New.
	(POWERPC32_PLT_CHECK_LEN): Rename from POWERPC32_PLT_STUB_LEN.
	Correct count.  Update uses.
	(ppc_skip_trampoline_code): Match powerpc32_plt_stub_so_2 too.
	Move common code reading PLT entry word.  Correct
	powerpc32_plt_stub PLT address calculation.
	* ppc64-tdep.c (ppc64_standard_linkage1): Make const.
	(ppc64_standard_linkage2, ppc64_standard_linkage3): Likewise.
	(ppc64_standard_linkage4, ppc64_standard_linkage5): Likewise.
	(ppc64_standard_linkage6, ppc64_standard_linkage7): Likewise.
	(ppc64_standard_linkage8): Likewise.
	* rs6000-tdep.c (ppc_insns_match_pattern): Make pattern const.
	Correct insns description.
	* ppc-tdep.h (ppc_insns_match_pattern): Update prototype.

Reviewed-By: Yao Qi <qiyaoltc@gmail.com>
2018-01-26 16:13:03 +10:30
Joel Brobecker e2882c8578 Update copyright year range in all GDB files
gdb/ChangeLog:

        Update copyright year range in all GDB files
2018-01-02 07:38:06 +04:00
Alan Modra db9077b727 PR22576, ppc64_skip_trampoline_code uses wrong r2 for EXEC_REVERSE
The TOC pointer register, r2, on powerpc64 is generally not mentioned
in debug info.  It is saved and restored by call linkage code, and
set to the callee value either by call stub code (ELFv1) or in the
callee global entry point code (ELFv2).  A call stub uses the caller
TOC pointer to access the PLT.  So for gdb to read the correct PLT
entry in order to determine the destination of the trampoline, gdb
needs to know the caller r2.  When skipping over trampolines in the
normal forward direction, the caller r2 is simply the current value of
r2 (at the start of the trampoline).  However, when reversing over
trampolines the current value of r2 is that for the callee.  Using
that value results in wild reads of memory rather than the correct PLT
entry.

This patch corrects the value of r2 by using the value saved on the
stack for reverse execution.  Note that in reverse execution mode it
isn't really necessary for skip_trampoline_code to return the actual
destination, so we're doing a little more work than needed here.  Any
non-zero return value would do (and it would be nicer if the interface
was changed to return the start of the stub).

	PR tdep/22576
	* ppc64-tdep.c (ppc64_plt_entry_point): Rewrite to take TOC-relative
	PLT offset, and retrieve r2 from stack when executing in reverse.
	(ppc64_standard_linkage1_target): Drop pc param.  Calculate offset
	rather than PLT address.
	(ppc64_standard_linkage2_target): Likewise.
	(ppc64_standard_linkage3_target): Likewise.
	(ppc64_standard_linkage4_target): Likewise.
	(ppc64_skip_trampoline_code_1): Adjust to suit.
2017-12-12 23:23:38 +10:30
Joel Brobecker 61baf725ec update copyright year range in GDB files
This applies the second part of GDB's End of Year Procedure, which
updates the copyright year range in all of GDB's files.

gdb/ChangeLog:

        Update copyright year range in all GDB files.
2017-01-01 10:52:34 +04:00
Joel Brobecker 618f726fcb GDB copyright headers update after running GDB's copyright.py script.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2016-01-01 08:43:22 +04:00
Jan Kratochvil 141c5cc4c4 [ppc64le] Use skip_entrypoint for skip_trampoline_code
ppc64le loses control when stepping between two PLT-called functions inside
a shared library:

29        shlib_second (); /* first-hit */^M
(gdb) PASS: gdb.base/solib-intra-step.exp: first-hit
step^M
^M
Program received signal SIGABRT, Aborted.^M
0x00003fffb7cbe578 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56^M
56        return INLINE_SYSCALL (tgkill, 3, pid, selftid, sig);^M
(gdb) FAIL: gdb.base/solib-intra-step.exp: second-hit
->
29        shlib_second (); /* first-hit */^M
(gdb) PASS: gdb.base/solib-intra-step.exp: first-hit
step^M
shlib_second () at ./gdb.base/solib-intra-step-lib.c:23^M
23        abort (); /* second-hit */^M
(gdb) PASS: gdb.base/solib-intra-step.exp: second-hit

This is because gdbarch_skip_trampoline_code() will resolve the final function
as shlib_second+0 and place there the breakpoint, but ld.so will jump after
the breakpoint - at shlib_second+8 - as it is ELFv2 local symbol optimization:

Dump of assembler code for function shlib_second:
   0x0000000000000804 <+0>:     addis   r2,r12,2
   0x0000000000000808 <+4>:     addi    r2,r2,30668
   0x000000000000080c <+8>:     mflr    r0

Currently gdbarch_skip_entrypoint() has been called in skip_prologue_sal() and
fill_in_stop_func() but that is not enough.  I believe
gdbarch_skip_entrypoint() should be called after every
gdbarch_skip_trampoline_code().

gdb/ChangeLog
2015-09-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* linespec.c (minsym_found): Call gdbarch_skip_entrypoint.
	* ppc64-tdep.c (ppc64_skip_trampoline_code): Rename to ...
	(ppc64_skip_trampoline_code_1): ... here.
	(ppc64_skip_trampoline_code): New wrapper function.
	* symtab.c (find_function_start_sal): Call gdbarch_skip_entrypoint.

gdb/testsuite/ChangeLog
2015-09-15  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* gdb.opt/solib-intra-step-lib.c: New file.
	* gdb.opt/solib-intra-step-main.c: New file.
	* gdb.opt/solib-intra-step.exp: New file.
2015-09-15 19:08:04 +02:00
Wei-cheng Wang ddeca1dffb Add missing comments in rs6000-tdep.c, ppc64-tdep.c and ppc-linux-tdep.c.
gdb/ChangeLog:

	* ppc-linux-tdep.c (ppc_skip_trampoline_code,
	ppc_canonicalize_syscall, ppc_linux_syscall_record,
	ppc_linux_record_signal, ppc_init_linux_record_tdep): Add comments.
	* ppc64-tdep.c (ppc64_skip_trampoline_code): Likewise.
	* rs6000-tdep.c (rs6000_epilogue_frame_cache,
	rs6000_epilogue_frame_this_id, rs6000_epilogue_frame_prev_register,
	rs6000_epilogue_frame_sniffer, ppc_record_vsr, ppc_process_record_op4,
	ppc_process_record_op19, ppc_process_record_op31,
	ppc_process_record_op59, ppc_process_record_op60,
	ppc_process_record_op63): Likewise.
2015-01-21 23:38:09 +08:00
Wei-cheng Wang cf90fd9a07 Skip-trampoline for PowerPC reverse-stepping. 2015-01-17 19:48:22 +08:00
Joel Brobecker 32d0add0a6 Update year range in copyright notice of all files owned by the GDB project.
gdb/ChangeLog:

        Update year range in copyright notice of all files.
2015-01-01 13:32:14 +04:00
Alan Modra 397998fc32 Support fusion for ELFv2 stubs
Power8 fuses addis,addi and addis,ld sequences when the target of the
addis is the same as the addi/ld.  Thus
    addis r12,r2,xxx@ha
    addi r12,r12,xxx@l / ld r12,xxx@l(r12)
is faster than
    addis r11,r2,xxx@ha
    addi r12,r11,xxx@l / ld r12,xxx@l(r11)
So use the form that allows fusion in plt call and branch stubs.

bfd/
	* elf64-ppc.c (ADDIS_R12_R2): Define.
	(build_plt_stub): Support fusion on ELFv2 stub.
	(ppc_build_one_stub): Likewise for plt branch stubs.
gold/
	* powerpc.cc (addis_12_2): Define.
	(Stub_table::do_write): Support fusion on ELFv2 stubs.
ld/testsuite/
	* ld-powerpc/elfv2exe.d: Update for changed plt call stubs.
gdb/
	* ppc64-tdep.c (ppc64_standard_linkage8): New.
	(ppc64_skip_trampoline_code): Recognise ELFv2 stub supporting fusion.
2014-06-03 10:55:29 +09:30
Ulrich Weigand fa0079ea72 Fix typo in ppc64_standard_linkage7
The ppc64_standard_linkage7 pattern added by Alan's recent patch:
https://sourceware.org/ml/gdb-patches/2013-11/msg00274.html
contains a typo: the ELFv2 TOC slot offset is 24, not 40.
This was correct in the comment, but not the actual code.

ChangeLog:

	* ppc64-tdep.c (ppc64_standard_linkage7): Fix typo.
2014-01-28 17:49:13 +01:00
Joel Brobecker ecd75fc8ee Update Copyright year range in all files maintained by GDB. 2014-01-01 07:54:24 +04:00
Alan Modra ef1bc9e72f PowerPC64 ELFv2 trampoline match
ELFv2 needs different plt call stubs to ELFv1, register usage differs
too.  When I added these to ld I changed register usage in the ELFv1
stubs as well, simplifying the linker code and (perhaps) future
maintenance.  All well and good, but this means gdb needs to cope with
more stub variants.  This patch also handles skipping over addis/addi
setting up r2 in ELFv2 global entry code.  We want breakpoints to be
set past this point to catch calls via the local entry point.

	* ppc64-tdep.c (ppc64_plt_entry_point): Renamed from..
	(ppc64_desc_entry_point): ..this.  Update comments here and at
	call points.
	(ppc64_standard_linkage1, ppc64_standard_linkage2,
	ppc64_standard_linkage3): Update comments.
	(ppc64_standard_linkage4, ppc64_standard_linkage5,
	(ppc64_standard_linkage6, ppc64_standard_linkage7): New insn
	patterns.
	(ppc64_standard_linkage4_target): New function.
	(ppc64_skip_trampoline_code): Skip ELFv2 patterns too.
	* rs6000-tdep.c (skip_prologue): Skip ELFv2 r2 setup.  Correct
	nop match.  Fix comment wrap.
2013-11-15 10:32:06 +10:30
Doug Evans 57e6060ea5 * nto-tdep.c (nto_relocate_section_addresses): Update,
target_section.bfd deleted.
	* ppc64-tdep.c (ppc64_convert_from_func_ptr_addr): Ditto.
	* s390-tdep.c (s390_load): Ditto.
	* solib-aix.c (solib_aix_relocate_section_addresses): Ditto.
2013-07-17 05:28:04 +00:00
Alan Modra 845d47080b * ppc-tdep.h (ppc_insns_match_pattern): Update prototype.
* rs6000-tdep.c (read_insn): Add frame param, don't assume big-endian.
	(ppc_insns_match_pattern): Add frame param.  Avoid multiple
	target mem reads on optional insns.
	* ppc-linux-tdep.c (ppc_skip_trampoline_code): Update
	ppc_insns_match_pattern calls.
	* ppc64-tdep.c (ppc64_standard_linkage2, ppc64_standard_linkage3):
	Add match for power7 thread safety insns, and new order of
	std 2,40(1) insn.  Correct code shown for _dl_runtime_resolve
	invocation in comment, and update rest of comment.
	(PPC64_STANDARD_LINKAGE1_LEN, PPC64_STANDARD_LINKAGE2_LEN,
	PPC64_STANDARD_LINKAGE3_LEN): Delete.
	(ppc64_standard_linkage2_target): Update insn offsets.
	(ppc64_skip_trampoline_code): Use a single insn buffer.  Match newer
	stubs first.  Update calls.
2013-06-04 02:44:35 +00:00
Alan Modra 24c274a133 * elfread.c (elf_symtab_read): Do not use udata.p here to find
symbol size.
	* ppc64-tdep.c (ppc64_elf_make_msymbol_special): New function.
	* ppc64-tdep.h (ppc64_elf_make_msymbol_special): Declare.
	* ppc-linux-tdep.c (ppc_linux_init_abi): Set up to use the above.
	* ppcfbsd-tdep.c (ppcfbsd_init_abi): Likewise.
2013-02-22 23:24:24 +00:00
Andreas Tobler 45fe57e7a5 Add missing file from the previous commit. 2013-02-01 20:59:08 +00:00