# This shell script emits a C file. -*- C -*-
-# Copyright 2003, 2005, 2007 Free Software Foundation, Inc.
+# Copyright 2003, 2005, 2007, 2008, 2009 Free Software Foundation, Inc.
#
# This file is part of the GNU Binutils.
#
#include "libbfd.h"
#include "elf32-ppc.h"
-extern const bfd_target bfd_elf32_powerpc_vec;
-extern const bfd_target bfd_elf32_powerpcle_vec;
-extern const bfd_target bfd_elf32_powerpc_vxworks_vec;
-
-static inline int
-is_ppc_elf32_vec(const bfd_target * vec)
-{
- return (vec == &bfd_elf32_powerpc_vec
- || vec == &bfd_elf32_powerpc_vxworks_vec
- || vec == &bfd_elf32_powerpcle_vec);
-}
+#define is_ppc_elf(bfd) \
+ (bfd_get_flavour (bfd) == bfd_target_elf_flavour \
+ && elf_object_id (bfd) == PPC32_ELF_TDATA)
/* Whether to run tls optimization. */
static int notlsopt = 0;
+static int no_tls_get_addr_opt = 0;
/* Whether to emit symbols for stubs. */
-static int emit_stub_syms = 0;
+static int emit_stub_syms = -1;
/* Chooses the correct place for .plt and .got. */
static enum ppc_elf_plt_type plt_style = PLT_UNSET;
static void
ppc_after_open (void)
{
- if (is_ppc_elf32_vec (link_info.hash->creator))
+ if (is_ppc_elf (link_info.output_bfd))
{
int new_plt;
int keep_new;
lang_output_section_statement_type *plt_os[2];
lang_output_section_statement_type *got_os[2];
- emit_stub_syms |= link_info.emitrelocations;
- new_plt = ppc_elf_select_plt_layout (output_bfd, &link_info, plt_style,
- emit_stub_syms);
+ if (emit_stub_syms < 0)
+ emit_stub_syms = link_info.emitrelocations || link_info.shared;
+ new_plt = ppc_elf_select_plt_layout (link_info.output_bfd, &link_info,
+ plt_style, emit_stub_syms);
if (new_plt < 0)
einfo ("%X%P: select_plt_layout problem %E\n");
static void
ppc_before_allocation (void)
{
- if (is_ppc_elf32_vec (link_info.hash->creator))
+ if (is_ppc_elf (link_info.output_bfd))
{
- if (ppc_elf_tls_setup (output_bfd, &link_info) && !notlsopt)
+ if (ppc_elf_tls_setup (link_info.output_bfd, &link_info,
+ no_tls_get_addr_opt)
+ && !notlsopt)
{
- if (!ppc_elf_tls_optimize (output_bfd, &link_info))
+ if (!ppc_elf_tls_optimize (link_info.output_bfd, &link_info))
{
einfo ("%X%P: TLS problem %E\n");
return;
}
}
}
+
gld${EMULATION_NAME}_before_allocation ();
+
+ /* Turn on relaxation if executable sections have addresses that
+ might make branches overflow. */
+ if (!command_line.relax)
+ {
+ bfd_vma low = (bfd_vma) -1;
+ bfd_vma high = 0;
+ asection *o;
+
+ /* Run lang_size_sections (if not already done). */
+ if (expld.phase != lang_mark_phase_enum)
+ {
+ expld.phase = lang_mark_phase_enum;
+ expld.dataseg.phase = exp_dataseg_none;
+ one_lang_size_sections_pass (NULL, FALSE);
+ lang_reset_memory_regions ();
+ }
+
+ for (o = link_info.output_bfd->sections; o != NULL; o = o->next)
+ {
+ if ((o->flags & (SEC_ALLOC | SEC_CODE)) != (SEC_ALLOC | SEC_CODE))
+ continue;
+ if (o->rawsize == 0)
+ continue;
+ if (low > o->vma)
+ low = o->vma;
+ if (high < o->vma + o->rawsize - 1)
+ high = o->vma + o->rawsize - 1;
+ }
+ if (high > low && high - low > (1 << 25) - 1)
+ command_line.relax = TRUE;
+ }
}
EOF
#
PARSE_AND_LIST_PROLOGUE='
#define OPTION_NO_TLS_OPT 301
-#define OPTION_NEW_PLT 302
-#define OPTION_OLD_PLT 303
-#define OPTION_OLD_GOT 304
-#define OPTION_STUBSYMS 305
+#define OPTION_NO_TLS_GET_ADDR_OPT (OPTION_NO_TLS_OPT + 1)
+#define OPTION_NEW_PLT (OPTION_NO_TLS_GET_ADDR_OPT + 1)
+#define OPTION_OLD_PLT (OPTION_NEW_PLT + 1)
+#define OPTION_OLD_GOT (OPTION_OLD_PLT + 1)
+#define OPTION_STUBSYMS (OPTION_OLD_GOT + 1)
+#define OPTION_NO_STUBSYMS (OPTION_STUBSYMS + 1)
'
PARSE_AND_LIST_LONGOPTS='
{ "emit-stub-syms", no_argument, NULL, OPTION_STUBSYMS },
+ { "no-emit-stub-syms", no_argument, NULL, OPTION_NO_STUBSYMS },
{ "no-tls-optimize", no_argument, NULL, OPTION_NO_TLS_OPT },
+ { "no-tls-get-addr-optimize", no_argument, NULL, OPTION_NO_TLS_GET_ADDR_OPT },
{ "secure-plt", no_argument, NULL, OPTION_NEW_PLT },
{ "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\
- --secure-plt Use new-style PLT if possible.\n\
- --bss-plt Force old-style BSS PLT.\n\
- --sdata-got Force GOT location just before .sdata.\n"
+ --emit-stub-syms Label linker stubs with a symbol.\n\
+ --no-emit-stub-syms Don'\''t label linker stubs with a symbol.\n\
+ --no-tls-optimize Don'\''t try to optimize TLS accesses.\n\
+ --no-tls-get-addr-optimize Don'\''t use a special __tls_get_addr call.\n\
+ --secure-plt Use new-style PLT if possible.\n\
+ --bss-plt Force old-style BSS PLT.\n\
+ --sdata-got Force GOT location just before .sdata.\n"
));
'
emit_stub_syms = 1;
break;
+ case OPTION_NO_STUBSYMS:
+ emit_stub_syms = 0;
+ break;
+
case OPTION_NO_TLS_OPT:
notlsopt = 1;
break;
+ case OPTION_NO_TLS_GET_ADDR_OPT:
+ no_tls_get_addr_opt = 1;
+ break;
+
case OPTION_NEW_PLT:
plt_style = PLT_NEW;
break;