From nobody Fri Aug 27 13:41:30 2021 X-Original-To: freebsd-current@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 3EBDB179FAA2 for ; Fri, 27 Aug 2021 13:41:42 +0000 (UTC) (envelope-from tijl@freebsd.org) Received: from mailsec216.isp.belgacom.be (mailsec216.isp.belgacom.be [195.238.22.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "relay.skynet.be", Issuer "GlobalSign RSA OV SSL CA 2018" (not verified)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Gx18j3BkNz4WRN; Fri, 27 Aug 2021 13:41:41 +0000 (UTC) (envelope-from tijl@freebsd.org) IronPort-SDR: 8qN7Ko9WjiI+CVUCOH0Dfykg1M/6UvhLHi10NbKIYWO29YQ7u0InPAWN9IovD9ja22/eNI3GNA XMm6K4JdfpN6pI0QzdCFuNQ9uilnlEW7AyKcB4qB1nF3cDrIScubrDkxzqztn+OoZ2KQ39sPlS z9CLkzvD9+znCR/2uTtxj0AGMqyox3fX4I/lhSjmWj64pu1+uxPXMBChbdLEz/niHFGOOx9QQZ 9/MRw202wGL+0JjpU5hZtb6NtNnc469NVXPagicXYCsw2x/8hSaUXLps0/M07fJS+V8hsQvDGz 0Q4= X-IPAS-Result: =?us-ascii?q?A2AnAABu6ihh/wSs8lFaHAEBAQEBAQcBARIBAQQEAQFAC?= =?us-ascii?q?YE8BwEBCwGDDGsBUY0FYIVigl8Bgm2YUYF8CwEBAQEBAQEBAUoEAQGHHyY0C?= =?us-ascii?q?Q4BAgQBAQEBAwIDAQEBAQUBAQYBAQEBAQEFBAGBI4UvRoI1IoQsaIEVAYYPq?= =?us-ascii?q?nWBM4EBhGiDZ4EngToBiX2EP4FLQoZOiG0EinWfSp1+glpbnkBHlViRJJYXp?= =?us-ascii?q?zJmgS5NMAiDJU8ZD44sFo4wP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HzjH85nEQQfaez3ZQJdn+3Be9mLFiDb XrrmNcBHjRCgg1rYO3viUGYQHZ6YXqoXql0sj06DaqIF4rObLuBxrub03H/VpNMa21MEVzJG mrybYiCR98ici+fCPRN1DseWuuPUYgkgC1JsEfRzL18I+/d/DZQ4Y7i1txdyffemDsJ2XpzF cvLgDLFdH19gm5dH2x+56t4u0Eokj++ IronPort-HdrOrdr: A9a23:LcqnMKnmb7bYZ0OF/5OqKMJNXiPpDfLz3DAbv31ZSRFFG/Fw9v re+8jzuiWatN6OMEtQ4OxoVJPvfZq+z+8Q3WByB8bBYOCOggLBR+sOgbcKpQeBJ8VmndQts5 uIXJIeNDSaNykesS+V2njaLz6WreP3i5yAtKPi6VcoYTBSV5pPxzpUKivzKDwNeOGRaKBJaa a01456gwDIQwVuUviG X-IronPort-Anti-Spam-Filtered: true Received: from 4.172-242-81.adsl-dyn.isp.belgacom.be (HELO kalimero.tijl.coosemans.org) ([81.242.172.4]) by relay.proximus.be with ESMTP; 27 Aug 2021 15:41:33 +0200 Received: from localhost (localhost [127.0.0.1]) by kalimero.tijl.coosemans.org (8.16.1/8.16.1) with ESMTP id 17RDfVK4002405; Fri, 27 Aug 2021 15:41:31 +0200 (CEST) (envelope-from tijl@FreeBSD.org) Date: Fri, 27 Aug 2021 15:41:30 +0200 From: =?UTF-8?B?VMSzbA==?= Coosemans To: Dimitry Andric , freebsd-current@FreeBSD.org Subject: i386 kernel modules unusable due to .plt sections Message-ID: <20210827154130.7a5b141c@FreeBSD.org> List-Id: Discussions about the use of FreeBSD-current List-Archive: https://lists.freebsd.org/archives/freebsd-current List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-current@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-Rspamd-Queue-Id: 4Gx18j3BkNz4WRN X-Spamd-Bar: / Authentication-Results: mx1.freebsd.org; none X-Spamd-Result: default: False [0.00 / 15.00]; local_wl_from(0.00)[freebsd.org]; ASN(0.00)[asn:5432, ipnet:195.238.0.0/19, country:BE] X-ThisMailContainsUnwantedMimeParts: N 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 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