Hi Peter, * Peter Ekberg wrote on Wed, Aug 31, 2005 at 05:52:43PM CEST: > I wrote: > > Ralf Wildenhues wrote: > > > * Peter Ekberg wrote on Tue, Aug 30, 2005 at 12:43:16PM CEST: > > > > > > > awk is a possible candidate, but please try to stay within POSIX > > > features. > > > > There is *little* documentation that I have found which is helpful. > > > > Here is some: > > http://msdn.microsoft.com/library/en-us/vccore/html/_dumpbin_2f.symbols.asp
Thanks. > > I look at the output and then try to make educated guesses, > > which has not been 100% successful. I think I'm closing in > > on the target though. *snip* > > In the above there are five section lines, and SECT5 is the > > Highest SECTn there is. This is documented in the above URL. > > > > The following are my educated guesses: > > > > Section lines are never repeated. > > > > Immediately before the nth section line, a "section symbol" > > appears which is the first reference with SECTn. This symbol > > appears to be the section name, so may contain info as > > to what kind of segment it is. I mean .drectve, .debug$S, > > .data, .text and .rdata are probably pretty standard names. > > To me, the last three look familiar, but using the section > > name to deduce section type seems fragile, so I'd go for > > the "(pick any)" string in the section line following the > > first "section symbol" of the new section instead. > > > > So, I think what's needed is to keep track of if which > > sections are marked "(pick any)", and ignore any symbols > > from those sections. > > > > This will be cumbersome to do with sed as symbols from e.g. > > the 4th section may appear after the 5th section header > > (see _foo1_LTX_hello, which should be exported), so it is > > best to keep track of all previous sections. > > > > I think awk will be a good tool to solve this, but awk is > > another tool which I will need to read up on... > > 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. > 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. > 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 a lot for your work! 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. (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.) Cheers, Ralf 2005-09-08 Peter Ekberg <[EMAIL PROTECTED]> * 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 *| *\([EMAIL PROTECTED]@?]*\).*/T \1 \1/p; - s/.*External *| *\([EMAIL PROTECTED]@?]*\).*/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]~/[EMAIL PROTECTED]/{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