Align source and assembly

I have a source file, converted it to assembly and added 2 instructions and generated the final elf. When I load this final elf, symbols doesnt match the source due to assembly instructions addition.

Is there a way to align them ? am using ARM cortex-M4 and cortex-M0. I have tried to edit #line in assembly file to make sure lines match with source code but that doesn't give a good alignment. Any ideas?

Parents
  • Alignment seen on T32, Tried to highlight the source code

    -----------------------------------

    ______addr/line|code_____|label____|mnemonic________________|comment______________________________________________________|

                   |...

                   |

                   |        REQUIRE _printf_percent

                   |        REQUIRE _printf_d

                   |        REQUIRE _printf_int_dec

                   |

                   |foo2 PROC

                   |

                   |                           ; PATCH TOOL - START

                 16|       PUSH {R0}

        ST:00008098|B401      foo2:     push    {r0}

                 17|       POP {R0}

        ST:0000809A|BC01                pop     {r0}

                   |#include<stdio.h>

                   |

                   |

                   |void foo2()         ------------------ this is what I inserted

                  5|{                      

    ____ST:0000809C|A011________________add_____r0,pc,#0x44

                  6|        printf("In foo2");

        ST:0000809E|F000                bl_h    0x809E

        ST:000080A0|B837                undef   0xB837

                   |

                   |

                  |}

                   |

                   |void foo1() ------------------  this is what came by default

                 12|{

        ST:000080A2|B401      foo1:     push    {r0}

                 13|        printf("In foo1");

        ST:000080A4|BC01                pop     {r0}

                   |

                   |

                  |}

                   |

                   |void foo1()------------------ this is what I inserted

                 12|{                                                    

        ST:000080A6|A011                add     r0,pc,#0x44

                 13|        printf("In foo1");

        ST:000080A8|F000                bl_h    0x80A8

        ST:000080AA|B832                undef   0xB832

                   |

                   |

                   |}

Reply
  • Alignment seen on T32, Tried to highlight the source code

    -----------------------------------

    ______addr/line|code_____|label____|mnemonic________________|comment______________________________________________________|

                   |...

                   |

                   |        REQUIRE _printf_percent

                   |        REQUIRE _printf_d

                   |        REQUIRE _printf_int_dec

                   |

                   |foo2 PROC

                   |

                   |                           ; PATCH TOOL - START

                 16|       PUSH {R0}

        ST:00008098|B401      foo2:     push    {r0}

                 17|       POP {R0}

        ST:0000809A|BC01                pop     {r0}

                   |#include<stdio.h>

                   |

                   |

                   |void foo2()         ------------------ this is what I inserted

                  5|{                      

    ____ST:0000809C|A011________________add_____r0,pc,#0x44

                  6|        printf("In foo2");

        ST:0000809E|F000                bl_h    0x809E

        ST:000080A0|B837                undef   0xB837

                   |

                   |

                  |}

                   |

                   |void foo1() ------------------  this is what came by default

                 12|{

        ST:000080A2|B401      foo1:     push    {r0}

                 13|        printf("In foo1");

        ST:000080A4|BC01                pop     {r0}

                   |

                   |

                  |}

                   |

                   |void foo1()------------------ this is what I inserted

                 12|{                                                    

        ST:000080A6|A011                add     r0,pc,#0x44

                 13|        printf("In foo1");

        ST:000080A8|F000                bl_h    0x80A8

        ST:000080AA|B832                undef   0xB832

                   |

                   |

                   |}

Children