How to use a variable from another c file in linux kernel?

I know how normal, and I tried, but it seems like it is not working.

In linux / net / sched / sch_htb.c, I define a variable:

unsigned int queuelength;
EXPORT_SYMBOL(queuelength);

And some actions regarding the variable are not important.

In linux / net / ipv4 / tcp_dctcp.c,

extern unsigned int queuelength;

Error using net / built-in.o:

In function `dctcp_update_alpha':
linux/net/ipv4/tcp_dctcp.c:230: undefined reference to `queuelength'

The kernel version is v4.6.

+4
source share
1 answer

It depends on how the source file that defines the variable (usually a symbol) and the source file that uses the variable (symbol) are compiled: either as part of the kernel module , or as part of the kernel kernel (i.e., embedded in the kernel).

, define-symbol.c use-symbol.c , 5 :

  • define-symbol.c use-symbol.c โ€‹โ€‹ .

    EXPORT_SYMBOL .

  • define-symbol.c โ€‹โ€‹, use-symbol.c .

    EXPORT_SYMBOL.

  • define-symbol.c , use-symbol.c โ€‹โ€‹ .

    .

  • define-symbol.c use-symbol.c .

    EXPORT_SYMBOL .

  • define-symbol.c use-symbol.c .

    EXPORT_SYMBOL.

, .

, , 3: net/ipv4/tcp_dctcp.c built-in.o, .


, โ€‹โ€‹ . , .

+1

Source: https://habr.com/ru/post/1676851/


All Articles