Build a linux module without source code

旧巷老猫 提交于 2019-12-02 14:13:48

问题


I just wonder, whether it is possible to build/ to insert a module without the source code. Say I have downloaded an openSuse operating system, and the kernel source code did not come with it. How can I compile a module and insert the module without recompiling the kernel?

For openSuse without kernel source code, it is really hard to find exactly the same version of the source code. Even if the configuration of the kernel is different you cannot insert the module inside the current openSuse.

But this could not happen in the industry, could it? We cannot write a driver and let a user download the newest version of the source code and figure out the correct configuration.

How is this problem solved in the industry? I am curious. I am relatively new to this.


回答1:


To build a module you need the kernel headers not the entire source code. NVidia rebuilds it's kernel module this way, so this would be one way of how the industry has solved the problem. Linux is not very friendly to binary only modules and in fact the kernel developers used to routinely change ABIs and structures to break binary only modules.




回答2:


It is unclear what industrie you're talking about. Why do they use linux? Where - on the server, on the client? As desktop system?

If they know that they might need to build modules - why don't they have kernel sources?

I don't know specifically for OpenSuse, but for Ubuntu, you can download the kernel headers for the current patchlevel of your kernel. Then you can compile modules. It's not hard to find them in synaptic, the software repository managing program.




回答3:


If you are a hardware manufacturer, ideally you would get your driver in the official linux development tree, so all distributions would eventually inherit it. You will no doubt get some rather frank feedback on your original submission, and getting it accepted for inclusion would require making whatever coding style/quality, interface choice, etc changes the maintainers insist on.

If you are a small volume integrator purchasing boards with a binary-only distro already on them, realize than in addition to technical challenges, you'll probably get some grief (or worse) from ultimate customers who know they are supposed to be able to request to get the source for it.

If you are doing it for in-house use only, then you just have the technical challenges. Likely for an unmodified upstream-supported architecture you can obtain a close enough set of kernel headers, possibly from Suse, or even the upstream tree, once you figure out what you need. However, if your board has hardware which is not officially supported (lacks public data sheets) and relies on unpublished kernel patches and/or unpublished gcc patches, then you are in a tough spot - there is probably no fully aboveboard path using a system based on such a chip, unless you can reverse-engineer enough of the hardware uniqueness to be able to build your own kernel form source using a compiler you can build from source. There are a lot of grey-market Android tablets stuck in such limbo right now.

Ultimately, if your project relies on a binary of a software base such as linux or gcc which you cannot re-create from source, you are in a precarious position. If it's a project intended for more than incidental internal usage, you should probably think about switching to a platform where the necessary support code - or at least the data sheet details needed to re-implement it - is published.



来源:https://stackoverflow.com/questions/10456628/build-a-linux-module-without-source-code

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!