// File: /workspace/github_c_makefile_star2_O3/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
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0xb8, %rsp
movl %ecx, %r12d
movq %rdx, %r14
movl %esi, %ebx
leaq 0xf0(%rsp), %r13
movq 0x10(%r13), %rax
movq %rax, 0x10(%rsp)
movaps (%r13), %xmm0
movups %xmm0, (%rsp)
callq 0x272d
movq %rax, 0x80(%rsp)
movq (%r13), %rax
movq 0x8(%r13), %rdi
movl %ebx, 0x6c(%rsp)
movslq %ebx, %rbx
leaq (%rbx,%rbx,4), %rdx
movq 0x20(%rax,%rdx,8), %rcx
movq %rcx, 0xb0(%rsp)
movups (%rax,%rdx,8), %xmm0
movq %rdx, 0x70(%rsp)
movups 0x10(%rax,%rdx,8), %xmm1
movaps %xmm1, 0xa0(%rsp)
movaps %xmm0, 0x90(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x20(%rsp)
movaps 0x90(%rsp), %xmm0
movaps 0xa0(%rsp), %xmm1
movups %xmm1, 0x10(%rsp)
movups %xmm0, (%rsp)
callq 0x1e35
movq %rax, %r15
testl %r12d, %r12d
jne 0x3023
movq (%r13), %rax
movq 0x70(%rsp), %rcx
movl 0x10(%rax,%rcx,8), %edx
movl 0x14(%rax,%rcx,8), %eax
leal 0x7(%rax), %ecx
testl %eax, %eax
cmovnsl %eax, %ecx
sarl $0x3, %ecx
leaq 0x208e(%rip), %rdi      # 0x509b
movq %r15, %rsi
xorl %eax, %eax
callq 0x1090
leaq 0x20cb(%rip), %rdi      # 0x50e9
callq 0x1060
movq %r15, %rdi
callq 0x1030
movq 0x8(%r14), %rdi
movslq (%r14), %rax
movq (%r13), %rcx
shlq $0x3, %rbx
leaq (%rbx,%rbx,4), %rbx
movl 0x14(%rcx,%rbx), %ecx
leal 0x7(%rcx), %edx
testl %ecx, %ecx
cmovnsl %ecx, %edx
sarl $0x3, %edx
movslq %edx, %rsi
addq %rax, %rsi
shlq $0x3, %rsi
callq 0x10f0
movq %rax, 0x8(%r14)
movq 0x10(%r14), %rdi
movslq (%r14), %rax
movq (%r13), %rcx
movl 0x14(%rcx,%rbx), %ecx
leal 0x7(%rcx), %edx
testl %ecx, %ecx
cmovnsl %ecx, %edx
sarl $0x3, %edx
movslq %edx, %rsi
addq %rax, %rsi
shlq $0x2, %rsi
callq 0x10f0
movq %rax, 0x10(%r14)
movq (%r13), %rdx
cmpl $0x8, 0x14(%rdx,%rbx)
movl 0x6c(%rsp), %r9d
movq 0x70(%rsp), %r10
jl 0x3264
movq %r14, %r8
leaq 0x108(%rsp), %rcx
movb 0x5(%rcx), %r11b
movq 0x80(%rsp), %rbp
movq %rbp, %rbx
addq $0x4, %rbx
xorl %r14d, %r14d
movl %r12d, 0x7c(%rsp)
movq %r8, 0x88(%rsp)
movb %r11b, 0x6b(%rsp)
cmpb $0x2, %r11b
jne 0x30fb
xorl %ecx, %ecx
xorl %r13d, %r13d
shlq $0x8, %r13
movzbl (%rbp,%rcx), %esi
orq %rsi, %r13
incq %rcx
cmpq $0x4, %rcx
jne 0x30e4
jmp 0x311b
movq %rbp, %rsi
xorl %ecx, %ecx
xorl %r13d, %r13d
movzbl (%rsi), %edi
shll %cl, %edi
movslq %edi, %rdi
orq %rdi, %r13
addq $0x8, %rcx
incq %rsi
cmpq $0x20, %rcx
jne 0x3103
cmpb $0x2, %r11b
jne 0x313c
xorl %ecx, %ecx
xorl %r15d, %r15d
shlq $0x8, %r15
movzbl (%rbx,%rcx), %esi
orq %rsi, %r15
incq %rcx
cmpq $0x4, %rcx
jne 0x3126
jmp 0x315c
movq %rbx, %rsi
xorl %ecx, %ecx
xorl %r15d, %r15d
movzbl (%rsi), %edi
shll %cl, %edi
movslq %edi, %rdi
orq %rdi, %r15
addq $0x8, %rcx
incq %rsi
cmpq $0x20, %rcx
jne 0x3144
testl %r12d, %r12d
jne 0x3222
leaq 0x1f6d(%rip), %rdi      # 0x50d9
movq %r13, %rsi
movq %r15, %rdx
xorl %eax, %eax
callq 0x1090
movzbl %r15b, %r12d
movl %r12d, %edi
callq 0x2dd1
cmpl $0x28, %r12d
leaq 0xf0(%rsp), %r12
je 0x31f4
movq %r15, %rdi
shrq $0x8, %rdi
movq 0x10(%r12), %rax
movq %rax, 0x60(%rsp)
movups (%r12), %xmm0
movups %xmm0, 0x50(%rsp)
leaq 0x108(%rsp), %rcx
movl 0x30(%rcx), %eax
movl %eax, 0x48(%rsp)
movups (%rcx), %xmm0
movups 0x10(%rcx), %xmm1
movups 0x20(%rcx), %xmm2
movups %xmm2, 0x38(%rsp)
movups %xmm1, 0x28(%rsp)
movups %xmm0, 0x18(%rsp)
leaq 0x140(%rsp), %rcx
movq 0x10(%rcx), %rax
movq %rax, 0x10(%rsp)
movups (%rcx), %xmm0
movups %xmm0, (%rsp)
callq 0x2e6a
movl $0xa, %edi
callq 0x1040
movq 0x88(%rsp), %r8
movq 0x10(%r8), %rax
movq (%r12), %rdx
movl 0x7c(%rsp), %r12d
movl 0x6c(%rsp), %r9d
movq 0x70(%rsp), %r10
movb 0x6b(%rsp), %r11b
movslq (%r8), %rcx
leaq 0x1(%rcx), %rsi
movl %esi, (%r8)
movq 0x8(%r8), %rsi
movl %r13d, (%rsi,%rcx,8)
movl %r15d, 0x4(%rsi,%rcx,8)
movl %r9d, (%rax,%rcx,4)
incq %r14
movl 0x14(%rdx,%r10,8), %ecx
leal 0x7(%rcx), %esi
testl %ecx, %ecx
cmovnsl %ecx, %esi
sarl $0x3, %esi
movslq %esi, %rcx
addq $0x8, %rbp
addq $0x8, %rbx
cmpq %rcx, %r14
jl 0x30d9
movq 0x80(%rsp), %rdi
addq $0xb8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x1030