// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/t_elf32.c
// Function: elf32_dynrefs
static void elf32_dynrefs(struct GlobalVars *gv,struct Elf32_Ehdr *ehdr,
                          struct ObjectUnit *ou,struct Elf32_Shdr *shdr,
                          bool be,
                          uint8_t (*reloc_elf2vlink)(uint8_t,struct RelocInsert *))
/* Find all relocs in a shared object which refer to an undefined symbol. */
{
  uint8_t *data = (uint8_t *)ehdr + read32(be,shdr->sh_offset);
  unsigned long entsize = read32(be,shdr->sh_entsize);
  uint32_t symndx = read32(be,shdr->sh_link);
  int nrelocs = (int)(read32(be,shdr->sh_size) / (uint32_t)entsize);
  struct LinkFile *lf = ou->lnkfile;
  struct Section *sec;
  struct Reloc *r;

  if ((data < lf->data)
      || (data + read32(be,shdr->sh_size) > lf->data + lf->length)) {
    error(51,lf->pathname,"reloc",lf->objname);  /* illegal offset */
  }

  /* just put all xrefs into the first section of the shared object */
  sec = abs_section(ou);

  for (; nrelocs; nrelocs--,data+=entsize) {
    struct Elf32_Rela *elfrel = (struct Elf32_Rela *)data;
    struct Elf32_Shdr *symhdr = elf32_shdr(lf,ehdr,symndx);
    struct Elf32_Sym *sym = elf32_symtab(lf,ehdr,symndx) +
                            ELF32_R_SYM(read32(be,elfrel->r_info));
    uint32_t offs = read32(be,elfrel->r_offset);
    uint32_t shndx = (uint32_t)read16(be,sym->st_shndx);
    struct RelocInsert ri,*ri_ptr;
    uint8_t rtype;

    if (shndx == SHN_UNDEF || shndx == SHN_COMMON) {
      memset(&ri,0,sizeof(struct RelocInsert));
      rtype = reloc_elf2vlink(ELF32_R_TYPE(read32(be,elfrel->r_info)),&ri);
      if (rtype == R_NONE)
        continue;
      r = newreloc(gv,sec,elf32_strtab(lf,ehdr,read32(be,symhdr->sh_link))
                   + read32(be,sym->st_name),
                   NULL,0,read32(be,elfrel->r_offset),rtype,0);
      for (ri_ptr=&ri; ri_ptr; ri_ptr=ri_ptr->next)
        addreloc(sec,r,ri_ptr->bpos,ri_ptr->bsiz,ri_ptr->mask);

      /* referenced symbol is weak? */
      if (ELF32_ST_BIND(*sym->st_info)==STB_WEAK)
        r->flags |= RELF_WEAK;
    }
  }
}

// Assembly:
subq $0x108, %rsp            # imm = 0x108
movq %rdi, 0x100(%rsp)
movq %rsi, 0xf8(%rsp)
movq %rdx, 0xf0(%rsp)
movq %rcx, 0xe8(%rsp)
movl %r8d, 0xe4(%rsp)
movq %r9, 0xd8(%rsp)
movq 0xf8(%rsp), %rax
movq %rax, 0x58(%rsp)
movl 0xe4(%rsp), %edi
movq 0xe8(%rsp), %rsi
addq $0x10, %rsi
callq 0x8060
movl %eax, %ecx
movq 0x58(%rsp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, 0xd0(%rsp)
movl 0xe4(%rsp), %edi
movq 0xe8(%rsp), %rsi
addq $0x24, %rsi
callq 0x8060
movl %eax, %eax
movq %rax, 0xc8(%rsp)
movl 0xe4(%rsp), %edi
movq 0xe8(%rsp), %rsi
addq $0x18, %rsi
callq 0x8060
movl %eax, 0xc4(%rsp)
movl 0xe4(%rsp), %edi
movq 0xe8(%rsp), %rsi
addq $0x14, %rsi
callq 0x8060
movq 0xc8(%rsp), %rcx
xorl %edx, %edx
divl %ecx
movl %eax, 0xc0(%rsp)
movq 0xf0(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0xb8(%rsp)
movq 0xd0(%rsp), %rax
movq 0xb8(%rsp), %rcx
cmpq 0x28(%rcx), %rax
jb 0x21c74
movq 0xd0(%rsp), %rax
movq %rax, 0x50(%rsp)
movl 0xe4(%rsp), %edi
movq 0xe8(%rsp), %rsi
addq $0x14, %rsi
callq 0x8060
movl %eax, %ecx
movq 0x50(%rsp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq 0xb8(%rsp), %rcx
movq 0x28(%rcx), %rcx
movq 0xb8(%rsp), %rdx
addq 0x30(%rdx), %rcx
cmpq %rcx, %rax
jbe 0x21c9f
movq 0xb8(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0xb8(%rsp), %rax
movq 0x20(%rax), %rcx
movl $0x33, %edi
leaq 0x1528b(%rip), %rdx     # 0x36f23
movb $0x0, %al
callq 0x8c00
movq 0xf0(%rsp), %rdi
callq 0x128a0
movq %rax, 0xb0(%rsp)
cmpl $0x0, 0xc0(%rsp)
je 0x21f82
movq 0xd0(%rsp), %rax
movq %rax, 0xa0(%rsp)
movq 0xb8(%rsp), %rdi
movq 0xf8(%rsp), %rsi
movl 0xc4(%rsp), %eax
movzwl %ax, %edx
callq 0x1f7f0
movq %rax, 0x98(%rsp)
movq 0xb8(%rsp), %rdi
movq 0xf8(%rsp), %rsi
movl 0xc4(%rsp), %edx
callq 0x1fa90
movq %rax, 0x48(%rsp)
movl 0xe4(%rsp), %edi
movq 0xa0(%rsp), %rsi
addq $0x4, %rsi
callq 0x8060
movl %eax, %ecx
movq 0x48(%rsp), %rax
shrl $0x8, %ecx
movl %ecx, %ecx
shlq $0x4, %rcx
addq %rcx, %rax
movq %rax, 0x90(%rsp)
movl 0xe4(%rsp), %edi
movq 0xa0(%rsp), %rsi
callq 0x8060
movl %eax, 0x8c(%rsp)
movl 0xe4(%rsp), %edi
movq 0x90(%rsp), %rsi
addq $0xe, %rsi
callq 0x8010
movzwl %ax, %eax
movl %eax, 0x88(%rsp)
cmpl $0x0, 0x88(%rsp)
je 0x21da5
cmpl $0xfff2, 0x88(%rsp) # imm = 0xFFF2
jne 0x21f52
leaq 0x70(%rsp), %rdi
xorl %esi, %esi
movl $0x18, %edx
callq 0x5100
movq 0xd8(%rsp), %rax
movq %rax, 0x40(%rsp)
movl 0xe4(%rsp), %edi
movq 0xa0(%rsp), %rsi
addq $0x4, %rsi
callq 0x8060
movl %eax, %ecx
movq 0x40(%rsp), %rax
leaq 0x70(%rsp), %rsi
movzbl %cl, %edi
callq *%rax
movb %al, 0x67(%rsp)
movzbl 0x67(%rsp), %eax
cmpl $0x0, %eax
jne 0x21dff
jmp 0x21f54
movq 0x100(%rsp), %rax
movq %rax, 0x28(%rsp)
movq 0xb0(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0xb8(%rsp), %rax
movq %rax, 0x10(%rsp)
movq 0xf8(%rsp), %rax
movq %rax, 0x18(%rsp)
movl 0xe4(%rsp), %edi
movq 0x98(%rsp), %rsi
addq $0x18, %rsi
callq 0x8060
movq 0x10(%rsp), %rdi
movq 0x18(%rsp), %rsi
movl %eax, %edx
callq 0x1f960
movq %rax, 0x20(%rsp)
movl 0xe4(%rsp), %edi
movq 0x90(%rsp), %rsi
callq 0x8060
movl %eax, %ecx
movq 0x20(%rsp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, 0x38(%rsp)
movl 0xe4(%rsp), %edi
movq 0xa0(%rsp), %rsi
callq 0x8060
movq 0x28(%rsp), %rdi
movq 0x30(%rsp), %rsi
movq 0x38(%rsp), %rdx
movl %eax, %eax
movl %eax, %r9d
xorl %eax, %eax
movl %eax, %ecx
xorl %r8d, %r8d
movzbl 0x67(%rsp), %eax
movl %eax, (%rsp)
movq $0x0, 0x8(%rsp)
callq 0x10850
movq %rax, 0xa8(%rsp)
leaq 0x70(%rsp), %rax
movq %rax, 0x68(%rsp)
cmpq $0x0, 0x68(%rsp)
je 0x21f2a
movq 0xb0(%rsp), %rdi
movq 0xa8(%rsp), %rsi
movq 0x68(%rsp), %rax
movw 0x8(%rax), %cx
movq 0x68(%rsp), %rax
movw 0xa(%rax), %ax
movq 0x68(%rsp), %rdx
movq 0x10(%rdx), %r8
movzwl %cx, %edx
movzwl %ax, %ecx
callq 0x109b0
movq 0x68(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x68(%rsp)
jmp 0x21edd
movq 0x90(%rsp), %rax
movzbl 0xc(%rax), %eax
sarl $0x4, %eax
cmpl $0x2, %eax
jne 0x21f50
movq 0xa8(%rsp), %rax
movzbl 0x39(%rax), %ecx
orl $0x1, %ecx
movb %cl, 0x39(%rax)
jmp 0x21f52
jmp 0x21f54
movl 0xc0(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0xc0(%rsp)
movq 0xc8(%rsp), %rax
addq 0xd0(%rsp), %rax
movq %rax, 0xd0(%rsp)
jmp 0x21cb4
addq $0x108, %rsp            # imm = 0x108
retq
nopw (%rax,%rax)