tinycc-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Tinycc-devel] if (0 == 1) { some_code(); }


From: Sergey Korshunoff
Subject: Re: [Tinycc-devel] if (0 == 1) { some_code(); }
Date: Sun, 24 Apr 2016 11:58:20 +0300

> May be it don't generate a code, but a reference to the
A test program:

extern int printf(const char *format, ...);
main() {
    if(0 == 1)
        printf("There must be not printf reference in *.o\n");
    return 0;
}

a gcc test.o disassembled:
Disassembly of section .text:
00000000 <main>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   83 ec 08                sub    $0x8,%esp
   6:   83 e4 f0                and    $0xfffffff0,%esp
   9:   b8 00 00 00 00          mov    $0x0,%eax
   e:   83 c0 0f                add    $0xf,%eax
  11:   83 c0 0f                add    $0xf,%eax
  14:   c1 e8 04                shr    $0x4,%eax
  17:   c1 e0 04                shl    $0x4,%eax
  1a:   29 c4                   sub    %eax,%esp
  1c:   b8 00 00 00 00          mov    $0x0,%eax
  21:   c9                      leave
  22:   c3                      ret

a tcc test.o disassmbled:
isassembly of section .text:

00000000 <main>:
   0:   55                      push   %ebp
   1:   89 e5                   mov    %esp,%ebp
   3:   81 ec 00 00 00 00       sub    $0x0,%esp
   9:   e9 0e 00 00 00          jmp    1c <main+0x1c>
   e:   b8 00 00 00 00          mov    $0x0,%eax
                        f: R_386_32     L.0
  13:   50                      push   %eax
  14:   e8 fc ff ff ff          call   15 <main+0x15>
                        15: R_386_PC32  printf
  19:   83 c4 04                add    $0x4,%esp
  1c:   b8 00 00 00 00          mov    $0x0,%eax
  21:   e9 00 00 00 00          jmp    26 <main+0x26>
  26:   c9                      leave
  27:   c3                      ret

A call to the printf is present.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]