Print symbol index for unsupported relocation types
It is unlikely, but possible, that an unrecognized or unsupported relocation type is encountered while trying to load a kernel module. If this occurs we should offer the symbol index as a hint to the user. While here, fix some small style issues. Reviewed by: markj, kib (amd64 part, in D26701) Sponsored by: NetApp, Inc. Sponsored by: Klara, Inc.
This commit is contained in:
parent
194ddc011a
commit
8481aab1ac
@ -309,11 +309,11 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
case R_X86_64_NONE: /* none */
|
||||
break;
|
||||
|
||||
case R_X86_64_64: /* S + A */
|
||||
case R_X86_64_64: /* S + A */
|
||||
error = lookup(lf, symidx, 1, &addr);
|
||||
val = addr + addend;
|
||||
if (error != 0)
|
||||
return -1;
|
||||
return (-1);
|
||||
if (*where != val)
|
||||
*where = val;
|
||||
break;
|
||||
@ -325,7 +325,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
where32 = (Elf32_Addr *)where;
|
||||
val32 = (Elf32_Addr)(addr + addend - (Elf_Addr)where);
|
||||
if (error != 0)
|
||||
return -1;
|
||||
return (-1);
|
||||
if (*where32 != val32)
|
||||
*where32 = val32;
|
||||
break;
|
||||
@ -335,7 +335,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
val32 = (Elf32_Addr)(addr + addend);
|
||||
where32 = (Elf32_Addr *)where;
|
||||
if (error != 0)
|
||||
return -1;
|
||||
return (-1);
|
||||
if (*where32 != val32)
|
||||
*where32 = val32;
|
||||
break;
|
||||
@ -345,14 +345,15 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
* There shouldn't be copy relocations in kernel
|
||||
* objects.
|
||||
*/
|
||||
printf("kldload: unexpected R_COPY relocation\n");
|
||||
printf("kldload: unexpected R_COPY relocation, "
|
||||
"symbol index %ld\n", symidx);
|
||||
return (-1);
|
||||
|
||||
case R_X86_64_GLOB_DAT: /* S */
|
||||
case R_X86_64_JMP_SLOT: /* XXX need addend + offset */
|
||||
error = lookup(lf, symidx, 1, &addr);
|
||||
if (error != 0)
|
||||
return -1;
|
||||
return (-1);
|
||||
if (*where != addr)
|
||||
*where = addr;
|
||||
break;
|
||||
@ -372,8 +373,8 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("kldload: unexpected relocation type %ld\n",
|
||||
rtype);
|
||||
printf("kldload: unexpected relocation type %ld, "
|
||||
"symbol index %ld\n", rtype, symidx);
|
||||
return (-1);
|
||||
}
|
||||
return (0);
|
||||
|
@ -236,7 +236,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
case R_ARM_ABS32:
|
||||
error = lookup(lf, symidx, 1, &addr);
|
||||
if (error != 0)
|
||||
return -1;
|
||||
return (-1);
|
||||
store_ptr(where, addr + load_ptr(where));
|
||||
break;
|
||||
|
||||
@ -245,8 +245,9 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
* There shouldn't be copy relocations in kernel
|
||||
* objects.
|
||||
*/
|
||||
printf("kldload: unexpected R_COPY relocation\n");
|
||||
return -1;
|
||||
printf("kldload: unexpected R_COPY relocation, "
|
||||
"symbol index %d\n", symidx);
|
||||
return (-1);
|
||||
break;
|
||||
|
||||
case R_ARM_JUMP_SLOT:
|
||||
@ -260,9 +261,9 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("kldload: unexpected relocation type %d\n",
|
||||
rtype);
|
||||
return -1;
|
||||
printf("kldload: unexpected relocation type %d, "
|
||||
"symbol index %d\n", rtype, symidx);
|
||||
return (-1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
@ -227,7 +227,8 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
*where = val;
|
||||
break;
|
||||
default:
|
||||
printf("kldload: unexpected relocation type %d\n", rtype);
|
||||
printf("kldload: unexpected relocation type %d, "
|
||||
"symbol index %d\n", rtype, symidx);
|
||||
return (-1);
|
||||
}
|
||||
return (error);
|
||||
|
@ -213,7 +213,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
case R_386_32: /* S + A */
|
||||
error = lookup(lf, symidx, 1, &addr);
|
||||
if (error != 0)
|
||||
return -1;
|
||||
return (-1);
|
||||
addr += addend;
|
||||
if (*where != addr)
|
||||
*where = addr;
|
||||
@ -222,7 +222,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
case R_386_PC32: /* S + A - P */
|
||||
error = lookup(lf, symidx, 1, &addr);
|
||||
if (error != 0)
|
||||
return -1;
|
||||
return (-1);
|
||||
addr += addend - (Elf_Addr)where;
|
||||
if (*where != addr)
|
||||
*where = addr;
|
||||
@ -233,14 +233,15 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
* There shouldn't be copy relocations in kernel
|
||||
* objects.
|
||||
*/
|
||||
printf("kldload: unexpected R_COPY relocation\n");
|
||||
return -1;
|
||||
printf("kldload: unexpected R_COPY relocation, "
|
||||
"symbol index %d\n", symidx);
|
||||
return (-1);
|
||||
break;
|
||||
|
||||
case R_386_GLOB_DAT: /* S */
|
||||
error = lookup(lf, symidx, 1, &addr);
|
||||
if (error != 0)
|
||||
return -1;
|
||||
return (-1);
|
||||
if (*where != addr)
|
||||
*where = addr;
|
||||
break;
|
||||
@ -255,9 +256,9 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
*where = addr;
|
||||
break;
|
||||
default:
|
||||
printf("kldload: unexpected relocation type %d\n",
|
||||
rtype);
|
||||
return -1;
|
||||
printf("kldload: unexpected relocation type %d, "
|
||||
"symbol index %d\n", rtype, symidx);
|
||||
return (-1);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
@ -454,12 +454,12 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("kldload: unexpected relocation type %d\n",
|
||||
rtype);
|
||||
printf("kldload: unexpected relocation type %d, "
|
||||
"symbol index %d\n", rtype, symidx);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -262,14 +262,14 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
case R_PPC_ADDR32: /* word32 S + A */
|
||||
error = lookup(lf, symidx, 1, &addr);
|
||||
if (error != 0)
|
||||
return -1;
|
||||
return (-1);
|
||||
*where = elf_relocaddr(lf, addr + addend);
|
||||
break;
|
||||
|
||||
case R_PPC_ADDR16_LO: /* #lo(S) */
|
||||
error = lookup(lf, symidx, 1, &addr);
|
||||
if (error != 0)
|
||||
return -1;
|
||||
return (-1);
|
||||
/*
|
||||
* addend values are sometimes relative to sections
|
||||
* (i.e. .rodata) in rela, where in reality they
|
||||
@ -284,7 +284,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
case R_PPC_ADDR16_HA: /* #ha(S) */
|
||||
error = lookup(lf, symidx, 1, &addr);
|
||||
if (error != 0)
|
||||
return -1;
|
||||
return (-1);
|
||||
/*
|
||||
* addend values are sometimes relative to sections
|
||||
* (i.e. .rodata) in rela, where in reality they
|
||||
@ -311,7 +311,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
*/
|
||||
error = lookup(lf, symidx, 1, &addr);
|
||||
if (error != 0)
|
||||
return -1;
|
||||
return (-1);
|
||||
*where = elf_relocaddr(lf, addr + addend);
|
||||
break;
|
||||
|
||||
@ -323,11 +323,11 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("kldload: unexpected relocation type %d\n",
|
||||
(int) rtype);
|
||||
return -1;
|
||||
printf("kldload: unexpected relocation type %d, "
|
||||
"symbol index %d\n", (int)rtype, symidx);
|
||||
return (-1);
|
||||
}
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -342,7 +342,7 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
case R_PPC64_ADDR64: /* doubleword64 S + A */
|
||||
error = lookup(lf, symidx, 1, &addr);
|
||||
if (error != 0)
|
||||
return -1;
|
||||
return (-1);
|
||||
addr += addend;
|
||||
*where = addr;
|
||||
break;
|
||||
@ -369,11 +369,11 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("kldload: unexpected relocation type %d\n",
|
||||
(int) rtype);
|
||||
return -1;
|
||||
printf("kldload: unexpected relocation type %d, "
|
||||
"symbol index %d\n", (int)rtype, symidx);
|
||||
return (-1);
|
||||
}
|
||||
return(0);
|
||||
return (0);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -479,7 +479,8 @@ elf_reloc_internal(linker_file_t lf, Elf_Addr relocbase, const void *data,
|
||||
break;
|
||||
|
||||
default:
|
||||
printf("kldload: unexpected relocation type %ld\n", rtype);
|
||||
printf("kldload: unexpected relocation type %ld, "
|
||||
"symbol index %ld\n", rtype, symidx);
|
||||
return (-1);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user