libtool-patches
[Top][All Lists]
Advanced

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

RE: state of MSVC patches for HEAD


From: Peter Ekberg
Subject: RE: state of MSVC patches for HEAD
Date: Wed, 31 Aug 2005 17:52:43 +0200

I wrote:
> Ralf Wildenhues wrote:
> > Hi Peter,
> > 
> > * Peter Ekberg wrote on Tue, Aug 30, 2005 at 12:43:16PM CEST:
> > > 
> > > CRAP! After fixing some problems with this patch (it doesn't work
> > > for a number of reasons, so don't waste your time trying) I have
> > > realized that sed is not the correct tool for this pipe. It is
> > > best written in some other language. Which languages can I select
> > > from? awk?
> > 
> > Before answering that:  I don't understand what exactly you are
> > trying to achieve.
> > 
> > > More context than one row plus one hold buffer is needed to
> > > determine if a symbol is global...
> > > 
> > > (Symbols marked SECTn in the above snippet should be mapped to the
> > >  nth section line)
> > 
> > Can you describe the format a bit more precisely (pointer to docs?)?
> > Then we might be able to come up with something that works better.
> > 
> > Can section lines be repeated?  Are section lines guaranteed to come
> > before their contents (or can we do separate calls to only get at
> > one or the other output?)
> > 
> > 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
> 
> 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.
> 
> An example:
> ------------8<-------------
> Microsoft (R) COFF/PE Dumper Version 7.10.3077
> Copyright (C) Microsoft Corporation.  All rights reserved.
> 
> 
> Dump of file foo1.obj
> 
> File Type: COFF OBJECT
> 
> COFF SYMBOL TABLE
> 000 00000000 DEBUG  notype       Filename     | .file
>     c:/cygwin/home/peda/libtool/head-msvc/libtool/tests/mdemo/foo1.c
> 005 005F0C05 ABS    notype       Static       | @comp.id
> 006 00000001 ABS    notype       Static       | @feat.00
> 007 00000000 SECT1  notype       Static       | .drectve
>     Section length   2A, #relocs    0, #linenums    0, 
> checksum        0
> 009 00000000 SECT2  notype       Static       | .debug$S
>     Section length   92, #relocs    0, #linenums    0, 
> checksum        0
> 00B 00000000 SECT3  notype       Static       | .data
>     Section length   28, #relocs    0, #linenums    0, 
> checksum DBF01B20
> 00D 00000010 SECT3  notype       Static       | $SG913
> 00E 00000000 SECT3  notype       Static       | $SG910
> 00F 00000004 UNDEF  notype       External     | _foo1_LTX_nothing
> 010 00000000 SECT4  notype       Static       | .text
>     Section length   57, #relocs    8, #linenums    0, 
> checksum C722AC18
> 012 00000000 SECT4  notype ()    External     | __foo1_helper
> 013 00000000 UNDEF  notype ()    External     | _sub
> 014 00000010 SECT4  notype ()    External     | _foo1_LTX_foo1
> 015 00000000 UNDEF  notype ()    External     | _printf
> 016 00000000 UNDEF  notype ()    External     | _cos
> 017 00000000 SECT5  notype       Static       | .rdata
>     Section length    8, #relocs    0, #linenums    0, checksum
> 0, selection    2 (pick any)
> 019 00000000 SECT5  notype       External     | 
> address@hidden
> 01A 00000000 UNDEF  notype ()    External     | __fltused
> 01B 00000040 SECT4  notype ()    External     | _foo1_LTX_hello
> 
> String Table Size = 0x65 bytes
> 
>   Summary
> 
>           28 .data
>           92 .debug$S
>           2A .drectve
>            8 .rdata
>           57 .text
> ------------8<-------------
> 
> 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?

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:

libtool: link: dumpbin -symbols
libltdl/loaders/.libs/libltdl_libltdl_la-preopen.obj
libltdl/.libs/libltdl_libltdl_la-lt__alloc.obj
libltdl/.libs/libltdl_libltdl_la-lt_dlloader.obj
libltdl/.libs/libltdl_libltdl_la-lt_error.obj
libltdl/.libs/libltdl_libltdl_la-ltdl.obj
libltdl/.libs/libltdl_libltdl_la-slist.obj ./libltdl/.libs/argz.obj
./libltdl/.libs/lt__dirent.obj ./libltdl/.libs/lt__strl.obj
libltdl/.libs/ltdlS.obj  | gawk '
      {last_section=section; section=}
      /Section length .*#relocs.*(pick any)/{hide[last_section]=1}
      ./libtool!~/External *\|/{next}
      / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next}
      {if(hide[section]) next}
      {f=0}; ./libtool~/\(\).*\|/{f=1}; {printf f ? "T " : "D "}
      {split(./libtool, 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=^_ | /bin/sed 's/.* //' | sort | uniq >
libltdl/.libs/ltdl.exp

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...

Works for me (MSVC 6 and now also MSVC 2003), ok to commit?

        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.text: Update to hint at new findings
        concerning "pick any" sections.

Cheers,
Peter

Attachment: head-ignore-pick-any-sections-3.patch
Description: head-ignore-pick-any-sections-3.patch


reply via email to

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