Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

  #include <stdio.h>

  int main()
  {
    printf("Hello World!");
    return 0;
  }
Becomes:

    .cstring
  LC0:
    .ascii "Hello World!\0"
    .text
  .globl _main
  _main:
    pushl   %ebp
    movl    %esp, %ebp
    pushl   %ebx
    subl    $20, %esp
    call    L3
  "L00000000001$pb":
  L3:
    popl    %ebx
    leal    LC0-"L00000000001$pb"(%ebx), %eax
    movl    %eax, (%esp)
    call    L_printf$stub
    movl    $0, %eax
    addl    $20, %esp
    popl    %ebx
    leave
    ret
    .section __IMPORT,__jump_table,symbol_stubs,
      self_modifying_code+pure_instructions,5
  L_printf$stub:
    .indirect_symbol _printf
    hlt ; hlt ; hlt ; hlt ; hlt
    .subsections_via_symbols
Look at all that bloat! I just want to write out "Hello World" to the screen. Why do I need to create a function stack of 20 whole bytes? What a waste! And when I do that, I have to go through the onerous effort of saving my stack pointer to a whole 'nother register. What a waste of my system resources.

It's bad enough I have to call printf in the first place when I really could just use the write system call, but look how it doesn't even call printf right away! First I have to call some locally defined function which has to allocate even more space for another stack. More waste and bloat. And look at how all of this is organized, these sections are completely unnecessary. I just want to write out something to the screen! I don't need this level of organization and abstraction to do this simple task.



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: