To debug C program on assembly level

Andrew Haley aph@redhat.com
Sat Jul 11 18:18:00 GMT 2015


On 07/10/2015 08:12 PM, Nicholas Mc Guire wrote:
> see the Linux kernel scripts/makelst for more.

Like so:

 $ gcc -g -Wa,-adhls hello.c
AARCH64 GAS  /tmp/ccEYoCV9.s                    page 1


   1                            .cpu generic+fp+simd
   2                            .file   "hello.c"
   3                            .text
   4                    .Ltext0:
   5                            .section        .rodata
   6                            .align  3
   7                    .LC0:
   8 0000 48656C6C              .string "Hello, world!"
   8      6F2C2077
   8      6F726C64
   8      2100
   9 000e 0000                  .text
  10                            .align  2
  11                            .global main
  13                    main:
  14                    .LFB0:
  15                            .file 1 "hello.c"
   1:hello.c       **** #include <stdio.h>
   2:hello.c       ****
   3:hello.c       **** int main(void) {
  16                            .loc 1 3 0
  17                            .cfi_startproc
  18 0000 FD7BBFA9              stp     x29, x30, [sp, -16]!
  19                            .cfi_def_cfa_offset 16
  20                            .cfi_offset 29, -16
  21                            .cfi_offset 30, -8
  22 0004 FD030091              add     x29, sp, 0
  23                            .cfi_def_cfa_register 29
   4:hello.c       ****   puts("Hello, world!");
  24                            .loc 1 4 0
  25 0008 00000090              adrp    x0, .LC0
  26 000c 00000091              add     x0, x0, :lo12:.LC0
  27 0010 00000094              bl      puts
   5:hello.c       **** }
  28                            .loc 1 5 0
  29 0014 FD7BC1A8              ldp     x29, x30, [sp], 16
  30                            .cfi_restore 30
  31                            .cfi_restore 29
  32                            .cfi_def_cfa 31, 0
  33 0018 C0035FD6              ret
  34                            .cfi_endproc
  35                    .LFE0:
  37                    .Letext0:

Andrew.



More information about the Gcc-help mailing list