Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8073491
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T14:21:18+00:00 2026-06-05T14:21:18+00:00

I have written a sample hello.ko kernel module: #include <linux/module.h> /* Needed by all

  • 0

I have written a sample hello.ko kernel module:

#include <linux/module.h>      /* Needed by all modules */
#include <linux/kernel.h>      /* Needed for KERN_INFO */

int init_module(void)
{
        printk(KERN_INFO "Hello world.\n");
        return 0;
}

void cleanup_module(void)
{
        printk(KERN_INFO "Goodbye world 1.\n");
}

Here, I have used “printk” method which is a Kernel API exposed by Linux. I can see the Linux exported symbols in “/proc/kallsyms”. I am curious to know how do gcc/ld links the called Kernel APIs? Does gcc/ld gets address of kernel method from “/proc/kallsyms” or some other file and perform linking? If yes, how do gcc/ld get to know that? I could not any option which tells that.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T14:21:19+00:00Added an answer on June 5, 2026 at 2:21 pm

    The Linux kernel’s module loader basically contains a special-purpose runtime linker. The .ko file is really an object file like any other, and as such it comes with a symbol table. If you run nm on it (nm <path/to/some_module.ko>), you’ll see a lot of symbols marked “U”, that is, “undefined”. This includes symbols for core kernel functions that are used by the module, such as printk, __kmalloc, kfree, etc. but in many cases also symbols implemented by other modules.

    When the module is loaded, the kernel runs through the module’s undefined symbols and looks them up in the (run-time) symbol table, patching the relevant memory locations, much like any other linker. If any undefined symbols aren’t already in the symbol table, loading will fail (easy to demo by using insmod instead of modprobe as it won’t load dependencies). It also adds any symbols exported by the module to the symbol table for other modules to use, tracking dependencies so you can’t yank out a module used by another. Ilya Matveychikov has linked to the relevant code in the module loader in the comments, which will help if you want to know all the gory details.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have written a simple Hello World program. #include <stdio.h> int main() { printf(Hello
I have written some sample program and DLL to learn the concept of DLL
I have written a sample application to write to a public and private queues
Below I have written a sample program that I have written to learn about
I have written grammar for a language (sample code below) //this is a procedure
I have a sample app written in Play and Scala talking to Amazon DynamoDB
I have written a Hello, world program with JNI. Java calls c program with
Environment - C#, .net 4.0, VS 2010 Hello, I have written a simple shell
I have written simple first stage bootloader which displays Hello world using interrupt to
I have written simple code to get content from xml file to php. $xml

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.