mirror of
https://github.com/espressif/binutils-gdb.git
synced 2025-06-28 15:18:37 +08:00
PowerPC64: plt_stub_pad
* elf64-ppc.c (plt_stub_pad): Simplify parameters and untangle from plt_stub_size. (ppc_size_one_stub): Call plt_stub_size before plt_stub_pad to provide size. Recalculate size if it might change.
This commit is contained in:
@ -11183,29 +11183,22 @@ plt_stub_size (struct ppc_link_hash_table *htab,
|
|||||||
boundaries if we align, then return the padding needed to do so. */
|
boundaries if we align, then return the padding needed to do so. */
|
||||||
|
|
||||||
static inline unsigned int
|
static inline unsigned int
|
||||||
plt_stub_pad (struct ppc_link_hash_table *htab,
|
plt_stub_pad (int plt_stub_align,
|
||||||
struct ppc_stub_hash_entry *stub_entry,
|
|
||||||
bfd_vma stub_off,
|
bfd_vma stub_off,
|
||||||
bfd_vma plt_off,
|
unsigned int stub_size)
|
||||||
unsigned int odd)
|
|
||||||
{
|
{
|
||||||
int stub_align;
|
unsigned int stub_align;
|
||||||
unsigned stub_size;
|
|
||||||
|
|
||||||
if (htab->params->plt_stub_align >= 0)
|
if (plt_stub_align >= 0)
|
||||||
|
stub_align = 1u << plt_stub_align;
|
||||||
|
else
|
||||||
{
|
{
|
||||||
stub_align = 1 << htab->params->plt_stub_align;
|
stub_align = 1u << -plt_stub_align;
|
||||||
if ((stub_off & (stub_align - 1)) != 0)
|
if (((stub_off + stub_size - 1) & -stub_align) - (stub_off & -stub_align)
|
||||||
return stub_align - (stub_off & (stub_align - 1));
|
<= ((stub_size - 1) & -stub_align))
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
return stub_align - 1 - ((stub_off - 1) & (stub_align - 1));
|
||||||
stub_align = 1 << -htab->params->plt_stub_align;
|
|
||||||
stub_size = plt_stub_size (htab, stub_entry, plt_off, odd);
|
|
||||||
if (((stub_off + stub_size - 1) & -stub_align) - (stub_off & -stub_align)
|
|
||||||
> ((stub_size - 1) & -stub_align))
|
|
||||||
return stub_align - (stub_off & (stub_align - 1));
|
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Build a toc using .plt call stub. */
|
/* Build a toc using .plt call stub. */
|
||||||
@ -12245,7 +12238,7 @@ ppc_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
|
|||||||
struct ppc_link_hash_table *htab;
|
struct ppc_link_hash_table *htab;
|
||||||
asection *plt;
|
asection *plt;
|
||||||
bfd_vma targ, off, r2off;
|
bfd_vma targ, off, r2off;
|
||||||
unsigned int size, extra, lr_used, delta, odd;
|
unsigned int size, pad, extra, lr_used, delta, odd;
|
||||||
bfd_vma stub_offset;
|
bfd_vma stub_offset;
|
||||||
|
|
||||||
/* Massage our args to the form they really have. */
|
/* Massage our args to the form they really have. */
|
||||||
@ -12504,13 +12497,14 @@ ppc_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
|
|||||||
odd = off & 4;
|
odd = off & 4;
|
||||||
off = targ - off;
|
off = targ - off;
|
||||||
|
|
||||||
if (htab->params->plt_stub_align != 0)
|
size = plt_stub_size (htab, stub_entry, off, odd);
|
||||||
|
pad = plt_stub_pad (htab->params->plt_stub_align, stub_offset, size);
|
||||||
|
if (pad != 0)
|
||||||
{
|
{
|
||||||
unsigned pad = plt_stub_pad (htab, stub_entry, stub_offset, off, odd);
|
|
||||||
|
|
||||||
stub_offset += pad;
|
stub_offset += pad;
|
||||||
off -= pad;
|
off -= pad;
|
||||||
odd ^= pad & 4;
|
odd ^= pad & 4;
|
||||||
|
size = plt_stub_size (htab, stub_entry, off, odd);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info->emitrelocations)
|
if (info->emitrelocations)
|
||||||
@ -12524,8 +12518,6 @@ ppc_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
|
|||||||
stub_entry->group->stub_sec->flags |= SEC_RELOC;
|
stub_entry->group->stub_sec->flags |= SEC_RELOC;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = plt_stub_size (htab, stub_entry, off, odd);
|
|
||||||
|
|
||||||
if (stub_entry->type.sub != ppc_stub_notoc)
|
if (stub_entry->type.sub != ppc_stub_notoc)
|
||||||
{
|
{
|
||||||
/* After the bcl, lr has been modified so we need to emit
|
/* After the bcl, lr has been modified so we need to emit
|
||||||
@ -12578,12 +12570,9 @@ ppc_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
|
|||||||
+ htab->sec_info[stub_entry->group->link_sec->id].toc_off);
|
+ htab->sec_info[stub_entry->group->link_sec->id].toc_off);
|
||||||
off = targ - off;
|
off = targ - off;
|
||||||
|
|
||||||
if (htab->params->plt_stub_align != 0)
|
size = plt_stub_size (htab, stub_entry, off, 0);
|
||||||
{
|
pad = plt_stub_pad (htab->params->plt_stub_align, stub_offset, size);
|
||||||
unsigned pad = plt_stub_pad (htab, stub_entry, stub_offset, off, 0);
|
|
||||||
|
|
||||||
stub_offset += pad;
|
stub_offset += pad;
|
||||||
}
|
|
||||||
|
|
||||||
if (info->emitrelocations)
|
if (info->emitrelocations)
|
||||||
{
|
{
|
||||||
@ -12596,8 +12585,6 @@ ppc_size_one_stub (struct bfd_hash_entry *gen_entry, void *in_arg)
|
|||||||
stub_entry->group->stub_sec->flags |= SEC_RELOC;
|
stub_entry->group->stub_sec->flags |= SEC_RELOC;
|
||||||
}
|
}
|
||||||
|
|
||||||
size = plt_stub_size (htab, stub_entry, off, 0);
|
|
||||||
|
|
||||||
if (stub_entry->h != NULL
|
if (stub_entry->h != NULL
|
||||||
&& is_tls_get_addr (&stub_entry->h->elf, htab)
|
&& is_tls_get_addr (&stub_entry->h->elf, htab)
|
||||||
&& htab->params->tls_get_addr_opt
|
&& htab->params->tls_get_addr_opt
|
||||||
|
Reference in New Issue
Block a user