This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: PowerPC PLT stub matching


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 (齐尧)


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]