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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T16:04:18+00:00 2026-05-16T16:04:18+00:00

I know I can get the assembler source code generated by the compiler by

  • 0

I know I can get the assembler source code generated by the compiler by using:

gcc -S ...

even though that annoyingly doesn’t give me an object file as part of the process.

But how can I get everything about the compiled code? I mean addresses, the bytes generated and so forth.

The instructions output by gcc -S do not tell me anything about instruction lengths or encodings, which is what I want to see.

  • 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-16T16:04:19+00:00Added an answer on May 16, 2026 at 4:04 pm

    I like objdump for this, but the most useful options are non-obvious – especially if you’re using it on an object file which contains relocations, rather than a final binary.

    objdump -d some_binary does a reasonable job.

    objdump -d some_object.o is less useful because calls to external functions don’t get disassembled helpfully:

    ...
    00000005 <foo>:
       5:   55                      push   %ebp
       6:   89 e5                   mov    %esp,%ebp
       8:   53                      push   %ebx
    ...
      29:   c7 04 24 00 00 00 00    movl   $0x0,(%esp)
      30:   e8 fc ff ff ff          call   31 <foo+0x2c>
      35:   89 d8                   mov    %ebx,%eax
    ...
    

    The call is actually to printf()… adding the -r flag helps with that; it marks relocations. objdump -dr some_object.o gives:

    ...
      29:   c7 04 24 00 00 00 00    movl   $0x0,(%esp)
                            2c: R_386_32    .rodata.str1.1
      30:   e8 fc ff ff ff          call   31 <foo+0x2c>
                            31: R_386_PC32  printf
    ...
    

    Then, I find it useful to see each line annotated as <symbol+offset>. objdump has a handy option for that, but it has the annoying side effect of turning off the dump of the actual bytes – objdump --prefix-addresses -dr some_object.o gives:

    ...
    00000005 <foo> push   %ebp
    00000006 <foo+0x1> mov    %esp,%ebp
    00000008 <foo+0x3> push   %ebx
    ...
    

    But it turns out that you can undo that by providing another obscure option, finally arriving at my favourite objdump incantation:

    objdump --prefix-addresses --show-raw-insn -dr file.o

    which gives output like this:

    ...
    00000005 <foo> 55                       push   %ebp
    00000006 <foo+0x1> 89 e5                        mov    %esp,%ebp
    00000008 <foo+0x3> 53                           push   %ebx
    ...
    00000029 <foo+0x24> c7 04 24 00 00 00 00        movl   $0x0,(%esp)
                            2c: R_386_32    .rodata.str1.1
    00000030 <foo+0x2b> e8 fc ff ff ff              call   00000031 <foo+0x2c>
                            31: R_386_PC32  printf
    00000035 <foo+0x30> 89 d8                       mov    %ebx,%eax
    ...
    

    And if you’ve built with debugging symbols (i.e. compiled with -g), and you replace the -dr with -Srl, it will attempt to annotate the output with the corresponding source lines.

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

Sidebar

Related Questions

I know that I can get word completion through CTRL+N & CTRL+P and code
Does anyone know how I can get rid of the following assembler warning? Code
In CassandraDB, using an ordered column family. I know you can get slices, but
I know that I can get the true bits with the simple loop, but
I know that I can get a POSIX int file handle from NSURL by
I know I can get touch events in my iPhone app. But these touch
I know you can get the SQL, but it's paramterized without the parameters being
I know I can get answers here but I was wondering if anyone knows
Does anyone know how we can get previous versions of z3 for linux 64?
Does anyone know how I can get the phone number of the device I

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.