I have a simple Hello world C program that uses write:
Code:
#include <unistd.h>
int main(void)
{
write(STDOUT_FILENO, "Hello world.\n", 13);
return 0;
}
When I last compiled it (5 years ago) it produced:
Code:
.file "helloWorld2.c"
.section .rodata
.LC0:
.string "Hello world.\n" # constant data
.text
.globl main
.type main, @function
main:
pushq %rbp
movq %rsp, %rbp
movl $13, %edx # third argument
movl $.LC0, %esi # second argument
movl $1, %edi # first argument
call write
movl $0, %eax
popq %rbp
ret
.size main, .-main
.ident "GCC: (Ubuntu/Linaro 4.7.0-7ubuntu3) 4.7.0"
.section .note.GNU-stack,"",@progbits
Now it produces:
Code:
.file "helloWorld2.c"
.section .rodata
.LC0:
.string "Hello world.\n"
.text
.globl main
.type main, @function
main:
.LFB0:
.cfi_startproc
pushq %rbp
.cfi_def_cfa_offset 16
.cfi_offset 6, -16
movq %rsp, %rbp
.cfi_def_cfa_register 6
movl $13, %edx
leaq .LC0(%rip), %rsi
movl $1, %edi
call write@PLT
movl $0, %eax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (Ubuntu 7.2.0-8ubuntu3.2) 7.2.0"
.section .note.GNU-stack,"",@progbits
When did gcc start producing PIC?
Bookmarks