diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 9448475b81..2535b9e9da 100644 --- a/bfd/ChangeLog +++ b/bfd/ChangeLog @@ -1,3 +1,13 @@ +1999-07-21 Mark Elbrecht + + * coffcode.h (styp_to_sec_flags): If COFF_LONG_SECTION_NAMES and + COFF_SUPPORT_GNU_LINKONCE, mark sections whose names begin with + .gnu.linkonce with SEC_LINKONCE and SEC_LINK_DUPLICATES_DISCARD. + * coff-go32.c: (COFF_LONG_SECTION_NAMES): Define. + (COFF_SUPPORT_GNU_LINKONCE): Define. + * coff-stgo32.c: (COFF_LONG_SECTION_NAMES): Define. + (COFF_SUPPORT_GNU_LINKONCE): Define. + 1999-07-21 Ian Lance Taylor From Mark Elbrecht: diff --git a/bfd/coff-go32.c b/bfd/coff-go32.c index be4adb24f5..0b783a07a7 100644 --- a/bfd/coff-go32.c +++ b/bfd/coff-go32.c @@ -21,5 +21,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #define TARGET_SYM go32coff_vec #define TARGET_NAME "coff-go32" #define TARGET_UNDERSCORE '_' +#define COFF_LONG_SECTION_NAMES +#define COFF_SUPPORT_GNU_LINKONCE #include "coff-i386.c" diff --git a/bfd/coff-stgo32.c b/bfd/coff-stgo32.c index f1d38ba801..1868f673c5 100644 --- a/bfd/coff-stgo32.c +++ b/bfd/coff-stgo32.c @@ -39,6 +39,8 @@ #define TARGET_NAME "coff-go32-exe" #define TARGET_UNDERSCORE '_' #define COFF_GO32_EXE +#define COFF_LONG_SECTION_NAMES +#define COFF_SUPPORT_GNU_LINKONCE #include "bfd.h" diff --git a/bfd/coffcode.h b/bfd/coffcode.h index f905c940a2..185cbcf17d 100644 --- a/bfd/coffcode.h +++ b/bfd/coffcode.h @@ -687,6 +687,17 @@ styp_to_sec_flags (abfd, hdr, name) } #endif +#if defined (COFF_LONG_SECTION_NAMES) && defined (COFF_SUPPORT_GNU_LINKONCE) + /* As a GNU extension, if the name begins with .gnu.linkonce, we + only link a single copy of the section. This is used to support + g++. g++ will emit each template expansion in its own section. + The symbols will be defined as weak, so that multiple definitions + are permitted. The GNU linker extension is to actually discard + all but one of the sections. */ + if (strncmp (name, ".gnu.linkonce", sizeof ".gnu.linkonce" - 1) == 0) + sec_flags |= SEC_LINK_ONCE | SEC_LINK_DUPLICATES_DISCARD; +#endif + return (sec_flags); }