helloworld module

Flynn, Neill Neill.Flynn at itg.com
Wed Oct 26 22:04:44 UTC 2011


Hi all,

 

Not strictly a redhat issue as such.....but I'm really stuck, tried to
google the issue and just got more and more confused (after 3 days going
in circles).

 

I need to compile a kernel with a new helloworld module.....

 

I have done the following...

 

me at linux1a:/usr/src/linux-3.0.4/kernel$ sudo vi helloworld.c

 

 

                #include <linux/linkage.h>

                #include <linux/kernel.h>

                asmlinkage int sys_helloworld() {                   

                printk(KERN_EMERG "hello_world!");

                return 1;

                }

 

 

 

 

                

                me at linux1a:/usr/src/linux-3.0.4/kernel$ sudo vi Makefile

                

                obj-y += helloworld.o

 

                

                                

 

                melinux1a:/usr/src/linux-3.0.4/arch/x86/kernel$ sudo vi
/usr/src/linux-3.0.4/arch/x86/kernel/syscall_table_32.S

                .long sys_sendmmsg              /* 345 */

        .long sys_setns

        .long sys_helloworld                              

 

 

 

 

                me at linux1a:/usr/src/linux-3.0.4$ sudo vi
/usr/src/linux-3.0.4/arch/x86/include/asm/unistd_32.h

                changed:

                                #define __NR_open_by_handle_at  342

                                #define __NR_clock_adjtime      343

                                #define __NR_syncfs             344

                                #define __NR_sendmmsg           345

                                #define __NR_setns              346

                                

                                #ifdef __KERNEL__

 

                                #define NR_syscalls 347

                to:

 

                                #define __NR_open_by_handle_at  342

                                #define __NR_clock_adjtime      343

                                #define __NR_syncfs             344

                                #define __NR_sendmmsg           345

                                #define __NR_setns              346

                                #define __NR_helloworld         347

 

                                #ifdef __KERNEL__

                

                                #define NR_syscalls 348

 

                Note the two changes in the above file....

                                1)added:              #define
__NR_helloworld         347

 

                                2) changed: #define NR_syscalls 347

                                   to:      #define NR_syscalls 348

 

 

 

 

                me at linux1a:/usr/src/linux-3.0.4$ sudo vi
/usr/src/linux-3.0.4/arch/x86/include/asm/syscalls.h

                changed:

                                /* X86_32 only */

                                #ifdef CONFIG_X86_32

                

                to:

                                /* X86_32 only */

                                #ifdef CONFIG_X86_32

                                asmlinkage int sys_helloworld();

 

 

 

when I go to make the kernel, I get:

me at linux1a:/usr/src/linux-3.0.4$ date; sudo make; date

Wed Oct 26 23:35:26 IST 2011

  CHK     include/linux/version.h

  CHK     include/generated/utsrelease.h

  CALL    scripts/checksyscalls.sh

  CHK     include/generated/compile.h

  VDSOSYM arch/x86/vdso/vdso32-int80-syms.lds

  VDSOSYM arch/x86/vdso/vdso32-sysenter-syms.lds

  VDSOSYM arch/x86/vdso/vdso32-syms.lds

  LD      arch/x86/vdso/built-in.o

  LD      arch/x86/built-in.o

  LD      kernel/built-in.o

  CC [M]  kernel/helloworld.o

kernel/helloworld.c:3:16: warning: function declaration isn't a
prototype

  LD      vmlinux.o

  MODPOST vmlinux.o

WARNING: modpost: Found 3 section mismatch(es).

To see full details build your kernel with:

'make CONFIG_DEBUG_SECTION_MISMATCH=y'

  GEN     .version

  CHK     include/generated/compile.h

  UPD     include/generated/compile.h

  CC      init/version.o

  LD      init/built-in.o

  LD      .tmp_vmlinux1

arch/x86/built-in.o: In function `sys_call_table':

(.rodata+0x58c): undefined reference to `sys_helloworld'

make: *** [.tmp_vmlinux1] Error 1

Wed Oct 26 23:41:07 IST 2011

 

As I've said, I'm stuck, if this is the wrong list, please ignore with
my apologies.

 

If anyone can help, thanks in advance.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/redhat-sysadmin-list/attachments/20111026/c300ee03/attachment.htm>
-------------- next part --------------
This message is for the named person's use only. This communication is for informational purposes only and has been obtained from sources believed to be reliable, but it is not necessarily complete and its accuracy cannot be guaranteed. It is not intended as an offer or solicitation for the purchase or sale of any financial instrument or as an official confirmation of any transaction. Moreover, this material should not be construed to contain any recommendation regarding, or opinion concerning, any security. It may contain confidential, proprietary or legally privileged information. No confidentiality or privilege is waived or lost by any mistransmission. If you receive this message in error, please immediately delete it and all copies of it from your system, destroy any hard copies of it and notify the sender. You must not, directly or indirectly, use, disclose, distribute, print, or copy any part of this message if you are not the intended recipient.  Any views expressed in this message are those of the individual sender, except where the message states otherwise and the sender is authorized to state them to be the views of any such entity.

Securities products and services provided to Canadian investors are offered by ITG Canada Corp. (member CIPF and IIROC - Investment Industry Regulatory Organization of Canada), an affiliate of Investment Technology Group, Inc.

Investment research products and services are produced and offered by ITG Investment Research, Inc. and not ITG Inc. (a FINRA member firm and SIPC member).

ITG Inc. and/or its affiliates reserves the right to monitor and archive all electronic communications through its network.

ITG Inc. Member FINRA, SIPC

ITG? is a global brand that, in Europe, refers to Investment Technology Group Limited (?ITGL?) (Registered in Ireland No. 283940) and/or its wholly owned subsidiary, Investment Technology Group Europe Limited (?ITGEL?) (Registered in Ireland No. 283939). ITGL and ITGEL are authorised by the Central Bank of Ireland under the European Communities (Markets in Financial Instruments) Regulations, 2007 (as amended) and provide services within other member states of the European Community under the Markets in Financial Instruments Directive. ITGL is a member of the London Stock Exchange, Euronext and Deutsche B?rse and operates POSIT?, the multilateral trading facility. ITGEL London Branch is authorised by the UK Financial Services Authority whilst ITGEL French Branch is authorised by the Banque de France.

ITG may monitor traffic data of both business and personal e-mails. By replying to this e-mail, you consent to ITG monitoring the content of any e-mails you send to or receive from ITG.


More information about the redhat-sysadmin-list mailing list