Skip to content

Did the pdf translation into a markdown file for helloword-print.pdf #133

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 14 additions & 14 deletions dynamic-linking.ro.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand All @@ -79,9 +79,9 @@ Putem investiga bibliotecile dinamice folosite de un executabil prin intermediul

``console
[..]/06-dynamic$ ldd main
linux-gate.so.1 (0xf7f97000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7d8a000)
/lib/ld-linux.so.2 (0xf7f98000)
linux-gate.so.1 (0xf7f97000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7d8a000)
/lib/ld-linux.so.2 (0xf7f98000)
```

În rezultatul de mai sus, observăm că executabilul folosește biblioteca standard C, localizată la calea `/lib/i386-linux-gnu/libc.so.6`.
Expand Down Expand Up @@ -159,10 +159,10 @@ O eroare similară obținem dacă folosim utilitarul `ldd`:

```console
[..]/07-dynlib$ ldd ./main
linux-gate.so.1 (0xf7f9f000)
libinc.so => not found
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7d92000)
/lib/ld-linux.so.2 (0xf7fa0000)
linux-gate.so.1 (0xf7f9f000)
libinc.so => not found
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7d92000)
/lib/ld-linux.so.2 (0xf7fa0000)
```

La fel, biblioteca `libinc.so` nu este găsită.
Expand All @@ -175,15 +175,15 @@ Odată folosită variabila de mediu `LD_LIBRARY_PATH`, lansarea în execuție a

```console
[..]/07-dynlib$ LD_LIBRARY_PATH=. ldd ./main
linux-gate.so.1 (0xf7eda000)
libinc.so => ./libinc.so (0xf7ed2000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7cca000)
/lib/ld-linux.so.2 (0xf7edb000)
linux-gate.so.1 (0xf7eda000)
libinc.so => ./libinc.so (0xf7ed2000)
libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xf7cca000)
/lib/ld-linux.so.2 (0xf7edb000)

[..]/07-dynlib$ LD_LIBRARY_PATH=. ./main
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).
267 changes: 267 additions & 0 deletions helloworld.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,267 @@
## Helloworld Programs

![helloworld](helloworld.png)

We list below Helloworld programs for different programming languages, i.e. programs that print "Hello, World!".
The specified compiler or interpreter is requried for each programming languages.

The table below smmarizes 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](#c) | GCC | `build-essential` |
| C++ | [The Standard - C++](https://isocpp.org/std/the-standard) | [C++](#c++) | GCC / G++ | `build-essential`, `g++` |
| Dlang | [D Programming Language: Home](https://dlang.org/) | [Dlang](#dlang) | GCC / GDC | `build-essential`, `gdc` |
| Go | [The Go Programming Language](https://go.dev/) | [Go](#go) | Go | `golang` |
| Rust | [Rust Programming Language](https://www.rust-lang.org/) | [Rust](#rust) | Rust (Crate) | `rustlang` |
| Java | [Java Programming Language](https://docs.oracle.com/javase/8/docs/technotes/guides/language/) | [Java](#java) | JDK | `openjdk-17-jdk` |
| x86_64 assembly | [x86 and amd64 instruction reference](https://www.felixcloutier.com/x86/) | [x86_64 Assembly](#x86_64-assembly) | GCC / GAS | `build-essential` |
| ARM64 assembly | [Arm A64 Instruction Set Architecture](https://developer.arm.com/documentation/ddi0596/latest/) | [ARM64 Assembly](#arm64-assembly) | GCC / GAS (AArch64) | `build-essential` |
| Bash | [Bash Reference Manual](https://www.gnu.org/s/bash/manual/bash.html) | [Bash](#bash) | Bash | `bash` |
| Python | [Welcome to Python.org](https://www.python.org/) | [Python](#python) | Python | `python` |
| Ruby | [Ruby Programming Language](https://www.ruby-lang.org/en/) | [Ruby](#ruby) | Ruby | `ruby` |
| PHP | [PHP: Hypertext Preprocessor](https://www.php.net/) | [PHP](#php) | PHP | `php` |
| Perl | [The Perl Programming Language](https://www.perl.org/) | [Perl](#perl) | Perl | `perl` |
| Lua | [The Programming Language Lua](https://www.lua.org/) | [Lua](#lua) | Lua | `lua` |

## C

```C
#include <stdio.h>

int main(void)
{
puts("Hello, World!");
return 0;
}
```

Build with:

```console
gcc -Wall -o helloworld helloworld.c
```

Run with:

```console
./helloworld
```

## C++

```c++
#include <iostream>
int main()
{
std::cout << "Hello, World!" << std::endl;
return 0;
}
```

Build with:

```console
g++ -Wall -o helloworld helloworld.cpp
```

Run with:

```console
./helloworld
```

## Dlang

```dlang
import std.stdio;

void main()
{
writeln("Hello, World!");
}
```

Build with:

```console
gdc -Wall -o helloworld helloworld.cpp
```

Run with:

```console
./helloworld
```

## Go

```go
package main

import "fmt"

func main() {
fmt.Println("Hello, World!")
}
```

Build and run with:

```console
go run helloworld.go
```

## Rust

```rs
fn main() {
println!("Hello, World");
}
```

Build with:

```console
rustc hello.rs
```

Run with:

```console
./helloworld
```

## Java

```java
public class HelloWorld {
public static void main(String[] args) {
System.out.println("Hello, World!");
}
}
```

Build with:

```console
javac HelloWorld.java
```

Run with:

```console
java HelloWorld
```

## x86_64 Assembly

```as

```

Build with:

```console
TODO
```

Run with:

```console
./helloworld
```

TODO

## ARM64 Assembly

```as

```

Build with:

```console
TODO
```

Run with:

```console
./helloworld
```

## Bash

```bash
echo "Hello, World!"
```

Run with:

```console
bash helloworld.sh
```

## Python

```py
print("Hello, World!")
```

Run with:

```console
python helloworld.py
```

## Ruby

```rb
puts "Hello, World!"
```

Run with:

```console
ruby helloworld.rb
```

## PHP

```php
<?php
echo "Hello, World!"
?>
```

Run with:

```console
./helloworld
```

## Perl

```pl
print("Hello, World!\n")
```

Run with:

```console
perl helloworld.pl
```

## Lua

```lua
print("Hello, World!")
```

Run with:

```console
lua helloworld.lua
```
Empty file added my_markdown.md
Empty file.