From e3e942e9908d0fa4d4abf2b39edd99aa07a11535 Mon Sep 17 00:00:00 2001 From: Alan Modra Date: Mon, 1 Jul 2002 08:07:31 +0000 Subject: * 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. --- ld/ChangeLog | 19 ++++++++++++++++++ ld/emulparams/elf64ppc.sh | 2 +- ld/emultempl/aix.em | 4 ++-- ld/emultempl/armcoff.em | 8 ++++---- ld/emultempl/armelf.em | 6 +++--- ld/emultempl/pe.em | 10 +++++----- ld/emultempl/ppc64elf.em | 13 ++++++++++++ ld/ldlang.c | 51 ++++++++++++++++++++--------------------------- ld/ldlang.h | 2 +- ld/ldlex.l | 1 + ld/ldmain.c | 1 + 11 files changed, 72 insertions(+), 45 deletions(-) (limited to 'ld') diff --git a/ld/ChangeLog b/ld/ChangeLog index b7a99c4..a529f1b 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,22 @@ +2002-07-01 Alan Modra + + * 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 * emulparams/m68hc12elfb.sh (EEPROM_MEMORY): Define. diff --git a/ld/emulparams/elf64ppc.sh b/ld/emulparams/elf64ppc.sh index f1647d5..10593f2 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 3caa018..4388e05 100644 --- a/ld/emultempl/aix.em +++ b/ld/emultempl/aix.em @@ -9,7 +9,7 @@ cat >e${EMULATION_NAME}.c < AIX support by Ian Lance Taylor @@ -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 c6a9895..0b5e7bc 100644 --- a/ld/emultempl/armcoff.em +++ b/ld/emultempl/armcoff.em @@ -4,7 +4,7 @@ cat >e${EMULATION_NAME}.c <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 26c4121..cb4b6d3 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 cacec19..68ed7fc 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 2c406eb..7943a9e 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; -- cgit v1.1