Skip to content

Commit

Permalink
Fix relocation type.
Browse files Browse the repository at this point in the history
Clang produces ELF code with relocation type 10 or 1, but ubpf expects
relocation type 2.

For more info, see:
iovisor#20

Signed-off-by: Martin Ichilevici de Oliveira <martin.i.oliveira@gmail.com>
  • Loading branch information
iomartin committed Jul 5, 2019
1 parent 507ddae commit af4a54c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion vm/ubpf_loader.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,11 +182,15 @@ ubpf_load_elf(struct ubpf_vm *vm, const void *elf, size_t elf_size, char **errms
for (j = 0; j < rel->size/sizeof(Elf64_Rel); j++) {
const Elf64_Rel *r = &rs[j];

if (ELF64_R_TYPE(r->r_info) != 2) {
if (ELF64_R_TYPE(r->r_info) == 1)
continue;

if (ELF64_R_TYPE(r->r_info) != 10) {
*errmsg = ubpf_error("bad relocation type %u", ELF64_R_TYPE(r->r_info));
goto error;
}


uint32_t sym_idx = ELF64_R_SYM(r->r_info);
if (sym_idx >= num_syms) {
*errmsg = ubpf_error("bad symbol index");
Expand Down

0 comments on commit af4a54c

Please sign in to comment.