Skip to content

Instantly share code, notes, and snippets.

@sufianrhazi
Created October 1, 2015 13:36
Show Gist options
  • Save sufianrhazi/c4fa1c81f2189dd162af to your computer and use it in GitHub Desktop.
Save sufianrhazi/c4fa1c81f2189dd162af to your computer and use it in GitHub Desktop.
#include <stdio.h>
int main(int argc, char *argv[]) {
static char arr[40] = "this is a string referenced by an array";
printf("arr = %s; sizeof arr = %ld\n", arr, sizeof arr);
return 0;
}
.section __TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 10
.globl _main
_main: ## @main
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp0:
.cfi_def_cfa_offset 16
Ltmp1:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Ltmp2:
.cfi_def_cfa_register %rbp
leaq L_.str(%rip), %rdi
leaq _main.arr(%rip), %rsi
movl $40, %edx
xorl %eax, %eax
callq _printf
xorl %eax, %eax
popq %rbp
retq
.cfi_endproc
.section __DATA,__data
.align 4 ## @main.arr
_main.arr:
.asciz "this is a string referenced by an array"
.section __TEXT,__cstring,cstring_literals
L_.str: ## @.str
.asciz "arr = %s; sizeof arr = %ld\n"
.subsections_via_symbols
#include <stdio.h>
int main(int argc, char *argv[]) {
char *ptr = "this is a string referenced by a pointer";
printf("ptr = %s; sizeof ptr = %ld\n", ptr, sizeof ptr);
return 0;
}
.section __TEXT,__text,regular,pure_instructions
.macosx_version_min 10, 10
.globl _main
_main: ## @main
.cfi_startproc
## BB#0:
pushq %rbp
Ltmp0:
.cfi_def_cfa_offset 16
Ltmp1:
.cfi_offset %rbp, -16
movq %rsp, %rbp
Ltmp2:
.cfi_def_cfa_register %rbp
leaq L_.str1(%rip), %rdi
leaq L_.str(%rip), %rsi
movl $8, %edx
xorl %eax, %eax
callq _printf
xorl %eax, %eax
popq %rbp
retq
.cfi_endproc
.section __TEXT,__cstring,cstring_literals
L_.str: ## @.str
.asciz "this is a string referenced by a pointer"
L_.str1: ## @.str1
.asciz "ptr = %s; sizeof ptr = %ld\n"
.subsections_via_symbols
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment