| ... | @@ -1,33 +1,33 @@ | ... | @@ -1,33 +1,33 @@ |
| 1 | /// Represents export trie used in MachO executables and dynamic libraries. | 1 | //! Represents export trie used in MachO executables and dynamic libraries. |
| 2 | /// The purpose of an export trie is to encode as compactly as possible all | 2 | //! The purpose of an export trie is to encode as compactly as possible all |
| 3 | /// export symbols for the loader `dyld`. | 3 | //! export symbols for the loader `dyld`. |
| 4 | /// The export trie encodes offset and other information using ULEB128 | 4 | //! The export trie encodes offset and other information using ULEB128 |
| 5 | /// encoding, and is part of the __LINKEDIT segment. | 5 | //! encoding, and is part of the __LINKEDIT segment. |
| 6 | /// | 6 | //! |
| 7 | /// Description from loader.h: | 7 | //! Description from loader.h: |
| 8 | /// | 8 | //! |
| 9 | /// The symbols exported by a dylib are encoded in a trie. This is a compact | 9 | //! The symbols exported by a dylib are encoded in a trie. This is a compact |
| 10 | /// representation that factors out common prefixes. It also reduces LINKEDIT pages | 10 | //! representation that factors out common prefixes. It also reduces LINKEDIT pages |
| 11 | /// in RAM because it encodes all information (name, address, flags) in one small, | 11 | //! in RAM because it encodes all information (name, address, flags) in one small, |
| 12 | /// contiguous range. The export area is a stream of nodes. The first node sequentially | 12 | //! contiguous range. The export area is a stream of nodes. The first node sequentially |
| 13 | /// is the start node for the trie. | 13 | //! is the start node for the trie. |
| 14 | /// | 14 | //! |
| 15 | /// Nodes for a symbol start with a uleb128 that is the length of the exported symbol | 15 | //! Nodes for a symbol start with a uleb128 that is the length of the exported symbol |
| 16 | /// information for the string so far. If there is no exported symbol, the node starts | 16 | //! information for the string so far. If there is no exported symbol, the node starts |
| 17 | /// with a zero byte. If there is exported info, it follows the length. | 17 | //! with a zero byte. If there is exported info, it follows the length. |
| 18 | /// | 18 | //! |
| 19 | /// First is a uleb128 containing flags. Normally, it is followed by a uleb128 encoded | 19 | //! First is a uleb128 containing flags. Normally, it is followed by a uleb128 encoded |
| 20 | /// offset which is location of the content named by the symbol from the mach_header | 20 | //! offset which is location of the content named by the symbol from the mach_header |
| 21 | /// for the image. If the flags is EXPORT_SYMBOL_FLAGS_REEXPORT, then following the flags | 21 | //! for the image. If the flags is EXPORT_SYMBOL_FLAGS_REEXPORT, then following the flags |
| 22 | /// is a uleb128 encoded library ordinal, then a zero terminated UTF8 string. If the string | 22 | //! is a uleb128 encoded library ordinal, then a zero terminated UTF8 string. If the string |
| 23 | /// is zero length, then the symbol is re-export from the specified dylib with the same name. | 23 | //! is zero length, then the symbol is re-export from the specified dylib with the same name. |
| 24 | /// If the flags is EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER, then following the flags is two | 24 | //! If the flags is EXPORT_SYMBOL_FLAGS_STUB_AND_RESOLVER, then following the flags is two |
| 25 | /// uleb128s: the stub offset and the resolver offset. The stub is used by non-lazy pointers. | 25 | //! uleb128s: the stub offset and the resolver offset. The stub is used by non-lazy pointers. |
| 26 | /// The resolver is used by lazy pointers and must be called to get the actual address to use. | 26 | //! The resolver is used by lazy pointers and must be called to get the actual address to use. |
| 27 | /// | 27 | //! |
| 28 | /// After the optional exported symbol information is a byte of how many edges (0-255) that | 28 | //! After the optional exported symbol information is a byte of how many edges (0-255) that |
| 29 | /// this node has leaving it, followed by each edge. Each edge is a zero terminated UTF8 of | 29 | //! this node has leaving it, followed by each edge. Each edge is a zero terminated UTF8 of |
| 30 | /// the addition chars in the symbol, followed by a uleb128 offset for the node that edge points to. | 30 | //! the addition chars in the symbol, followed by a uleb128 offset for the node that edge points to. |
| 31 | const Trie = @This(); | 31 | const Trie = @This(); |
| 32 | | 32 | |
| 33 | const std = @import("std"); | 33 | const std = @import("std"); |