Quirk with objdump on binary files compiled on a different operating system

61 Views Asked by At

I have found some odd behavior when using objdump. For an example to describe this issue, consider the simple c file:

#include <stdio.h>
int main()
{
    return 0;
}

If I then compile using the command line:

arm-none-eabi-gcc.exe -g --specs=nosys.specs -o foo.o foo.c

and run the command:

arm-none-eabi-objdump.exe -S foo.o

I can see the source code in the output

0000821c <main>:
#include <stdio.h>
int main()
{
    821c:       e52db004        push    {fp}            ; (str fp, [sp, #-4]!)
    8220:       e28db000        add     fp, sp, #0
        return 0;
    8224:       e3a03000        mov     r3, #0
    8228:       e1a00003        mov     r0, r3
    822c:       e24bd000        sub     sp, fp, #0
    8230:       e49db004        pop     {fp}            ; (ldr fp, [sp], #4)
    8234:       e12fff1e        bx      lr

All well so far.

But if I copy the foo.o to a linux machine with the same toolchain and run the objdump command

0000821c <main>:
    821c:   e52db004    push    {fp}        ; (str fp, [sp, #-4]!)
    8220:   e28db000    add fp, sp, #0
    8224:   e3a03000    mov r3, #0
    8228:   e1a00003    mov r0, r3
    822c:   e24bd000    sub sp, fp, #0
    8230:   e49db004    pop {fp}        ; (ldr fp, [sp], #4)
    8234:   e12fff1e    bx  lr

No Source code. It happens in the opposite direction, i.e compile in Linux and dump in Windows.

Anyone have any ideas why?

0

There are 0 best solutions below