Adding the assembly by GCC for the same program, for comparison.

On Thu, Aug 1, 2024 at 11:45, Jonathan M. Wilbur <jonathan@wilbur.space> wrote:

> Hello,
>
> When TinyCC compiles a program using nolibc's 
> [crt.h](https://github.com/torvalds/linux/blob/21b136cc63d2a9ddd60d4699552b69c214b32964/tools/include/nolibc/crt.h),
>  the resulting program always has an argc of 0, but this does not happen with 
> GCC. I simply don't have a grasp on assembly enough to see what is wrong, but 
> I have attached it if somebody could help me interpret it.
>
> Cheers,
>
> - Jonathan M. Wilbur
0000000000401540 <_start_c>:
  401540:       f3 0f 1e fa             endbr64 
  401544:       41 55                   push   %r13
  401546:       41 54                   push   %r12
  401548:       4c 8d 67 08             lea    0x8(%rdi),%r12
  40154c:       55                      push   %rbp
  40154d:       53                      push   %rbx
  40154e:       50                      push   %rax
  40154f:       48 8b 1f                mov    (%rdi),%rbx
  401552:       4c 8d 6c df 10          lea    0x10(%rdi,%rbx,8),%r13
  401557:       4c 89 2d d2 4d 00 00    mov    %r13,0x4dd2(%rip)        # 
406330 <environ>
  40155e:       4c 89 e8                mov    %r13,%rax
  401561:       48 83 c0 08             add    $0x8,%rax
  401565:       48 83 78 f8 00          cmpq   $0x0,-0x8(%rax)
  40156a:       75 f5                   jne    401561 <_start_c+0x21>
  40156c:       48 89 05 b5 4d 00 00    mov    %rax,0x4db5(%rip)        # 
406328 <_auxv>
  401573:       48 c7 c5 e0 5f 40 00    mov    $0x405fe0,%rbp
  40157a:       48 81 fd e0 5f 40 00    cmp    $0x405fe0,%rbp
  401581:       73 09                   jae    40158c <_start_c+0x4c>
  401583:       ff 55 00                callq  *0x0(%rbp)
  401586:       48 83 c5 08             add    $0x8,%rbp
  40158a:       eb ee                   jmp    40157a <_start_c+0x3a>
  40158c:       48 c7 c5 e0 5f 40 00    mov    $0x405fe0,%rbp
  401593:       48 81 fd e0 5f 40 00    cmp    $0x405fe0,%rbp
  40159a:       73 09                   jae    4015a5 <_start_c+0x65>
  40159c:       ff 55 00                callq  *0x0(%rbp)
  40159f:       48 83 c5 08             add    $0x8,%rbp
  4015a3:       eb ee                   jmp    401593 <_start_c+0x53>
  4015a5:       89 df                   mov    %ebx,%edi
  4015a7:       4c 89 ea                mov    %r13,%rdx
  4015aa:       4c 89 e6                mov    %r12,%rsi
  4015ad:       e8 4e fa ff ff          callq  401000 <main>
  4015b2:       48 c7 c3 e0 5f 40 00    mov    $0x405fe0,%rbx
  4015b9:       89 c5                   mov    %eax,%ebp
  4015bb:       48 39 1d 1e 4a 00 00    cmp    %rbx,0x4a1e(%rip)        # 
405fe0 <__fini_array_end>
  4015c2:       73 08                   jae    4015cc <_start_c+0x8c>
  4015c4:       48 83 eb 08             sub    $0x8,%rbx
  4015c8:       ff 13                   callq  *(%rbx)
  4015ca:       eb ef                   jmp    4015bb <_start_c+0x7b>
  4015cc:       89 ef                   mov    %ebp,%edi
  4015ce:       e8 51 1f 00 00          callq  403524 <sys_exit>

_______________________________________________
Tinycc-devel mailing list
Tinycc-devel@nongnu.org
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

Reply via email to