Skip to content

Instantly share code, notes, and snippets.

@emilyst emilyst/program.c
Last active Mar 21, 2017

Embed
What would you like to do?
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
int is_valid(const char* password) {
if (strcmp(password, "poop") == 0) {
return 1;
} else {
return 0;
}
}
int main()
{
char* input = malloc(256);
printf("Please input a word: ");
scanf("%s", input);
if (is_valid(input)) {
printf("That's correct!\n");
} else {
printf("That's not correct!\n");
}
free(input);
return 0;
}
/**
* gcc program.c -o program
* gobjdump -S -l -C -F -t -w program
*/
program: file format mach-o-x86-64
SYMBOL TABLE:
0000000100000000 g 0f SECT 01 0010 [.text] _mh_execute_header
0000000100000e10 g 0f SECT 01 0000 [.text] is_valid
0000000100000e60 g 0f SECT 01 0000 [.text] main
0000000000000000 g 01 UND 00 0100 free
0000000000000000 g 01 UND 00 0100 malloc
0000000000000000 g 01 UND 00 0100 printf
0000000000000000 g 01 UND 00 0100 scanf
0000000000000000 g 01 UND 00 0100 strcmp
0000000000000000 g 01 UND 00 0100 dyld_stub_binder
Disassembly of section .text:
0000000100000e10 <is_valid> (File Offset: 0xe10):
100000e10: 55 push %rbp
100000e11: 48 89 e5 mov %rsp,%rbp
100000e14: 48 83 ec 10 sub $0x10,%rsp
100000e18: 48 89 7d f0 mov %rdi,-0x10(%rbp)
100000e1c: 48 8b 7d f0 mov -0x10(%rbp),%rdi
100000e20: 48 8d 35 33 01 00 00 lea 0x133(%rip),%rsi # 100000f5a <strcmp$stub+0x4a> (File Offset: 0xf5a)
100000e27: e8 e4 00 00 00 callq 100000f10 <strcmp$stub> (File Offset: 0xf10)
100000e2c: 3d 00 00 00 00 cmp $0x0,%eax
100000e31: 0f 85 0c 00 00 00 jne 100000e43 <is_valid+0x33> (File Offset: 0xe43)
100000e37: c7 45 fc 01 00 00 00 movl $0x1,-0x4(%rbp)
100000e3e: e9 07 00 00 00 jmpq 100000e4a <is_valid+0x3a> (File Offset: 0xe4a)
100000e43: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp)
100000e4a: 8b 45 fc mov -0x4(%rbp),%eax
100000e4d: 48 83 c4 10 add $0x10,%rsp
100000e51: 5d pop %rbp
100000e52: c3 retq
100000e53: 66 66 66 66 2e 0f 1f 84 00 00 00 00 00 data16 data16 data16 nopw %cs:0x0(%rax,%rax,1)
0000000100000e60 <main> (File Offset: 0xe60):
100000e60: 55 push %rbp
100000e61: 48 89 e5 mov %rsp,%rbp
100000e64: 48 83 ec 20 sub $0x20,%rsp
100000e68: 48 bf 00 01 00 00 00 00 00 00 movabs $0x100,%rdi
100000e72: c7 45 fc 00 00 00 00 movl $0x0,-0x4(%rbp)
100000e79: e8 80 00 00 00 callq 100000efe <malloc$stub> (File Offset: 0xefe)
100000e7e: 48 8d 3d da 00 00 00 lea 0xda(%rip),%rdi # 100000f5f <strcmp$stub+0x4f> (File Offset: 0xf5f)
100000e85: 48 89 45 f0 mov %rax,-0x10(%rbp)
100000e89: b0 00 mov $0x0,%al
100000e8b: e8 74 00 00 00 callq 100000f04 <printf$stub> (File Offset: 0xf04)
100000e90: 48 8d 3d de 00 00 00 lea 0xde(%rip),%rdi # 100000f75 <strcmp$stub+0x65> (File Offset: 0xf75)
100000e97: 48 8b 75 f0 mov -0x10(%rbp),%rsi
100000e9b: 89 45 ec mov %eax,-0x14(%rbp)
100000e9e: b0 00 mov $0x0,%al
100000ea0: e8 65 00 00 00 callq 100000f0a <scanf$stub> (File Offset: 0xf0a)
100000ea5: 48 8b 7d f0 mov -0x10(%rbp),%rdi
100000ea9: 89 45 e8 mov %eax,-0x18(%rbp)
100000eac: e8 5f ff ff ff callq 100000e10 <is_valid> (File Offset: 0xe10)
100000eb1: 3d 00 00 00 00 cmp $0x0,%eax
100000eb6: 0f 84 16 00 00 00 je 100000ed2 <main+0x72> (File Offset: 0xed2)
100000ebc: 48 8d 3d b5 00 00 00 lea 0xb5(%rip),%rdi # 100000f78 <strcmp$stub+0x68> (File Offset: 0xf78)
100000ec3: b0 00 mov $0x0,%al
100000ec5: e8 3a 00 00 00 callq 100000f04 <printf$stub> (File Offset: 0xf04)
100000eca: 89 45 e4 mov %eax,-0x1c(%rbp)
100000ecd: e9 11 00 00 00 jmpq 100000ee3 <main+0x83> (File Offset: 0xee3)
100000ed2: 48 8d 3d b0 00 00 00 lea 0xb0(%rip),%rdi # 100000f89 <strcmp$stub+0x79> (File Offset: 0xf89)
100000ed9: b0 00 mov $0x0,%al
100000edb: e8 24 00 00 00 callq 100000f04 <printf$stub> (File Offset: 0xf04)
100000ee0: 89 45 e0 mov %eax,-0x20(%rbp)
100000ee3: 48 8b 7d f0 mov -0x10(%rbp),%rdi
100000ee7: e8 0c 00 00 00 callq 100000ef8 <free$stub> (File Offset: 0xef8)
100000eec: b8 00 00 00 00 mov $0x0,%eax
100000ef1: 48 83 c4 20 add $0x20,%rsp
100000ef5: 5d pop %rbp
100000ef6: c3 retq
Disassembly of section __TEXT.__stubs:
0000000100000ef8 <free$stub> (File Offset: 0xef8):
100000ef8: ff 25 12 01 00 00 jmpq *0x112(%rip) # 100001010 <free$stub> (File Offset: 0x1010)
0000000100000efe <malloc$stub> (File Offset: 0xefe):
100000efe: ff 25 14 01 00 00 jmpq *0x114(%rip) # 100001018 <malloc$stub> (File Offset: 0x1018)
0000000100000f04 <printf$stub> (File Offset: 0xf04):
100000f04: ff 25 16 01 00 00 jmpq *0x116(%rip) # 100001020 <printf$stub> (File Offset: 0x1020)
0000000100000f0a <scanf$stub> (File Offset: 0xf0a):
100000f0a: ff 25 18 01 00 00 jmpq *0x118(%rip) # 100001028 <scanf$stub> (File Offset: 0x1028)
0000000100000f10 <strcmp$stub> (File Offset: 0xf10):
100000f10: ff 25 1a 01 00 00 jmpq *0x11a(%rip) # 100001030 <strcmp$stub> (File Offset: 0x1030)
Disassembly of section __TEXT.__stub_helper:
0000000100000f18 <__TEXT.__stub_helper> (File Offset: 0xf18):
100000f18: 4c 8d 1d e9 00 00 00 lea 0xe9(%rip),%r11 # 100001008 <> (File Offset: 0x1008)
100000f1f: 41 53 push %r11
100000f21: ff 25 d9 00 00 00 jmpq *0xd9(%rip) # 100001000 <dyld_stub_binder$stub> (File Offset: 0x1000)
100000f27: 90 nop
100000f28: 68 00 00 00 00 pushq $0x0
100000f2d: e9 e6 ff ff ff jmpq 100000f18 <strcmp$stub+0x8> (File Offset: 0xf18)
100000f32: 68 0c 00 00 00 pushq $0xc
100000f37: e9 dc ff ff ff jmpq 100000f18 <strcmp$stub+0x8> (File Offset: 0xf18)
100000f3c: 68 1a 00 00 00 pushq $0x1a
100000f41: e9 d2 ff ff ff jmpq 100000f18 <strcmp$stub+0x8> (File Offset: 0xf18)
100000f46: 68 28 00 00 00 pushq $0x28
100000f4b: e9 c8 ff ff ff jmpq 100000f18 <strcmp$stub+0x8> (File Offset: 0xf18)
100000f50: 68 35 00 00 00 pushq $0x35
100000f55: e9 be ff ff ff jmpq 100000f18 <strcmp$stub+0x8> (File Offset: 0xf18)
Disassembly of section __TEXT.__unwind_info:
0000000100000fa0 <__TEXT.__unwind_info> (File Offset: 0xfa0):
100000fa0: 01 00 add %eax,(%rax)
100000fa2: 00 00 add %al,(%rax)
100000fa4: 1c 00 sbb $0x0,%al
100000fa6: 00 00 add %al,(%rax)
100000fa8: 00 00 add %al,(%rax)
100000faa: 00 00 add %al,(%rax)
100000fac: 1c 00 sbb $0x0,%al
100000fae: 00 00 add %al,(%rax)
100000fb0: 00 00 add %al,(%rax)
100000fb2: 00 00 add %al,(%rax)
100000fb4: 1c 00 sbb $0x0,%al
100000fb6: 00 00 add %al,(%rax)
100000fb8: 02 00 add (%rax),%al
100000fba: 00 00 add %al,(%rax)
100000fbc: 10 0e adc %cl,(%rsi)
100000fbe: 00 00 add %al,(%rax)
100000fc0: 34 00 xor $0x0,%al
100000fc2: 00 00 add %al,(%rax)
100000fc4: 34 00 xor $0x0,%al
100000fc6: 00 00 add %al,(%rax)
100000fc8: f8 clc
100000fc9: 0e (bad)
100000fca: 00 00 add %al,(%rax)
100000fcc: 00 00 add %al,(%rax)
100000fce: 00 00 add %al,(%rax)
100000fd0: 34 00 xor $0x0,%al
100000fd2: 00 00 add %al,(%rax)
100000fd4: 03 00 add (%rax),%eax
100000fd6: 00 00 add %al,(%rax)
100000fd8: 0c 00 or $0x0,%al
100000fda: 01 00 add %eax,(%rax)
100000fdc: 10 00 adc %al,(%rax)
100000fde: 01 00 add %eax,(%rax)
100000fe0: 00 00 add %al,(%rax)
100000fe2: 00 00 add %al,(%rax)
100000fe4: 00 00 add %al,(%rax)
100000fe6: 00 01 add %al,(%rcx)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.