From: Alan Modra Date: Thu, 28 Mar 2002 06:26:58 +0000 (+0000) Subject: Merge from mainline. X-Git-Tag: binutils-2_12_1~81 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=388c55261513b2f51f87cf524a67c2dc23a13241;p=thirdparty%2Fbinutils-gdb.git Merge from mainline. 2002-03-21 Albert Chin-A-Young * genscripts.sh (LIB_SEARCH_DIRS): Quote path. 2002-03-20 Alan Modra * ldlang.c (ldlang_add_undef): If the output bfd has been opened, add the symbol to the linker hash table immediately. (lang_place_undefineds): Split symbol creation out.. (insert_undefined): ..to here. 2002-03-18 Alan Modra * ldmain.c (main): Move .text readonly flag fudges from here.. * ldlang.c (lang_process): ..to here. 2002-03-14 Alan Modra * ldlang.c (lang_check): Remove the word size check added in last change. Treat emitrelocations case as for relocatable links. 2002-03-13 Alan Modra * ldlang.c (lang_check): Do relocatable link checks first, so that warn_mismatch can't override. Check compatible and word size too. 2002-03-04 H.J. Lu * scripttempl/elf.sc: Put .preinit_array, .init_array and .fini_array in the data segment. 2002-03-04 Alan Modra * scripttempl/elf.sc: Correct syntax errors in 2002-03-01 commit. 2002-03-01 David Mosberger * scripttempl/elf.sc (SECTIONS): Add entries for .preinit_array, .init_array, and .fini_array. --- diff --git a/ld/ChangeLog b/ld/ChangeLog index 941ffeb6db4..2042d248e03 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -1,3 +1,38 @@ +2002-03-28 Alan Modra + + Merge from mainline. + 2002-03-21 Albert Chin-A-Young + * genscripts.sh (LIB_SEARCH_DIRS): Quote path. + + 2002-03-20 Alan Modra + * ldlang.c (ldlang_add_undef): If the output bfd has been opened, + add the symbol to the linker hash table immediately. + (lang_place_undefineds): Split symbol creation out.. + (insert_undefined): ..to here. + + 2002-03-18 Alan Modra + * ldmain.c (main): Move .text readonly flag fudges from here.. + * ldlang.c (lang_process): ..to here. + + 2002-03-14 Alan Modra + * ldlang.c (lang_check): Remove the word size check added in last + change. Treat emitrelocations case as for relocatable links. + + 2002-03-13 Alan Modra + * ldlang.c (lang_check): Do relocatable link checks first, so that + warn_mismatch can't override. Check compatible and word size too. + + 2002-03-04 H.J. Lu + * scripttempl/elf.sc: Put .preinit_array, .init_array and + .fini_array in the data segment. + + 2002-03-04 Alan Modra + * scripttempl/elf.sc: Correct syntax errors in 2002-03-01 commit. + + 2002-03-01 David Mosberger + * scripttempl/elf.sc (SECTIONS): Add entries for .preinit_array, + .init_array, and .fini_array. + 2002-03-18 David O'Brien * emultempl/elf32.em: Use lbasename vs. basename to fix problem where @@ -8,10 +43,7 @@ Mon Mar 18 18:07:20 CET 2002 Jan Hubicka Andreas Jaeger Andreas Schwab - * cpu-i386.c (bfd_x86_64_arch): Rename to "i386:x86-64" - * configure.tgt (x86_64-*-linux-gnu*): Configure i386 as native. - * elf_x86_64.sh (ARCH): Set to i386:x86-64 set libraries to default to lib64 paths. diff --git a/ld/genscripts.sh b/ld/genscripts.sh index 501a68c8b9a..fe1fa499f5a 100755 --- a/ld/genscripts.sh +++ b/ld/genscripts.sh @@ -69,7 +69,7 @@ fi # Always search $(tooldir)/lib, aka /usr/local/TARGET/lib. LIB_PATH=${LIB_PATH}:${tool_lib} -LIB_SEARCH_DIRS=`echo ${LIB_PATH} | tr ':' ' ' | sed -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\1);/g'` +LIB_SEARCH_DIRS=`echo ${LIB_PATH} | tr ':' ' ' | sed -e 's/\([^ ][^ ]*\)/SEARCH_DIR(\\"\1\\");/g'` # Generate 5 or 6 script files from a master script template in # ${srcdir}/scripttempl/${SCRIPT_NAME}.sh. Which one of the 5 or 6 diff --git a/ld/ldlang.c b/ld/ldlang.c index a5b1dd7e7e6..5257547b952 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -92,6 +92,7 @@ static bfd *open_output PARAMS ((const char *)); static void ldlang_open_output PARAMS ((lang_statement_union_type *)); static void open_input_bfds PARAMS ((lang_statement_union_type *, boolean)); static void lang_reasonable_defaults PARAMS ((void)); +static void insert_undefined PARAMS ((const char *)); static void lang_place_undefineds PARAMS ((void)); static void map_input_to_output_sections PARAMS ((lang_statement_union_type *, const char *, @@ -2007,7 +2008,11 @@ lang_reasonable_defaults () } /* Add the supplied name to the symbol table as an undefined reference. - Remove items from the chain as we open input bfds. */ + This is a two step process as the symbol table doesn't even exist at + the time the ld command line is processed. First we put the name + 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; @@ -2028,6 +2033,28 @@ ldlang_add_undef (name) ldlang_undef_chain_list_head = new; new->name = xstrdup (name); + + if (output_bfd != NULL) + insert_undefined (new->name); +} + +/* Insert NAME as undefined in the symbol table. */ + +static void +insert_undefined (name) + const char *name; +{ + struct bfd_link_hash_entry *h; + + h = bfd_link_hash_lookup (link_info.hash, name, true, false, true); + if (h == (struct bfd_link_hash_entry *) NULL) + einfo (_("%P%F: bfd_link_hash_lookup failed: %E\n")); + if (h->type == bfd_link_hash_new) + { + h->type = bfd_link_hash_undefined; + h->u.undef.abfd = NULL; + bfd_link_add_undef (link_info.hash, h); + } } /* Run through the list of undefineds created above and place them @@ -2043,17 +2070,7 @@ lang_place_undefineds () ptr != (ldlang_undef_chain_list_type *) NULL; ptr = ptr->next) { - struct bfd_link_hash_entry *h; - - h = bfd_link_hash_lookup (link_info.hash, ptr->name, true, false, true); - if (h == (struct bfd_link_hash_entry *) NULL) - einfo (_("%P%F: bfd_link_hash_lookup failed: %E\n")); - if (h->type == bfd_link_hash_new) - { - h->type = bfd_link_hash_undefined; - h->u.undef.abfd = NULL; - bfd_link_add_undef (link_info.hash, h); - } + insert_undefined (ptr->name); } } @@ -3517,8 +3534,25 @@ lang_check () file = file->input_statement.next) { input_bfd = file->input_statement.the_bfd; - compatible = bfd_arch_get_compatible (input_bfd, - output_bfd); + compatible = bfd_arch_get_compatible (input_bfd, output_bfd); + + /* In general it is not possible to perform a relocatable + link between differing object formats when the input + file has relocations, because the relocations in the + input format may not have equivalent representations in + the output format (and besides BFD does not translate + relocs for other link purposes than a final link). */ + if ((link_info.relocateable || link_info.emitrelocations) + && (compatible == NULL + || bfd_get_flavour (input_bfd) != bfd_get_flavour (output_bfd)) + && (bfd_get_file_flags (input_bfd) & HAS_RELOC) != 0) + { + einfo (_("%P%F: Relocatable linking with relocations from format %s (%B) to format %s (%B) is not supported\n"), + bfd_get_target (input_bfd), input_bfd, + bfd_get_target (output_bfd), output_bfd); + /* einfo with %F exits. */ + } + if (compatible == NULL) { if (command_line.warn_mismatch) @@ -3526,18 +3560,6 @@ lang_check () bfd_printable_name (input_bfd), input_bfd, bfd_printable_name (output_bfd)); } - else if (link_info.relocateable - /* In general it is not possible to perform a relocatable - link between differing object formats when the input - file has relocations, because the relocations in the - input format may not have equivalent representations in - the output format (and besides BFD does not translate - relocs for other link purposes than a final link). */ - && bfd_get_flavour (input_bfd) != bfd_get_flavour (output_bfd) - && (bfd_get_file_flags (input_bfd) & HAS_RELOC) != 0) - einfo (_("%P%F: Relocatable linking with relocations from format %s (%B) to format %s (%B) is not supported\n"), - bfd_get_target (input_bfd), input_bfd, - bfd_get_target (output_bfd), output_bfd); else if (bfd_count_sections (input_bfd)) { /* If the input bfd has no contents, it shouldn't set the @@ -4141,6 +4163,22 @@ lang_process () /* Find any sections not attached explicitly and handle them. */ lang_place_orphans (); + if (! link_info.relocateable) + { + /* Look for a text section and set the readonly attribute in it. */ + asection *found = bfd_get_section_by_name (output_bfd, ".text"); + + if (found != (asection *) NULL) + { + if (config.text_read_only) + found->flags |= SEC_READONLY; + else + found->flags &= ~SEC_READONLY; + } + } + + /* Do anything special before sizing sections. This is where ELF + and other back-ends size dynamic sections. */ ldemul_before_allocation (); /* We must record the program headers before we try to fix the diff --git a/ld/ldmain.c b/ld/ldmain.c index 12e31dd91fb..5bda3d3928c 100644 --- a/ld/ldmain.c +++ b/ld/ldmain.c @@ -404,20 +404,6 @@ main (argc, argv) /* Print error messages for any missing symbols, for any warning symbols, and possibly multiple definitions. */ - if (! link_info.relocateable) - { - /* Look for a text section and switch the readonly attribute in it. */ - asection *found = bfd_get_section_by_name (output_bfd, ".text"); - - if (found != (asection *) NULL) - { - if (config.text_read_only) - found->flags |= SEC_READONLY; - else - found->flags &= ~SEC_READONLY; - } - } - if (link_info.relocateable) output_bfd->flags &= ~EXEC_P; else diff --git a/ld/scripttempl/elf.sc b/ld/scripttempl/elf.sc index fe8e2422dd5..fd31d037806 100644 --- a/ld/scripttempl/elf.sc +++ b/ld/scripttempl/elf.sc @@ -272,6 +272,23 @@ cat <