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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:00:52+00:00 2026-06-14T00:00:52+00:00

I am trying to get information about calling conventions from DWARF info. More specific,

  • 0

I am trying to get information about calling conventions from DWARF info. More specific, I want to get which registers / stack locations are used to pass arguments to functions. My problem is that I am getting somehow wrong information in some cases from DWARF dump. The example I am using is the following “C code”:

int __attribute__ ((fastcall)) __attribute__ ((noinline)) mult (int x, int y) {
return x*y;
}

I compile this example using the following command:

gcc -c -g -m32 test.c -o test.o

Now when I use the following command to get the dwarf dump:

dwarfdump test.o

I am getting the following information about this function:

< 2><0x00000042>      DW_TAG_formal_parameter
                        DW_AT_name                  "x"
                        DW_AT_decl_file             0x00000001 /home/khaled/Repo_current/trunk/test.c
                        DW_AT_decl_line             0x00000001
                        DW_AT_type                  <0x0000005b>
                        DW_AT_location              DW_OP_fbreg -12
< 2><0x0000004e>      DW_TAG_formal_parameter
                        DW_AT_name                  "y"
                        DW_AT_decl_file             0x00000001 /home/khaled/Repo_current/trunk/test.c
                        DW_AT_decl_line             0x00000001
                        DW_AT_type                  <0x0000005b>
                        DW_AT_location              DW_OP_fbreg -16

Looking at the DW_AT_location entries, it is some offset from the frame base. This implies they are memory arguments, but the actual calling convention “fastcall” forces passing them into registers. By looking at the disassembly of the produced object file, I can see they are copied from registers to stack locations at the entry point of the function. Is there a way to know from the dwarf dump –or using any other way– where the arguments are passed at the call initially?

Thanks,

  • 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-14T00:00:55+00:00Added an answer on June 14, 2026 at 12:00 am

    Because you are using gcc -c -g -m32 test.c -o test.o. Although it is a fastcall function, GCC still needs to generate code to save values from registers to the stack frame at the beginning of the function. Without that, any debugger or gdb cannot debug the program or they will say the argument is being optimized and not shown. It makes debugging impossible.

    In x86_64, compiler also uses some registers to pass some arguments by default, even without specifying attribute fastcall for a function. You can also find those registers are being copied to the stack as well.

    // x86_64 assembly code
    _mult:
    Leh_func_begin1:
          pushq   %rbp
    Ltmp0:
          movq    %rsp, %rbp
    Ltmp1:
          movl    %edi, -4(%rbp)
          movl    %esi, -8(%rbp)
          movl    -4(%rbp), %eax
          movl    -8(%rbp), %ecx
          imull   %ecx, %eax
    

    If you turn on optimization flag -O, -O2, -O3 (no matter -g or not), you can disassemble and find there is nothing being copied to the stack frame. And when you gdb the optimized executable file, and stop at the beginning of the function to show local variables, gdb will tell you those arguments are being optimized out.

    the dwarfdump example of the 32-bit program would look like

    0x00000083:      TAG_formal_parameter [4]  
                     AT_name( "x" )
                     AT_decl_file( "test.c" )
                     AT_decl_line( 1 )
                     AT_type( {0x0000005f} ( int ) )
                     AT_location( 0x00000000
                        0x00000000 - 0x00000003: ecx
                        0x00000003 - 0x00000018: ecx )
    
    0x00000090:      TAG_formal_parameter [4]  
                     AT_name( "y" )
                     AT_decl_file( "test.c" )
                     AT_decl_line( 1 )
                     AT_type( {0x0000005f} ( int ) )
                     AT_location( 0x0000001e
                        0x00000000 - 0x00000003: edx
                        0x00000003 - 0x00000018: edx )
    

    And you can find the generated assembly code is much simple and clean.

    _mult:
            pushl   %ebp
            movl    %esp, %ebp
            movl    %ecx, %eax
            imull   %edx, %eax
            popl    %ebp
            ret     $12
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've spend some time trying to get information about users from my OenLDAP server.
I'm trying to get information about a Windows Mobile device from a desktop application
I am trying to get some information about YouTube channel's from the YouTube API.
I am trying to get information about a movie (resolution, frame rate, bit rate,
I'm trying to get some information about Azure blob (last modified UTC date time).
I'm trying to get information from this site: http://www.gocrimson.com/sports/mbkb/2011-12/roster If you look at that
Hi I am trying to get information on an Oracle package directly from PHP
I am trying to get information on the version of Windows installed from WMI.
I'm trying to get information from a cookie into Alfresco Share. I have a
i have two tables i am trying to get information from. login table -

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.