unsigned int new_plt:1;
unsigned int old_plt:1;
+ /* Set if we should emit symbols for stubs. */
+ unsigned int emit_stub_syms:1;
+
/* Small local sym to section mapping cache. */
struct sym_sec_cache sym_sec;
int
ppc_elf_select_plt_layout (bfd *output_bfd ATTRIBUTE_UNUSED,
struct bfd_link_info *info,
- int force_old_plt)
+ int force_old_plt,
+ int emit_stub_syms)
{
struct ppc_elf_link_hash_table *htab;
flagword flags;
if (force_old_plt || !htab->new_plt)
htab->old_plt = 1;
+ htab->emit_stub_syms = emit_stub_syms;
+
if (htab->is_vxworks)
{
/* The VxWorks PLT is a loaded section with contents. */
return TRUE;
}
\f
+/* Generate a symbol to mark plt call stubs, of the form
+ xxxxxxxx_plt_call_<callee> where xxxxxxxx is a hex number, usually 0,
+ specifying the addend on the plt relocation, or for -fPIC,
+ xxxxxxxx.got2_plt_call_<callee>. */
+
+static bfd_boolean
+add_stub_sym (struct plt_entry *ent,
+ struct elf_link_hash_entry *h,
+ struct ppc_elf_link_hash_table *htab)
+{
+ struct elf_link_hash_entry *sh;
+ size_t len1, len2, len3;
+ char *name;
+
+ len1 = strlen (h->root.root.string);
+ len2 = sizeof ("plt_call_") - 1;
+ len3 = 0;
+ if (ent->sec)
+ len3 = strlen (ent->sec->name);
+ name = bfd_malloc (len1 + len2 + len3 + 10);
+ if (name == NULL)
+ return FALSE;
+ sprintf (name, "%08x", (unsigned) ent->addend & 0xffffffff);
+ if (ent->sec)
+ memcpy (name + 8, ent->sec->name, len3);
+ name[len3 + 8] = '_';
+ memcpy (name + len3 + 9, "plt_call_", len2);
+ memcpy (name + len3 + 9 + len2, h->root.root.string, len1 + 1);
+ sh = elf_link_hash_lookup (&htab->elf, name, TRUE, FALSE, FALSE);
+ if (sh == NULL)
+ return FALSE;
+ if (sh->root.type == bfd_link_hash_new)
+ {
+ sh->root.type = bfd_link_hash_defined;
+ sh->root.u.def.section = htab->glink;
+ sh->root.u.def.value = ent->glink_offset;
+ sh->ref_regular = 1;
+ sh->def_regular = 1;
+ sh->ref_regular_nonweak = 1;
+ sh->forced_local = 1;
+ sh->non_elf = 0;
+ }
+ return TRUE;
+}
+
/* Allocate NEED contiguous space in .got, and return the offset.
Handles allocation of the got header when crossing 32k. */
h->root.u.def.value = glink_offset;
}
ent->glink_offset = glink_offset;
+
+ if (htab->emit_stub_syms
+ && !add_stub_sym (ent, h, htab))
+ return FALSE;
}
else
{
/* Pad out to align the start of PLTresolve. */
htab->glink->size += -htab->glink->size & 15;
htab->glink->size += GLINK_PLTRESOLVE;
+
+ if (htab->emit_stub_syms)
+ {
+ struct elf_link_hash_entry *sh;
+ sh = elf_link_hash_lookup (&htab->elf, "__glink",
+ TRUE, FALSE, FALSE);
+ if (sh == NULL)
+ return FALSE;
+ if (sh->root.type == bfd_link_hash_new)
+ {
+ sh->root.type = bfd_link_hash_defined;
+ sh->root.u.def.section = htab->glink;
+ sh->root.u.def.value = htab->glink_pltresolve;
+ sh->ref_regular = 1;
+ sh->def_regular = 1;
+ sh->ref_regular_nonweak = 1;
+ sh->forced_local = 1;
+ sh->non_elf = 0;
+ }
+ sh = elf_link_hash_lookup (&htab->elf, "__glink_PLTresolve",
+ TRUE, FALSE, FALSE);
+ if (sh == NULL)
+ return FALSE;
+ if (sh->root.type == bfd_link_hash_new)
+ {
+ sh->root.type = bfd_link_hash_defined;
+ sh->root.u.def.section = htab->glink;
+ sh->root.u.def.value = htab->glink->size - GLINK_PLTRESOLVE;
+ sh->ref_regular = 1;
+ sh->def_regular = 1;
+ sh->ref_regular_nonweak = 1;
+ sh->forced_local = 1;
+ sh->non_elf = 0;
+ }
+ }
}
/* We've now determined the sizes of the various dynamic sections.
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA 02110-1301, USA. */
-int ppc_elf_select_plt_layout (bfd *, struct bfd_link_info *, int);
+int ppc_elf_select_plt_layout (bfd *, struct bfd_link_info *, int, int);
asection *ppc_elf_tls_setup (bfd *, struct bfd_link_info *);
bfd_boolean ppc_elf_tls_optimize (bfd *, struct bfd_link_info *);
void ppc_elf_set_sdata_syms (bfd *, struct bfd_link_info *);
/* Whether to run tls optimization. */
static int notlsopt = 0;
+/* Whether to emit symbols for stubs. */
+static int emit_stub_syms = 0;
+
/* Chooses the correct place for .plt and .got. */
static int old_plt = 0;
static int old_got = 0;
lang_output_section_statement_type *plt_os[2];
lang_output_section_statement_type *got_os[2];
- new_plt = ppc_elf_select_plt_layout (output_bfd, &link_info, old_plt);
+ emit_stub_syms |= link_info.emitrelocations;
+ new_plt = ppc_elf_select_plt_layout (output_bfd, &link_info, old_plt,
+ emit_stub_syms);
if (new_plt < 0)
einfo ("%X%P: select_plt_layout problem %E\n");
#define OPTION_NO_TLS_OPT 301
#define OPTION_OLD_PLT 302
#define OPTION_OLD_GOT 303
+#define OPTION_STUBSYMS 304
'
PARSE_AND_LIST_LONGOPTS='
+ { "emit-stub-syms", no_argument, NULL, OPTION_STUBSYMS },
{ "no-tls-optimize", no_argument, NULL, OPTION_NO_TLS_OPT },
{ "bss-plt", no_argument, NULL, OPTION_OLD_PLT },
{ "sdata-got", no_argument, NULL, OPTION_OLD_GOT },
PARSE_AND_LIST_OPTIONS='
fprintf (file, _("\
+ --emit-stub-syms Label linker stubs with a symbol.\n\
--no-tls-optimize Don'\''t try to optimize TLS accesses.\n\
--bss-plt Force old-style BSS PLT.\n\
--sdata-got Force GOT location just before .sdata.\n"
'
PARSE_AND_LIST_ARGS_CASES='
+ case OPTION_STUBSYMS:
+ emit_stub_syms = 1;
+ break;
+
case OPTION_NO_TLS_OPT:
notlsopt = 1;
break;