Date: Fri, 27 Aug 2021 15:41:30 +0200 From: =?UTF-8?B?VMSzbA==?= Coosemans <tijl@FreeBSD.org> To: Dimitry Andric <dim@FreeBSD.org>, freebsd-current@FreeBSD.org Subject: i386 kernel modules unusable due to .plt sections Message-ID: <20210827154130.7a5b141c@FreeBSD.org>
next in thread | raw e-mail | index | archive | help
Hi, I use devel/llvm* to build base and just switched to llvm12. It seems that on i386 clang12 uses R_386_PLT32 relocations for some calls to at least memset, memcpy and __stack_chk_fail (clang11 uses R_386_PC32). These are converted to R_386_JMP_SLOT relocations by the linker which aren't supported by the kernel, e.g. loading linux.ko gives "kldload: unexpected relocation type" from sys/i386/i386/elf_machdep.c. The PLT entries also depend on a base pointer in %ebx but kernel modules aren't compiled with -fPIC, so this can't work and I suspect this is a regression in clang12. The following code shows the difference between clang11 and clang12: -------- #include <string.h> void * test_memset(void *p, int c, size_t len) { return (memset(p, c, len)); } void * test_memcpy(void *dst, const void *src, size_t len) { return (memcpy(dst, src, len)); } void * test_memmove(void *dst, const void *src, size_t len) { return (memmove(dst, src, len)); } -------- Output of "readelf -r test.o" when compiled with "clang12 -c test.c -m32": r_offset r_info r_type st_value st_name 0000002c 00000504 R_386_PLT32 00000000 memset 00000067 00000304 R_386_PLT32 00000000 memcpy 000000a7 00000402 R_386_PC32 00000000 memmove With clang11: r_offset r_info r_type st_value st_name 00000036 00000502 R_386_PC32 00000000 memset 00000083 00000302 R_386_PC32 00000000 memcpy 000000d2 00000402 R_386_PC32 00000000 memmove
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20210827154130.7a5b141c>