This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: PowerPC PLT stub matching
- From: Yao Qi <qiyaoltc at gmail dot com>
- To: Alan Modra <amodra at gmail dot com>
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 24 Jan 2018 16:06:02 +0000
- Subject: Re: PowerPC PLT stub matching
- Authentication-results: sourceware.org; auth=none
- References: <20180124062015.GN20622@bubble.grove.modra.org>
Alan Modra <amodra@gmail.com> writes:
Hi Alan,
Thanks for the clean up, patch is good to me. Please push.
A general question below,
> -/* PLT stub in executable. */
> -static struct ppc_insn_pattern powerpc32_plt_stub[] =
> +/* PLT stub in an executable. */
> +static const struct ppc_insn_pattern powerpc32_plt_stub[] =
> {
> { 0xffff0000, 0x3d600000, 0 }, /* lis r11, xxxx */
> { 0xffff0000, 0x816b0000, 0 }, /* lwz r11, xxxx(r11) */
> @@ -266,16 +266,30 @@ static struct ppc_insn_pattern powerpc32_plt_stub[] =
> { 0, 0, 0 }
> };
>
> -/* PLT stub in shared library. */
> -static struct ppc_insn_pattern powerpc32_plt_stub_so[] =
> +/* PLT stubs in a shared library or PIE.
> + The first variant is used when the PLT entry is within +/-32k of
> + the GOT pointer (r30). */
> +static const struct ppc_insn_pattern powerpc32_plt_stub_so_1[] =
> {
> { 0xffff0000, 0x817e0000, 0 }, /* lwz r11, xxxx(r30) */
> { 0xffffffff, 0x7d6903a6, 0 }, /* mtctr r11 */
> { 0xffffffff, 0x4e800420, 0 }, /* bctr */
> - { 0xffffffff, 0x60000000, 0 }, /* nop */
> { 0, 0, 0 }
> };
> -#define POWERPC32_PLT_STUB_LEN ARRAY_SIZE (powerpc32_plt_stub)
> +
> +/* The second variant is used when the PLT entry is more than +/-32k
> + from the GOT pointer (r30). */
> +static const struct ppc_insn_pattern powerpc32_plt_stub_so_2[] =
> + {
> + { 0xffff0000, 0x3d7e0000, 0 }, /* addis r11, r30, xxxx */
> + { 0xffff0000, 0x816b0000, 0 }, /* lwz r11, xxxx(r11) */
> + { 0xffffffff, 0x7d6903a6, 0 }, /* mtctr r11 */
> + { 0xffffffff, 0x4e800420, 0 }, /* bctr */
> + { 0, 0, 0 }
> + };
These instruction sequences reflect what
bfd/elf32-ppc.c:write_glink_stub does, IIUC. Is there any way we can
correlate these two sides, PLT stub generation and matching? Ideally, I
want to such sequences are defined once, but shared by linker and debugger.
--
Yao (齐尧)