// File: /workspace/github_c_makefile_star2_O2/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movl %r9d, 0x14(%rsp)
movq %r8, %r14
movq %rcx, %r12
movq %rdx, %rbx
movq %rsi, %r15
movq %rdi, 0x8(%rsp)
movq 0x10(%rdx), %r13
testq %r13, %r13
je 0x179a2
movq 0x17e0b(%rip), %rbp     # 0x2f778
movq %r13, %rdi
callq 0x69ee
xorl %edx, %edx
divq 0x17e02(%rip)           # 0x2f780
leaq (%rbp,%rdx,8), %rbp
movq (%rbp), %rbp
testq %rbp, %rbp
je 0x179bc
movq 0x18(%rbp), %rsi
movq %r13, %rdi
callq 0x5160
testl %eax, %eax
je 0x179d5
addq $0x10, %rbp
jmp 0x17983
leaq 0xa0cf(%rip), %rdi      # 0x21a78
leaq 0xa095(%rip), %rsi      # 0x21a45
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x6b2c
jmp 0x179dd
movq 0x10(%rbx), %rdx
leaq 0xa092(%rip), %rdi      # 0x21a59
leaq 0xa077(%rip), %rsi      # 0x21a45
xorl %eax, %eax
callq 0x6b2c
movl 0x30(%rbp), %r13d
shll $0x8, %r13d
movl 0x50(%rsp), %ebp
movq %rbx, %rdi
callq *%r14
movl %eax, %r14d
testb %al, %al
jne 0x17a54
movq 0x30(%rbx), %rax
testq %rax, %rax
je 0x17a3f
movq 0x8(%rsp), %rcx
movzbl 0x50(%rcx), %ecx
leaq 0x17789(%rip), %rdx     # 0x2f190
movq (%rdx,%rcx,8), %rcx
movq (%rcx), %rsi
movzbl 0x38(%rbx), %ecx
leaq 0x178e7(%rip), %rdx     # 0x2f300
movq (%rdx,%rcx,8), %rdx
movzwl 0x8(%rax), %ecx
movzwl 0xa(%rax), %r8d
movq 0x10(%rax), %r9
pushq $0x20
popq %rdi
xorl %eax, %eax
pushq 0x20(%rbx)
pushq 0x18(%r15)
callq 0x6c19
popq %rax
popq %rcx
jmp 0x17a54
leaq 0xa044(%rip), %rdi      # 0x21a8a
leaq 0x9ff8(%rip), %rsi      # 0x21a45
xorl %eax, %eax
callq 0x6b2c
movl 0x20(%rbx), %edx
addl 0x40(%r15), %edx
movl %ebp, %edi
movq %r12, %rsi
callq 0x6681
leaq 0x4(%r12), %rsi
movzbl %r14b, %eax
orl %eax, %r13d
movl %ebp, %edi
movl %r13d, %edx
callq 0x6681
cmpl $0x0, 0x14(%rsp)
je 0x17aae
addq $0x8, %r12
movl 0x28(%rbx), %edx
movl %ebp, %edi
movq %r12, %rsi
callq 0x6681
movq 0x78(%r15), %rsi
addq 0x20(%rbx), %rsi
movq 0x8(%rsp), %rdi
movq %rbx, %rdx
xorl %ecx, %ecx
callq 0xaf7b
pushq $0xc
jmp 0x17ac9
movq 0x78(%r15), %rsi
addq 0x20(%rbx), %rsi
movq 0x28(%rbx), %rcx
movq 0x8(%rsp), %rdi
movq %rbx, %rdx
callq 0xaf7b
pushq $0x8
popq %rax
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq
nopl (%rax)