// File: /workspace/github_c_makefile_star2_O1/deplinenoise[P]vlink/t_elf32.c
// Function: elf32_dyncreate
void elf32_dyncreate(struct GlobalVars *gv,const char *pltgot_name)
/* generate .hash, populate .dynstr and .dynamic, allocate .dynsym,
   so that all sections have a valid size for the address calculation */
{
  const char *fn = "elf32_bssentry():";
  struct Section *dynstr,*dynsym,*pltgot;
  struct LibPath *lpn;

  if (gv->dynobj == NULL)
    ierror("%s no dynobj",fn);

  /* write SONAME and RPATHs */
  if (gv->soname && gv->dest_sharedobj)
    elf32_dynamicentry(gv,DT_SONAME,elf32_adddynstr(gv->soname),NULL);
  for (lpn=(struct LibPath *)gv->rpaths.first; lpn->n.next!=NULL;
       lpn=(struct LibPath *)lpn->n.next) {
    elf32_dynamicentry(gv,DT_RPATH,elf32_adddynstr(lpn->path),NULL);
  }

  /* generate .hash section */
  elf32_makehash(gv);

  /* allocate and populate .dynstr section */
  if (dynstr = find_sect_name(gv->dynobj,dynstr_name)) {
    dynstr->size = elf32dstrlist.nextindex;
    dynstr->data = alloc(dynstr->size);
    elf32_putstrtab(dynstr->data,&elf32dstrlist);
  }
  else
    ierror("%s %s missing",fn,dynstr_name);

  /* allocate .dynsym section - populate it later, when addresses are fixed */
  if (dynsym = find_sect_name(gv->dynobj,dynsym_name)) {
    dynsym->size = elf32dsymlist.nextindex * sizeof(struct Elf32_Sym);
    dynsym->data = alloc(dynsym->size);
  }
  else
    ierror("%s %s missing",fn,dynsym_name);

  /* finish .dynamic section */
  elf32_dynamicentry(gv,DT_HASH,0,find_sect_name(gv->dynobj,hash_name));
  elf32_dynamicentry(gv,DT_STRTAB,0,dynstr);
  elf32_dynamicentry(gv,DT_SYMTAB,0,dynsym);
  elf32_dynamicentry(gv,DT_STRSZ,dynstr->size,NULL);
  elf32_dynamicentry(gv,DT_SYMENT,sizeof(struct Elf32_Sym),NULL);
  elf32_dynamicentry(gv,DT_DEBUG,0,NULL); /* needed? */
  /* do we have a .plt or .got section (target dependant) */
  if (pltgot = find_sect_name(gv->dynobj,pltgot_name)) {
    elf32_dynamicentry(gv,DT_PLTGOT,0,pltgot);    
  }
  /* do we have .plt relocations? */
  if (pltrelocs) {
    elf32_dynamicentry(gv,DT_PLTRELSZ,pltrelocs->size,NULL);
    elf32_dynamicentry(gv,DT_PLTREL,
                       gv->reloctab_format==RTAB_ADDEND?DT_RELA:DT_REL,
                       NULL);
    elf32_dynamicentry(gv,DT_JMPREL,0,pltrelocs);
  }
  /* do we have any other dynamic relocations? */
  if (dynrelocs) {
    if (gv->reloctab_format == RTAB_ADDEND) {
      elf32_dynamicentry(gv,DT_RELA,0,dynrelocs);
      elf32_dynamicentry(gv,DT_RELASZ,dynrelocs->size,NULL);
      elf32_dynamicentry(gv,DT_RELAENT,sizeof(struct Elf32_Rela),NULL);
    }
    else {
      elf32_dynamicentry(gv,DT_REL,0,dynrelocs);
      elf32_dynamicentry(gv,DT_RELSZ,dynrelocs->size,NULL);
      elf32_dynamicentry(gv,DT_RELENT,sizeof(struct Elf32_Rel),NULL);
    }
  }
  /* end tag */
  elf32_dynamicentry(gv,DT_NULL,0,NULL);
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rsi, 0x10(%rsp)
movq %rdi, %r14
cmpq $0x0, 0x1e0(%rdi)
jne 0x16571
leaq 0xcfe6(%rip), %rdi      # 0x23549
leaq 0xd0b9(%rip), %rsi      # 0x23623
xorl %eax, %eax
callq 0x52b0
movq 0xe0(%r14), %rsi
testq %rsi, %rsi
je 0x165a1
cmpl $0x0, 0x58(%r14)
je 0x165a1
leaq 0x19225(%rip), %rdi     # 0x2f7b0
callq 0x169a2
movq %r14, %rdi
movl $0xe, %esi
movl %eax, %edx
xorl %ecx, %ecx
callq 0x16455
movq 0xf0(%r14), %rbx
cmpq $0x0, (%rbx)
je 0x165db
leaq 0x191fb(%rip), %r15     # 0x2f7b0
movq 0x10(%rbx), %rsi
movq %r15, %rdi
callq 0x169a2
movq %r14, %rdi
movl $0xf, %esi
movl %eax, %edx
xorl %ecx, %ecx
callq 0x16455
movq (%rbx), %rbx
cmpq $0x0, (%rbx)
jne 0x165b5
movb 0x1922f(%rip), %al      # 0x2f810
movl 0x19190(%rip), %r13d    # 0x2f778
movl $0x1, %esi
leaq 0xce3c(%rip), %rcx      # 0x23430
leaq 0x1(%rsi), %rdx
cmpq %r13, (%rcx,%rsi,8)
ja 0x16607
cmpq $0x10, %rsi
movq %rdx, %rsi
jne 0x165f4
xorl %ebp, %ebp
cmpb $0x1, %al
sete %bl
movq -0x10(%rcx,%rdx,8), %r15
movq %r14, 0x8(%rsp)
movq 0x1e0(%r14), %rdi
leaq 0xcdd1(%rip), %rsi      # 0x233f7
callq 0xbe62
testq %rax, %rax
je 0x166cc
movq %rax, %r14
movb %bl, %bpl
leaq (%r15,%r13), %rdi
addq $0x2, %rdi
shlq $0x2, %rdi
movq %rdi, 0x48(%rax)
callq 0x66b6
movq %rax, %r12
movq %rax, 0x40(%r14)
movl %ebp, %edi
movq %rax, %rsi
movl %r15d, %edx
callq 0x6a19
leaq 0x4(%r12), %rsi
movl %ebp, %edi
movl %r13d, %edx
callq 0x6a19
movq 0x190d7(%rip), %r14     # 0x2f750
cmpq $0x0, (%r14)
je 0x166e1
leaq 0x2(%r15), %rax
leaq (%r12,%rax,4), %rbx
addq $0x8, %r12
movq 0x18(%r14), %rdi
callq 0x6e09
xorl %edx, %edx
divq %r15
leaq (%r12,%rdx,4), %r13
movl %ebp, %edi
movq %r13, %rsi
callq 0x69b3
testl %eax, %eax
je 0x166b3
movl %eax, %eax
leaq (%rbx,%rax,4), %r13
jmp 0x1669d
movl 0x30(%r14), %edx
movl %ebp, %edi
movq %r13, %rsi
callq 0x6a19
movq (%r14), %r14
cmpq $0x0, (%r14)
jne 0x1668b
jmp 0x166e1
leaq 0xd2aa(%rip), %rdi      # 0x2397d
leaq 0xcd1d(%rip), %rsi      # 0x233f7
xorl %eax, %eax
callq 0x52b0
movq 0x8(%rsp), %rbx
movq 0x1e0(%rbx), %rdi
leaq 0xcd11(%rip), %rsi      # 0x23405
callq 0xbe62
movq %rax, %r15
testq %rax, %rax
je 0x1675a
movl 0x190d1(%rip), %edi     # 0x2f7d8
leaq 0x190a2(%rip), %r14     # 0x2f7b0
movq %rdi, 0x48(%r15)
callq 0x6668
movq %rax, %r12
movq %rax, 0x40(%r15)
movq %r14, %rdi
movq 0x8(%rsp), %rbx
callq 0x676f
testq %rax, %rax
je 0x16776
leaq 0x19079(%rip), %r13     # 0x2f7b0
movq 0x18(%rax), %rax
movb (%rax), %cl
incq %rax
movb %cl, (%r12)
incq %r12
testb %cl, %cl
jne 0x1673b
movq %r13, %rdi
callq 0x676f
testq %rax, %rax
jne 0x16737
jmp 0x16776
leaq 0xced4(%rip), %rdi      # 0x23635
leaq 0xcebb(%rip), %rsi      # 0x23623
leaq 0xcc96(%rip), %rdx      # 0x23405
xorl %eax, %eax
callq 0x52b0
movq 0x1e0(%rbx), %rdi
leaq 0xcc79(%rip), %rsi      # 0x233fd
callq 0xbe62
movq %rax, %r12
testq %rax, %rax
je 0x167ac
movl 0x18fe1(%rip), %edi     # 0x2f778
shlq $0x4, %rdi
movq %rdi, 0x48(%r12)
callq 0x6668
movq %rax, 0x40(%r12)
jmp 0x167c8
leaq 0xce82(%rip), %rdi      # 0x23635
leaq 0xce69(%rip), %rsi      # 0x23623
leaq 0xcc3c(%rip), %rdx      # 0x233fd
xorl %eax, %eax
callq 0x52b0
movq 0x1e0(%rbx), %rdi
leaq 0xcc21(%rip), %rsi      # 0x233f7
callq 0xbe62
movq %rbx, %rdi
movl $0x4, %esi
xorl %edx, %edx
movq %rax, %rcx
callq 0x16455
movq %rbx, %rdi
movl $0x5, %esi
xorl %edx, %edx
movq %r15, %rcx
callq 0x16455
movq %rbx, %rdi
movl $0x6, %esi
xorl %edx, %edx
movq %r12, %rcx
callq 0x16455
movl 0x48(%r15), %edx
movq %rbx, %rdi
movl $0xa, %esi
xorl %ecx, %ecx
callq 0x16455
movq %rbx, %rdi
movl $0xb, %esi
movl $0x10, %edx
xorl %ecx, %ecx
callq 0x16455
movq %rbx, %rdi
movl $0x15, %esi
xorl %edx, %edx
xorl %ecx, %ecx
callq 0x16455
movq 0x1e0(%rbx), %rdi
movq 0x10(%rsp), %rsi
callq 0xbe62
testq %rax, %rax
je 0x16871
movq %rbx, %rdi
movl $0x3, %esi
xorl %edx, %edx
movq %rax, %rcx
callq 0x16455
movq 0x1d078(%rip), %rax     # 0x338f0
testq %rax, %rax
je 0x168c5
movl 0x48(%rax), %edx
movq %rbx, %rdi
movl $0x2, %esi
xorl %ecx, %ecx
callq 0x16455
cmpb $0x2, 0x6e(%rbx)
movl $0x7, %eax
movl $0x11, %edx
cmovel %eax, %edx
movq %rbx, %rdi
movl $0x14, %esi
xorl %ecx, %ecx
callq 0x16455
movq 0x1d03a(%rip), %rcx     # 0x338f0
movq %rbx, %rdi
movl $0x17, %esi
xorl %edx, %edx
callq 0x16455
movq 0x1d02c(%rip), %rcx     # 0x338f8
testq %rcx, %rcx
je 0x1694a
cmpb $0x2, 0x6e(%rbx)
jne 0x1690e
movq %rbx, %rdi
movl $0x7, %esi
xorl %edx, %edx
callq 0x16455
movq 0x1d00b(%rip), %rax     # 0x338f8
movl 0x48(%rax), %edx
movq %rbx, %rdi
movl $0x8, %esi
xorl %ecx, %ecx
callq 0x16455
movq %rbx, %rdi
movl $0x9, %esi
movl $0xc, %edx
jmp 0x16943
movq %rbx, %rdi
movl $0x11, %esi
xorl %edx, %edx
callq 0x16455
movq 0x1cfd4(%rip), %rax     # 0x338f8
movl 0x48(%rax), %edx
movq %rbx, %rdi
movl $0x12, %esi
xorl %ecx, %ecx
callq 0x16455
movq %rbx, %rdi
movl $0x13, %esi
movl $0x8, %edx
xorl %ecx, %ecx
callq 0x16455
movq %rbx, %rdi
xorl %esi, %esi
xorl %edx, %edx
xorl %ecx, %ecx
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
jmp 0x16455