X-Git-Url: https://oss.titaniummirror.com/gitweb?p=msp430-binutils.git;a=blobdiff_plain;f=ld%2Femultempl%2Fppc32elf.em;fp=ld%2Femultempl%2Fppc32elf.em;h=3befe75091a325f17e51665e135189eb48243a10;hp=0b8d887563618f3699145e36bbd937721b47e58d;hb=d5da4f291af551c0b8b79e1d4a9b173d60e5c10e;hpb=7b5ea4fcdf2819e070665ab5610f8b48e3867c10 diff --git a/ld/emultempl/ppc32elf.em b/ld/emultempl/ppc32elf.em index 0b8d887..3befe75 100644 --- a/ld/emultempl/ppc32elf.em +++ b/ld/emultempl/ppc32elf.em @@ -1,5 +1,5 @@ # 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. # @@ -27,23 +27,16 @@ fragment <creator)) + if (is_ppc_elf (link_info.output_bfd)) { int new_plt; int keep_new; @@ -62,9 +55,10 @@ ppc_after_open (void) 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"); @@ -109,18 +103,53 @@ ppc_after_open (void) 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 @@ -149,15 +178,19 @@ fi # 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 }, @@ -165,11 +198,13 @@ PARSE_AND_LIST_LONGOPTS=' 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" )); ' @@ -178,10 +213,18 @@ PARSE_AND_LIST_ARGS_CASES=' 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;