liens.txt 4.06 KB


//////////////////////////////////       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