// File: /workspace/github_c_makefile_star2_O0/Astor-Bizard[P]ProjetS5_Groupe2/src/affichage_relocation.c
// Function: afficher_sectionR
void afficher_sectionR(FILE *f,
                        SectionsHeadersList liste_sections,
                        Elf32_Ehdr header,
                        int numS, 
                        Str_Reloc *RETOUR, 
                        ListeSymboles table_symbol, 
                        int silent)
{
	int i;
	unsigned char *section;
    section = recuperer_section_num(f, liste_sections, numS); // Y'a rien a voir circulez!
	unsigned long long int addr;
	unsigned long long int info;
    unsigned char type;
    unsigned int sym;
    
    char *nom_section = getSectionNameBis(liste_sections.names, liste_sections.headers[numS]);
    if(!silent)
    {
    	printf("\nRelocation section '%s' at offset 0x%x contains %i entries:\n",
                nom_section,
                liste_sections.headers[numS].sh_offset,
    			(int) liste_sections.headers[numS].sh_size/8);
    	printf(" Offset     Info    Type            Sym.Value  Sym. Name\n");
    }
    free(nom_section);

    RETOUR->Rel = realloc(RETOUR->Rel,sizeof(Elf32_Rel)*(RETOUR->nb_Rel+(int) liste_sections.headers[numS].sh_size/8));
    RETOUR->Sec_Rel = realloc(RETOUR->Sec_Rel,sizeof(int)*(RETOUR->nb_Rel+(int) liste_sections.headers[numS].sh_size/8));

	for(i=0; i<(int) liste_sections.headers[numS].sh_size/8; i++)
	{
		addr = lire_octets_charT(section, header.e_ident[EI_DATA], i*8, 4);
		info = lire_octets_charT(section, header.e_ident[EI_DATA], i*8 +4,4);
        type = info;
        sym = info >>8;

        if(!silent)
        {
    		printf("%08llx  %08llx ", addr,info);
            type_relocation(type);
            if(type != 40) print_symbol(sym, table_symbol, header, liste_sections);
            //print_section(addr, liste_sections, header); 
            
            //on affiche les infos.
            sym = sym *2;
            printf("\n");
        }
        RETOUR->nb_Rel ++;

        
        RETOUR->Rel[RETOUR->nb_Rel-1].r_offset = addr;
        RETOUR->Rel[RETOUR->nb_Rel-1].r_info = info;
        RETOUR->Sec_Rel[RETOUR->nb_Rel-1] = numS;
	}
	free(section);
}

// Assembly:
pushq %rbp
movq %rsp, %rbp
subq $0x110, %rsp            # imm = 0x110
leaq 0x60(%rbp), %rax
movq %rax, -0x90(%rbp)
leaq 0x28(%rbp), %rax
movq %rax, -0x88(%rbp)
leaq 0x10(%rbp), %rax
movq %rax, -0x80(%rbp)
movq %rdi, -0x8(%rbp)
movl %esi, -0xc(%rbp)
movq %rdx, -0x18(%rbp)
movl %ecx, -0x1c(%rbp)
movq -0x8(%rbp), %rdi
movl -0xc(%rbp), %esi
movq (%rax), %rcx
movq %rcx, (%rsp)
movq 0x8(%rax), %rcx
movq %rcx, 0x8(%rsp)
movq 0x10(%rax), %rax
movq %rax, 0x10(%rsp)
callq 0x33a0
movq %rax, %rcx
movq -0x80(%rbp), %rax
movq %rcx, -0x28(%rbp)
movq 0x8(%rax), %rcx
movq %rcx, -0x78(%rbp)
movq (%rax), %rsi
movslq -0xc(%rbp), %rax
imulq $0x28, %rax, %rax
addq %rax, %rsi
leaq -0x70(%rbp), %rdi
movl $0x28, %edx
callq 0x10b0
movq -0x78(%rbp), %rdi
movq -0x50(%rbp), %rcx
movq %rsp, %rax
movq %rcx, 0x20(%rax)
movups -0x70(%rbp), %xmm0
movups -0x60(%rbp), %xmm1
movups %xmm1, 0x10(%rax)
movups %xmm0, (%rax)
callq 0x24f0
movq %rax, -0x48(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x4434
movq -0x80(%rbp), %rax
movq -0x48(%rbp), %rsi
movq (%rax), %rcx
movslq -0xc(%rbp), %rdx
imulq $0x28, %rdx, %rdx
addq %rdx, %rcx
movl 0x10(%rcx), %ecx
movl %ecx, -0x94(%rbp)
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl -0x94(%rbp), %edx
movl %eax, %ecx
leaq 0x1e90(%rip), %rdi      # 0x62af
movb $0x0, %al
callq 0x1070
leaq 0x1ec0(%rip), %rdi      # 0x62ed
movb $0x0, %al
callq 0x1070
movq -0x48(%rbp), %rdi
callq 0x1030
movq -0x80(%rbp), %rax
movq -0x18(%rbp), %rcx
movq 0x8(%rcx), %rdi
movq -0x18(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, -0x9c(%rbp)
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x9c(%rbp), %eax
addl %ecx, %eax
movslq %eax, %rsi
shlq $0x3, %rsi
callq 0x10e0
movq %rax, %rdx
movq -0x80(%rbp), %rax
movq -0x18(%rbp), %rcx
movq %rdx, 0x8(%rcx)
movq -0x18(%rbp), %rcx
movq 0x10(%rcx), %rdi
movq -0x18(%rbp), %rcx
movl (%rcx), %ecx
movl %ecx, -0x98(%rbp)
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0x98(%rbp), %eax
addl %ecx, %eax
movslq %eax, %rsi
shlq $0x2, %rsi
callq 0x10e0
movq %rax, %rcx
movq -0x18(%rbp), %rax
movq %rcx, 0x10(%rax)
movl $0x0, -0x20(%rbp)
movq -0x80(%rbp), %rax
movl -0x20(%rbp), %ecx
movl %ecx, -0xa0(%rbp)
movq (%rax), %rax
movslq -0xc(%rbp), %rcx
imulq $0x28, %rcx, %rcx
addq %rcx, %rax
movl 0x14(%rax), %eax
movl $0x8, %ecx
cltd
idivl %ecx
movl %eax, %ecx
movl -0xa0(%rbp), %eax
cmpl %ecx, %eax
jge 0x4690
movq -0x88(%rbp), %rax
movq -0x28(%rbp), %rdi
movzbl 0x5(%rax), %esi
movl -0x20(%rbp), %edx
shll $0x3, %edx
movl $0x4, %ecx
callq 0x3e00
movq %rax, %rcx
movq -0x88(%rbp), %rax
movq %rcx, -0x30(%rbp)
movq -0x28(%rbp), %rdi
movzbl 0x5(%rax), %esi
movl -0x20(%rbp), %edx
shll $0x3, %edx
addl $0x4, %edx
movl $0x4, %ecx
callq 0x3e00
movq %rax, -0x38(%rbp)
movq -0x38(%rbp), %rax
movb %al, -0x39(%rbp)
movq -0x38(%rbp), %rax
shrq $0x8, %rax
movl %eax, -0x40(%rbp)
cmpl $0x0, -0x1c(%rbp)
jne 0x4622
movq -0x30(%rbp), %rsi
movq -0x38(%rbp), %rdx
leaq 0x1d92(%rip), %rdi      # 0x6327
movb $0x0, %al
callq 0x1070
movzbl -0x39(%rbp), %edi
callq 0x3eb0
movzbl -0x39(%rbp), %eax
cmpl $0x28, %eax
je 0x460c
movq -0x90(%rbp), %rcx
movq -0x88(%rbp), %rdx
movq -0x80(%rbp), %rsi
movl -0x40(%rbp), %edi
movq 0x10(%rsi), %r8
movq %rsp, %rax
movq %rax, -0xa8(%rbp)
movq %r8, 0x60(%rax)
movups (%rsi), %xmm0
movups %xmm0, 0x50(%rax)
movl 0x30(%rdx), %esi
movl %esi, 0x48(%rax)
movups (%rdx), %xmm0
movups 0x10(%rdx), %xmm1
movups 0x20(%rdx), %xmm2
movups %xmm2, 0x38(%rax)
movups %xmm1, 0x28(%rax)
movups %xmm0, 0x18(%rax)
movq 0x10(%rcx), %rdx
movq %rdx, 0x10(%rax)
movups (%rcx), %xmm0
movups %xmm0, (%rax)
callq 0x4210
movl -0x40(%rbp), %eax
shll %eax
movl %eax, -0x40(%rbp)
leaq 0x145f(%rip), %rdi      # 0x5a7a
movb $0x0, %al
callq 0x1070
movq -0x18(%rbp), %rax
movl (%rax), %ecx
addl $0x1, %ecx
movl %ecx, (%rax)
movq -0x30(%rbp), %rax
movl %eax, %edx
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,8)
movq -0x38(%rbp), %rax
movl %eax, %edx
movq -0x18(%rbp), %rax
movq 0x8(%rax), %rax
movq -0x18(%rbp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, 0x4(%rax,%rcx,8)
movl -0xc(%rbp), %edx
movq -0x18(%rbp), %rax
movq 0x10(%rax), %rax
movq -0x18(%rbp), %rcx
movl (%rcx), %ecx
subl $0x1, %ecx
movslq %ecx, %rcx
movl %edx, (%rax,%rcx,4)
movl -0x20(%rbp), %eax
addl $0x1, %eax
movl %eax, -0x20(%rbp)
jmp 0x44e8
movq -0x28(%rbp), %rdi
callq 0x1030
addq $0x110, %rsp            # imm = 0x110
popq %rbp
retq
nopw %cs:(%rax,%rax)