llext: elf.h: fix wrong 32 bits length of elf64_rela fields

Fixes commit a9a82d557c ("llext: use elf_rela_t instead of elf_rel_t")

Also switch sign of (unused?) `r_addend` to unsigned.

https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.reloc.html

Issue found thanks to the following warnings when compiling in 64bits:

```
/__w/zephyr/zephyr/include/zephyr/llext/elf.h:349:29: error:
  right shift count >= width of type [-Werror=shift-count-overflow]
     349 | #define ELF64_R_SYM(i) ((i) >> 32)
```

The name `elf64_word` was admittedly confusing.

Signed-off-by: Marc Herbert <marc.herbert@intel.com>
This commit is contained in:
Marc Herbert 2024-03-10 04:23:29 +00:00 committed by Anas Nashif
commit 7eb1d3d57d
2 changed files with 7 additions and 6 deletions

View file

@ -746,9 +746,10 @@ static int llext_link(struct llext_loader *ldr, struct llext *ext, bool do_local
name = llext_string(ldr, ext, LLEXT_MEM_STRTAB, sym.st_name);
LOG_DBG("relocation %d:%d info %x (type %d, sym %d) offset %zd sym_name "
LOG_DBG("relocation %d:%d info %zx (type %zd, sym %zd) offset %zd sym_name "
"%s sym_type %d sym_bind %d sym_ndx %d",
i, j, rel.r_info, ELF_R_TYPE(rel.r_info), ELF_R_SYM(rel.r_info),
i, j, (size_t)rel.r_info, (size_t)ELF_R_TYPE(rel.r_info),
(size_t)ELF_R_SYM(rel.r_info),
(size_t)rel.r_offset, name, ELF_ST_TYPE(sym.st_info),
ELF_ST_BIND(sym.st_info), sym.st_shndx);
@ -784,9 +785,9 @@ static int llext_link(struct llext_loader *ldr, struct llext *ext, bool do_local
name, ELF_ST_TYPE(sym.st_info), ELF_ST_BIND(sym.st_info),
sym.st_shndx, (size_t)rel.r_offset, shdr.sh_link);
LOG_INF("writing relocation symbol %s type %d sym %d at addr 0x%lx "
LOG_INF("writing relocation symbol %s type %zd sym %zd at addr 0x%lx "
"addr 0x%lx",
name, ELF_R_TYPE(rel.r_info), ELF_R_SYM(rel.r_info),
name, (size_t)ELF_R_TYPE(rel.r_info), (size_t)ELF_R_SYM(rel.r_info),
op_loc, link_addr);
/* relocation */