From: Ian Lance Taylor Date: Sun, 12 Sep 1999 16:10:00 +0000 (+0000) Subject: 1999-09-12 Donn Terry X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=bb8fe706a0428fb66102378066d64af3796f0487;p=binutils-gdb.git 1999-09-12 Donn Terry * ldlang.c (section_already_linked): Use comdat information if it is available. --- diff --git a/ld/ChangeLog b/ld/ChangeLog index 66bf46ef053..ddd70feea17 100644 --- a/ld/ChangeLog +++ b/ld/ChangeLog @@ -23,6 +23,9 @@ 1999-09-12 Donn Terry + * ldlang.c (section_already_linked): Use comdat information if it + is available. + * emultempl/pe.em (PE_DEF_SECTION_ALIGNMENT): If OVERRIDE_SECTION_ALIGNMENT is defined, change to that. (gld_${EMULATION_NAME}_before_parse): Use EXECUTABLE_NAME if it is diff --git a/ld/ldlang.c b/ld/ldlang.c index 102ece9bc19..56a00540103 100644 --- a/ld/ldlang.c +++ b/ld/ldlang.c @@ -862,9 +862,11 @@ exp_init_os (exp) /* Sections marked with the SEC_LINK_ONCE flag should only be linked once into the output. This routine checks each sections, and arranges to discard it if a section of the same name has already - been linked. This code assumes that all relevant sections have the - SEC_LINK_ONCE flag set; that is, it does not depend solely upon the - section name. This is called via bfd_map_over_sections. */ + been linked. If the section has COMDAT information, then it uses + that to decide whether the section should be included. This code + assumes that all relevant sections have the SEC_LINK_ONCE flag set; + that is, it does not depend solely upon the section name. This is + called via bfd_map_over_sections. */ /*ARGSUSED*/ static void @@ -919,7 +921,10 @@ section_already_linked (abfd, sec, data) for (l = sec_link_once_list; l != NULL; l = l->next) { - if (strcmp (name, bfd_get_section_name (l->sec->owner, l->sec)) == 0) + if (strcmp (name, bfd_get_section_name (l->sec->owner, l->sec)) == 0 + && (sec->comdat == NULL + || l->sec->comdat == NULL + || strcmp (sec->comdat->name, l->sec->comdat->name) == 0)) { /* The section has already been linked. See if we should issue a warning. */ @@ -932,8 +937,12 @@ section_already_linked (abfd, sec, data) break; case SEC_LINK_DUPLICATES_ONE_ONLY: - einfo (_("%P: %B: warning: ignoring duplicate section `%s'\n"), - abfd, name); + if (sec->comdat == NULL) + einfo (_("%P: %B: warning: ignoring duplicate section `%s'\n"), + abfd, name); + else + einfo (_("%P: %B: warning: ignoring duplicate `%s' section symbol `%s'\n"), + abfd, name, sec->comdat->name); break; case SEC_LINK_DUPLICATES_SAME_CONTENTS: @@ -952,8 +961,13 @@ section_already_linked (abfd, sec, data) } /* Set the output_section field so that wild_doit does not - create a lang_input_section structure for this section. */ + create a lang_input_section structure for this section. + Since there might be a symbol in the section being + discarded, we must retain a pointer to the section which + we are really going to use. */ sec->output_section = bfd_abs_section_ptr; + if (sec->comdat != NULL) + sec->comdat->sec = l->sec; return; }