|
2 | 2 |
|
3 | 3 | The scripts for testing and playing around with libhal exceptions. |
4 | 4 |
|
5 | | -## Near Point Script? |
| 5 | +## `nearpoint.py` |
6 | 6 |
|
7 | 7 | ```plaintext |
8 | | -usage: nearpoint.py [-h] [-b BLOCK_POWER] [-s SMALL_BLOCK_POWER] [-n] file |
| 8 | +usage: nearpoint.py [-h] [-b BLOCK_POWER] [-s SMALL_BLOCK_POWER] [-e ERROR_THRESHOLD] [--auto-optimize] [--tool-prefix TOOL_PREFIX] -m MAP |
| 9 | + [-o ORDER_FILE] [-n NEARPOINT_FILE] [-v] |
| 10 | + elf_file |
| 11 | +
|
| 12 | +Generate nearpoint exception tables and linker script from a .map and .elf file |
9 | 13 |
|
10 | 14 | positional arguments: |
11 | | - file text file with a list of function addresses in your code starting from 0 to N where N is the last function |
12 | | - address, or output from the command: nm app.elf --size-sort --radix=d | grep " [Tt] " | awk '{print $1}' |
| 15 | + elf_file Path to the ELF binary |
13 | 16 |
|
14 | 17 | options: |
15 | 18 | -h, --help show this help message and exit |
16 | | - -b BLOCK_POWER, --block_power BLOCK_POWER |
17 | | - Set the block size based on a power of 2. |
18 | | - -s SMALL_BLOCK_POWER, --small_block_power SMALL_BLOCK_POWER |
19 | | - Set the small block size based on a power of 2. |
20 | | - -n, --nm The input file is actually output from an NM command: nm app.elf --size-sort --radix=d | grep " [Tt] " | awk |
21 | | - '{print $1}' |
| 19 | + -b BLOCK_POWER, --block-power BLOCK_POWER |
| 20 | + Normal block size power of 2 (0 = auto-optimize) |
| 21 | + -s SMALL_BLOCK_POWER, --small-block-power SMALL_BLOCK_POWER |
| 22 | + Small block size power of 2 (0 = auto-optimize) (NOT CURRENTLY SUPPORTED!) |
| 23 | + -e ERROR_THRESHOLD, --error-threshold ERROR_THRESHOLD |
| 24 | + Error threshold for small table generation (default: 8, min: 4) (NOT CURRENTLY SUPPORTED!) |
| 25 | + --auto-optimize Automatically find optimal block sizes (NOT CURRENTLY SUPPORTED!) |
| 26 | + --tool-prefix TOOL_PREFIX |
| 27 | + Toolchain prefix for objdump/nm (e.g., "arm-none-eabi-" or full path) |
| 28 | + -m MAP, --map MAP Path to map file for executable |
| 29 | + -o ORDER_FILE, --order_file ORDER_FILE |
| 30 | + Path to where to store the ordering file. |
| 31 | + -n NEARPOINT_FILE, --nearpoint_file NEARPOINT_FILE |
| 32 | + Path to where to store the nearpoint table. |
| 33 | + -v, --verbose Enable verbose logging |
22 | 34 | ``` |
23 | 35 |
|
24 | | -The script works with output from nm following this: |
| 36 | +You will need to pass in the map file generated by your linker as well as the |
| 37 | +final elf file. |
25 | 38 |
|
26 | 39 | ```bash |
27 | 40 | python3 nearpoint.py --tool-prefix="/path/to/arm-none-eabi/bin/" --map="app.elf.map" app.elf |
28 | 41 | ``` |
29 | 42 |
|
30 | | -After |
| 43 | +This will generate a `order.ld` file which you can add as an additonal linker |
| 44 | +script with `-Torder.ld`. The `order.ld` file uses the `INSERT BEFORE .text` |
| 45 | +directive which allows it to be added to the set of linkers and does not |
| 46 | +overtake your linker script. |
31 | 47 |
|
32 | | -What this will do is create a size sorted list of each function in the program |
33 | | -and output its starting address. This easy to execute script enable 3rd parties |
34 | | -to send us this information in a mostly erased fashion to compare against our |
35 | | -application. Even if the application does not use exceptions. |
| 48 | +This command will also generate a `nearpoint.cpp` which contains the nearpoint |
| 49 | +descriptor and the nearpoint table. |
36 | 50 |
|
37 | | -```bash |
38 | | -python3 scripts/nearpoint.py demos/multi_levels.elf.nm -n -b 10 |
| 51 | +## `prel31.py` |
| 52 | + |
| 53 | +Converts a positive relative 31-bit (or `prel31`) number and the location of the number to the absolute address of where the object points to. |
| 54 | + |
| 55 | +```plaintext |
| 56 | +usage: prel31.py [-h] [-a ADDRESS] [-e {big,little}] prel31_offset |
| 57 | +
|
| 58 | +Converts a positive relative 31-bit (or `prel31`) number and the location of the number to the absolute address of where the object points to. |
| 59 | +
|
| 60 | +positional arguments: |
| 61 | + prel31_offset value to convert |
| 62 | +
|
| 63 | +options: |
| 64 | + -h, --help show this help message and exit |
| 65 | + -a ADDRESS, --address ADDRESS |
| 66 | + Address of the prel31 offset value which is needed to get an absolute value. The default of 0 returns the relative offset |
| 67 | + from the value |
| 68 | + -e {big,little}, --endian {big,little} |
| 69 | + Set the endianess of the prel31_offset. The address must be big endian (or the way its spelled) |
39 | 70 | ``` |
0 commit comments