// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/t_elf32.c
// Function: elf32_putdynreloc
static size_t elf32_putdynreloc(struct GlobalVars *gv,struct LinkedSection *ls,
                                struct Reloc *rel,void *dst,
                                uint8_t (*reloc_vlink2elf)(struct Reloc *),
                                bool rela,bool be)
{
  const char *fn = "elf32_putdynreloc()";
  struct Elf32_Rela *rp = (struct Elf32_Rela *)dst;
  uint32_t symidx;
  uint8_t rtype;

  if (rel->xrefname) {
    struct SymbolNode *sn;

    sn = elf32_findSymNode(&elf32dsymlist,rel->xrefname);
    if (sn == NULL)
      ierror("%s no symbol <%s> in dyn.table",fn,rel->xrefname);
    symidx = sn->index;
  }
  else
    ierror("%s no symbol base",fn);

  if (!(rtype = reloc_vlink2elf(rel))) {
    struct RelocInsert *ri;

    if (ri = rel->insert)
      error(32,fff[gv->dest_format]->tname,reloc_name[rel->rtype],
            (int)ri->bpos,(int)ri->bsiz,ri->mask,ls->name,rel->offset);
    else
      ierror("%s Reloc without insert-field",fn);
  }

  write32(be,rp->r_offset,(uint32_t)(ls->base + rel->offset));
  write32(be,rp->r_info,ELF32_R_INFO(symidx,(uint32_t)rtype));

  if (rela) {
    write32(be,rp->r_addend,(uint32_t)rel->addend);
    writesection(gv,ls->data+rel->offset,rel,0);
    return sizeof(struct Elf32_Rela);
  }
  writesection(gv,ls->data+rel->offset,rel,rel->addend);
  return sizeof(struct Elf32_Rel);
}

// Assembly:
subq $0x78, %rsp
movl 0x80(%rsp), %eax
movq %rdi, 0x68(%rsp)
movq %rsi, 0x60(%rsp)
movq %rdx, 0x58(%rsp)
movq %rcx, 0x50(%rsp)
movq %r8, 0x48(%rsp)
movl %r9d, 0x44(%rsp)
leaq 0xf345(%rip), %rax      # 0x368a5
movq %rax, 0x38(%rsp)
movq 0x50(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0x58(%rsp), %rax
cmpq $0x0, 0x10(%rax)
je 0x275c7
movq 0x58(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0x18c85(%rip), %rdi     # 0x40210
callq 0x277c0
movq %rax, 0x20(%rsp)
cmpq $0x0, 0x20(%rsp)
jne 0x275b9
movq 0x38(%rsp), %rsi
movq 0x58(%rsp), %rax
movq 0x10(%rax), %rdx
leaq 0xf307(%rip), %rdi      # 0x368b9
movb $0x0, %al
callq 0x8ae0
movq 0x20(%rsp), %rax
movl 0x30(%rax), %eax
movl %eax, 0x2c(%rsp)
jmp 0x275da
movq 0x38(%rsp), %rsi
leaq 0xf305(%rip), %rdi      # 0x368d8
movb $0x0, %al
callq 0x8ae0
movq 0x48(%rsp), %rax
movq 0x58(%rsp), %rdi
callq *%rax
movb %al, 0x2b(%rsp)
cmpb $0x0, %al
jne 0x2768f
movq 0x58(%rsp), %rax
movq 0x30(%rax), %rax
movq %rax, 0x18(%rsp)
cmpq $0x0, %rax
je 0x2767a
movq 0x68(%rsp), %rax
movzbl 0x50(%rax), %eax
movl %eax, %ecx
leaq 0x18418(%rip), %rax     # 0x3fa30
movq (%rax,%rcx,8), %rax
movq (%rax), %rsi
movq 0x58(%rsp), %rax
movzbl 0x38(%rax), %eax
movl %eax, %ecx
leaq 0x1856f(%rip), %rax     # 0x3fba0
movq (%rax,%rcx,8), %rdx
movq 0x18(%rsp), %rax
movzwl 0x8(%rax), %ecx
movq 0x18(%rsp), %rax
movzwl 0xa(%rax), %r8d
movq 0x18(%rsp), %rax
movq 0x10(%rax), %r9
movq 0x60(%rsp), %rax
movq 0x18(%rax), %r10
movq 0x58(%rsp), %rax
movq 0x20(%rax), %rax
movl $0x20, %edi
movq %r10, (%rsp)
movq %rax, 0x8(%rsp)
movb $0x0, %al
callq 0x8c00
jmp 0x2768d
movq 0x38(%rsp), %rsi
leaq 0xf264(%rip), %rdi      # 0x368ea
movb $0x0, %al
callq 0x8ae0
jmp 0x2768f
movl 0x80(%rsp), %edi
movq 0x30(%rsp), %rsi
movq 0x60(%rsp), %rax
movq 0x40(%rax), %rax
movq 0x58(%rsp), %rcx
addq 0x20(%rcx), %rax
movl %eax, %edx
callq 0x8130
movl 0x80(%rsp), %edi
movq 0x30(%rsp), %rsi
addq $0x4, %rsi
movl 0x2c(%rsp), %edx
shll $0x8, %edx
movzbl 0x2b(%rsp), %eax
movzbl %al, %eax
addl %eax, %edx
callq 0x8130
cmpl $0x0, 0x44(%rsp)
je 0x27731
movl 0x80(%rsp), %edi
movq 0x30(%rsp), %rsi
addq $0x8, %rsi
movq 0x58(%rsp), %rax
movq 0x28(%rax), %rax
movl %eax, %edx
callq 0x8130
movq 0x68(%rsp), %rdi
movq 0x60(%rsp), %rax
movq 0x78(%rax), %rsi
movq 0x58(%rsp), %rax
addq 0x20(%rax), %rsi
movq 0x58(%rsp), %rdx
xorl %eax, %eax
movl %eax, %ecx
callq 0x110c0
movq $0xc, 0x70(%rsp)
jmp 0x27764
movq 0x68(%rsp), %rdi
movq 0x60(%rsp), %rax
movq 0x78(%rax), %rsi
movq 0x58(%rsp), %rax
addq 0x20(%rax), %rsi
movq 0x58(%rsp), %rdx
movq 0x58(%rsp), %rax
movq 0x28(%rax), %rcx
callq 0x110c0
movq $0x8, 0x70(%rsp)
movq 0x70(%rsp), %rax
addq $0x78, %rsp
retq
nop