// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/t_elf32.c
// Function: elf32_addrelocs
void elf32_addrelocs(struct GlobalVars *gv,
                     uint8_t (*reloc_vlink2elf)(struct Reloc *))
/* creates relocations for all sections */
{
  bool be = elf32_endianess == _BIG_ENDIAN_;
  struct LinkedSection *ls;
  struct Reloc *rel;
  uint32_t sroffs=0,roffs=0;

  for (ls=(struct LinkedSection *)gv->lnksec.first;
       ls->n.next!=NULL; ls=(struct LinkedSection *)ls->n.next) {
    sroffs = roffs;

    /* relocations */
    for (rel=(struct Reloc *)ls->relocs.first;
         rel->n.next!=NULL; rel=(struct Reloc *)rel->n.next) {
      roffs += elf32_addrela(gv,ls,rel,be,reloc_vlink2elf);
    }

    /* external references */
    for (rel=(struct Reloc *)ls->xrefs.first;
         rel->n.next!=NULL; rel=(struct Reloc *)rel->n.next) {
      roffs += elf32_addrela(gv,ls,rel,be,reloc_vlink2elf);
    }

    if (roffs != sroffs) {
      /* create ".rel(a).name" header */
      char *relname = (char *)alloc(strlen(ls->name)+6);

      sprintf(relname,".%s%s",
              gv->reloctab_format==RTAB_ADDEND ? "rela" : "rel",
              ls->name);
      elf32_addshdr(elf32_addshdrstr(relname),
                    gv->reloctab_format==RTAB_ADDEND ? SHT_RELA : SHT_REL,
                    0,0,sroffs,roffs-sroffs,0,(uint32_t)ls->index,4,
                    gv->reloctab_format==RTAB_ADDEND ?
                      sizeof(struct Elf32_Rela) : sizeof(struct Elf32_Rel),
                    be);
      /* sroffs is relative and will be corrected later */
      /* sh_link will be initialized, when .symtab exists */
    }
  }
}

// Assembly:
subq $0x68, %rsp
movq %rdi, 0x60(%rsp)
movq %rsi, 0x58(%rsp)
movsbl 0x1ad3b(%rip), %eax     # 0x402d0
cmpl $0x1, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x54(%rsp)
movl $0x0, 0x3c(%rsp)
movl $0x0, 0x38(%rsp)
movq 0x60(%rsp), %rax
movq 0x1c0(%rax), %rax
movq %rax, 0x48(%rsp)
movq 0x48(%rsp), %rax
cmpq $0x0, (%rax)
je 0x2577b
movl 0x38(%rsp), %eax
movl %eax, 0x3c(%rsp)
movq 0x48(%rsp), %rax
movq 0x80(%rax), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
cmpq $0x0, (%rax)
je 0x2562c
movq 0x60(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x40(%rsp), %rdx
movl 0x54(%rsp), %ecx
movq 0x58(%rsp), %r8
callq 0x25780
addl 0x38(%rsp), %eax
movl %eax, 0x38(%rsp)
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x40(%rsp)
jmp 0x255ed
movq 0x48(%rsp), %rax
movq 0x98(%rax), %rax
movq %rax, 0x40(%rsp)
movq 0x40(%rsp), %rax
cmpq $0x0, (%rax)
je 0x2567c
movq 0x60(%rsp), %rdi
movq 0x48(%rsp), %rsi
movq 0x40(%rsp), %rdx
movl 0x54(%rsp), %ecx
movq 0x58(%rsp), %r8
callq 0x25780
addl 0x38(%rsp), %eax
movl %eax, 0x38(%rsp)
movq 0x40(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x40(%rsp)
jmp 0x2563d
movl 0x38(%rsp), %eax
cmpl 0x3c(%rsp), %eax
je 0x25767
movq 0x48(%rsp), %rax
movq 0x18(%rax), %rdi
callq 0x50c0
movq %rax, %rdi
addq $0x6, %rdi
callq 0x71f0
movq %rax, 0x30(%rsp)
movq 0x30(%rsp), %rdi
movq 0x60(%rsp), %rax
movzbl 0x6e(%rax), %ecx
leaq 0x1113e(%rip), %rdx     # 0x367fc
leaq 0x11131(%rip), %rax     # 0x367f6
cmpl $0x2, %ecx
cmoveq %rax, %rdx
movq 0x48(%rsp), %rax
movq 0x18(%rax), %rcx
leaq 0x10f52(%rip), %rsi     # 0x3662e
movb $0x0, %al
callq 0x5230
movq 0x30(%rsp), %rdi
callq 0x25b90
movl %eax, %edi
movq 0x60(%rsp), %rax
movzbl 0x6e(%rax), %ecx
movl $0x9, %esi
movl $0x4, %eax
cmpl $0x2, %ecx
cmovel %eax, %esi
movl 0x3c(%rsp), %r8d
movl 0x38(%rsp), %r9d
subl 0x3c(%rsp), %r9d
movq 0x48(%rsp), %rax
movl 0x10(%rax), %r11d
movq 0x60(%rsp), %rax
movzbl 0x6e(%rax), %edx
movl $0x8, %eax
movl $0xc, %ecx
cmpl $0x2, %edx
cmoveq %rcx, %rax
movl %eax, %r10d
movl 0x54(%rsp), %eax
xorl %ecx, %ecx
movl %ecx, %edx
movl $0x0, (%rsp)
movl %r11d, 0x8(%rsp)
movl $0x4, 0x10(%rsp)
movl %r10d, 0x18(%rsp)
movl %eax, 0x20(%rsp)
callq 0x25a40
jmp 0x25769
movq 0x48(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x48(%rsp)
jmp 0x255c5
addq $0x68, %rsp
retq