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 295605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T06:28:22+00:00 2026-05-12T06:28:22+00:00

I wanted to know how linker resolves the printf symbol in the following assembly

  • 0

I wanted to know how linker resolves the printf symbol in the following assembly code.

#include<stdio.h>
void main()
{
     printf("Hello ");
}




    .file   "test.c"
    .def    ___main;    .scl    2;  .type   32; .endef
    .section .rdata,"dr"
LC0:
    .ascii "Hello \0"
    .text
.globl _main
    .def    _main;  .scl    2;  .type   32; .endef
_main:
    pushl   %ebp
    movl    %esp, %ebp
    subl    $8, %esp
    andl    $-16, %esp
    movl    $0, %eax
    addl    $15, %eax
    addl    $15, %eax
    shrl    $4, %eax
    sall    $4, %eax
    movl    %eax, -4(%ebp)
    movl    -4(%ebp), %eax
    call    __alloca
    call    ___main
    movl    $LC0, (%esp)
    **call  _printf**
    leave
    ret
    .def    **_printf**;    .scl    3;  .type   32; .endef

Bit of Low Level Explanation will be highly appreciated.

Thanks in advance.

  • 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-05-12T06:28:22+00:00Added an answer on May 12, 2026 at 6:28 am

    Assuming ELF file format, the assembler will generate an undefined symbol reference in the object file. This’ll look like this:

    Symbol table '.symtab' contains 11 entries:
       Num:    Value  Size Type    Bind   Vis      Ndx Name
         0: 00000000     0 NOTYPE  LOCAL  DEFAULT  UND
         1: 00000000     0 FILE    LOCAL  DEFAULT  ABS test.c
         2: 00000000     0 SECTION LOCAL  DEFAULT    1
         3: 00000000     0 SECTION LOCAL  DEFAULT    3
         4: 00000000     0 SECTION LOCAL  DEFAULT    4
         5: 00000000     0 SECTION LOCAL  DEFAULT    5
         6: 00000000     0 SECTION LOCAL  DEFAULT    6
         7: 00000000     0 SECTION LOCAL  DEFAULT    7
         8: 00000000    52 FUNC    GLOBAL DEFAULT    1 main
         9: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND printf
        10: 00000000     0 NOTYPE  GLOBAL DEFAULT  UND exit
    

    It’ll also create a relocation entry to point to the part of the code image that needs to be updated by the linker with the correct address. It’ll look like this:

    $ readelf -r test.o
    
    Relocation section '.rel.text' at offset 0x358 contains 3 entries:
     Offset     Info    Type            Sym.Value  Sym. Name
    0000001f  00000501 R_386_32          00000000   .rodata
    00000024  00000902 R_386_PC32        00000000   printf
    00000030  00000a02 R_386_PC32        00000000   exit
    

    The linker’s job is then to walk through the relocation table fixing up the code image with the final symbol addresses.

    There’s an excellent book, but I can’t find the details right now (and it’s out of print). However, this looks like it may be useful: http://www.linuxjournal.com/article/6463

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

Sidebar

Related Questions

I wanted to know that how much easy is to decompile python byte code.
I need to develop a file indexing application in python and wanted to know
I wanted to know, while deciding which language or technology to use for implementing
I wanted to know what the public opinion is about Resharper vs Devxpress CodeRush
I wanted to know why UDP is used in RTP rather than TCP ?.
Just wanted to know if it is possible to disallow the whole site for
I just wanted to know your experience with using resharper. We have a very
I just wanted to know what's the difference between clear() and str(); For example:
I am putting together a build system and wanted to know if there is
I'm looking at using OpenID for my authentication scheme and wanted to know what

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.