// File: /workspace/github_c_makefile_star2_O1/deplinenoise[P]vlink/t_elf32.c
// Function: elf32_setlnksym
void elf32_setlnksym(struct GlobalVars *gv,struct Symbol *xdef)
/* Initialize common ELF32 linker symbol structure during resolve_xref() */
{
  if (xdef->flags & SYMF_LNKSYM) {
    struct LinkedSection *ls;

    switch (xdef->extra) {
      case SDABASE:
        if (!(ls = find_lnksec(gv,sdata_name,ST_DATA,0,0,0)))
          if (!(ls = find_lnksec(gv,sbss_name,ST_UDATA,0,0,0)))
            ls = smalldata_section(gv);
        xdef->relsect = (struct Section *)ls->sections.first;
        break;
      case SDA2BASE:
        if (!(ls = find_lnksec(gv,sdata2_name,ST_DATA,0,0,0)))
          if (!(ls = find_lnksec(gv,sbss2_name,ST_UDATA,0,0,0)))
            ls = smalldata_section(gv);
        xdef->relsect = (struct Section *)ls->sections.first;
        break;
      case CTORS:
        if (ls = find_lnksec(gv,ctors_name,0,0,0,0)) {
          xdef->type = SYM_RELOC;
          xdef->relsect = (struct Section *)ls->sections.first;
        }
        break;
      case DTORS:
        if (ls = find_lnksec(gv,dtors_name,0,0,0,0)) {
          xdef->type = SYM_RELOC;
          xdef->relsect = (struct Section *)ls->sections.first;
        }
        break;
      case GLOBOFFSTAB:
        if (ls = find_lnksec(gv,got_name,0,0,0,0)) {
          xdef->type = SYM_RELOC;
          xdef->relsect = (struct Section *)ls->sections.first;
        }
        break;
      case PROCLINKTAB:
        if (ls = find_lnksec(gv,plt_name,0,0,0,0)) {
          xdef->type = SYM_RELOC;
          xdef->relsect = (struct Section *)ls->sections.first;
        }
        break;
      case DYNAMICSYM:
        if (ls = find_lnksec(gv,dyn_name,0,0,0,0)) {
          xdef->value = ls->base;
        }
        /* @@@ when .dynamic was not created _DYNAMIC stays NULL - ok? */
        break;
    }
    xdef->flags &= ~SYMF_LNKSYM;  /* do not init again */
  }
}

// Assembly:
testb $0x1, 0x41(%rsi)
je 0x15b1f
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl 0x48(%rsi), %eax
cmpq $0x6, %rax
ja 0x15b14
movq %rdi, %r14
leaq 0xd944(%rip), %rcx      # 0x23390
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xcb55(%rip), %rsi      # 0x225b1
movq %r14, %rdi
movl $0x2, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xbeb0
testq %rax, %rax
jne 0x15b0c
leaq 0xcb37(%rip), %rsi      # 0x225b8
jmp 0x15ac6
leaq 0xcb51(%rip), %rsi      # 0x225db
jmp 0x15af1
leaq 0xcb3a(%rip), %rsi      # 0x225cd
jmp 0x15af1
leaq 0xcb38(%rip), %rsi      # 0x225d4
jmp 0x15af1
leaq 0xcb19(%rip), %rsi      # 0x225be
movq %r14, %rdi
movl $0x2, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xbeb0
testq %rax, %rax
jne 0x15b0c
leaq 0xcb00(%rip), %rsi      # 0x225c6
movq %r14, %rdi
movl $0x3, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xbeb0
testq %rax, %rax
jne 0x15b0c
movq %r14, %rdi
callq 0xca33
jmp 0x15b0c
leaq 0xcaef(%rip), %rsi      # 0x225e0
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xbeb0
testq %rax, %rax
je 0x15b14
movb $0x2, 0x40(%rbx)
movq 0x60(%rax), %rax
movq %rax, 0x38(%rbx)
andb $-0x2, 0x41(%rbx)
addq $0x8, %rsp
popq %rbx
popq %r14
retq
leaq 0xd8c7(%rip), %rsi      # 0x233ee
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xbeb0
testq %rax, %rax
je 0x15b14
movq 0x40(%rax), %rax
movq %rax, 0x30(%rbx)
jmp 0x15b14