// File: /workspace/github_c_makefile_star2_O0/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:
subq $0x58, %rsp
movq %rdi, 0x50(%rsp)
movq %rsi, 0x48(%rsp)
leaq 0x130fe(%rip), %rax     # 0x36483
movq %rax, 0x40(%rsp)
movq 0x50(%rsp), %rax
cmpq $0x0, 0x1e0(%rax)
jne 0x233ac
movq 0x40(%rsp), %rsi
leaq 0x13004(%rip), %rdi     # 0x363a9
movb $0x0, %al
callq 0x8ae0
movq 0x50(%rsp), %rax
cmpq $0x0, 0xe0(%rax)
je 0x233f6
movq 0x50(%rsp), %rax
cmpl $0x0, 0x58(%rax)
je 0x233f6
movq 0x50(%rsp), %rax
movq %rax, 0x18(%rsp)
movq 0x50(%rsp), %rax
movq 0xe0(%rax), %rdi
callq 0x23770
movq 0x18(%rsp), %rdi
movl %eax, %edx
movl $0xe, %esi
xorl %eax, %eax
movl %eax, %ecx
callq 0x23210
movq 0x50(%rsp), %rax
movq 0xf0(%rax), %rax
movq %rax, 0x20(%rsp)
movq 0x20(%rsp), %rax
cmpq $0x0, (%rax)
je 0x2344e
movq 0x50(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0x20(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x23770
movq 0x10(%rsp), %rdi
movl %eax, %edx
movl $0xf, %esi
xorl %eax, %eax
movl %eax, %ecx
callq 0x23210
movq 0x20(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x20(%rsp)
jmp 0x23407
movq 0x50(%rsp), %rdi
callq 0x23790
movq 0x50(%rsp), %rax
movq 0x1e0(%rax), %rdi
leaq 0x12dee(%rip), %rsi     # 0x36259
callq 0x12040
movq %rax, 0x38(%rsp)
cmpq $0x0, %rax
je 0x234bd
movl 0x1ce17(%rip), %eax     # 0x40298
movl %eax, %ecx
movq 0x38(%rsp), %rax
movq %rcx, 0x48(%rax)
movq 0x38(%rsp), %rax
movq 0x48(%rax), %rdi
callq 0x71f0
movq %rax, %rcx
movq 0x38(%rsp), %rax
movq %rcx, 0x40(%rax)
movq 0x38(%rsp), %rax
movq 0x40(%rax), %rdi
leaq 0x1cdba(%rip), %rsi     # 0x40270
callq 0x23940
jmp 0x234d7
movq 0x40(%rsp), %rsi
leaq 0x12fcc(%rip), %rdi     # 0x36495
leaq 0x12d89(%rip), %rdx     # 0x36259
movb $0x0, %al
callq 0x8ae0
movq 0x50(%rsp), %rax
movq 0x1e0(%rax), %rdi
leaq 0x12d67(%rip), %rsi     # 0x36251
callq 0x12040
movq %rax, 0x30(%rsp)
cmpq $0x0, %rax
je 0x2352b
movl 0x1cd38(%rip), %eax     # 0x40238
movl %eax, %ecx
shlq $0x4, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x48(%rax)
movq 0x30(%rsp), %rax
movq 0x48(%rax), %rdi
callq 0x71f0
movq %rax, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x40(%rax)
jmp 0x23545
movq 0x40(%rsp), %rsi
leaq 0x12f5e(%rip), %rdi     # 0x36495
leaq 0x12d13(%rip), %rdx     # 0x36251
movb $0x0, %al
callq 0x8ae0
movq 0x50(%rsp), %rax
movq %rax, 0x8(%rsp)
movq 0x50(%rsp), %rax
movq 0x1e0(%rax), %rdi
leaq 0x12ce9(%rip), %rsi     # 0x3624b
callq 0x12040
movq 0x8(%rsp), %rdi
movq %rax, %rcx
movl $0x4, %esi
xorl %edx, %edx
callq 0x23210
movq 0x50(%rsp), %rdi
movq 0x38(%rsp), %rcx
movl $0x5, %esi
xorl %edx, %edx
callq 0x23210
movq 0x50(%rsp), %rdi
movq 0x30(%rsp), %rcx
movl $0x6, %esi
xorl %edx, %edx
callq 0x23210
movq 0x50(%rsp), %rdi
movq 0x38(%rsp), %rax
movq 0x48(%rax), %rax
movl %eax, %edx
movl $0xa, %esi
xorl %eax, %eax
movl %eax, %ecx
callq 0x23210
movq 0x50(%rsp), %rdi
movl $0xb, %esi
movl $0x10, %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x23210
movq 0x50(%rsp), %rdi
movl $0x15, %esi
xorl %edx, %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x23210
movq 0x50(%rsp), %rax
movq 0x1e0(%rax), %rdi
movq 0x48(%rsp), %rsi
callq 0x12040
movq %rax, 0x28(%rsp)
cmpq $0x0, %rax
je 0x23629
movq 0x50(%rsp), %rdi
movq 0x28(%rsp), %rcx
movl $0x3, %esi
xorl %edx, %edx
callq 0x23210
cmpq $0x0, 0x2168f(%rip)     # 0x44cc0
je 0x23697
movq 0x50(%rsp), %rdi
movq 0x21681(%rip), %rax     # 0x44cc0
movq 0x48(%rax), %rax
movl %eax, %edx
movl $0x2, %esi
xorl %eax, %eax
movl %eax, %ecx
callq 0x23210
movq 0x50(%rsp), %rdi
movq 0x50(%rsp), %rax
movzbl 0x6e(%rax), %ecx
movl $0x11, %edx
movl $0x7, %eax
cmpl $0x2, %ecx
cmovel %eax, %edx
movl $0x14, %esi
xorl %eax, %eax
movl %eax, %ecx
callq 0x23210
movq 0x50(%rsp), %rdi
movq 0x21635(%rip), %rcx     # 0x44cc0
movl $0x17, %esi
xorl %edx, %edx
callq 0x23210
cmpq $0x0, 0x21629(%rip)     # 0x44cc8
je 0x23757
movq 0x50(%rsp), %rax
movzbl 0x6e(%rax), %eax
cmpl $0x2, %eax
jne 0x23705
movq 0x50(%rsp), %rdi
movq 0x21609(%rip), %rcx     # 0x44cc8
movl $0x7, %esi
xorl %edx, %edx
callq 0x23210
movq 0x50(%rsp), %rdi
movq 0x215f1(%rip), %rax     # 0x44cc8
movq 0x48(%rax), %rax
movl %eax, %edx
movl $0x8, %esi
xorl %eax, %eax
movl %eax, %ecx
callq 0x23210
movq 0x50(%rsp), %rdi
movl $0x9, %esi
movl $0xc, %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x23210
jmp 0x23755
movq 0x50(%rsp), %rdi
movq 0x215b7(%rip), %rcx     # 0x44cc8
movl $0x11, %esi
xorl %edx, %edx
callq 0x23210
movq 0x50(%rsp), %rdi
movq 0x2159f(%rip), %rax     # 0x44cc8
movq 0x48(%rax), %rax
movl %eax, %edx
movl $0x12, %esi
xorl %eax, %eax
movl %eax, %ecx
callq 0x23210
movq 0x50(%rsp), %rdi
movl $0x13, %esi
movl $0x8, %edx
xorl %eax, %eax
movl %eax, %ecx
callq 0x23210
jmp 0x23757
movq 0x50(%rsp), %rdi
xorl %edx, %edx
xorl %eax, %eax
movl %eax, %ecx
movl %edx, %esi
callq 0x23210
addq $0x58, %rsp
retq
nop