Skip to content

Commit 83df560

Browse files
committed
Updated readme to reflect new ELF file support.
Closes #1
1 parent dbc40b4 commit 83df560

File tree

1 file changed

+46
-9
lines changed

1 file changed

+46
-9
lines changed

README.md

Lines changed: 46 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,48 @@ Kaisa the Sharp Librarian
66
[![NuGet Version](https://img.shields.io/nuget/v/Kaisa?style=flat-square)](https://www.nuget.org/packages/Kaisa/)
77
[![Sponsor](https://img.shields.io/badge/sponsor-%E2%9D%A4-lightgrey?logo=github&style=flat-square)](https://github.com/sponsors/PathogenDavid)
88

9-
Kaisa is a C# parser for [Windows `.lib` archive/library files](https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#archive-library-file-format). It is primarily intended to read import libraries, but it does provide basic support for parsing object files too.
9+
Kaisa is a C# parser for various library files consumed by linkers. It is primarily intended to support locating where and how symbols are exported by dynamic and static libraries. However basic information about unrelated object sections is exposed for advanced users.
10+
11+
The following formats are currently supported:
12+
13+
* [Windows `.lib` archive/library files](https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#archive-library-file-format)
14+
* [Linux `.a` archive files](https://refspecs.linuxfoundation.org/elf/gabi41.pdf#page=152)
15+
* [Linux `.o`/`.so` ELF files](https://refspecs.linuxfoundation.org/elf/gabi4+/contents.html)
16+
17+
It also supports automatic identification of such files. Including a best guess differentiation between Windows and Linux archives (which use the same-yet-different non-standardized format.)
18+
19+
Note that PE images (IE: `.dll` files) are not supported since linkers on Windows do not consume them.
1020

1121
## License
1222

1323
This project is licensed under the MIT License. [See the license file for details](LICENSE.txt).
1424

15-
## Library file feature support
25+
## Archive file feature support
1626

17-
The parser should tolerate any library file, but only the following information is explicitly parsed and exposed:
27+
The parser should tolerate any library archive file, but only the following information is explicitly parsed and exposed:
1828

1929
* [V1 index files](https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#first-linker-member) (AKA "first linker member")
20-
* [V2 index files](https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#second-linker-member) (AKA "second linker member")
30+
* [V2 index files*](https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#second-linker-member) (AKA "second linker member")
2131
* [The longnames file](https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#longnames-member)
22-
* [Import objects](https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-library-format)
23-
* COFF objects
32+
* [Import members*](https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#import-library-format)
33+
* COFF object members*
2434
* [Header](https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#coff-file-header-object-and-image) (all members)
25-
* Extended names from the string table (IE: `/123`) are not resolved
2635
* [The section table](https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#section-table-section-headers)
36+
* Extended names from the string table (IE: `/123`) are currently not resolved
2737
* [The symbol table](https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#coff-symbol-table), including [the string table](https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#coff-string-table).
2838
* Note that the string table is not exposed on the API surface. It is discarded after the symbol table is read.
39+
* ELF object members** (see ELF support below for details.)
40+
* Unrecognized members (only exposes a data range in case you want to parse something exotic yourself)
41+
* "Unrecognized" is tricky due to COFF members having no magic signature. For a member to be considered unrecognized, all of the following must be true:
42+
* It is not recognized as an import object
43+
* It is not recognized as an ELF file
44+
* It would have an invalid [COFF machine type](https://docs.microsoft.com/en-us/windows/win32/debug/pe-format#machine-types) if it were parsed as a COFF object
45+
46+
<sup>\* Specific to Windows archives<br>\*\* Specific to Linux archives</sup>
47+
48+
Note that the parser currently requires the symbol index file to be present. As such it cannot be used to parse non-library archive files such as `.deb` packages. It also does not currently understand BSD-style library archives (including those used on macOS.)
49+
50+
### Unsupported COFF object member features
2951

3052
The following are explicitly not parsed or exposed for COFF objects: (Although enough information is exposed that you should be able to parse them yourself.)
3153

@@ -36,9 +58,24 @@ The following are explicitly not parsed or exposed for COFF objects: (Although e
3658
* The (image-only) attribute certificate table
3759
* Delay-load import only tables (image-only)
3860

39-
There is currently no attempt at parsing System V or GNU AR archives since it is currently implemented from the Microsoft spec. Some AR archive fields that are meaningless to the Microsoft spec (such as the UID and GID) are skipped when parsing.
61+
### Other unsupported features
62+
63+
Some AR archive fields that are meaningless to the Microsoft spec (such as the UID and GID) are skipped when parsing. (They aren't particularly useful or important to linkers on Linux either, they're an artifact from archive files being a general-purpose archive format.)
64+
65+
## ELF file feature support
66+
67+
The parser should tolerate any ELF file, but only the following sections are explicitly parsed and exposed:
68+
69+
* [General and dynamic symbols tables](https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.symtab.html) (`SHT_SYMTAB` and `SHT_DYNSYM`)
70+
* Extended index tables (`SHT_SYMTAB_SHNDX`) -- Not directly exposed but extended indices are automatically resolved on symbols.
71+
* [String tables](https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.strtab.html) (`SHT_STRTAB`)
72+
* Basic metadata of other unrecognized sections
73+
* Including whether the section is a [special well-known section](https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.sheader.html#special_sections) or a non-standard operating system or processor-specific extension section.
74+
* Advanced users can extract the range of these sections for manual parsing if so desired.
75+
76+
Additionally, relevant [x64-specific extensions](https://refspecs.linuxfoundation.org/elf/x86_64-abi-0.99.pdf#page=61) are exposed. (Although not many actually affect the features we do expose.)
4077

41-
There is no support for PE (image) files. (You can probably use [System.Reflection.PortableExecutable](https://docs.microsoft.com/en-us/dotnet/api/system.reflection.portableexecutable) for those.)
78+
In theory 32-bit ELF files are supported, but their support is not regularly exercised. Big endian ELF files are not supported unless your app is running on a big endian platform. Developers with more advanced needs might consider evaluating [LibObjectFile](https://github.com/xoofx/LibObjectFile) instead.
4279

4380
## API Stability
4481

0 commit comments

Comments
 (0)