public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
* !RE: [PATCH] gcc3/ld patch for direct-linking-to-dll and auto-importsupport
       [not found] <20030908012857.13640.qmail@web21406.mail.yahoo.com>
@ 2003-09-08  6:19 ` Ralf Habacker
  0 siblings, 0 replies; only message in thread
From: Ralf Habacker @ 2003-09-08  6:19 UTC (permalink / raw)
  To: cygwin; +Cc: binutils, kde-cygwin

Hi,


> > From: Nick Clifton <nickc at redhat dot com>
> >
> > Hi Ralf,
> >
> > > while compiling trolltechs qt/xfree library with gcc3 (3.2x) on
> > > cygwin I recognized, that the auto-import stuff in combination of
> > > recent ld does not work in case of const variables in a dll when
> > > using direct linking to a dll, because gcc put those variables into
> > > a readonly, that means the .text section.
> > >
> > > The patch and a testcase is appended. A documentation could be found
> > > in the patch file.
> >
> > Are you sure that the current linker does not work ?
> >
> > When I tried it, using the test case you supplied, but without the
> > patch applied, I got this:
> >
> >   % make
> >   ../gcc/g++ -B ../gcc/ -g  -save-temps -c -o dll.o dll.cc
> >   ../gcc/g++ -B ../gcc/ -g  --shared -L ../i686-pc-cygwin/newlib -L
> ../i686-pc-cygwin/libstdc++-v3/src/.libs dll.o -o dll.dll
> >   ../gcc/g++ -B ../gcc/ -g  -save-temps -c -o client.o client.cc
> >   ../gcc/g++ -B ../gcc/ -g  -o client client.o -L
> ../i686-pc-cygwin/newlib -L
> ../i686-pc-cygwin/libstdc++-v3/src/.libs -L. -ldll
> >   Info: resolving _var by linking to __imp__var (auto-import)
> >   Info: resolving test::var      by linking to __imp___ZN4test3varE
> (auto-import)
> >
There must be four auto imported vars.

>
> Yes, but try running ./client.exe.  Since the const data variables are
> in .text section they are treated as functions, not data.  They are
> imported without warning, but not as data.
>
> 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.
>
What gcc release you are using ?  It seems that gcc3.2 (which is the recent
cygwin release) does not support this. (See the ! below)
Are there any other gcc options to archive this ?

$ gcc --version
gcc (GCC) 3.2 20020927 (prerelease)

$ make
g++  -save-temps -fdata-sections    -c -o dll.o dll.cc

$ less dll.s
        .file   "dll.cc"
.globl _var
        .section        .data$var,"w"
        .align 4
_var:
        .long   1
.globl _constvar
!        .section        .text$constvar,""
        .align 4
_constvar:
        .long   2
!        .section        .text$_ZZ4funcvE14staticconstvar,""
        .align 4
_ZZ4funcvE14staticconstvar:
        .long   2
        .text
        .align 2
.globl __Z4funcv
        .def    __Z4funcv;      .scl    2;      .type   32;     .endef
__Z4funcv:
LFB1:
        pushl   %ebp
LCFI0:
        movl    %esp, %ebp
LCFI1:
        subl    $4, %esp
LCFI2:
        movl    $3, -4(%ebp)
        movl    $1, %eax
        leave
        ret
LFE1:
.globl __ZN4test3varE
        .section        .data$_ZN4test3varE,"w"
        .align 4
__ZN4test3varE:
        .long   4
.globl __ZN4test14staticconstvarE
!        .section        .text$_ZN4test14staticconstvarE,""
        .align 4
__ZN4test14staticconstvarE:
        .long   5



--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2003-09-08  6:19 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20030908012857.13640.qmail@web21406.mail.yahoo.com>
2003-09-08  6:19 ` !RE: [PATCH] gcc3/ld patch for direct-linking-to-dll and auto-importsupport Ralf Habacker

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).