You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`gen-elf` is a utility for generating ELF files (Shared Objects and Relocatable Objects) specifically designed for testing ELF loaders. It simplifies the process of creating binaries with specific symbol structures and relocation entries for `elf_loader` verification.
3
+
`gen-elf` is a utility for generating ELF files (Shared Objects and Relocatable Objects) specifically designed for testing ELF loaders. It simplifies the process of creating binaries with specific symbol structures, relocation entries, and memory layouts for `elf_loader` verification.
`gen-elf` can also be used as a standalone command-line tool:
72
+
### `SymbolDesc`
73
+
Describe symbols with various scopes and types:
62
74
63
-
```bash
64
-
# Generate a default x86_64 dynamic library
65
-
cargo run -p gen-elf -- --dynamic -o ./out
66
-
67
-
# Generate for a specific architecture
68
-
cargo run -p gen-elf -- --target aarch64 --dynamic -o ./out
69
-
```
75
+
-`SymbolDesc::global_func(name, code)`: A global function.
76
+
-`SymbolDesc::global_object(name, data)`: A global variable.
77
+
-`SymbolDesc::global_tls(name, data)`: A thread-local variable.
78
+
-`SymbolDesc::undefined_func(name)`: Reference to an external function.
79
+
-`.with_scope(SymbolScope::Weak)`: Mark a symbol as weak.
70
80
71
81
## Usage in Tests
72
82
73
-
This tool is particularly useful for integration testing of `elf_loader`. You can dynamically generate an ELF with specific relocation types, load it with your loader, and verify that relocations are applied correctly.
83
+
This tool is particularly useful for integration testing of `elf_loader`. You can dynamically generate an ELF with specific relocation types, load it with your loader, and verify that relocations are applied correctly by inspecting `ElfWriteOutput`.
74
84
75
-
See `tests/gen_elf.rs` for examples.
85
+
See `tests/gen_elf.rs` for comprehensive examples.
0 commit comments