RE: How to link the module ?

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

 



Thanks to all!!
Able to get it linked.

Changed the linking command to 

ld -m elf_i386 -r -o driver.o main.o. pipe.o fifo.o msg_q.o

Nobody told me about the use of -m option and elf_i386 value given to
liker.
Can someone please make clear, what is the use of "-m elf_i386" in
linking command. On man pages of ld its mentioned that -m is used to
specify different emulation, what does that mean?

Regards,
GD.


-----Original Message-----
From: mohanlal jangir [mailto:mohanlal@samsung.com] 
Sent: Tuesday, June 22, 2004 2:13 PM
To: Dhiman, Gaurav; Vishwas Raman
Cc: Kernel Newbies
Subject: Re: How to link the module ?

You have to give output file name after -o option.
Change ld $(LFLAGS) main.o pipe.o fifo.o msg_q.o
to ld $(LFLAGS) $@ main.o pipe.o fifo.o msg_q.o

Regards
Mohanlal

----- Original Message ----- 
From: "Dhiman, Gaurav" <Gaurav.Dhiman@ca.com>
To: "Vishwas Raman" <vishwas@eternal-systems.com>
Cc: "Kernel Newbies" <kernelnewbies@nl.linux.org>
Sent: Tuesday, June 22, 2004 11:37 AM
Subject: RE: How to link the module ?



Hi,

I tried what you suggested, but when I run that command it gives a lot
of linking errors saying multiple definations of functions.

I looked for the same on net and found one simple makefile containing
the following command for linking:

ld -m elf_i386 -r -o pipe.c fifo.c msg_q.c main.c

When I include this linking command in my Makefile, it does not give any
error and creates the corresponding .o file for each .c file but does
not create the single relocatable object file through which I can load
or unload the module. I do not get any error with following makefile,
but at the same time it does not link the .o file to make final module.
Please let me know what the problem is

Also please explain me about -m option of 'ld', whats the use of this
option ?

I am pasting below my Makefile for your reference

******************************************
Makefile - Starts
******************************************

KERNELDIR = /usr/src/linux-2.4

CC = gcc

include $(KERNELDIR)/include/linux/config.h

CFLAGS = -I$(KERNELDIR)/include  -D__KERNEL__ -DMODULE \
   -O -Wall -c

LFLAGS = -m elf_i386 -r -o

ifdef CONFIG_SMP
CFLAGS +=  -DSMP
endif

all: driver.o

driver.o: main.o pipe.o fifo.o msg_q.o
ld $(LFLAGS) main.o pipe.o fifo.o msg_q.o

main.o: main.c
$(CC) $(CFLAGS) main.c

fifo.o: fifo.c
$(CC) $(CFLAGS) fifo.c

pipe.o: pipe.c
$(CC) $(CFLAGS) pipe.c

msg_q.o: msg_q.c
$(CC) $(CFLAGS) msg_q.c

#all: main.o pipe.o fifo.o msg_q.o
# $(CC) $(CFLAGS) main.c pipe.c fifo.c msg_q.c

clean:
rm -f *.o *~ core

******************************************
Makefile - Ends
******************************************

Regards,
GD.



-----Original Message-----
From: kernelnewbies-bounce@nl.linux.org
[mailto:kernelnewbies-bounce@nl.linux.org] On Behalf Of Vishwas Raman
Sent: Monday, June 21, 2004 10:02 PM
To: Gaurav Dhiman
Cc: Kernel Newbies
Subject: Re: How to link the module ?

ld -r *.o -o complete_module.o

and then do an insmod on complete_module.o to insert the module in the
running kernel.

this should work.

-Vishwas.


On Mon, 2004-06-21 at 07:43, Gaurav Dhiman wrote:
> Hi,
>  
> I have made the multi source file module and compiled it sucssufully
> with following comand:
>  
> gcc - c main.c pipe.c fifo.c msg_q.c
>  
> Now I have the corresponding .o file with me. Can someone tell me how
> can I link it to each other to form one file of module. How can we
> resolve the internal reference (reference to our own variable and
> functions) without getting any errors or warninng for kernel symbols.
> I know kernel symbols are resolved at load time by 'insmod'.
> Please let me know how to resolve the internal symbols and get one
> file for module which we can load using 'insmod'. Please let me know
> the command.
>  
> Regards,
> Gaurav.
>  
> 
> 
> ______________________________________________________________________
> Do you Yahoo!?
> New and Improved Yahoo! Mail - 100MB free storage!


--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/



--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/





--
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