From f5dfce1617bf916e4ca864feddac0620f9faf1af Mon Sep 17 00:00:00 2001 From: JunkJumper Date: Fri, 4 Sep 2020 11:09:08 +0200 Subject: [PATCH] Exo 1 finis --- 2020-2021/S3T_TP_00_REVISIONS/hello.s | 53 +++++++++++++++++++++ 2020-2021/S3T_TP_00_REVISIONS/processus_1.c | 14 ++++-- 2020-2021/S3T_TP_00_REVISIONS/processus_3.c | 22 +++++++++ 3 files changed, 84 insertions(+), 5 deletions(-) create mode 100644 2020-2021/S3T_TP_00_REVISIONS/hello.s create mode 100755 2020-2021/S3T_TP_00_REVISIONS/processus_3.c diff --git a/2020-2021/S3T_TP_00_REVISIONS/hello.s b/2020-2021/S3T_TP_00_REVISIONS/hello.s new file mode 100644 index 0000000..6e8942c --- /dev/null +++ b/2020-2021/S3T_TP_00_REVISIONS/hello.s @@ -0,0 +1,53 @@ + .file "hello.c" + .text + .section .rodata +.LC0: + .string "./hello.c" +.LC1: + .string "argc == 2" +.LC2: + .string "\nhello %s\n\n" + .text + .globl main + .type main, @function +main: +.LFB6: + .cfi_startproc + pushq %rbp + .cfi_def_cfa_offset 16 + .cfi_offset 6, -16 + movq %rsp, %rbp + .cfi_def_cfa_register 6 + subq $32, %rsp + movl %edi, -4(%rbp) + movq %rsi, -16(%rbp) + movq %rdx, -24(%rbp) + cmpl $2, -4(%rbp) + je .L2 + leaq __PRETTY_FUNCTION__.2887(%rip), %rcx + movl $6, %edx + leaq .LC0(%rip), %rsi + leaq .LC1(%rip), %rdi + call __assert_fail@PLT +.L2: + movq -16(%rbp), %rax + addq $8, %rax + movq (%rax), %rax + movq %rax, %rsi + leaq .LC2(%rip), %rdi + movl $0, %eax + call printf@PLT + movl $0, %eax + leave + .cfi_def_cfa 7, 8 + ret + .cfi_endproc +.LFE6: + .size main, .-main + .section .rodata + .type __PRETTY_FUNCTION__.2887, @object + .size __PRETTY_FUNCTION__.2887, 5 +__PRETTY_FUNCTION__.2887: + .string "main" + .ident "GCC: (Debian 8.3.0-6) 8.3.0" + .section .note.GNU-stack,"",@progbits diff --git a/2020-2021/S3T_TP_00_REVISIONS/processus_1.c b/2020-2021/S3T_TP_00_REVISIONS/processus_1.c index ed869bb..52fd339 100755 --- a/2020-2021/S3T_TP_00_REVISIONS/processus_1.c +++ b/2020-2021/S3T_TP_00_REVISIONS/processus_1.c @@ -5,11 +5,15 @@ #include #include -int main(int argc, char * argv[]){ +int main(int argc, char *argv[]) +{ int i; - for (i=1; i< argc; i++) { - printf("argument %d: %s\n",i,argv[i]); + for (i = 1; i < argc; i++) + { + printf("argument %d: %s\n", i, argv[i]); } - printf("\nPID = %d - PPID = %d \n\n",getpid(), getppid()); - return 0; + printf("\nPID = %d - PPID = %d \n\n", getpid(), getppid()); + + //sleep(60); + return 0; } diff --git a/2020-2021/S3T_TP_00_REVISIONS/processus_3.c b/2020-2021/S3T_TP_00_REVISIONS/processus_3.c new file mode 100755 index 0000000..f18d8ba --- /dev/null +++ b/2020-2021/S3T_TP_00_REVISIONS/processus_3.c @@ -0,0 +1,22 @@ +/** + * @ Author: JunkJumper + * @ Link: https://github.com/JunkJumper + * @ Copyright: Creative Common 4.0 (CC BY 4.0) + * @ Create Time: 04-09-2020 10:41:01 + * @ Modified by: JunkJumper + * @ Modified time: 04-09-2020 10:58:23 + * @ Description: + */ + +#include +#include + +int main(int argc, char *argv[], char* envp[]) +{ + int i = 0; + while(envp[i] != NULL) { + i++; + printf("%s\n", envp[i]); + } + return 0; +}