// File: /workspace/github_c_makefile_star2_O2/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 0x14815
pushq %r14
pushq %rbx
pushq %rax
movq %rsi, %rbx
movl 0x48(%rsi), %eax
cmpq $0x6, %rax
ja 0x1480a
movq %rdi, %r14
leaq 0xcc48(%rip), %rcx      # 0x21390
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
leaq 0xbe59(%rip), %rsi      # 0x205b1
pushq $0x2
popq %rdx
movq %r14, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xb7e9
testq %rax, %rax
jne 0x14802
leaq 0xbe3d(%rip), %rsi      # 0x205b8
jmp 0x147be
leaq 0xbe57(%rip), %rsi      # 0x205db
jmp 0x147e7
leaq 0xbe40(%rip), %rsi      # 0x205cd
jmp 0x147e7
leaq 0xbe3e(%rip), %rsi      # 0x205d4
jmp 0x147e7
leaq 0xbe1f(%rip), %rsi      # 0x205be
pushq $0x2
popq %rdx
movq %r14, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xb7e9
testq %rax, %rax
jne 0x14802
leaq 0xbe08(%rip), %rsi      # 0x205c6
pushq $0x3
popq %rdx
movq %r14, %rdi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xb7e9
testq %rax, %rax
jne 0x14802
movq %r14, %rdi
callq 0xc25a
jmp 0x14802
leaq 0xbdf9(%rip), %rsi      # 0x205e0
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xb7e9
testq %rax, %rax
je 0x1480a
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 0xcbd1(%rip), %rsi      # 0x213ee
movq %r14, %rdi
xorl %edx, %edx
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
callq 0xb7e9
testq %rax, %rax
je 0x1480a
movq 0x40(%rax), %rax
movq %rax, 0x30(%rbx)
jmp 0x1480a