aboutsummaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@gmail.com>2014-02-17 17:08:00 +1030
committerAlan Modra <amodra@gmail.com>2014-02-17 17:11:11 +1030
commite7d1c40ce59ff355d2a51ff64a657c772eabbbfe (patch)
tree11d9412733613c625dd827c08e669e47b4fa1be9 /ld
parent668e22e51bc50b884a8c1872a2371a6b00a08f9d (diff)
downloadfsf-binutils-gdb-e7d1c40ce59ff355d2a51ff64a657c772eabbbfe.zip
fsf-binutils-gdb-e7d1c40ce59ff355d2a51ff64a657c772eabbbfe.tar.gz
fsf-binutils-gdb-e7d1c40ce59ff355d2a51ff64a657c772eabbbfe.tar.bz2
Consolidate ppc64 ld/bfd communication
Moves assorted variables used to communicate between ld and bfd into a struct, hooks it into the bfd link_hash_table early, and removes all other places where such variables were passed piecemeal. bfd/ * elf64-ppc.h (struct ppc64_elf_params): Define. (ppc64_elf_init_stub_bfd, ppc64_elf_edit_opd, ppc64_elf_tls_setup, ppc64_elf_setup_section_lists, ppc64_elf_size_stubs, ppc64_elf_build_stubs): Update prototype. * elf64-ppp.c (struct ppc_link_hash_table): Add params, delete other fields now in params. Adjust code throughout file. (ppc64_elf_init_stub_bfd): Delete "abfd" parameter, add "params". Save params pointer in htab. (ppc64_elf_edit_opd, ppc64_elf_tls_setup, ppc64_elf_setup_section_lists, ppc64_elf_size_stubs, ppc64_elf_build_stubs): Remove parameters now in "params". ld/ * emultemps/ppc64elf.em (params): New static struct replacing various other static vars. Adjust code throughout file.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog5
-rw-r--r--ld/emultempl/ppc64elf.em84
2 files changed, 39 insertions, 50 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index 38d81b0..1bd1c99 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,5 +1,10 @@
2014-02-17 Alan Modra <amodra@gmail.com>
+ * emultemps/ppc64elf.em (params): New static struct replacing
+ various other static vars. Adjust code throughout file.
+
+2014-02-17 Alan Modra <amodra@gmail.com>
+
* emultempl/ppc32elf.em (ppc_after_open_output): Really enable
ppc476 workaround for ld -r.
diff --git a/ld/emultempl/ppc64elf.em b/ld/emultempl/ppc64elf.em
index c126297..56cd0af 100644
--- a/ld/emultempl/ppc64elf.em
+++ b/ld/emultempl/ppc64elf.em
@@ -31,6 +31,16 @@ fragment <<EOF
#include "elf64-ppc.h"
#include "ldlex.h"
+static asection *ppc_add_stub_section (const char *, asection *);
+static void ppc_layout_sections_again (void);
+
+static struct ppc64_elf_params params = { NULL,
+ &ppc_add_stub_section,
+ &ppc_layout_sections_again,
+ 1, 0, 0,
+ ${DEFAULT_PLT_STATIC_CHAIN-0}, -1, 0,
+ 0, -1};
+
/* Fake input file for stubs. */
static lang_input_statement_type *stub_file;
static int stub_added = 0;
@@ -38,17 +48,11 @@ static int stub_added = 0;
/* Whether we need to call ppc_layout_sections_again. */
static int need_laying_out = 0;
-/* Maximum size of a group of input sections that can be handled by
- one stub section. A value of +/-1 indicates the bfd back-end
- should use a suitable default size. */
-static bfd_signed_vma group_size = 1;
-
/* Whether to add ".foo" entries for each "foo" in a version script. */
static int dotsyms = 1;
/* Whether to run tls optimization. */
static int no_tls_opt = 0;
-static int no_tls_get_addr_opt = 0;
/* Whether to run opd optimization. */
static int no_opd_opt = 0;
@@ -56,30 +60,14 @@ static int no_opd_opt = 0;
/* Whether to run toc optimization. */
static int no_toc_opt = 0;
-/* Whether to allow multiple toc sections. */
-static int no_multi_toc = 0;
-
/* Whether to sort input toc and got sections. */
static int no_toc_sort = 0;
-/* Set if PLT call stubs should load r11. */
-static int plt_static_chain = ${DEFAULT_PLT_STATIC_CHAIN-0};
-
-/* Set if PLT call stubs need to be thread safe on power7+. */
-static int plt_thread_safe = -1;
-
/* Set if individual PLT call stubs should be aligned. */
static int plt_stub_align = 0;
-/* Whether to emit symbols for stubs. */
-static int emit_stub_syms = -1;
-
static asection *toc_section = 0;
-/* Whether to canonicalize .opd so that there are no overlapping
- .opd entries. */
-static int non_overlapping_opd = 0;
-
/* This is called before the input files are opened. We create a new
fake input file to hold the stub sections. */
@@ -107,7 +95,8 @@ ppc_create_output_section_statements (void)
stub_file->the_bfd->flags |= BFD_LINKER_CREATED;
ldlang_add_file (stub_file);
- if (!ppc64_elf_init_stub_bfd (stub_file->the_bfd, &link_info))
+ params.stub_bfd = stub_file->the_bfd;
+ if (!ppc64_elf_init_stub_bfd (&link_info, &params))
einfo ("%F%P: can not init BFD: %E\n");
}
@@ -256,10 +245,10 @@ ppc_before_allocation (void)
if (stub_file != NULL)
{
if (!no_opd_opt
- && !ppc64_elf_edit_opd (&link_info, non_overlapping_opd))
+ && !ppc64_elf_edit_opd (&link_info))
einfo ("%X%P: can not edit %s: %E\n", "opd");
- if (ppc64_elf_tls_setup (&link_info, no_tls_get_addr_opt, &no_multi_toc)
+ if (ppc64_elf_tls_setup (&link_info)
&& !no_tls_opt)
{
/* Size the sections. This is premature, but we want to know the
@@ -480,16 +469,14 @@ gld${EMULATION_NAME}_after_allocation (void)
stubs. */
if (stub_file != NULL && !link_info.relocatable)
{
- int ret = ppc64_elf_setup_section_lists (&link_info,
- &ppc_add_stub_section,
- &ppc_layout_sections_again);
+ int ret = ppc64_elf_setup_section_lists (&link_info);
if (ret < 0)
einfo ("%X%P: can not size stub section: %E\n");
else if (ret > 0)
{
ppc64_elf_start_multitoc_partition (&link_info);
- if (!no_multi_toc)
+ if (!params.no_multi_toc)
{
toc_section = bfd_get_section_by_name (link_info.output_bfd,
".got");
@@ -498,7 +485,7 @@ gld${EMULATION_NAME}_after_allocation (void)
}
if (ppc64_elf_layout_multitoc (&link_info)
- && !no_multi_toc
+ && !params.no_multi_toc
&& toc_section != NULL)
lang_for_each_statement (build_toc_list);
@@ -510,9 +497,7 @@ gld${EMULATION_NAME}_after_allocation (void)
einfo ("%P: .init/.fini fragments use differing TOC pointers\n");
/* Call into the BFD backend to do the real work. */
- if (!ppc64_elf_size_stubs (&link_info, group_size,
- plt_static_chain, plt_thread_safe,
- plt_stub_align))
+ if (!ppc64_elf_size_stubs (&link_info))
einfo ("%X%P: can not size stub section: %E\n");
}
}
@@ -542,10 +527,9 @@ gld${EMULATION_NAME}_finish (void)
char *msg = NULL;
char *line, *endline;
- if (emit_stub_syms < 0)
- emit_stub_syms = 1;
- if (!ppc64_elf_build_stubs (emit_stub_syms, &link_info,
- config.stats ? &msg : NULL))
+ if (params.emit_stub_syms < 0)
+ params.emit_stub_syms = 1;
+ if (!ppc64_elf_build_stubs (&link_info, config.stats ? &msg : NULL))
einfo ("%X%P: can not build stubs: %E\n");
fflush (stdout);
@@ -766,26 +750,26 @@ PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LIST_ARGS_CASES}'
case OPTION_STUBGROUP_SIZE:
{
const char *end;
- group_size = bfd_scan_vma (optarg, &end, 0);
+ params.group_size = bfd_scan_vma (optarg, &end, 0);
if (*end)
einfo (_("%P%F: invalid number `%s'\''\n"), optarg);
}
break;
case OPTION_PLT_STATIC_CHAIN:
- plt_static_chain = 1;
+ params.plt_static_chain = 1;
break;
case OPTION_NO_PLT_STATIC_CHAIN:
- plt_static_chain = 0;
+ params.plt_static_chain = 0;
break;
case OPTION_PLT_THREAD_SAFE:
- plt_thread_safe = 1;
+ params.plt_thread_safe = 1;
break;
case OPTION_NO_PLT_THREAD_SAFE:
- plt_thread_safe = 0;
+ params.plt_thread_safe = 0;
break;
case OPTION_PLT_ALIGN:
@@ -806,11 +790,11 @@ PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LIST_ARGS_CASES}'
break;
case OPTION_STUBSYMS:
- emit_stub_syms = 1;
+ params.emit_stub_syms = 1;
break;
case OPTION_NO_STUBSYMS:
- emit_stub_syms = 0;
+ params.emit_stub_syms = 0;
break;
case OPTION_DOTSYMS:
@@ -826,7 +810,7 @@ PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LIST_ARGS_CASES}'
break;
case OPTION_NO_TLS_GET_ADDR_OPT:
- no_tls_get_addr_opt = 1;
+ params.no_tls_get_addr_opt = 1;
break;
case OPTION_NO_OPD_OPT:
@@ -838,7 +822,7 @@ PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LIST_ARGS_CASES}'
break;
case OPTION_NO_MULTI_TOC:
- no_multi_toc = 1;
+ params.no_multi_toc = 1;
break;
case OPTION_NO_TOC_SORT:
@@ -846,17 +830,17 @@ PARSE_AND_LIST_ARGS_CASES=${PARSE_AND_LIST_ARGS_CASES}'
break;
case OPTION_NON_OVERLAPPING_OPD:
- non_overlapping_opd = 1;
+ params.non_overlapping_opd = 1;
break;
case OPTION_TRADITIONAL_FORMAT:
no_tls_opt = 1;
- no_tls_get_addr_opt = 1;
+ params.no_tls_get_addr_opt = 1;
no_opd_opt = 1;
no_toc_opt = 1;
- no_multi_toc = 1;
+ params.no_multi_toc = 1;
no_toc_sort = 1;
- plt_static_chain = 1;
+ params.plt_static_chain = 1;
return FALSE;
'