-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssembly_List_Generation.c
More file actions
29 lines (26 loc) · 933 Bytes
/
Assembly_List_Generation.c
File metadata and controls
29 lines (26 loc) · 933 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
/*
The first column is a line number, next is a byte offset, next is the machine code,
then labels and assembler directives and finally the assembly language itself.
Try changing the program to see what code it produces.
*/
#include <stdio.h>
#include <stdlib.h>
int function() {
int i, sum = 0;
for (i = 0; i < 100; i++) {
sum += i;
}
return sum;
}
int main(int argc, char *argv[]) {
if (argc > 0) {
char s[256];
// Ensure we don't exceed the buffer; consider the format string and potential space for the command
snprintf(s, sizeof(s), "gcc -O -o %s %s.c -Wa,-aldn", argv[0], argv[0]); // Fixed potential buffer overflow issue
system(s); // Note: using system() is generally not recommended for security reasons
} else {
printf("Usage: %s <source_file_without_extension>\n", argv[0]);
return 1;
}
return 0;
}