# How to use Linker script in kernel module



## Hrishikesh (Oct 10, 2014)

Hi,
I am new to FreeBSD and FreeBSD kernel programming and facing some issue in context to linker script.
Requesting for your inputs/pointers on the following :
I have done changes in ldscript.i386 for adding a new lookup "set" and I am able to read/get the set data successfully inside kernel using function linker_file_lookup_set. But I am unable to use the above logic for kernel module and after investigation found that the "sets" are not added for the kernel module. I feel that the ldscript.i386 is not getting used while linking the kernel module hence the above call returns that no sets are found.

I tried adding the below in kernel module's Makefile :

```
LDFLAGS+= -T @/conf/ldscript.${MACHINE_ARCH}
```
But it gives me compilation error as follow:

```
Warning: Object directory not changed from original /usr/home/hrishi/hellow
ld  -T/usr/src/sys/conf/ldscript.i386 -d -warn-common -r -d -o hello.kld hello.o
/usr/src/sys/conf/ldscript.i386:136 invalid assignment to location counter
*** Error code 1
```

Thanks & Regards,
Hrishikesh Gokhale


----------



## Hrishikesh (Oct 10, 2014)

Adding info that i am using FreeBSD 7.3


----------



## SirDice (Oct 10, 2014)

Hrishikesh said:
			
		

> Adding info that i am using FreeBSD 7.3


Please be informed that FreeBSD 7.3 has been end-of-life since March 2012 and is not supported anymore. Please upgrade to a supported version.

Topics about unsupported FreeBSD versions


----------

