From 242eabea02320aecd550be46e84c2d27d4395770 Mon Sep 17 00:00:00 2001 From: Ian Lance Taylor Date: Thu, 22 Jul 1999 01:39:23 +0000 Subject: 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. --- bfd/ChangeLog | 10 ++++++++++ bfd/coff-go32.c | 2 ++ bfd/coff-stgo32.c | 2 ++ bfd/coffcode.h | 11 +++++++++++ 4 files changed, 25 insertions(+) diff --git a/bfd/ChangeLog b/bfd/ChangeLog index 9448475..2535b9e 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 be4adb2..0b783a0 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 f1d38ba..1868f67 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 f905c94..185cbcf 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); } -- cgit v1.1