Skip to content

Commit 16e5b94

Browse files
committed
review comments
1 parent d49e507 commit 16e5b94

File tree

6 files changed

+13
-25
lines changed

6 files changed

+13
-25
lines changed

include/elf.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ typedef struct elf64_program_header {
168168
typedef int (*elf_mmu_map_cb)(uint64_t, uint64_t, uint32_t);
169169
int elf_load_image_mmu(uint8_t *image, uintptr_t *entry, elf_mmu_map_cb mmu_cb);
170170
int elf_load_image(uint8_t *image, uintptr_t *entry, int is_ext);
171-
int elf_hdr_pht_combined_size(const unsigned char *ehdr);
171+
int64_t elf_hdr_pht_combined_size(const unsigned char* ehdr);
172172
int elf_open(const unsigned char *ehdr, int *is_elf32);
173173

174174

src/elf.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ static int check_scatter_format(const unsigned char* ehdr, int is_elf32)
203203

204204
/* Returns the combined size of the elf header and program header table. This
205205
* assumes the program header table immediately follows the elf header. */
206-
int elf_hdr_pht_combined_size(const unsigned char* ehdr)
206+
int64_t elf_hdr_pht_combined_size(const unsigned char* ehdr)
207207
{
208208
int sz = 0;
209209
int is_elf32;

src/image.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1631,7 +1631,7 @@ int wolfBoot_check_flash_image_elf(uint8_t part, unsigned long* entry_out)
16311631
eh->entry, (unsigned long)entry_off, entry_count);
16321632
}
16331633

1634-
elf_hdr_sz = elf_hdr_pht_combined_size(elf_h);
1634+
elf_hdr_sz = (size_t)elf_hdr_pht_combined_size(elf_h);
16351635
wolfBoot_printf("ELF: [CHECK] Header size: %zu bytes\n", elf_hdr_sz);
16361636

16371637
/* Hash the elf header and program header in the image, assuming the PHT

tools/scripts/tc3xx/wbaurixtool.sh

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ HSM=""
4343
ELF=""
4444
OPERATIONS=()
4545

46+
# Important Constants
47+
PFLASH1_RANGE="0xA0300000-0xA0500000"
48+
4649
# Structure to hold command options
4750
declare -A KEYGEN_OPTS=(
4851
[sign_algo]="$DEFAULT_SIGN_ALGO"
@@ -208,7 +211,7 @@ do_sign() {
208211
if [[ "${SIGN_OPTS[file_ext]}" == ".elf" ]]; then
209212
local temp_file="${bin_path}.squashed"
210213
echo "Preprocessing ELF file with $SQUASHELF"
211-
"$SQUASHELF" -v --nosht -r 0xA0300000-0xA0500000 "$bin_path" "$temp_file"
214+
"$SQUASHELF" -v --nosht -r "$PFLASH1_RANGE" "$bin_path" "$temp_file"
212215
echo "Replacing original ELF with squashed version"
213216
cp "$temp_file" "$bin_path"
214217
rm "$temp_file"
@@ -241,11 +244,15 @@ do_gen_target() {
241244
local wolfboot_partition_swap_address
242245

243246
if [[ -n "${TARGET_OPTS[use_elf_format]}" ]]; then
247+
# These addresses and values must match those defined in the test-app
248+
# linker file
244249
wolfboot_partition_size=0xC0000
245250
wolfboot_partition_boot_address=0xA047C000
246251
wolfboot_partition_update_address=0xA053C000
247252
wolfboot_partition_swap_address=0xA05FC000
248253
else
254+
# These addresses and values must match those defined in the test-app
255+
# linker file
249256
wolfboot_partition_size=0x17C000
250257
wolfboot_partition_boot_address=0xA0300000
251258
wolfboot_partition_update_address=0xA047C000

tools/squashelf/README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,3 @@ squashelf [options] <input.elf> <output.elf>
6060
```bash
6161
squashelf --help
6262
```
63-
64-
## Dependencies
65-
66-
`squashelf` depends on `libelf`. You can typically install the development package for `libelf` using your system's package manager.
67-
68-
* **Debian/Ubuntu:** `sudo apt-get install libelf-dev`
69-

tools/squashelf/squashelf.c

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -107,20 +107,8 @@ static int parseRange(const char* rangeStr, AddressRange* range)
107107
char* minStr = copyStr;
108108
char* maxStr = dashPos + 1;
109109

110-
/* Check for hex or decimal format and convert */
111-
if (strncmp(minStr, "0x", 2) == 0 || strncmp(minStr, "0X", 2) == 0) {
112-
range->min = strtoull(minStr, NULL, 16);
113-
}
114-
else {
115-
range->min = strtoull(minStr, NULL, 10);
116-
}
117-
118-
if (strncmp(maxStr, "0x", 2) == 0 || strncmp(maxStr, "0X", 2) == 0) {
119-
range->max = strtoull(maxStr, NULL, 16);
120-
}
121-
else {
122-
range->max = strtoull(maxStr, NULL, 10);
123-
}
110+
range->min = strtoull(minStr, NULL, 0);
111+
range->max = strtoull(maxStr, NULL, 0);
124112

125113
free(copyStr);
126114

0 commit comments

Comments
 (0)