From 6ae167fecd2fe949468c63a7732605c1b1ab8e96 Mon Sep 17 00:00:00 2001 From: Serban Ciumacencu Date: Sat, 21 Mar 2026 12:38:48 +0200 Subject: [PATCH 1/6] Fixed Markdown File Signed-off-by: Serban Ciumacencu --- dynamic-linking.ro.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/dynamic-linking.ro.md b/dynamic-linking.ro.md index 3630d63..5bdddf4 100644 --- a/dynamic-linking.ro.md +++ b/dynamic-linking.ro.md @@ -1,7 +1,7 @@ # Linkare dinamică Linkarea dinamică înseamnă că în executabil nu sunt incluse componentele folosite din bibliotecă. -Acestea vor fi incluse mai târziu, la încărcare (*load time*) sau chiar la rulare (*runtime). +Acestea vor fi incluse mai târziu, la încărcare (*load time*) sau chiar la rulare (*runtime*). În urma linkării dinamice, executabilul reține referințe la bibliotecile folosite și la simbolurile folosite din cadrul acestora. Aceste referințe sunt similare unor simboluri nedefinite. Rezolvarea acestor simboluri are loc mai târziu, prin folosirea unui loader / linker dinamic. @@ -13,7 +13,7 @@ Diferența este că acum, folosim linkare dinamică în loc de linkare statică Pentru aceasta, am renunțat la argumentul `-static` folosit la linkare. Pentru acest exemplu, obținem un singur executabil `main`, din legarea statică cu biblioteca `libinc.a` și legarea dinamică cu biblioteca standard C. -Similar exemplului din directorul `05-static/, folosim comanda `make` pentru a obține executabilul `main`: +Similar exemplului din directorul `05-static/`, folosim comanda `make` pentru a obține executabilul `main`: ```console [..]/06-dynamic$ ls @@ -39,11 +39,11 @@ main: ELF 32-bit LSB executable, Intel 80386, version 1 (SYSV), dynamically link [..]/06-dynamic$ file ../05-static/main ../05-static/main: ELF 32-bit LSB executable, Intel 80386, version 1 (GNU/Linux), statically linked, for GNU/Linux 3.2.0, BuildID[sha1]=60adf8390374c898998c0b713a8b1ea0c255af38, not stripped -`` +``` Fișierul executabil `main` obținut prin linkare dinamică are un comportament identic fișierului executabil `main` obținut prin linkare statică. Observăm că dimensiunea sa este mult mai redusă: ocupă `7 KB` comparativ cu `600 KB` cât avea varianta sa statică. -De asemenea, folosind utilitarul `file`, aflăm că este executabil obținut prin linkare dinamică (*dynamically linked*), în vreme cel obținut în exemplul anterior este executabil obținut prin linkare statică (*statically linked). +De asemenea, folosind utilitarul `file`, aflăm că este executabil obținut prin linkare dinamică (*dynamically linked*), în vreme cel obținut în exemplul anterior este executabil obținut prin linkare statică (*statically linked*). Investigăm simbolurile executabilului: @@ -66,7 +66,7 @@ Investigăm simbolurile executabilului: Simbolurile obținute din modulul obiect `main.o` și din biblioteca statică `libinc.o` sunt rezolvate și au adrese stabilite. Observăm că folosirea bibliotecii standard C a dus la existența simboblului `_start`, care este entry pointul programului. -Dar, simbolurile din biblioteca standard C, (`printf`, __libc_start_main`) sunt marcate ca nedefinite (`U`). +Dar, simbolurile din biblioteca standard C, (`printf`,` __libc_start_main`) sunt marcate ca nedefinite (`U`). Aceste simboluri nu sunt prezente în executabil: rezolvarea, stabilirea adreselor și relocarea lor se va realiza mai târziu, la încărcare (load time). La încărcare, o altă componentă software a sistemului, loaderul / linkerul dinamic, se va ocupa de: @@ -77,7 +77,7 @@ La încărcare, o altă componentă software a sistemului, loaderul / linkerul d Putem investiga bibliotecile dinamice folosite de un executabil prin intermediul utilitarului `ldd`: -``console +```console [..]/06-dynamic$ ldd main linux-gate.so.1 (0xf7f97000) libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7d8a000) @@ -186,4 +186,4 @@ num_items: 1 Variabila de mediu `LD_LIBRARY_PATH` pentru loader este echivalentul opțiunii `-L` în comanda de linkare: precizează directoarele în care să fie căutate biblioteci pentru a fi încărcate, respectiv linkate. Folosirea variabilei de mediu `LD_LIBRARY_PATH` este recomandată pentru teste. -Pentru o folosire robustă, există alte mijloace de precizare a căilor de căutare a bibliotecilor partajate, documentate în (pagina de manual a loaderului / linkerului dinamic)(https://man7.org/linux/man-pages/man8/ld.so.8.html#DESCRIPTION). +Pentru o folosire robustă, există alte mijloace de precizare a căilor de căutare a bibliotecilor partajate, documentate în (pagina de manual a loaderului / linkerului dinamic)[https://man7.org/linux/man-pages/man8/ld.so.8.html#DESCRIPTION]. From b4c80fa20bb44b5dd2b3f3ec0a51f95325ce86b6 Mon Sep 17 00:00:00 2001 From: SerbaC6 Date: Mon, 23 Mar 2026 23:12:35 +0200 Subject: [PATCH 2/6] Created my first Markdown. Long way to go from now on... Signed-off-by: SerbaC6 --- helloworld.md | 84 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 helloworld.md diff --git a/helloworld.md b/helloworld.md new file mode 100644 index 0000000..5fc909f --- /dev/null +++ b/helloworld.md @@ -0,0 +1,84 @@ +# Helloworld Programs + +![Hello, World!](/home/serbaan/Desktop/CDL/lab_3_Markdown_Makefile/workshop-markdown-fork/helloworld.png) + +We list below Helloworld programs for different programming languages, i.e. programs that print "Hello, World!". The +specified compiler or interpreter is required for each programming languages. + +The table below summarizes the programs: + +| *Language* | *Language (Spec) Site* | *Section* | *Build / Run Toolchain* | *Debian / Ubuntu Packages* | +| :----- | :--------------------: | :-------: | :---------------------: | :------------------------: | +| C | [The Standard - C](https://www.iso-9899.info/wiki/The_Standard) | [C]() | GCC |``build-essential`` | +| C++ | [The Standard - C++](https://isocpp.org/std/the-standard) | [C++]() | GCC / G++ |``build-essential, g++`` | +| Dlang | [D Programming Language: Hpme](https://dlang.org/) | [Dlang]() | GCC / GDC |``build-essential, gdc`` | +| Go | [The Go Programming Language](https://go.dev/) | [Go]() | Go |``golang`` | +| Rust | [Rust Programming Language](https://www.rust-lang.org/) | [Rust]() | Rust(Crate) |``rustlang`` | +|Java | [Java Programming Language](https://docs.oracle.com/javase/8/docs/technotes/guides/language/) | [Java]() | JDK | ``openjdk-17-jdk`` | +|x86_64 assembly | [x86 and amd64 instruction reference](https://www.felixcloutier.com/x86/) | [x86_64]() | Assembly GCC / GAS | ``build-essential`` | +|ARM64 assembly | [Arm A64 Instruction Set Architecture](https://developer.arm.com/documentation/ddi0596/latest/) | [ARM64 Assembly]() | GCC / GAS (AArch64) | ``build-essential``| +|Bash | [Bash Reference Manual](https://www.gnu.org/s/bash/manual/bash.html) | [Bash]() | Bash | ``bash``| +|Python| [Welcome to Python.org](https://www.python.org/)| [Python]() | Python | ``python``| +|Ruby | [Ruby Programming Language](https://www.ruby-lang.org/en/) | [Ruby]() | Ruby |``ruby``| +|PHP | [PHP: Hypertext Preprocessor](https://www.php.net/)| [PHP]() | PHP | ``php`` | +|Perl| [The Perl Programming Language](https://www.perl.org/) | [Perl]() | Perl | ``perl``| +|Lua | [The Programming Language Lua](https://www.lua.org/) | [Lua]() | Lua | ``lua``| + + + +# C +```C +#include +int main(void) +{ +puts("Hello, World!"); +return 0; + +} +``` + +Build with: +```bash +gcc -Wall -o helloworld helloworld.c +``` +Run with: +```bash +./helloworld +``` + +# C++ +```C++ +#include +int main() +{ +std::cout << "Hello, World!" << std::endl; +return 0; +} +``` + +Build with: +```bash +g++ -Wall -o helloworld helloworld.cpp +``` + +Run with: +```bash +./helloworld +``` + +# Dlang +```dlang +import std.stdio; +void main() +{ +writeln("Hello, World!"); +} +``` +Build with: +```bash +gdc -Wall -o helloworld helloworld.cpp +``` +Run with: +```bash +./helloworld +``` \ No newline at end of file From a495c1c04bc576523de040c3e7f70d4b686ef866 Mon Sep 17 00:00:00 2001 From: SerbaC6 Date: Mon, 23 Mar 2026 23:17:20 +0200 Subject: [PATCH 3/6] Changed the pic of the Markdowm file from local file to internet file Signed-off-by: SerbaC6 --- helloworld.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/helloworld.md b/helloworld.md index 5fc909f..159a94f 100644 --- a/helloworld.md +++ b/helloworld.md @@ -1,6 +1,6 @@ # Helloworld Programs -![Hello, World!](/home/serbaan/Desktop/CDL/lab_3_Markdown_Makefile/workshop-markdown-fork/helloworld.png) +![Hello, World!](https://github.com/SerbaC6/workshop-markdown-fork/blob/helloworld/helloworld.png?raw=true) We list below Helloworld programs for different programming languages, i.e. programs that print "Hello, World!". The specified compiler or interpreter is required for each programming languages. From 7ae3f93c91f0cc49294893cd2105aee163b58783 Mon Sep 17 00:00:00 2001 From: SerbaC6 Date: Mon, 23 Mar 2026 23:57:47 +0200 Subject: [PATCH 4/6] Made my own md file about Segfaults Signed-off-by: SerbaC6 --- Segfault.md | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Segfault.md diff --git a/Segfault.md b/Segfault.md new file mode 100644 index 0000000..a0166ff --- /dev/null +++ b/Segfault.md @@ -0,0 +1,34 @@ +# Segfaults. We hate them... + +## Definiton: +In computing, a segmentation fault (often shortened to segfault) or access violation is a failure condition raised by hardware with memory protection, notifying an operating system (OS) that the software has attempted to access a restricted area of memory (a memory access violation). On standard x86 computers, this is a form of general protection fault. The operating system kernel will, in response, usually perform some corrective action, generally passing the fault on to the offending process by sending the process a signal. Processes can in some cases install a custom signal handler, allowing them to recover on their own, but otherwise the OS default signal handler is used, generally causing abnormal termination of the process (a program crash), and sometimes a core dump. +([Source](https://en.wikipedia.org/wiki/Segmentation_fault)). + +## Note: +This definition was purely for educational purposes, you can stop here if you don't hate Segfaults :nerd_face:. I am writing this with the intention of expressing my hate for this error, that made my hair go white. + +## Why I hate it :rage:: +1. It can be caused from basically everything if you are not paying attention when working with dinamically allocated memory. You didn't free? Segfault. You did free? Maybe Segfault. You allocated bad? Segfault. You allocated in the first place? Your chances of Segfaults are at 90%. +1. It can take time to repair...when a C or C++ program segfaults, the terminal typically spits out just a few unhelpful words: Segmentation fault (core dumped). There is no context, no line number, and no immediate clue as to what went wrong. You are entirely on your own to figure out where the crash happened. Just you and Valgrind... +1. Because segfaults are intimately tied to exactly how a program is laid out in the computer's physical RAM, attempting to debug them can inadvertently change their behavior. +If you add a simple print statement to try and track down where the code is failing, you alter the size of the compiled program and shift its memory layout. Suddenly, the segfault might move to a completely different part of the program, or it might vanish entirely—only to return the moment you remove your debugging code. + +## How do I solve Segfaults? +Well...there could be light after dark after all, your heroes are: +- **Valgrind**: + - Run with: + ``bash + valgrind + `` +- **GDB**: + 1. First, you have to compile your code with: + ```bash + gcc ... -g ... + ``` + 2. After that, you have to run it with: + ```bash + gdb + ``` + +### So, to end it on a funny note: +![Segfault Meme](https://i.programmerhumor.io/2025/07/39f9ce344066838d5f3d50da0abb33e99369f9f71afa6320a1d34ca6d8b016c5.png) \ No newline at end of file From 01d60ea63f611dc6197afa85a2768ab193da932b Mon Sep 17 00:00:00 2001 From: SerbaC6 Date: Tue, 24 Mar 2026 00:25:52 +0200 Subject: [PATCH 5/6] Made my first Makefile, unterstanding what .PHONY does Signed-off-by: SerbaC6 --- demo | Bin 0 -> 15968 bytes gnumake/Makefile | 7 +++++++ 2 files changed, 7 insertions(+) create mode 100755 demo diff --git a/demo b/demo new file mode 100755 index 0000000000000000000000000000000000000000..81229df70e7d2032c25012434c58aa10000b9945 GIT binary patch literal 15968 zcmeHOYit}>6~4Pp8k;({lP1M+ARf{L8d^{Mij@Fv*3XQ=PEyCAtptq6-m!P3eYm@` zjolw*D}z+4O%)^xE$WXTm6woEe)LC>Ky_M(iV&#z7ajtuB9e;&xT2txiY({MoNqcF z)~N&tsnT3&_q*pi=ezgLnY-(|o_oJIG&&rQ#S}`7x=*oHZt|FfIL`M-g&?60tF83j zs`jYc$ll~~o=4^6ByL-P%gH40T+AM#*cAjP2y(0u1X?q6_1oCsRP~gUhLFPVztL@1*EiQ1B-=9STxq^-{%}uQPq$vo>z!`LJT8r1Jg1HwKdq>l zW#%M}Dqi+%w8y?3;^+9j#P{whA9?)xzSKLve|n+r+YitFagk$q+^pdkF5Dib2-}z+ z9OLEVai*oN)D`=eS(n)0jWye=_zdE-Dm?d7Ek3zHd~pN5nfSf*`nNJya*E0{Dc#d% z(Xk4SnYGe6Vy5RUb0(d$GU-Qc#coc1k2*Fw(m!B!>Ye%_zuwiY%#n#PGiev>*>usd z3ln1lnS9Qku%#yv8WS#A{f429TMx|DNORA1#w|zgp<4+??SH55@y>2Z2VeRC^P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Dz%7(do)K=hCGT6p{x>3OXN zJ=Sx;?@GTsM$R+zSXZTq<3IJ#mt}xJtOqH?E!;-1JWK|!wV=oP%0~&t_z?$ujQqTI zgN^kYuwC@w@e8eZd^}|6v7Q7jOCb6WU;o!d-!E}kp8}C5)^k0q|0Z#q6SVLDeF*&> zq7b))@Bj0}2KAcgd=wo3e|~`93F#B!03vQ9{e_VJqzHiTrT<|_KPduWU1-9D+j}Xb z$NB@f6$2Lx=kKSY$Ng8D1PX@NKw7-9z+)2B3poPh#fKKh}9oq7TP& zU%|rbYUU)|cR?>{^m*umhHo( SX-!>SUq0jsT0(-5ss07k9n@6- literal 0 HcmV?d00001 diff --git a/gnumake/Makefile b/gnumake/Makefile index 5f5e31b..83017f2 100644 --- a/gnumake/Makefile +++ b/gnumake/Makefile @@ -3,3 +3,10 @@ # to the end of the line! # Start writing below this line... +.PHONY: clean + +clean: + rm example + +example: example.c + gcc -o example example.c \ No newline at end of file From eed3fc09843d75b76999a4a528a8d073e1b1aa29 Mon Sep 17 00:00:00 2001 From: SerbaC6 Date: Wed, 25 Mar 2026 02:13:45 +0200 Subject: [PATCH 6/6] Made my first Makefile Signed-off-by: SerbaC6 --- gnumake/custom/Makefile | 29 +++++++++++++++++++++++++++++ gnumake/custom/parts_makefile | 3 +++ 2 files changed, 32 insertions(+) create mode 100644 gnumake/custom/Makefile create mode 100644 gnumake/custom/parts_makefile diff --git a/gnumake/custom/Makefile b/gnumake/custom/Makefile new file mode 100644 index 0000000..665a194 --- /dev/null +++ b/gnumake/custom/Makefile @@ -0,0 +1,29 @@ +CC = gcc +CFLAGS = -Wall -Wextra +GDB_FLAGS = -g + +# rule that ignores files in the directory that have "all" title +# or "clean" title so that we can run these recipes safely +.PHONY: all clean + +# rule that executes all the rules that we give to her +all: greeting parts + +ifeq ($(CC), gcc) + $(info Using GCC compiler...) +else + $(warning Warning! C program needs to be executed with gcc) +endif + +# rule that uses a conditional to make clear that the program will compile +# with gcc and that runs the greeting.c file +greeting: greeting.c + $(CC) $(CFLAGS) $(GDB_FLAGS) $^ -o $@ + +# the clean rule removes all the object files made so that we won't +# have binary files that may corrupt our running and also executable files +clean: + rm -f *.o greeting parts + +# we put it here so when we run "make" simple it will take the all rule +include parts_makefile diff --git a/gnumake/custom/parts_makefile b/gnumake/custom/parts_makefile new file mode 100644 index 0000000..3da5009 --- /dev/null +++ b/gnumake/custom/parts_makefile @@ -0,0 +1,3 @@ +#We use another file for this rule so that we can see how can we scatter rules across different files +parts: header.h part1.c part2.c + $(CC) $(CFLAGS) $(GDB_FLAGS) $^ -o parts