Skip to content

Commit 7d228d2

Browse files
committed
draft print 0x41
1 parent 6fd3884 commit 7d228d2

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

draft/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
1+
CFLAGS += -D_GNU_SOURCE
12
CFLAGS += -Wall
23
CFLAGS += -pedantic-errors
34

45
draft: draft.c
56
$(CC) $(CFLAGS) -fno-omit-frame-pointer -g -o draft $^
67

78
barf: draft.c
8-
$(CC) $(CFLAGS) -fno-omit-frame-pointer -S $^ | tee draft.s
9+
$(CC) $(CFLAGS) -fno-omit-frame-pointer -S $^ -o draft.s
910

1011
debug: barf
1112
$(CC) -o draft draft.s -g

draft/draft.c

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,21 @@
22
#include <sys/stat.h>
33
#include <stddef.h>
44
#include <stdlib.h>
5+
#include <unistd.h>
6+
#include <sys/syscall.h>
7+
#include <sys/types.h>
58

69
int fh = 0;
10+
int i = 0;
711

812
int main(int argc, char *argv[])
913
{
10-
fh = 3;
11-
printf("%d\n", fh);
14+
char out[5];
15+
out[i++] = '0';
16+
out[i++] = 'x';
17+
out[i++] = '4';
18+
out[i++] = '1';
19+
out[i++] = '\n';
20+
syscall(__NR_write, 1, out, 5);
1221
return 0;
1322
}

0 commit comments

Comments
 (0)