Date: Wed, 26 Apr 2023 18:36:20 +0800 From: Zhenlei Huang <zlei@FreeBSD.org> To: FreeBSD CURRENT <freebsd-current@freebsd.org> Cc: Hans Petter Selasky <hselasky@freebsd.org>, Gleb Smirnoff <glebius@FreeBSD.org> Subject: Link modules to DYN type Message-ID: <97390FE1-1DF5-43A1-A3F4-2B945D681437@FreeBSD.org>
index | next in thread | raw e-mail
Hi, I'm recently working on https://reviews.freebsd.org/D39638 (sysctl(9): Enable vnet sysctl variables be loader tunable), the changes to `sys/kern/link_elf_obj.c` are runtime tested, but not those to `sys/kern/link_elf.c` . After some hacking I realized that `link_elf.c` is for EXEC (Executable file) or DYN (Shared object file), and `link_elf_obj.c` is for REL (Relocatable file). ``` /* link_elf.c */ static int link_elf_load_file(linker_class_t cls, const char* filename, linker_file_t* result) { ... if (hdr->e_type != ET_EXEC && hdr->e_type != ET_DYN) { error = ENOSYS; goto out; } ... } /* link_elf_obj.c */ static int link_elf_load_file(linker_class_t cls, const char *filename, linker_file_t *result) { ... if (hdr->e_type != ET_REL) { error = ENOSYS; goto out; } ... } ``` Run the following snip: ``` # find /boot/kernel -type f -name "*.ko" -exec readelf -h {} \; | grep Type ``` shows that all the kernel modules' types are `REL (Relocatable file)`. I guess if some module such as if_bridge is linked to DYN type, then I can do runtime for the changes to `sys/kern/link_elf.c`. I'm not familiar with elf and linkers, is that ( compile module and link it to DYN type ) possible ? Best regards, Zhenleihome | help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?97390FE1-1DF5-43A1-A3F4-2B945D681437>
