Re: extern functions

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



2007/6/15, Devvrat Tripathi <tripathidevvrat@xxxxxxxxx>:
can we declare an extern function(or say variable) inside the kernel and
then later define it using a kernel module.


I don't think this is possible (at least it isn't in OpenSolaris). The
reason is that extern has as a  purpose to tell the compiler that it
should not worry that it can not find the function or variable. You
assure him that it is there somewhere in some file.

However, when linking all object files together, all functions should
be present, otherwise you get a linker error. If you put the function
or variable in a module, this means it is not compiled together with
the kernel and thus the linker will not know what to do with it.

In OpenSolaris this issue can be resolved by using a function which
searches for the location of a certain symbol (variable or function)
at runtime and can then execute it. In OpenSolaris this function is
called kobj_getsymvalue(), but I'm pretty sure that Linux will provide
a similar mechanism..

Thomas

--
To unsubscribe from this list: send an email with
"unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx
Please read the FAQ at http://kernelnewbies.org/FAQ


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux