This is the mail archive of the
binutils@sourceware.cygnus.com
mailing list for the binutils project.
Patch for COFF .gnu.linkonce support
- To: binutils@sourceware.cygnus.com
- Subject: Patch for COFF .gnu.linkonce support
- From: "Mark E." <snowball3@bigfoot.com>
- Date: Mon, 19 Jul 1999 19:03:12 -0400
- CC: Ian Lance Taylor <ian@zembu.com>
Attached is the patch to enable .gnu.linkonce support for COFF. I'll
send that patch to enable it for DJGPP later.
[Ian, I'm CC:ing this to you in case ORBS blocks this message again.]
For the BFD ChangeLog:
1999-07-20 Mark Elbrecht <snowball3@bigfoot.com>
* coffcode.h (styp_to_sec_flags): If both
COFF_LONG_SECTION_NAMES and
COFF_SUPPORT_GNU_LINKONCE are defined, sections whose
names begin with .gnu.linkonce are marked with the flags
SEC_LINKONCE and SEC_LINK_DUPLICATES_DISCARD. This is an
optimization for GNU C++.
Mark
Attachments: C:\djgpp\cvs\binutils1.dif
---
Mark Elbrecht, snowball3@bigfoot.com
http://snowball.frogspace.net/
Index: binutils/bfd/coffcode.h
===================================================================
RCS file: /cvs/binutils/binutils/bfd/coffcode.h,v
retrieving revision 1.6
diff -c -3 -p -r1.6 coffcode.h
*** coffcode.h 1999/07/12 10:28:52 1.6
--- coffcode.h 1999/07/19 21:05:15
*************** styp_to_sec_flags (abfd, hdr, name)
*** 687,692 ****
--- 687,703 ----
}
#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);
}