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