Skip to content

Instantly share code, notes, and snippets.

@sjp38
Last active January 4, 2016 22:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sjp38/8686618 to your computer and use it in GitHub Desktop.
Save sjp38/8686618 to your computer and use it in GitHub Desktop.
#include <stdio.h>
char a[] = "abc";
int main(void)
{
printf("%p\n", a);
return 0;
}
.file "arr.c"
.globl a
.data
.type a, @object
.size a, 4
a:
.string "abc"
.section .rodata
.LC0:
.string "%p\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 $a, %esi
movl $.LC0, %edi
movl $0, %eax
call printf
movl $0, %eax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3"
.section .note.GNU-stack,"",@progbits
#include <stdio.h>
char *a = "abc";
int main(void)
{
printf("%p\n", a);
return 0;
}
.file "ptr.c"
.globl a
.section .rodata
.LC0:
.string "abc"
.data
.align 8
.type a, @object
.size a, 8
a:
.quad .LC0
.section .rodata
.LC1:
.string "%p\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
movq a(%rip), %rax
movq %rax, %rsi
movl $.LC1, %edi
movl $0, %eax
call printf
movl $0, %eax
popq %rbp
.cfi_def_cfa 7, 8
ret
.cfi_endproc
.LFE0:
.size main, .-main
.ident "GCC: (Ubuntu/Linaro 4.7.3-1ubuntu1) 4.7.3"
.section .note.GNU-stack,"",@progbits
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment