Commit 6f450eb2252aabb90b1ce3cbbfa5de6ba79bd23b
1 parent
42a7f240
ajout 23 mai
Showing
14 changed files
with
164 additions
and
0 deletions
Show diff stats
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type
@@ -0,0 +1,119 @@ | @@ -0,0 +1,119 @@ | ||
1 | + | ||
2 | + | ||
3 | +////////////////////////////////// exercice : piste noire /////////////////////////////////// | ||
4 | + | ||
5 | +en assembleur cela fonctionne __asm__ volatile("syscall" :: "a" (60), "D" (42) ); | ||
6 | + | ||
7 | +Avec readelf on voit qu'on utilise pas de bibliotheque et il n'utilise que 6 sections | ||
8 | + | ||
9 | +pcwik@gambrinus14:~/Desktop/pierrotc/liens$ ldd minimal | ||
10 | + not a dynamic executable | ||
11 | + | ||
12 | + | ||
13 | + | ||
14 | +//////////////////////////////////// exercice "épilogue" ////////////////////////////// | ||
15 | + | ||
16 | + | ||
17 | +l'executable n'a plus que 2 sections | ||
18 | + | ||
19 | +Section Headers: | ||
20 | + [Nr] Name Type Address Offset | ||
21 | + Size EntSize Flags Link Info Align | ||
22 | + [ 0] NULL 0000000000000000 00000000 | ||
23 | + 0000000000000000 0000000000000000 0 0 0 | ||
24 | + [ 1] .text PROGBITS 00000000004000b0 000000b0 | ||
25 | + 0000000000000014 0000000000000000 AX 0 0 1 | ||
26 | + [ 2] .shstrtab STRTAB 0000000000000000 000000c4 | ||
27 | + 0000000000000011 0000000000000000 0 0 1 | ||
28 | + | ||
29 | + | ||
30 | + | ||
31 | +EDITION DES LIENS 2/5 | ||
32 | + | ||
33 | +/////////////////////////////////// Exercice "segment pour constante" /////////////////////////////////////:: | ||
34 | + | ||
35 | + | ||
36 | +void _start(void) | ||
37 | +{ | ||
38 | + | ||
39 | +char *chaine = "salut"; | ||
40 | +int i=0; | ||
41 | + | ||
42 | +while(chaine[i] != '\0') { i++; } | ||
43 | + | ||
44 | +__asm__ volatile("syscall" :: "a" (60), "D" (i) ); | ||
45 | + | ||
46 | + | ||
47 | +} | ||
48 | + | ||
49 | +AVEC LE PROGRAMME CI DESSUS j'OBTIENT LES SECTIONS CI DESSOUS : | ||
50 | + | ||
51 | +Section Headers: | ||
52 | + [Nr] Name Type Address Offset | ||
53 | + Size EntSize Flags Link Info Align | ||
54 | + [ 0] NULL 0000000000000000 00000000 | ||
55 | + 0000000000000000 0000000000000000 0 0 0 | ||
56 | + [ 1] .text PROGBITS 00000000004000b0 000000b0 | ||
57 | + 000000000000003b 0000000000000000 AX 0 0 1 | ||
58 | + [ 2] .rodata PROGBITS 00000000004000eb 000000eb | ||
59 | + 0000000000000006 0000000000000000 A 0 0 1 | ||
60 | + [ 3] .shstrtab STRTAB 0000000000000000 000000f1 | ||
61 | + 0000000000000019 0000000000000000 0 0 1 | ||
62 | + | ||
63 | + | ||
64 | +//////////////////////////////////////////////////Exercice "segment pour variable globale initialisée" //////////////////////////////// | ||
65 | + | ||
66 | + | ||
67 | +int j = 42; | ||
68 | + | ||
69 | +void _start(void) | ||
70 | +{ | ||
71 | + | ||
72 | +__asm__ volatile("syscall" :: "a" (60), "D" (j) ); | ||
73 | + | ||
74 | + | ||
75 | +} | ||
76 | + | ||
77 | +Section Headers: | ||
78 | + [Nr] Name Type Address Offset | ||
79 | + Size EntSize Flags Link Info Align | ||
80 | + [ 0] NULL 0000000000000000 00000000 | ||
81 | + 0000000000000000 0000000000000000 0 0 0 | ||
82 | + [ 1] .text PROGBITS 00000000004000b0 000000b0 | ||
83 | + 0000000000000014 0000000000000000 AX 0 0 1 | ||
84 | + [ 2] .shstrtab STRTAB 0000000000000000 000000c4 | ||
85 | + 0000000000000011 0000000000000000 0 0 1 | ||
86 | + | ||
87 | + | ||
88 | +///////////////////////////////////////////////////:: STATIQUE ///////////////////////////////////////////////////:: | ||
89 | + | ||
90 | +void _start(void) | ||
91 | + | ||
92 | +{ | ||
93 | + | ||
94 | +static int i; | ||
95 | + | ||
96 | +__asm__ volatile("syscall" :: "a" (60), "D" (i) ); | ||
97 | + | ||
98 | + | ||
99 | +} | ||
100 | + | ||
101 | + | ||
102 | + | ||
103 | +Section Headers: | ||
104 | + [Nr] Name Type Address Offset | ||
105 | + Size EntSize Flags Link Info Align | ||
106 | + [ 0] NULL 0000000000000000 00000000 | ||
107 | + 0000000000000000 0000000000000000 0 0 0 | ||
108 | + [ 1] .text PROGBITS 00000000004000e8 000000e8 | ||
109 | + 0000000000000015 0000000000000000 AX 0 0 1 | ||
110 | + [ 2] .bss NOBITS 0000000000600100 00000100 | ||
111 | + 0000000000000008 0000000000000000 WA 0 0 4 | ||
112 | + [ 3] .shstrtab STRTAB 0000000000000000 000000fd | ||
113 | + 0000000000000016 0000000000000000 0 0 1 | ||
114 | + | ||
115 | + | ||
116 | + | ||
117 | + | ||
118 | + | ||
119 | + |
No preview for this file type
No preview for this file type
No preview for this file type
No preview for this file type