11

AFAIK,.dllPE格式的,怎么样.lib

4

5 回答 5

9

有 2 种带有 .lib 扩展名的文件:

  1. 静态库(用于静态链接)
  2. 导入库(用于动态链接)

两者都是 COFF 文件的存档。此存档的格式是“ar 存档”。

unix (cygwin/mingw) 命令 ar 可以像 tar 命令一样解析这个文件。

如果要查看 .lib 中的存档文件,可以执行以下操作:

ar tv <name>.lib

一般来说,如果你看到 .obj 文件,就意味着它是一个静态库。如果您看到 .dll,那么它就是一个导入库。

于 2014-03-28T09:14:02.080 回答
5

我一直以为它们是COFF格式

请参阅此处了解更多信息: http: //support.microsoft.com/ ?id=121460 存档

通用对象文件格式 (COFF)

文章 ID:Q121460
创建日期:05-OCT-1994
修订日期:12-OCT-1994

本文中的信息适用于:

  • Microsoft Windows NT 操作系统版本 3.1
  • Microsoft Windows NT 高级服务器 3.1 版
  • Microsoft Windows NT 工作站 3.5 版
  • Microsoft Windows NT 服务器版本 3.5

概括

Windows NT 对可执行(图像)文件和目标文件使用一种特殊格式。这些文件中使用的格式称为可移植可执行文件 (PE) 或通用对象文件格式 (COFF) 文件。Portable Executable 的名称是指可执行文件可以在多个平台上运行的事实。本文详细介绍了PE/COFF文件格式的内部特征及其参数。

更多信息

PE/COFF 文件头由 MS-DOS 存根、文件签名、COFF 头和可选头组成。目标文件仅包含 COFF 标头,但图像文件包含上述所有标头。这些头文件中最重要的是 COFF 头文件。下表描述了存储在 COFF 标头中的信息。

Offset Size Field               Description

0       2   Machine             Number identifying type of target machine.
2       2   Number of Sections  Number of sections; indicates size of the
                                Section Table, which immediately follows
                                the headers.
4       4   Time/Date Stamp     Time and date the file was created.
8       4   Pointer to Symbol   Offset, within the COFF file, of the symbol
            Table               table.
12      4   Number of Symbols   Number of entries in the symbol table.
                                This data can be used in locating the
                                string table, which immediately follows
                                the symbol table.
16      2   Optional Header     Size of the optional header, which is
            Size                included for executable files but not
                                object files. An object file should have a
                                value of 0 here.
18      2   Characteristics     Flags indicating attributes of the file.

Windows NT 软件开发工具包 (SDK) 提供了一个名为 DUMPBIN 的实用程序。DUMPBIN 是一个 32 位工具,可显示有关 32 位通用对象文件格式 (COFF) 二进制文件的信息。DUMPBIN 仅在命令提示符下运行。您可以使用 DUMPBIN 检查以下类型的 COFF 文件:对象文件、COFF 对象的标准库、可执行文件和动态链接库 (DLL) 文件。

要运行 DUMPBIN,请使用以下语法:

DUMPBIN [options] [files]

以下是 DUMPBIN 的选项参数和定义:

    /ALL
    /ARCHIVEMEMBERS
    /DISASM
    /EXPORTS
    /HEADERS
    /IMPORTS
    /LINENUMBERS
    /LINKERMEMBER[:{1|2}]
    /OUT:filename
    /PDATA
    /RAWDATA[:{NONE|BYTES|SHORTS|LONGS}[,#]]
    /RELOCATIONS
    /SECTION:name
    /SUMMARY
    /SYMBOLS

Options          Definition

/ALL             Setting this option causes DUMPBIN to display all
                 available information except code disassembly.

/ARCHIVEMEMBERS  Setting this option causes DUMPBIN to display minimal
                 information about member objects in a library.

/DISASM          Setting this option causes DUMPBIN to show disassembly
                 of code sections, using symbols if present in the file.

/EXPORTS         This option causes DUMPBIN to list all definitions
                 exported from an executable file or DLL.

/HEADERS         Setting this option causes DUMPBIN to display the file
                 header and the header for each section. When used with a
                 library, displays the header for each member object.

/IMPORTS         This option causes DUMPBIN to list all definitions
                 imported to an executable file or DLL.

/LINENUMBERS     Setting this option causes DUMPBIN to show COFF line
                 numbers. Line numbers exist in an object file if it was
                 compiled with /Zi. An executable file or DLL contains
                 COFF line numbers if it was linked with /DEBUG and
                 /DEBUGTYPE:COFF option.

/LINKERMEMBER [[:{1|2}]]
                 Setting this option causes DUMPBIN to list public symbols
                 defined in a library. Specify the 1 argument to display
                 symbols in object order, along with their offsets. Specify
                 the 2 argument to display offsets and index numbers of
                 objects, then list the symbols in alphabetical order along
                 with the object index for each. To get both outputs,
                 specify /LINKERMEMBER without the number argument.

/OUT:<filename>  This option specifies a filename for the output.
/RAWDATA [[:{BYTES|SHORTS|LONGS|NONE}[[,number]]]]
                 Setting this option causes DUMPBIN to display the raw
                 contents of each section in the file. The arguments
                 control the format of the display, as follows:
      Argument - Result
      BYTES    - The default. Contents are displayed in hexadecimal bytes,
                 and also as ASCII if they have a printed representation.
      SHORTS   - Contents are displayed in hexadecimal words.
      LONGS    - Contents are displayed in hexadecimal longwords.
      NONE     - Raw data is suppressed. This is useful to control the
                 output of /ALL.
      number   - Displayed lines are set to a width that holds number
                 values per line.

/RELOCATIONS     Setting this option causes DUMPBIN to display any
                 relocations in the object or image.

/SECTION: <section>
              This option restricts the output to information on the
              specified section.

/SUMMARY      Setting this option causes DUMPBIN to display minimal
              information about sections, including total size. This
              option is the default if no other option is specified
              in a DUMPBIN command.

/SYMBOLS      Setting this option causes DUMPBIN to display the COFF symbol
              table. Symbol tables exist in all object files. A COFF symbol
              table appears in an image file only if it is linked with
              /DEBUG /DEBUGTYPE:COFF

替代文字

于 2010-09-28T09:44:24.360 回答
4

一些编译器(例如 Microsoft)使用COFF 格式,而一些(例如 Borland/Codegear)使用OMF 格式

这是微软的 Lib 文件内容相同,工作链接)格式的描述。

于 2010-09-28T09:56:44.527 回答
0

在十六进制编辑器(Visual Studio 2010)中检查 lib 文件,数据似乎与 unix 上的 .a 文件相同......一个 ar 存档。它的开头有两个特殊文件(名称为空),它们是某种符号列表。

编辑:发现一个重复的问题静态库 (*.lib) 文件使用哪种格式?我在哪里可以找到 *.LIB 文件结构/格式的“官方”规范?- 它有一个确认这一点的链接。

于 2011-04-05T02:43:36.977 回答
0

如果您有兴趣实际查看内容:

  • Wayne J. Radburn 的PEView可以对其进行解码
  • 并且 7-zip 也可以提供有限的视野
于 2020-01-27T03:25:10.973 回答