Skip to content

Commit b3f3002

Browse files
committed
fix(elf_loader): Fixed the issue of getting wrong symbol type
1 parent 2f956b7 commit b3f3002

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

components/elf_loader/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
* Added support for the following RISC-V chips: ESP32-P4 and ESP32-C6
66
* Added support for linking other components to ELF file
7+
* Fixed the issue of getting wrong symbol type
78

89
## v0.1.0 - 2023-08-14
910

components/elf_loader/src/arch/esp_elf_riscv.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,8 @@ int esp_elf_arch_relocate(esp_elf_t *elf, const elf32_rela_t *rela,
8686
assert(elf && rela);
8787

8888
where = (uint32_t *)((uint8_t *)elf->psegment + rela->offset + elf->svaddr);
89-
ESP_LOGD(TAG, "where=%p addr=0x%x offset=0x%x",
90-
where, (int)elf->psegment, (int)rela->offset);
89+
ESP_LOGD(TAG, "type: %d, where=%p addr=0x%x offset=0x%x",
90+
ELF_R_TYPE(rela->info), where, (int)elf->psegment, (int)rela->offset);
9191

9292
/* Do relocation based on relocation type */
9393

components/elf_loader/src/arch/esp_elf_xtensa.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@ int esp_elf_arch_relocate(esp_elf_t *elf, const elf32_rela_t *rela,
8282

8383
where = (uint32_t *)esp_elf_map_sym(elf, rela->offset);
8484

85-
ESP_LOGD(TAG, "where=%p addr=0x%x offset=0x%x\n",
86-
where, (int)addr, (int)rela->offset);
85+
ESP_LOGD(TAG, "type: %d, where=%p addr=0x%x offset=0x%x\n",
86+
ELF_R_TYPE(rela->info), where, (int)addr, (int)rela->offset);
8787

8888
switch (ELF_R_TYPE(rela->info)) {
8989
case R_XTENSA_RELATIVE:

components/elf_loader/src/esp_elf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -410,8 +410,8 @@ int esp_elf_relocate(esp_elf_t *elf, const uint8_t *pbuf)
410410

411411
const elf32_sym_t *sym = &symtab[ELF_R_SYM(rela_buf.info)];
412412

413-
type = ELF_R_TYPE(rela->info);
414-
if (type == STT_COMMON || type == STT_OBJECT) {
413+
type = ELF_R_TYPE(rela_buf.info);
414+
if (type == STT_COMMON || type == STT_OBJECT || type == STT_SECTION) {
415415
const char *comm_name = strtab + sym->name;
416416

417417
if (comm_name[0]) {

0 commit comments

Comments
 (0)