Re: Re: extern variables in .c and .h files

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

 



Jan Hudec <bulb@ucw.cz> schrieb am 05.12.03 11:21:30:

>On Thu, Dec 04, 2003 at 21:34:43 +0100, threadhead@web.de wrote:
>> hi!
>> 
>> i've been been coding a LKM that should be
>> able to use variables, that are declared as extern.
>> i am using a 2.4.20 kernel.
>> 
>> the module is based on some code of
>> kernel/module.c.
>> (http://lxr.linux.no/source/kernel/module.c)
>> 
>> well, i tried different stuff with that LKM now.
>> take as an example:
>> i have the tulip module loaded. with my LKM i can make use of
>> extern const char * const medianame[];
>> (http://lxr.linux.no/source/drivers/net/tulip/tulip.h)
>> and display it, when using the same declaration in my LKM.
>> 
>> but for some strange reason i cannot use
>> variables that were declared a similar way in .c files in the
>> kernel source tree.
>> for example:
>> extern const struct exception_table_entry __start___ex_table[]; (kernel/module.c)
>> 
>> why can i access extern vars from header files and not
>> from source C files, that have been compiled as
>> part of my current kernel?

> Only symbols declared EXPROT_SYMBOL (see kernel/ksyms.c) are available
> to modules. Symbols defined by modules are exported by default unless
> turned off.

> -------------------------------------------------------------------------------
> Jan 'Bulb' Hudec <bulb@ucw.cz>


Is there another way of accessing the structs in kernel/module.c that have
been declared as extern with my module?
like:

extern struct module_symbol __start___ksymtab[];
extern struct module_symbol __stop___ksymtab[];

extern const struct exception_table_entry __start___ex_table[];
extern const struct exception_table_entry __stop___ex_table[];

extern const char __start___kallsyms[] __attribute__ ((weak));
extern const char __stop___kallsyms[] __attribute__ ((weak));

--

If no, why have they been declared as extern, if modules cannot access them?

Thanks for your reply!
______________________________________________________________________________
WEB.DE FreeMail wird 5 Jahre jung! Feiern Sie mit uns und
nutzen Sie die neuen Funktionen http://f.web.de/features/?mc=021130

--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           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