Skip to content

Commit

Permalink
fix(elf_loader): Fixed the issue of getting wrong symbol type
Browse files Browse the repository at this point in the history
  • Loading branch information
cwespressif committed Dec 19, 2024
1 parent 2f956b7 commit b3f3002
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
1 change: 1 addition & 0 deletions components/elf_loader/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

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

## v0.1.0 - 2023-08-14

Expand Down
4 changes: 2 additions & 2 deletions components/elf_loader/src/arch/esp_elf_riscv.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ int esp_elf_arch_relocate(esp_elf_t *elf, const elf32_rela_t *rela,
assert(elf && rela);

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

/* Do relocation based on relocation type */

Expand Down
4 changes: 2 additions & 2 deletions components/elf_loader/src/arch/esp_elf_xtensa.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ int esp_elf_arch_relocate(esp_elf_t *elf, const elf32_rela_t *rela,

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

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

switch (ELF_R_TYPE(rela->info)) {
case R_XTENSA_RELATIVE:
Expand Down
4 changes: 2 additions & 2 deletions components/elf_loader/src/esp_elf.c
Original file line number Diff line number Diff line change
Expand Up @@ -410,8 +410,8 @@ int esp_elf_relocate(esp_elf_t *elf, const uint8_t *pbuf)

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

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

if (comm_name[0]) {
Expand Down

0 comments on commit b3f3002

Please sign in to comment.