summaryrefslogtreecommitdiff
path: root/ld
diff options
context:
space:
mode:
authorAlan Modra <amodra@bigpond.net.au>2002-07-01 08:07:31 +0000
committerAlan Modra <amodra@bigpond.net.au>2002-07-01 08:07:31 +0000
commit1cf322d927af9488be65d82e52dc6fd6c27218f4 (patch)
tree899176e6731417411379647588dc150ed1d0d0e4 /ld
parent354f2991df93a569cd20094d999133d3bc31e684 (diff)
downloadbinutils-redhat-1cf322d927af9488be65d82e52dc6fd6c27218f4.tar.gz
* ldlang.h (entry_sym): Make it a struct bfd_sym_chain.
* ldlang.c (entry_sym): Likewise. (ldlang_undef_chain_list_type): Likewise. (lang_finish): Adjust references to entry_symbol. (lang_add_entry): Likewise. (lang_gc_sections): Use link_info.gc_sym_list. (lang_process): Set link_info.gc_sym_list. * ldlex.l: Include bfdlink.h. * ldmain.c (main): Init link_info.gc_sym_list. * emultempl/aix.em: Adjust references to entry_symbol. * emultempl/armcoff.em: Likewise. * emultempl/armelf.em: Likewise. * emultempl/pe.em: Likewise. * emultempl/ppc64elf.em (ppc_after_open): New function. (LDEMUL_AFTER_OPEN): Define. * emulparams/elf64ppc.sh: KEEP .opd sections.
Diffstat (limited to 'ld')
-rw-r--r--ld/ChangeLog19
-rw-r--r--ld/emulparams/elf64ppc.sh2
-rw-r--r--ld/emultempl/aix.em4
-rw-r--r--ld/emultempl/armcoff.em8
-rw-r--r--ld/emultempl/armelf.em6
-rw-r--r--ld/emultempl/pe.em10
-rw-r--r--ld/emultempl/ppc64elf.em13
-rw-r--r--ld/ldlang.c51
-rw-r--r--ld/ldlang.h2
-rw-r--r--ld/ldlex.l1
-rw-r--r--ld/ldmain.c1
11 files changed, 72 insertions, 45 deletions
diff --git a/ld/ChangeLog b/ld/ChangeLog
index b7a99c41e5..a529f1b772 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,22 @@
+2002-07-01 Alan Modra <amodra@bigpond.net.au>
+
+ * ldlang.h (entry_sym): Make it a struct bfd_sym_chain.
+ * ldlang.c (entry_sym): Likewise.
+ (ldlang_undef_chain_list_type): Likewise.
+ (lang_finish): Adjust references to entry_symbol.
+ (lang_add_entry): Likewise.
+ (lang_gc_sections): Use link_info.gc_sym_list.
+ (lang_process): Set link_info.gc_sym_list.
+ * ldlex.l: Include bfdlink.h.
+ * ldmain.c (main): Init link_info.gc_sym_list.
+ * emultempl/aix.em: Adjust references to entry_symbol.
+ * emultempl/armcoff.em: Likewise.
+ * emultempl/armelf.em: Likewise.
+ * emultempl/pe.em: Likewise.
+ * emultempl/ppc64elf.em (ppc_after_open): New function.
+ (LDEMUL_AFTER_OPEN): Define.
+ * emulparams/elf64ppc.sh: KEEP .opd sections.
+
2002-06-29 Stephane Carrez <stcarrez@nerim.fr>
* emulparams/m68hc12elfb.sh (EEPROM_MEMORY): Define.
diff --git a/ld/emulparams/elf64ppc.sh b/ld/emulparams/elf64ppc.sh
index f1647d50c0..10593f2194 100644
--- a/ld/emulparams/elf64ppc.sh
+++ b/ld/emulparams/elf64ppc.sh
@@ -27,7 +27,7 @@ OTHER_GOT_RELOC_SECTIONS="
.rela.toc ${RELOCATING-0} : { *(.rela.toc) }"
OTHER_READWRITE_SECTIONS="
.toc1 ${RELOCATING-0}${RELOCATING+ALIGN(8)} : { *(.toc1) }
- .opd ${RELOCATING-0}${RELOCATING+ALIGN(8)} : { *(.opd) }"
+ .opd ${RELOCATING-0}${RELOCATING+ALIGN(8)} : { KEEP (*(.opd)) }"
# Treat a host that matches the target with the possible exception of "64"
# in the name as if it were native.
diff --git a/ld/emultempl/aix.em b/ld/emultempl/aix.em
index 3caa018726..4388e05f7f 100644
--- a/ld/emultempl/aix.em
+++ b/ld/emultempl/aix.em
@@ -9,7 +9,7 @@ cat >e${EMULATION_NAME}.c <<EOF
/* This file is is generated by a shell script. DO NOT EDIT! */
/* AIX emulation code for ${EMULATION_NAME}
- Copyright 1991, 1993, 1995, 1996, 1997, 1998, 2000, 2001
+ Copyright 1991, 1993, 1995, 1996, 1997, 1998, 2000, 2001, 2002
Free Software Foundation, Inc.
Written by Steve Chamberlain <sac@cygnus.com>
AIX support by Ian Lance Taylor <ian@cygnus.com>
@@ -682,7 +682,7 @@ gld${EMULATION_NAME}_before_allocation ()
/* Let the XCOFF backend set up the .loader section. */
if (!bfd_xcoff_size_dynamic_sections
- (output_bfd, &link_info, libpath, entry_symbol, file_align,
+ (output_bfd, &link_info, libpath, entry_symbol.name, file_align,
maxstack, maxdata, gc && !unix_ld ? true : false,
modtype, textro ? true : false, unix_ld, special_sections,
rtld ? true : false))
diff --git a/ld/emultempl/armcoff.em b/ld/emultempl/armcoff.em
index c6a9895c30..0b5e7bc979 100644
--- a/ld/emultempl/armcoff.em
+++ b/ld/emultempl/armcoff.em
@@ -4,7 +4,7 @@ cat >e${EMULATION_NAME}.c <<EOF
/* This file is is generated by a shell script. DO NOT EDIT! */
/* emulate the original gld for the given ${EMULATION_NAME}
- Copyright 1991, 1993, 1996, 1997, 1998, 1999, 2000, 2001
+ Copyright 1991, 1993, 1996, 1997, 1998, 1999, 2000, 2001, 2002
Free Software Foundation, Inc.
Written by Steve Chamberlain steve@cygnus.com
@@ -203,10 +203,10 @@ gld${EMULATION_NAME}_finish PARAMS((void))
sprintf_vma (buffer + 2, val);
- if (entry_symbol != NULL && entry_from_cmdline)
+ if (entry_symbol.name != NULL && entry_from_cmdline)
einfo (_("%P: warning: '--thumb-entry %s' is overriding '-e %s'\n"),
- thumb_entry_symbol, entry_symbol);
- entry_symbol = buffer;
+ thumb_entry_symbol, entry_symbol.name);
+ entry_symbol.name = buffer;
}
else
einfo (_("%P: warning: connot find thumb start symbol %s\n"), thumb_entry_symbol);
diff --git a/ld/emultempl/armelf.em b/ld/emultempl/armelf.em
index 77cd4f778d..6f3cfc39b5 100644
--- a/ld/emultempl/armelf.em
+++ b/ld/emultempl/armelf.em
@@ -172,10 +172,10 @@ arm_elf_finish ()
sprintf_vma (buffer + 2, val);
- if (entry_symbol != NULL && entry_from_cmdline)
+ if (entry_symbol.name != NULL && entry_from_cmdline)
einfo (_("%P: warning: '--thumb-entry %s' is overriding '-e %s'\n"),
- thumb_entry_symbol, entry_symbol);
- entry_symbol = buffer;
+ thumb_entry_symbol, entry_symbol.name);
+ entry_symbol.name = buffer;
}
else
einfo (_("%P: warning: connot find thumb start symbol %s\n"),
diff --git a/ld/emultempl/pe.em b/ld/emultempl/pe.em
index b84a3c75f7..a6dfe46373 100644
--- a/ld/emultempl/pe.em
+++ b/ld/emultempl/pe.em
@@ -758,8 +758,8 @@ gld_${EMULATION_NAME}_after_parse ()
opened, so registering the symbol as undefined will make a
difference. */
- if (! link_info.relocateable && entry_symbol != NULL)
- ldlang_add_undef (entry_symbol);
+ if (! link_info.relocateable && entry_symbol.name != NULL)
+ ldlang_add_undef (entry_symbol.name);
}
/* pe-dll.c directly accesses pe_data_import_dll,
@@ -1418,10 +1418,10 @@ gld_${EMULATION_NAME}_finish ()
sprintf_vma (buffer + 2, val);
- if (entry_symbol != NULL && entry_from_cmdline)
+ if (entry_symbol.name != NULL && entry_from_cmdline)
einfo (_("%P: warning: '--thumb-entry %s' is overriding '-e %s'\n"),
- thumb_entry_symbol, entry_symbol);
- entry_symbol = buffer;
+ thumb_entry_symbol, entry_symbol.name);
+ entry_symbol.name = buffer;
}
else
einfo (_("%P: warning: connot find thumb start symbol %s\n"), thumb_entry_symbol);
diff --git a/ld/emultempl/ppc64elf.em b/ld/emultempl/ppc64elf.em
index 9ce7893b92..cf6918eeed 100644
--- a/ld/emultempl/ppc64elf.em
+++ b/ld/emultempl/ppc64elf.em
@@ -42,6 +42,7 @@ static bfd_signed_vma group_size = 1;
static int dotsyms = 1;
static void ppc_create_output_section_statements PARAMS ((void));
+static void ppc_after_open PARAMS ((void));
static asection *ppc_add_stub_section PARAMS ((const char *, asection *));
static void ppc_layout_sections_again PARAMS ((void));
static void gld${EMULATION_NAME}_after_allocation PARAMS ((void));
@@ -71,6 +72,17 @@ ppc_create_output_section_statements ()
ldlang_add_file (stub_file);
}
+static void
+ppc_after_open ()
+{
+ if (!ppc64_elf_mark_entry_syms (&link_info))
+ {
+ einfo ("%X%P: can not mark entry symbols %E\n");
+ return;
+ }
+
+ gld${EMULATION_NAME}_after_open ();
+}
struct hook_stub_info
{
@@ -473,6 +485,7 @@ PARSE_AND_LIST_ARGS_CASES='
# Put these extra ppc64elf routines in ld_${EMULATION_NAME}_emulation
#
+LDEMUL_AFTER_OPEN=ppc_after_open
LDEMUL_AFTER_ALLOCATION=gld${EMULATION_NAME}_after_allocation
LDEMUL_FINISH=gld${EMULATION_NAME}_finish
LDEMUL_CREATE_OUTPUT_SECTION_STATEMENTS=ppc_create_output_section_statements
diff --git a/ld/ldlang.c b/ld/ldlang.c
index abe38345fc..f621e00dd3 100644
--- a/ld/ldlang.c
+++ b/ld/ldlang.c
@@ -184,7 +184,7 @@ lang_output_section_statement_type *abs_output_section;
lang_statement_list_type lang_output_section_statement;
lang_statement_list_type *stat_ptr = &statement_list;
lang_statement_list_type file_chain = { NULL, NULL };
-const char *entry_symbol = NULL;
+struct bfd_sym_chain entry_symbol = { NULL, NULL };
const char *entry_section = ".text";
boolean entry_from_cmdline;
boolean lang_has_input_file = false;
@@ -2030,13 +2030,9 @@ lang_reasonable_defaults ()
on a list, then, once the output file has been opened, transfer the
name to the symbol table. */
-typedef struct ldlang_undef_chain_list
-{
- struct ldlang_undef_chain_list *next;
- char *name;
-} ldlang_undef_chain_list_type;
+typedef struct bfd_sym_chain ldlang_undef_chain_list_type;
-static ldlang_undef_chain_list_type *ldlang_undef_chain_list_head;
+#define ldlang_undef_chain_list_head entry_symbol.next
void
ldlang_add_undef (name)
@@ -3523,15 +3519,16 @@ lang_finish ()
else
warn = true;
- if (entry_symbol == (char *) NULL)
+ if (entry_symbol.name == (const char *) NULL)
{
/* No entry has been specified. Look for start, but don't warn
if we don't find it. */
- entry_symbol = "start";
+ entry_symbol.name = "start";
warn = false;
}
- h = bfd_link_hash_lookup (link_info.hash, entry_symbol, false, false, true);
+ h = bfd_link_hash_lookup (link_info.hash, entry_symbol.name,
+ false, false, true);
if (h != (struct bfd_link_hash_entry *) NULL
&& (h->type == bfd_link_hash_defined
|| h->type == bfd_link_hash_defweak)
@@ -3544,7 +3541,7 @@ lang_finish ()
h->u.def.section->output_section)
+ h->u.def.section->output_offset);
if (! bfd_set_start_address (output_bfd, val))
- einfo (_("%P%F:%s: can't set start address\n"), entry_symbol);
+ einfo (_("%P%F:%s: can't set start address\n"), entry_symbol.name);
}
else
{
@@ -3553,7 +3550,7 @@ lang_finish ()
/* We couldn't find the entry symbol. Try parsing it as a
number. */
- val = bfd_scan_vma (entry_symbol, &send, 0);
+ val = bfd_scan_vma (entry_symbol.name, &send, 0);
if (*send == '\0')
{
if (! bfd_set_start_address (output_bfd, val))
@@ -3570,7 +3567,8 @@ lang_finish ()
{
if (warn)
einfo (_("%P: warning: cannot find entry symbol %s; defaulting to %V\n"),
- entry_symbol, bfd_get_section_vma (output_bfd, ts));
+ entry_symbol.name,
+ bfd_get_section_vma (output_bfd, ts));
if (! bfd_set_start_address (output_bfd,
bfd_get_section_vma (output_bfd,
ts)))
@@ -3580,7 +3578,7 @@ lang_finish ()
{
if (warn)
einfo (_("%P: warning: cannot find entry symbol %s; not setting start address\n"),
- entry_symbol);
+ entry_symbol.name);
}
}
}
@@ -4146,25 +4144,16 @@ static void
lang_gc_sections ()
{
struct bfd_link_hash_entry *h;
- ldlang_undef_chain_list_type *ulist, fake_list_start;
+ ldlang_undef_chain_list_type *ulist;
/* Keep all sections so marked in the link script. */
lang_gc_sections_1 (statement_list.head);
- /* Keep all sections containing symbols undefined on the command-line.
- Handle the entry symbol at the same time. */
-
- if (entry_symbol != NULL)
- {
- fake_list_start.next = ldlang_undef_chain_list_head;
- fake_list_start.name = (char *) entry_symbol;
- ulist = &fake_list_start;
- }
- else
- ulist = ldlang_undef_chain_list_head;
+ /* Keep all sections containing symbols undefined on the command-line,
+ and the section containing the entry symbol. */
- for (; ulist; ulist = ulist->next)
+ for (ulist = link_info.gc_sym_list; ulist; ulist = ulist->next)
{
h = bfd_link_hash_lookup (link_info.hash, ulist->name,
false, false, false);
@@ -4201,6 +4190,10 @@ lang_process ()
current_target = default_target;
open_input_bfds (statement_list.head, false);
+ link_info.gc_sym_list = &entry_symbol;
+ if (entry_symbol.name == NULL)
+ link_info.gc_sym_list = ldlang_undef_chain_list_head;
+
ldemul_after_open ();
already_linked_table_free ();
@@ -4391,11 +4384,11 @@ lang_add_entry (name, cmdline)
const char *name;
boolean cmdline;
{
- if (entry_symbol == NULL
+ if (entry_symbol.name == NULL
|| cmdline
|| ! entry_from_cmdline)
{
- entry_symbol = name;
+ entry_symbol.name = name;
entry_from_cmdline = cmdline;
}
}
diff --git a/ld/ldlang.h b/ld/ldlang.h
index 26c4121fa7..cb4b6d332d 100644
--- a/ld/ldlang.h
+++ b/ld/ldlang.h
@@ -364,7 +364,7 @@ extern etree_type *base;
extern lang_statement_list_type *stat_ptr;
extern boolean delete_output_file_on_failure;
-extern const char *entry_symbol;
+extern struct bfd_sym_chain entry_symbol;
extern const char *entry_section;
extern boolean entry_from_cmdline;
extern lang_statement_list_type file_chain;
diff --git a/ld/ldlex.l b/ld/ldlex.l
index cacec19291..68ed7fc3ce 100644
--- a/ld/ldlex.l
+++ b/ld/ldlex.l
@@ -37,6 +37,7 @@ This was written by steve chamberlain
#include "bfd.h"
#include "sysdep.h"
#include "safe-ctype.h"
+#include "bfdlink.h"
#include "ld.h"
#include "ldmisc.h"
#include "ldexp.h"
diff --git a/ld/ldmain.c b/ld/ldmain.c
index 2c406eb1a7..7943a9eddf 100644
--- a/ld/ldmain.c
+++ b/ld/ldmain.c
@@ -245,6 +245,7 @@ main (argc, argv)
link_info.keep_memory = true;
link_info.input_bfds = NULL;
link_info.create_object_symbols_section = NULL;
+ link_info.gc_sym_list = NULL;
link_info.hash = NULL;
link_info.keep_hash = NULL;
link_info.notice_all = false;