// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/t_elf32.c
// Function: elf32_makedynamic
static void elf32_makedynamic(struct GlobalVars *gv,
                              uint8_t (*reloc_vlink2elf)(struct Reloc *))
{
  if (gv->dynamic) {
    const char *fn = "elf32_makedynamic():";
    bool be = elf32_endianess == _BIG_ENDIAN_;
    int rela = gv->reloctab_format==RTAB_ADDEND ? 1 : 0;
    struct LinkedSection *ls;
    uint8_t *dynp,*pltp;

    if (ls = find_lnksec(gv,dynrel_name[rela],0,0,0,0))
      dynp = ls->data;
    else
      dynp = NULL;
    if (ls = find_lnksec(gv,pltrel_name[rela],0,0,0,0))
      pltp = ls->data;
    else
      pltp = NULL;

    /* write dynamic relocations */
    for (ls=(struct LinkedSection *)gv->lnksec.first;
         ls->n.next!=NULL; ls=(struct LinkedSection *)ls->n.next) {
      struct Reloc *rel = (struct Reloc *)ls->xrefs.first;
      struct Reloc *nextrel;

      while (nextrel = (struct Reloc *)rel->n.next) {
        if (rel->flags & RELF_DYN) {
          if (dynp == NULL)
            ierror("%s %s lost",fn,dynrel_name[rela]);
          dynp += elf32_putdynreloc(gv,ls,rel,dynp,reloc_vlink2elf,rela,be);
          remnode(&rel->n);
          /* free rel */
        }
        else if (rel->flags & RELF_PLT) {
          if (pltp == NULL)
            ierror("%s %s lost",fn,pltrel_name[rela]);
          pltp += elf32_putdynreloc(gv,ls,rel,pltp,reloc_vlink2elf,rela,be);
          remnode(&rel->n);
          /* free rel */
        }
        rel = nextrel;
      }
    }

    /* write dynamic symbols to .dynsym and fix their values */
    if (ls = find_lnksec(gv,dynsym_name,0,0,0,0)) {
      struct Elf32_Sym *tab = (struct Elf32_Sym *)ls->data;
      struct DynSymNode *dsn;

      elf32_putsymtab(ls->data,&elf32dsymlist);
      while (dsn = (struct DynSymNode *)remhead(&dynsym_list)) {
        uint8_t symtype = elf32_getinfo(dsn->sym);

        write32(be,tab[dsn->idx].st_value,dsn->sym->value);
        write16(be,tab[dsn->idx].st_shndx,elf32_getshndx(gv,dsn->sym,symtype));
        /* free dsn? */
      }
    }
    else
      ierror("%s %s lost",fn,dynsym_name);
  }
}

// Assembly:
subq $0x78, %rsp
movq %rdi, 0x70(%rsp)
movq %rsi, 0x68(%rsp)
movq 0x70(%rsp), %rax
cmpl $0x0, 0x240(%rax)
je 0x27342
leaq 0xf88e(%rip), %rax      # 0x36885
movq %rax, 0x60(%rsp)
movsbl 0x192cd(%rip), %eax     # 0x402d0
cmpl $0x1, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x5c(%rsp)
movq 0x70(%rsp), %rax
movzbl 0x6e(%rax), %edx
xorl %eax, %eax
movl $0x1, %ecx
cmpl $0x2, %edx
cmovel %ecx, %eax
movl %eax, 0x58(%rsp)
movq 0x70(%rsp), %rdi
movslq 0x58(%rsp), %rcx
leaq 0x192e3(%rip), %rax     # 0x40320
movq (%rax,%rcx,8), %rsi
xorl %r9d, %r9d
movl %r9d, %edx
movl %r9d, %ecx
movl %r9d, %r8d
callq 0x12110
movq %rax, 0x50(%rsp)
cmpq $0x0, %rax
je 0x2706d
movq 0x50(%rsp), %rax
movq 0x78(%rax), %rax
movq %rax, 0x48(%rsp)
jmp 0x27076
movq $0x0, 0x48(%rsp)
movq 0x70(%rsp), %rdi
movslq 0x58(%rsp), %rcx
leaq 0x192a9(%rip), %rax     # 0x40330
movq (%rax,%rcx,8), %rsi
xorl %r9d, %r9d
movl %r9d, %edx
movl %r9d, %ecx
movl %r9d, %r8d
callq 0x12110
movq %rax, 0x50(%rsp)
cmpq $0x0, %rax
je 0x270b7
movq 0x50(%rsp), %rax
movq 0x78(%rax), %rax
movq %rax, 0x40(%rsp)
jmp 0x270c0
movq $0x0, 0x40(%rsp)
movq 0x70(%rsp), %rax
movq 0x1c0(%rax), %rax
movq %rax, 0x50(%rsp)
movq 0x50(%rsp), %rax
cmpq $0x0, (%rax)
je 0x27225
movq 0x50(%rsp), %rax
movq 0x98(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x30(%rsp)
cmpq $0x0, %rax
je 0x27211
movq 0x38(%rsp), %rax
movzbl 0x39(%rax), %eax
andl $0x80, %eax
cmpl $0x0, %eax
je 0x27186
cmpq $0x0, 0x48(%rsp)
jne 0x27146
movq 0x60(%rsp), %rsi
movslq 0x58(%rsp), %rcx
leaq 0x191ec(%rip), %rax     # 0x40320
movq (%rax,%rcx,8), %rdx
leaq 0xf75b(%rip), %rdi      # 0x3689a
movb $0x0, %al
callq 0x8ae0
movq 0x70(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq 0x48(%rsp), %rcx
movq 0x68(%rsp), %r8
movl 0x58(%rsp), %r9d
movl 0x5c(%rsp), %eax
movl %eax, (%rsp)
callq 0x27530
addq 0x48(%rsp), %rax
movq %rax, 0x48(%rsp)
movq 0x38(%rsp), %rdi
callq 0x7530
jmp 0x27202
movq 0x38(%rsp), %rax
movzbl 0x39(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x27200
cmpq $0x0, 0x40(%rsp)
jne 0x271c2
movq 0x60(%rsp), %rsi
movslq 0x58(%rsp), %rcx
leaq 0x19180(%rip), %rax     # 0x40330
movq (%rax,%rcx,8), %rdx
leaq 0xf6df(%rip), %rdi      # 0x3689a
movb $0x0, %al
callq 0x8ae0
movq 0x70(%rsp), %rdi
movq 0x50(%rsp), %rsi
movq 0x38(%rsp), %rdx
movq 0x40(%rsp), %rcx
movq 0x68(%rsp), %r8
movl 0x58(%rsp), %r9d
movl 0x5c(%rsp), %eax
movl %eax, (%rsp)
callq 0x27530
addq 0x40(%rsp), %rax
movq %rax, 0x40(%rsp)
movq 0x38(%rsp), %rdi
callq 0x7530
jmp 0x27202
movq 0x30(%rsp), %rax
movq %rax, 0x38(%rsp)
jmp 0x270f1
jmp 0x27213
movq 0x50(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x50(%rsp)
jmp 0x270d1
movq 0x70(%rsp), %rdi
leaq 0xf020(%rip), %rsi      # 0x36251
xorl %r9d, %r9d
movl %r9d, %edx
movl %r9d, %ecx
movl %r9d, %r8d
callq 0x12110
movq %rax, 0x50(%rsp)
cmpq $0x0, %rax
je 0x27326
movq 0x50(%rsp), %rax
movq 0x78(%rax), %rax
movq %rax, 0x28(%rsp)
movq 0x50(%rsp), %rax
movq 0x78(%rax), %rdi
leaq 0x18fa1(%rip), %rsi     # 0x40210
callq 0x27770
leaq 0x1da15(%rip), %rdi     # 0x44c90
callq 0x74d0
movq %rax, 0x20(%rsp)
cmpq $0x0, %rax
je 0x27324
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x22ba0
movb %al, 0x1f(%rsp)
movl 0x5c(%rsp), %edi
movq 0x28(%rsp), %rsi
movq 0x20(%rsp), %rax
movl 0x18(%rax), %eax
shlq $0x4, %rax
addq %rax, %rsi
addq $0x4, %rsi
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rax
movq 0x30(%rax), %rax
movl %eax, %edx
callq 0x8130
movl 0x5c(%rsp), %eax
movl %eax, 0xc(%rsp)
movq 0x28(%rsp), %rax
movq 0x20(%rsp), %rcx
movl 0x18(%rcx), %ecx
shlq $0x4, %rcx
addq %rcx, %rax
addq $0xe, %rax
movq %rax, 0x10(%rsp)
movq 0x70(%rsp), %rdi
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rsi
movzbl 0x1f(%rsp), %edx
callq 0x23b70
movl 0xc(%rsp), %edi
movq 0x10(%rsp), %rsi
movzwl %ax, %edx
callq 0x80e0
jmp 0x27274
jmp 0x27340
movq 0x60(%rsp), %rsi
leaq 0xf568(%rip), %rdi      # 0x3689a
leaq 0xef18(%rip), %rdx      # 0x36251
movb $0x0, %al
callq 0x8ae0
jmp 0x27342
addq $0x78, %rsp
retq
nopw (%rax,%rax)