Closed LazalazaRus closed 1 month ago
it seems to be similar to this issue: https://github.com/cilynx/rtl88x2bu/issues/185
if it's the only way to add missing calls by copying function's bodies from kernel sources to the driver's sources which could be complicated since each call can be connected to other function etc: https://elixir.bootlin.com/linux/v6.10/source/fs/proc/generic.c#L782 https://elixir.bootlin.com/linux/v5.10.222/source/fs/read_write.c#L465 https://elixir.bootlin.com/linux/v5.10.222/source/kernel/sched/core.c#L6189
похоже, это похоже на эту проблему: цилинкс/rtl88x2bu#185
если это единственный способ добавить недостающие вызовы путем копирования тел функций из исходных кодов ядра в исходные коды драйвера, что может оказаться сложным, поскольку каждый вызов может быть связан с другой функцией и т. д.: https://elixir.bootlin.com/linux/v6.10/source/fs/proc/generic.c#L782 https://elixir.bootlin.com/linux/v5.10.222/source/fs/read_write.c#L465 https://elixir.bootlin.com/linux/v5.10.222/source/kernel/sched/core.c#L6189
I do not deny that this can be tried, but where do I make changes to which "file.c", mod post only lets me know /root/Desktop/rtl8188eus/8188eu.ko ?
If I keep it more or less brief, at first we tried using the original kernel headers from kernel.org to compile the module. In the end, we got an "invalid module format" error, which indicated that the module was not built for the correct kernel. After that, I tried changing vermagic, but it didn't help. Later, I got to the GKI kernel of the same version from Google — the same result. The first problem was with the headers; we needed to use the ones patched by Samsung, but at that time, they simply didn't want to publish my new kernel. When they did publish it, I started working on it and realized that the kernel was built by one build script with several intermediaries involved. After studying the build script, I extracted the correct headers and compiled a test module as the build script does, using LLVM CLANG + GCC. It successfully loaded into the kernel. I started building a driver for rtl8188xx and encountered minor code issues and a problem with modpost, which was detecting undefined kernel functions like kernel_read, proc_get, etc. At this stage, I was stuck for two or three days because I couldn't understand why it couldn't find them or where it was looking. It turned out that modpost looks in Module.symvers, which stores all the exported symbols (functions, variables) of the modules and kernel, CRC, the module or binary from which it is exported, and the macro that exports the symbol (EXPORT_SYMBOL_GPL, EXPORT_SYMBOL). So, I looked in Module.symvers and realized that the functions modpost was trying to find were not there, although they were in vermagic and System.map. I thought, "What the hell is going on?" because normally, when the kernel is compiled, it should record every symbol that is present in the build and has a macro. But for some reason, they were not there, even though the macro is there and they are in the build. I tried various options and used makeshift solutions until I reached a function that could not be replaced or removed from the code. I realized that something was filtering the symbols based on certain parameters, and the first parameter that came to mind was: symbols that are used somewhere in the code are successfully exported. It turned out to be true; they were filtered out by Google's kernel build script. I exported a couple of variables into the working environment, and finally, everything worked.
How can I fix this behavior?
ERROR: modpost: "proc_get_parent_data" [/root/Desktop/rtl8188eus/8188eu.ko] undefined! ERROR: modpost: "kernel_read" [/root/Desktop/rtl8188eus/8188eu.ko] undefined! ERROR: modpost: "yield" [/root/Desktop/rtl8188eus/8188eu.ko] undefined!