Skip to content

Commit c29e0d3

Browse files
lyakhkartben
authored andcommitted
llext: xtensa: disable relative relocations for pre-located
When building pre-located LLEXTs of ET_DYN type (shared ELF object) on Xtensa, all the R_XTENSA_RELATIVE relocations are already correct, the current code actually breaks them by mobing the value from the target address-space to a storage range address. Simply removing the recalculation solves the issue. Signed-off-by: Guennadi Liakhovetski <[email protected]>
1 parent 9ba79f0 commit c29e0d3

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

arch/xtensa/core/elf.c

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,18 @@ LOG_MODULE_DECLARE(llext, CONFIG_LLEXT_LOG_LEVEL);
3434

3535
static void xtensa_elf_relocate(struct llext_loader *ldr, struct llext *ext,
3636
const elf_rela_t *rel, uintptr_t addr,
37-
uint8_t *loc, int type, uint32_t stb)
37+
uint8_t *loc, int type, uint32_t stb,
38+
const struct llext_load_param *ldr_parm)
3839
{
3940
elf_word *got_entry = (elf_word *)loc;
4041

4142
switch (type) {
4243
case R_XTENSA_RELATIVE:
43-
;
44+
if (ldr_parm && ldr_parm->pre_located) {
45+
/* Relative relocations are already correct in the pre-located case */
46+
break;
47+
}
48+
4449
/* Relocate a local symbol: Xtensa specific. Seems to only be used with PIC */
4550
unsigned int sh_ndx;
4651

@@ -146,7 +151,8 @@ void arch_elf_relocate_local(struct llext_loader *ldr, struct llext *ext, const
146151
sh_addr = ldr->sects[LLEXT_MEM_TEXT].sh_addr;
147152
}
148153

149-
xtensa_elf_relocate(ldr, ext, rel, sh_addr, rel_addr, type, ELF_ST_BIND(sym->st_info));
154+
xtensa_elf_relocate(ldr, ext, rel, sh_addr, rel_addr, type, ELF_ST_BIND(sym->st_info),
155+
ldr_parm);
150156
}
151157

152158
/**
@@ -163,5 +169,5 @@ void arch_elf_relocate_global(struct llext_loader *ldr, struct llext *ext, const
163169
}
164170

165171
xtensa_elf_relocate(ldr, ext, rel, (uintptr_t)link_addr, rel_addr, type,
166-
ELF_ST_BIND(sym->st_info));
172+
ELF_ST_BIND(sym->st_info), NULL);
167173
}

0 commit comments

Comments
 (0)