libtool-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

RE: fix dumpbin symbol pipe (was: state of MSVC patches for HEAD)


From: Peter Ekberg
Subject: RE: fix dumpbin symbol pipe (was: state of MSVC patches for HEAD)
Date: Fri, 9 Sep 2005 10:29:27 +0200

* Ralf Wildenhues wrote on Thursday, September 08, 2005 10:26 CEST:
> * Peter Ekberg wrote on Wed, Aug 31, 2005 at 05:52:43PM CEST:
> > > * Ralf Wildenhues wrote:
> > > > awk is a possible candidate, but please try to stay within POSIX
> > > > features.
> > 
> > Here's an attempt,I bet it could be made more efficient by
> > someone with more awk experience...
> > 
> > I have tried to stay away from gawk-specific constructs,
> > as documented by "info gawk", but allowed myself to
> > use posix stuff (split with regexp in 3rd arg), even if not
> > all awk implementations are posix compliant. But who does
> > not run gawk on MinGW and Cygwin?
> 
> OK, I think we can live with this for now.

If you want to be really portable (according to "info gawk") this
is a possible (untested) change I suppose:

-      {split(\$ 0, a, /\||\r/); split(a[2], s)}
+      {split(\$ 0, b, \"\r\"); split(b[1], a, \"\|\"); split(a[2], s)}

(but you did ask for POSIX...)

> > M4 got in the way a bit, so there are a couple of $][0 and
> > a $][3 in there that makes it hard(er) to read...
> > 
> > Also, the echo of the command is warped during build, which
> > is a bit unfortunate, e.g:
> 
> *snip*
> > As seen, $0 and $3 are replaced by "./libtool" and ""
> > respectively. I guess $][0 could be replaced by $""0 to
> > get around that, but that's ugly^Hier...
> 
> I fixed all of this the same way as in the AIX case: change 
> `$][3' to `$ 3'.  awk does not mind the space.

Nice!

> > Works for me (MSVC 6 and now also MSVC 2003), ok to commit?
> 
> Works much better for me than anything before that, so I committed the
> patch below to HEAD.

Thanks!

> Thanks a lot for your work!

Dito!

> A little note to keep in mind: before we release, we have to add a
> statement that all of the new (even if documented) features are
> experimental and bound to change.

Where to put that statement? NEWS?

>  (I'm not sure if going back to not
> using $NM as dumpbin would be a better idea, and I want to keep this
> option available to our discretion.)

Not sure either, seems to work though so what the hell? And it
would also mean that my first ever awk program would be rejected,
*sulk* :-) But I suppose the global_symbol_pipe for nm could be
fixed to allow MSVC style symbols instead. I.e. symbols starting
with and containing @ or ?, in addition to what gcc generates.
Hmm, perhaps that is orthogonal? Maybe gcc also generates such
symbols?

*testing*

$ cat foo.c
__declspec(fastcall) int foo(int a) { return 0; }
$ gcc -c foo.c -o foo.o
$ nm foo.o
00000000 b .bss
00000000 d .data
00000000 t .text
00000000 T @address@hidden

Yups, orthogonal IMO, the problem with these symbols starting
with @ is of course that global_symbol_to_cdecl is, how should I
put it, harder to get right. The @4 part is significant and for
C++ there's some real work to do...

Cheers,
Peter

> 2005-09-08  Peter Ekberg  <address@hidden>
> 
>       * libltdl/m4/libtool.m4 (_LT_CMD_GLOBAL_SYMBOLS) [dumpbin]:
>       Symbols in "pick any" sections are not global. Use
>       awk, not sed, in the global_symbol_pipe so that keeping
>       track of sections is easier.
>         * doc/libtool.texi (libtool script contents): Update to hint
>         at new findings concerning "pick any" sections.
> 
> Index: doc/libtool.texi
> ===================================================================
> RCS file: /cvsroot/libtool/libtool/doc/libtool.texi,v
> retrieving revision 1.197
> diff -u -r1.197 libtool.texi
> --- doc/libtool.texi  1 Sep 2005 11:54:50 -0000       1.197
> +++ doc/libtool.texi  8 Sep 2005 08:18:33 -0000
> @@ -5017,7 +5017,8 @@
>  @end example
>  
>  The @var{size} of the global variables are not zero and the 
> @var{section}
> -of the global functions are not "UNDEF".
> +of the global functions are not "UNDEF". Symbols in "pick 
> any" sections
> +("pick any" appears in the section header) are not global either.
>  @end defvar
>  
>  @defvar RANLIB
> Index: libltdl/m4/libtool.m4
> ===================================================================
> RCS file: /cvsroot/libtool/libtool/libltdl/m4/libtool.m4,v
> retrieving revision 1.16
> diff -u -r1.16 libtool.m4
> --- libltdl/m4/libtool.m4     8 Sep 2005 07:00:03 -0000       1.16
> +++ libltdl/m4/libtool.m4     8 Sep 2005 08:18:34 -0000
> @@ -3078,11 +3078,17 @@
>      # and D for any global variable.
>      # Also find C++ and __fastcall symbols from MSVC++,
>      # which start with @ or ?.
> -    lt_cv_sys_global_symbol_pipe="$SED -n -e ['/ UNDEF 
> [^|]*()/d; / 00* UNDEF /d;
> -     s/.*().*External *| *$ac_symprfx$sympat.*/T $ac_symprfx\1 \1/p;
> -     s/.*External *| *$ac_symprfx$sympat.*/D $ac_symprfx\1 \1/p;
> -     s/.*().*External *| *\(address@hidden@?]*\).*/T \1 \1/p;
> -     s/.*External *| *\(address@hidden@?]*\).*/D \1 \1/p']"
> +    lt_cv_sys_global_symbol_pipe="$AWK ['
> +      {last_section=section; section=\$ 3}
> +      /Section length .*#relocs.*(pick any)/{hide[last_section]=1}
> +      \$ 0!~/External *\|/{next}
> +      / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next}
> +      {if(hide[section]) next}
> +      {f=0}; \$ 0~/\(\).*\|/{f=1}; {printf f ? \"T \" : \"D \"}
> +      {split(\$ 0, a, /\||\r/); split(a[2], s)}
> +      s[1]~/address@hidden/{print s[1], s[1]; next}
> +      s[1]~prfx {split(s[1],t,\"@\"); print t[1], 
> substr(t[1],length(prfx))}
> +      ' prfx=^$ac_symprfx]"
>    else
>      lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[         
> ]]\($symcode$symcode*\)[[     ]][[    
> ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
>    fi
> 




reply via email to

[Prev in Thread] Current Thread [Next in Thread]