This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: a little help beginning (kernel module)

Andy Falanga (afalanga) schreef op 02-05-2016 18:43:
On 05/02/2016 08:37 AM, Xen wrote:

I have never really programmed in C or using makefiles before.

Maybe I should say Makefiles ;-).

It seems to me most Linux projects I have ever seen place object files
in the same directories as source files. To me that is rather ugly.

First observations are that your question isn't about C or the GCC
compiler.  It is about a build environment and the tools which enable
that. In this case, *make* and *kbuild*. I don't believe this forum is
the right venue.  You'd probably find better support for things like on
Stack Overflow.

If you had tried to send me to the gnu make mailing list, maybe you'd have had a point. Now you might as well tell me to kill myself. Sending someone to stack overflow is like the worst thing you can do to any living person.

For real I wish I could filter all of stackoverflow's google results without having to install that Chrome addon and using Google Chrome. Real writers always give better answers. But thanks for your response anyway.

Also I am trying to compile a simple kernel module and unless I am
specifying explicitly this line form the tutorial:

Rather ambitious for, "... never really programmed in C or using
makefiles before," don't you think?

You make it sound like ambition is a bad thing. Anyway, I'm out of here. It's not like you'd have trouble using gcc unless it is some kind of build problem.

For most people at least.

And besides, maybe you'd tell me to use something other than Make. The moment you go to a specific site for a specific product, you think they will ever recommend you anything other than their own product? That means that the answers you are getting are probably not going to be the most broad-minded you can get, and those kinds of answers are usually the ones that serve you best. Anyway.

make -C /lib/modules/$(shell uname -r)/build  M=$(PWD) modules

Yes, without this, you have no hope of compiling your kernel module.
Please read more on the kernel build system to understand why:

I encountered that document yes and Have read parts of it. Anyway, I was still able to "stage" my compiling by sourcing a directory, also based on reading that document!!!! And you don't even help me with that, while it is indeed possible, at least to the extent that I myself now have found.

Then it is impossible to compile anything because you run into a
million (header file inclusion) errors that seem completely unsolvable.

Yup  ...  read up on the kernel build environment.

Have done. I don't really need "pointers" like that ;-) I'm ankle deep in them already.

Lol I think I have found a function in the kernel that takes a parameter that is never used, and the parameter is just used as a local pointer (stack variable) for receiving a return value.

I was on my way to mail the kernel list about it, maybe it'd be fun :p.

All of your questions should be answered by reading the link above and
others related to kernel development.

No they couldn't. The thing I've done was not explicitly mentioned in there. The kernel build environment uses a very strict measure. There is not really any reason to include a subdir unless you need it for a target, it seems, but I did it anyway.

See the way the document explains it you can do "obj-m += file.o" but it doesn't explain that you can also do "obj-m += directory/"

It just adds "directory" as a "build target" for no reason really. Think outside the book. Maybe you'd get somewhere.

Also, read up on "Linux Device

I'm not writing a device driver. The documentation I find online is very outdated currently. For example, the tutorial I am following still uses the old (deprecated) proc_fs system (function calls) and there is no documentation in the source files.

I'm afraid of crashing the kernel but it is hard to see whether something is actually a parameter or not "can I send NULL to this or will it crash?".

That link is to the latest
revision of the book which is, unfortunately, quite dated now. However,
the 4th edition is due out this year (I think), but nothing is yet
available online.  Nevertheless, the link to LDD3 does cover, in
sufficient depth, the kernel build environment.

Right. Well I just want to get this thing going. What I know currently is almost enough I guess. Or it is enough. Writing to a mailing list is like writing to /proc. Sometimes something just happens just because you write ;-).

I have already achieved creating a functional /proc/filename but I wonder why it didn't allow me to create deeper in the tree.......


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]