add new system call - compiling error!

Discussion in 'General Computing' started by nada, May 1, 2014.

  1. nada

    nada New Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Hi,
    I downloaded kernel 2.6.32 ,and I want to add simple system call "hello world" , I followed steps - but while compiling I got these errors:

    Make[1]: no rule to make target ('block/hello/sys_hello.o' needed by 'block/hello/built-in.o')
    make ** [block/hello/]


    here is my code. I use c

    #include <linux/kernel.h>

    asmlinkage long sys_hello(void)
    {
    printk("Hello world\n");
    return 0;
    }


    This is the Makefile where I update only one line:



    ifeq ($(KBUILD_EXTMOD),)
    core-y += kernel/ mm/ fs/ ipc/ security/ crypto/ block/hello/

    vmlinux-dirs := $(patsubst %/,%,$(filter %/, $(init-y) $(init-m) \
    $(core-y) $(core-m) $(drivers-y) $(drivers-m) \
    $(net-y) $(net-m) $(libs-y) $(libs-m)))

    vmlinux-alldirs := $(sort $(vmlinux-dirs) $(patsubst %/,%,$(filter %/, \
    $(init-n) $(init-) \
    $(core-n) $(core-) $(drivers-n) $(drivers-) \
    $(net-n) $(net-) $(libs-n) $(libs-))))

    init-y := $(patsubst %/, %/built-in.o, $(init-y))
    core-y := $(patsubst %/, %/built-in.o, $(core-y))
    drivers-y := $(patsubst %/, %/built-in.o, $(drivers-y))
    net-y := $(patsubst %/, %/built-in.o, $(net-y))
    libs-y1 := $(patsubst %/, %/lib.a, $(libs-y))
    libs-y2 := $(patsubst %/, %/built-in.o, $(libs-y))
    libs-y := $(libs-y1) $(libs-y2)

    ....................
    I created another Makefile inside the folder I created named as hello

    obj-y := sys_hello.o

    I know that I should add some code in Makefile - Can you advise me what to add?

    Thanks & regards,
    N.A.S
  2. Akronix

    Akronix New Member

    Messages:
    10
    Likes Received:
    4
    Trophy Points:
    3
    Hello.
    You don't have to add more code to main Makefile, but just to fix it.
    There you are including a hypotetic directory block/hello/ (which doesn't exist), just add a whitespace between block/ and hello/.

    I've just compiled also my own kernel some days ago, but it was a more recent version: 3.2 following a internet tutorial . happy hacking!
    Last edited: May 1, 2014
    nada likes this.
  3. nada

    nada New Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Akronix, thank you so much for your quick response!

    I made a space ,and compiling is going on .Hope it works now.


    Many thanks ,you saved my life :)
  4. nada

    nada New Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Hi,
    After 3 hours of compilation , I got this error :

    ld: block: No such file: File format not recognized
    make: *** [vmlinux.o] Error 1


    How to solve this?

    Thanks
    Last edited: May 1, 2014
  5. Akronix

    Akronix New Member

    Messages:
    10
    Likes Received:
    4
    Trophy Points:
    3
    nada likes this.
  6. nada

    nada New Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Hi Akronix,
    I'm using ubuntu 10.4 , working on kernel 2.6.32..
    I downloaded a newer version of 2.6.32 kernel - v 2..6.32.61, it has been in compile for 4h till now.

    Pray it will finish successfully!

    For compiling ,I used [make oldconfig] & [make]
    Then I'll use [make install_modules install.].

    Thanks..
  7. Akronix

    Akronix New Member

    Messages:
    10
    Likes Received:
    4
    Trophy Points:
    3
    Hello again.
    But are you running ubuntu into a virtual machine or directly from the hard drive?

    I'm not really an expert of this (as I said, I've just compiled linux kernel for first time); but I'd try to compile it without install_modules. Also I'm not sure if make oldconfig is the right one, so I'd try to use a diferent configuration. Me, I used make menuconfig.

    Hope I have helped you in something, I don't think I can help you so much more.
    nada likes this.
  8. nada

    nada New Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    I use linux on VM.
    As for make oldconfig , I used it to copy all old configurations to the new kernel - I got an error if I tried to [make] first .
    I'll let you know about the result of my trial.

    Thanks a lot for your answers , your first response was really helpful!
  9. nada

    nada New Member

    Messages:
    7
    Likes Received:
    0
    Trophy Points:
    1
    Hi Akronix,
    It worked with me finally :)

Share This Page