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
00000000004003e8 <_start_c>:
  4003e8:       55                      push   %rbp
  4003e9:       48 89 e5                mov    %rsp,%rbp
  4003ec:       48 81 ec 40 00 00 00    sub    $0x40,%rsp
  4003f3:       48 89 7d f8             mov    %rdi,-0x8(%rbp)
  4003f7:       e8 b5 4b 00 00          callq  404fb1 <__stack_chk_init>
  4003fc:       48 8b 45 f8             mov    -0x8(%rbp),%rax
  400400:       48 8b 00                mov    (%rax),%rax
  400403:       48 89 45 f0             mov    %rax,-0x10(%rbp)
  400407:       48 8b 45 f8             mov    -0x8(%rbp),%rax
  40040b:       48 83 c0 08             add    $0x8,%rax
  40040f:       48 89 45 e8             mov    %rax,-0x18(%rbp)
  400413:       48 8b 45 f0             mov    -0x10(%rbp),%rax
  400417:       48 c1 e0 03             shl    $0x3,%rax
  40041b:       48 8b 4d e8             mov    -0x18(%rbp),%rcx
  40041f:       48 01 c1                add    %rax,%rcx
  400422:       48 83 c1 08             add    $0x8,%rcx
  400426:       48 89 4d e0             mov    %rcx,-0x20(%rbp)
  40042a:       4c 8b 1d 5f 9f 20 00    mov    0x209f5f(%rip),%r11        # 
60a390 <_GLOBAL_OFFSET_TABLE_+0x18>
  400431:       49 89 0b                mov    %rcx,(%r11)
  400434:       48 8b 45 e0             mov    -0x20(%rbp),%rax
  400438:       48 89 45 c8             mov    %rax,-0x38(%rbp)
  40043c:       48 8b 45 c8             mov    -0x38(%rbp),%rax
  400440:       48 89 c1                mov    %rax,%rcx
  400443:       48 83 c0 08             add    $0x8,%rax
  400447:       48 89 45 c8             mov    %rax,-0x38(%rbp)
  40044b:       48 8b 09                mov    (%rcx),%rcx
  40044e:       48 83 f9 00             cmp    $0x0,%rcx
  400452:       0f 84 02 00 00 00       je     40045a <_start_c+0x72>
  400458:       eb e2                   jmp    40043c <_start_c+0x54>
  40045a:       48 8b 45 c8             mov    -0x38(%rbp),%rax
  40045e:       4c 8b 1d 33 9f 20 00    mov    0x209f33(%rip),%r11        # 
60a398 <_GLOBAL_OFFSET_TABLE_+0x20>
  400465:       49 89 03                mov    %rax,(%r11)
  400468:       48 8b 05 31 9f 20 00    mov    0x209f31(%rip),%rax        # 
60a3a0 <_GLOBAL_OFFSET_TABLE_+0x28>
  40046f:       48 89 45 d0             mov    %rax,-0x30(%rbp)
  400473:       48 8b 45 d0             mov    -0x30(%rbp),%rax
  400477:       48 8b 0d 2a 9f 20 00    mov    0x209f2a(%rip),%rcx        # 
60a3a8 <_GLOBAL_OFFSET_TABLE_+0x30>
  40047e:       48 39 c8                cmp    %rcx,%rax
  400481:       0f 83 2a 00 00 00       jae    4004b1 <_start_c+0xc9>
  400487:       e9 11 00 00 00          jmpq   40049d <_start_c+0xb5>
  40048c:       48 8b 45 d0             mov    -0x30(%rbp),%rax
  400490:       48 89 c1                mov    %rax,%rcx
  400493:       48 83 c0 08             add    $0x8,%rax
  400497:       48 89 45 d0             mov    %rax,-0x30(%rbp)
  40049b:       eb d6                   jmp    400473 <_start_c+0x8b>
  40049d:       48 8b 45 d0             mov    -0x30(%rbp),%rax
  4004a1:       48 89 45 c0             mov    %rax,-0x40(%rbp)
  4004a5:       4c 8b 5d c0             mov    -0x40(%rbp),%r11
  4004a9:       4d 8b 1b                mov    (%r11),%r11
  4004ac:       41 ff d3                callq  *%r11
  4004af:       eb db                   jmp    40048c <_start_c+0xa4>
  4004b1:       48 8b 05 f8 9e 20 00    mov    0x209ef8(%rip),%rax        # 
60a3b0 <_GLOBAL_OFFSET_TABLE_+0x38>
  4004b8:       48 89 45 d0             mov    %rax,-0x30(%rbp)
  4004bc:       48 8b 45 d0             mov    -0x30(%rbp),%rax
  4004c0:       48 8b 0d f1 9e 20 00    mov    0x209ef1(%rip),%rcx        # 
60a3b8 <_GLOBAL_OFFSET_TABLE_+0x40>
  4004c7:       48 39 c8                cmp    %rcx,%rax
  4004ca:       0f 83 2a 00 00 00       jae    4004fa <_start_c+0x112>
  4004d0:       e9 11 00 00 00          jmpq   4004e6 <_start_c+0xfe>
  4004d5:       48 8b 45 d0             mov    -0x30(%rbp),%rax
  4004d9:       48 89 c1                mov    %rax,%rcx
  4004dc:       48 83 c0 08             add    $0x8,%rax
  4004e0:       48 89 45 d0             mov    %rax,-0x30(%rbp)
  4004e4:       eb d6                   jmp    4004bc <_start_c+0xd4>
  4004e6:       48 8b 45 d0             mov    -0x30(%rbp),%rax
  4004ea:       48 89 45 c0             mov    %rax,-0x40(%rbp)
  4004ee:       4c 8b 5d c0             mov    -0x40(%rbp),%r11
  4004f2:       4d 8b 1b                mov    (%r11),%r11
  4004f5:       41 ff d3                callq  *%r11
  4004f8:       eb db                   jmp    4004d5 <_start_c+0xed>
  4004fa:       48 8b 45 e0             mov    -0x20(%rbp),%rax
  4004fe:       49 89 c2                mov    %rax,%r10
  400501:       48 8b 45 e8             mov    -0x18(%rbp),%rax
  400505:       48 89 c6                mov    %rax,%rsi
  400508:       8b 45 f0                mov    -0x10(%rbp),%eax
  40050b:       48 89 c7                mov    %rax,%rdi
  40050e:       4c 89 d2                mov    %r10,%rdx
  400511:       e8 3b 96 00 00          callq  409b51 <main>
  400516:       89 45 dc                mov    %eax,-0x24(%rbp)
  400519:       48 8b 05 a0 9e 20 00    mov    0x209ea0(%rip),%rax        # 
60a3c0 <_GLOBAL_OFFSET_TABLE_+0x48>
  400520:       48 89 45 d0             mov    %rax,-0x30(%rbp)
  400524:       48 8b 45 d0             mov    -0x30(%rbp),%rax
  400528:       48 8b 0d 99 9e 20 00    mov    0x209e99(%rip),%rcx        # 
60a3c8 <_GLOBAL_OFFSET_TABLE_+0x50>
  40052f:       48 39 c8                cmp    %rcx,%rax
  400532:       0f 86 1c 00 00 00       jbe    400554 <_start_c+0x16c>
  400538:       48 8b 45 d0             mov    -0x30(%rbp),%rax
  40053c:       48 83 c0 f8             add    $0xfffffffffffffff8,%rax
  400540:       48 89 45 d0             mov    %rax,-0x30(%rbp)
  400544:       48 89 45 c0             mov    %rax,-0x40(%rbp)
  400548:       4c 8b 5d c0             mov    -0x40(%rbp),%r11
  40054c:       4d 8b 1b                mov    (%r11),%r11
  40054f:       41 ff d3                callq  *%r11
  400552:       eb d0                   jmp    400524 <_start_c+0x13c>
  400554:       8b 45 dc                mov    -0x24(%rbp),%eax
  400557:       48 89 c7                mov    %rax,%rdi
  40055a:       e8 f2 06 00 00          callq  400c51 <exit>
  40055f:       c9                      leaveq 
  400560:       c3                      retq   

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

Reply via email to