Setting the license for modules in the linux kernel

半城伤御伤魂 提交于 2019-12-08 21:14:23

问题


I've written some kernel modules in Ada, and I've hit a bit of a problem. License is defined as a c macro, and I can't work out what it actually is. Is it a suitable solution to simply have some c re-exporting all the c functions which require GPL if both the c and the ada module have GPL compatible licenses? Is there a better way to do this?


回答1:


Dealing with C macros is a royal PITA. I have a dream that one day C programmers will do the rest of the world a favor and quit using them.

If it were me, I'd run the macro to see what it outputs, then write some Ada code to output the equivalent.

From reading through Roland's answer, it looks to me like the implementation-defined pragma linker_section may be required.

pragma Linker_Section ( [Entity =>] LOCAL_NAME, [Section =>] static_string_EXPRESSION);

LOCAL_NAME must refer to an object that is declared at the library level. This pragma specifies the name of the linker section for the given entity. It is equivalent to __attribute__((section)) in GNU C and causes LOCAL_NAME to be placed in the static_string_EXPRESSION section of the executable (assuming the linker doesn't rename the section).




回答2:


I'm not sure if this question is a joke or not, but if you're serious about writing kernel modules in Ada, then I can't imagine that setting the module license is much of an obstacle compared to everything else you must have hit.

In any case, the module license is just a string like "license=GPL" in the .modinfo section of the .ko file. In C code, it's built by the __MODULE_INFO() macro from <linux/moduleparam.h>, which just creates an array of char that is set to the string as above, tagged with __attribute__((section(".modinfo"))).

I would guess that there is probably some analogous way to do this in Ada; if not, in the worst case, it should be possible to do with a linker script. Presumably, you already have some way of handling this anyway, to set the "vermagic=XXX" part of the .modinfo section.




回答3:


As an approach to sidestepping the problem, Could you leave the license part in C and use Annex B (Interfacing with other languages) features to access it ?

This should contain the problem at least, and allow you to move on with other modules.

At best it may allow you to examine in Ada, what the license looks like and reverse engineer it that way.




回答4:


As you are probably using GNAT, you may be able to use pragma License "to allow automated checking for appropriate license conditions with respect to the standard and modified GPL."



来源:https://stackoverflow.com/questions/11927590/setting-the-license-for-modules-in-the-linux-kernel

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