This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
RE: [PATCH] gcc3/ld patch for direct-linking-to-dll and auto-importsupport
- From: Danny Smith <danny_r_smith_2001 at yahoo dot co dot nz>
- To: Ralf Habacker <Ralf dot Habacker at freenet dot de>, Binutils <binutils at sources dot redhat dot com>
- Cc: Danny Smith <danny_r_smith_2001 at yahoo dot co dot nz>
- Date: Tue, 14 Oct 2003 08:36:35 +1000 (EST)
- Subject: RE: [PATCH] gcc3/ld patch for direct-linking-to-dll and auto-importsupport
--- Ralf Habacker <Ralf.Habacker@freenet.de> wrote: > Hi Danny,
>
> in the messages http://www.cygwin.com/ml/binutils/2003-09/msg00088.html you
> wrote:
>
> > >
> > > Ralf, what about a less intrusive approach? Compile dll
> > > code with -fdata-sections. This will put const data in
> > > .rdata$foo sections. Then, make pe_implied_import_dll()
> > > scan .rdata as well as .data and .bss. for data symbols
> > >
> > > I've tried that with your testcase and it seems to work.
> > >
> can this patch be applied to cvs ? If so would you apply this patch to
> binutils ?
>
> I'm asking because I have got an error report exactly for this combination
> and cygwin has updated to gcc 3.3.
>
> Thanks
>
> Ralf
Hi,
This patch allows correct identification of symbols in .rdata and
.rdata$* section as data symbols when direct importing (without import
lib) from a dll.
GCC trunk now puts initialized constants into .rdata rather than text.
When 3_3-branch reopens, I will submit backport patch to GCC. In the
interim, -fdata-sections will force initialized constants into named
.rdata$* sections.
ChangeLog
2003-10-14 Danny Smith <dannysmith@users,sourceforge.net>
* pe-dll.c (pe_implied_import_dll): Also scan .rdata sections
to identify data symbols.
Index: pe-dll.c
===================================================================
RCS file: /cvs/src/src/ld/pe-dll.c,v
retrieving revision 1.61
diff -c -3 -p -r1.61 pe-dll.c
*** pe-dll.c 2 Oct 2003 11:18:13 -0000 1.61
--- pe-dll.c 13 Oct 2003 21:17:09 -0000
*************** pe_implied_import_dll (const char *filen
*** 2442,2447 ****
--- 2442,2449 ----
will not be set by mistake, and avoids compiler warning. */
unsigned long data_start = 1;
unsigned long data_end = 0;
+ unsigned long rdata_start = 1;
+ unsigned long rdata_end = 0;
unsigned long bss_start = 1;
unsigned long bss_end = 0;
*************** pe_implied_import_dll (const char *filen
*** 2520,2525 ****
--- 2522,2536 ----
printf ("%s %s: 0x%08lx-0x%08lx (0x%08lx)\n",
__FUNCTION__, sec_name, vaddr, vaddr + vsize, flags);
}
+ else if (strcmp(sec_name,".rdata") == 0)
+ {
+ rdata_start = vaddr;
+ rdata_end = vaddr + vsize;
+
+ if (pe_dll_extra_pe_debug)
+ printf ("%s %s: 0x%08lx-0x%08lx (0x%08lx)\n",
+ __FUNCTION__, sec_name, vaddr, vaddr + vsize, flags);
+ }
else if (strcmp (sec_name,".bss") == 0)
{
bss_start = vaddr;
*************** pe_implied_import_dll (const char *filen
*** 2573,2581 ****
exported in buggy auto-import releases. */
if (strncmp (erva + name_rva, "_nm_", 4) != 0)
{
! /* is_data is true if the address is in the data or bss segment. */
is_data =
(func_rva >= data_start && func_rva < data_end)
|| (func_rva >= bss_start && func_rva < bss_end);
imp = def_file_add_import (pe_def_file, erva + name_rva,
--- 2584,2594 ----
exported in buggy auto-import releases. */
if (strncmp (erva + name_rva, "_nm_", 4) != 0)
{
! /* is_data is true if the address is in the data, rdata or bss
! segment. */
is_data =
(func_rva >= data_start && func_rva < data_end)
+ || (func_rva >= rdata_start && func_rva < rdata_end)
|| (func_rva >= bss_start && func_rva < bss_end);
imp = def_file_add_import (pe_def_file, erva + name_rva,
http://search.yahoo.com.au - Yahoo! Search
- Looking for more? Try the new Yahoo! Search