// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/t_elf32.c
// Function: elf32_symbols
void elf32_symbols(struct GlobalVars *gv,struct Elf32_Ehdr *ehdr,
                   struct ObjectUnit *ou,struct Elf32_Shdr *shdr)
/* convert ELF symbol definitions into internal format */
{
  bool be = (ehdr->e_ident[EI_DATA] == ELFDATA2MSB);
  uint8_t flags = (read32(be,shdr->sh_type)==SHT_DYNSYM) ? SYMF_SHLIB : 0;
  struct LinkFile *lf = ou->lnkfile;
  uint8_t *data = (uint8_t *)ehdr + read32(be,shdr->sh_offset);
  unsigned long entsize = read32(be,shdr->sh_entsize);
  int nsyms = (int)(read32(be,shdr->sh_size) / (uint32_t)entsize);
  char *strtab = elf32_strtab(lf,ehdr,read32(be,shdr->sh_link));
  struct Section *sec;
  struct Elf32_Sym *elfsym;

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

  /* read ELF xdef symbols and convert to internal format */
  while (--nsyms > 0) {
    int shndx;
    char *symname;
    uint8_t type=0;
    uint8_t objinfo,objbind;

    elfsym = (struct Elf32_Sym *)(data += entsize);
    symname = strtab + read32(be,elfsym->st_name);
    if (symname<(char *)lf->data || symname>(char *)lf->data+lf->length)
      error(127,lf->pathname,read32(be,elfsym->st_name),lf->objname);

    if (flags & SYMF_SHLIB) {
      /* don't import linker symbols from shared objects - we make our own */
      int i;

      for (i=0; i<(sizeof(elf32_symnames)/sizeof(elf32_symnames[0])); i++) {
        if (!strcmp(elf32_symnames[i],symname)) {
          symname = NULL;
          break;
        }
      }
      if (!symname)
        continue;
    }

    switch (shndx = (int)read16(be,elfsym->st_shndx)) {
      case SHN_UNDEF:
        sec = NULL;  /* ignore xrefs for now */
        break;
      /* assign a section for ABS and COMMON symbols */
      case SHN_ABS:
        sec = abs_section(ou);
        type = SYM_ABS;
        break;
      case SHN_COMMON:
        sec = common_section(gv,ou);
        type = SYM_COMMON;
        break;
      /* reloc symbols have a definite section to which they belong */
      default:
        if (read32(be,shdr->sh_type) == SHT_DYNSYM) {
          /* just put dynamic symbols into the first section -
             the section index might be wrong in .dynsym */
          sec = abs_section(ou);
        }
        else if (!(sec = find_sect_id(ou,shndx))) {
          /* a section with this index doesn't exist! */
          if (ELF32_ST_TYPE(*elfsym->st_info) != STT_SECTION)
            error(53,lf->pathname,symname,lf->objname,shndx);
        }
        type = SYM_RELOC;
        break;
    }

    if ((objinfo = ELF32_ST_TYPE(*elfsym->st_info)) == STT_SECTION)
      sec = NULL;  /* ignore section defines - will be reproduced */

    if (sec) {
      if (objinfo > STT_FILE) {
        /* illegal symbol type */
        error(54,lf->pathname,(int)objinfo,symname,lf->objname);
        objinfo = STT_NOTYPE;
      }
      switch (ELF32_ST_BIND(*elfsym->st_info)) {
        case STB_LOCAL:
          objbind = SYMB_LOCAL;
          break;
        case STB_GLOBAL:
          objbind = SYMB_GLOBAL;
          break;
        case STB_WEAK:
          objbind = SYMB_WEAK;
          break;
        default:  /* illegal binding type */
          error(55,lf->pathname,symname,ELF32_ST_BIND(*elfsym->st_info),
                lf->objname);
          objbind = SYMB_LOCAL;
          break;
      }

      /* add a new symbol definition */
      if (objbind == SYMB_LOCAL) {
        addlocsymbol(gv,sec,symname,NULL,(int32_t)read32(be,elfsym->st_value),
                     type,flags,objinfo,read32(be,elfsym->st_size));
      }
      else {
        addsymbol(gv,sec,symname,NULL,(int32_t)read32(be,elfsym->st_value),
                  type,flags,objinfo,objbind,read32(be,elfsym->st_size),TRUE);
      }
    }
  }
}

// Assembly:
pushq %rbx
subq $0x130, %rsp            # imm = 0x130
movq %rdi, 0x128(%rsp)
movq %rsi, 0x120(%rsp)
movq %rdx, 0x118(%rsp)
movq %rcx, 0x110(%rsp)
movq 0x120(%rsp), %rax
movzbl 0x5(%rax), %eax
cmpl $0x2, %eax
sete %al
andb $0x1, %al
movzbl %al, %eax
movl %eax, 0x10c(%rsp)
movl 0x10c(%rsp), %edi
movq 0x110(%rsp), %rsi
addq $0x4, %rsi
callq 0x8060
movl %eax, %edx
xorl %eax, %eax
movl $0x10, %ecx
cmpl $0xb, %edx
cmovel %ecx, %eax
movb %al, 0x10b(%rsp)
movq 0x118(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x100(%rsp)
movq 0x120(%rsp), %rax
movq %rax, 0xa0(%rsp)
movl 0x10c(%rsp), %edi
movq 0x110(%rsp), %rsi
addq $0x10, %rsi
callq 0x8060
movl %eax, %ecx
movq 0xa0(%rsp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, 0xf8(%rsp)
movl 0x10c(%rsp), %edi
movq 0x110(%rsp), %rsi
addq $0x24, %rsi
callq 0x8060
movl %eax, %eax
movq %rax, 0xf0(%rsp)
movl 0x10c(%rsp), %edi
movq 0x110(%rsp), %rsi
addq $0x14, %rsi
callq 0x8060
movq 0xf0(%rsp), %rcx
xorl %edx, %edx
divl %ecx
movl %eax, 0xec(%rsp)
movq 0x100(%rsp), %rax
movq %rax, 0xa8(%rsp)
movq 0x120(%rsp), %rax
movq %rax, 0xb0(%rsp)
movl 0x10c(%rsp), %edi
movq 0x110(%rsp), %rsi
addq $0x18, %rsi
callq 0x8060
movq 0xa8(%rsp), %rdi
movq 0xb0(%rsp), %rsi
movl %eax, %edx
callq 0x1f960
movq %rax, 0xe0(%rsp)
movq 0xf8(%rsp), %rax
movq 0x100(%rsp), %rcx
cmpq 0x28(%rcx), %rax
jb 0x20115
movq 0xf8(%rsp), %rax
movq %rax, 0x98(%rsp)
movl 0x10c(%rsp), %edi
movq 0x110(%rsp), %rsi
addq $0x14, %rsi
callq 0x8060
movl %eax, %ecx
movq 0x98(%rsp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq 0x100(%rsp), %rcx
movq 0x28(%rcx), %rcx
movq 0x100(%rsp), %rdx
addq 0x30(%rdx), %rcx
cmpq %rcx, %rax
jbe 0x20140
movq 0x100(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0x100(%rsp), %rax
movq 0x20(%rax), %rcx
movl $0x33, %edi
leaq 0x145be(%rip), %rdx     # 0x346f7
movb $0x0, %al
callq 0x8c00
jmp 0x20142
movl 0xec(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0xec(%rsp)
cmpl $0x0, %eax
jle 0x206f0
movb $0x0, 0xbf(%rsp)
movq 0xf0(%rsp), %rax
addq 0xf8(%rsp), %rax
movq %rax, 0xf8(%rsp)
movq %rax, 0xd0(%rsp)
movq 0xe0(%rsp), %rax
movq %rax, 0x90(%rsp)
movl 0x10c(%rsp), %edi
movq 0xd0(%rsp), %rsi
callq 0x8060
movl %eax, %ecx
movq 0x90(%rsp), %rax
movl %ecx, %ecx
addq %rcx, %rax
movq %rax, 0xc0(%rsp)
movq 0xc0(%rsp), %rax
movq 0x100(%rsp), %rcx
cmpq 0x28(%rcx), %rax
jb 0x201fa
movq 0xc0(%rsp), %rax
movq 0x100(%rsp), %rcx
movq 0x28(%rcx), %rcx
movq 0x100(%rsp), %rdx
addq 0x30(%rdx), %rcx
cmpq %rcx, %rax
jbe 0x20244
movq 0x100(%rsp), %rax
movq 0x10(%rax), %rax
movq %rax, 0x88(%rsp)
movl 0x10c(%rsp), %edi
movq 0xd0(%rsp), %rsi
callq 0x8060
movq 0x88(%rsp), %rsi
movl %eax, %edx
movq 0x100(%rsp), %rax
movq 0x20(%rax), %rcx
movl $0x7f, %edi
movb $0x0, %al
callq 0x8c00
movzbl 0x10b(%rsp), %eax
andl $0x10, %eax
cmpl $0x0, %eax
je 0x202c7
movl $0x0, 0xb8(%rsp)
movslq 0xb8(%rsp), %rax
cmpq $0x7, %rax
jae 0x202b5
movslq 0xb8(%rsp), %rcx
leaq 0x20064(%rip), %rax     # 0x402e0
movq (%rax,%rcx,8), %rdi
movq 0xc0(%rsp), %rsi
callq 0x5130
cmpl $0x0, %eax
jne 0x202a0
movq $0x0, 0xc0(%rsp)
jmp 0x202b5
jmp 0x202a2
movl 0xb8(%rsp), %eax
addl $0x1, %eax
movl %eax, 0xb8(%rsp)
jmp 0x2025f
cmpq $0x0, 0xc0(%rsp)
jne 0x202c5
jmp 0x20142
jmp 0x202c7
movl 0x10c(%rsp), %edi
movq 0xd0(%rsp), %rsi
addq $0xe, %rsi
callq 0x8010
movzwl %ax, %ecx
movl %ecx, 0x84(%rsp)
movl %ecx, 0xcc(%rsp)
testw %ax, %ax
je 0x20317
jmp 0x202f7
movl 0x84(%rsp), %eax
subl $0xfff1, %eax           # imm = 0xFFF1
je 0x20328
jmp 0x20307
movl 0x84(%rsp), %eax
subl $0xfff2, %eax           # imm = 0xFFF2
je 0x2034a
jmp 0x20374
movq $0x0, 0xd8(%rsp)
jmp 0x2041e
movq 0x118(%rsp), %rdi
callq 0x128a0
movq %rax, 0xd8(%rsp)
movb $0x1, 0xbf(%rsp)
jmp 0x2041e
movq 0x128(%rsp), %rdi
movq 0x118(%rsp), %rsi
callq 0x12780
movq %rax, 0xd8(%rsp)
movb $0x3, 0xbf(%rsp)
jmp 0x2041e
movl 0x10c(%rsp), %edi
movq 0x110(%rsp), %rsi
addq $0x4, %rsi
callq 0x8060
cmpl $0xb, %eax
jne 0x203a8
movq 0x118(%rsp), %rdi
callq 0x128a0
movq %rax, 0xd8(%rsp)
jmp 0x20416
movq 0x118(%rsp), %rdi
movl 0xcc(%rsp), %esi
callq 0x11fe0
movq %rax, 0xd8(%rsp)
cmpq $0x0, %rax
jne 0x20414
movq 0xd0(%rsp), %rax
movzbl 0xc(%rax), %eax
andl $0xf, %eax
cmpl $0x3, %eax
je 0x20412
movq 0x100(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0xc0(%rsp), %rdx
movq 0x100(%rsp), %rax
movq 0x20(%rax), %rcx
movl 0xcc(%rsp), %r8d
movl $0x35, %edi
movb $0x0, %al
callq 0x8c00
jmp 0x20414
jmp 0x20416
movb $0x2, 0xbf(%rsp)
movq 0xd0(%rsp), %rax
movzbl 0xc(%rax), %eax
andl $0xf, %eax
movb %al, 0xbe(%rsp)
movzbl %al, %eax
cmpl $0x3, %eax
jne 0x20448
movq $0x0, 0xd8(%rsp)
cmpq $0x0, 0xd8(%rsp)
je 0x206eb
movzbl 0xbe(%rsp), %eax
cmpl $0x4, %eax
jle 0x204a0
movq 0x100(%rsp), %rax
movq 0x10(%rax), %rsi
movzbl 0xbe(%rsp), %edx
movq 0xc0(%rsp), %rcx
movq 0x100(%rsp), %rax
movq 0x20(%rax), %r8
movl $0x36, %edi
movb $0x0, %al
callq 0x8c00
movb $0x0, 0xbe(%rsp)
movq 0xd0(%rsp), %rax
movzbl 0xc(%rax), %eax
shrl $0x4, %eax
movl %eax, 0x80(%rsp)
testl %eax, %eax
je 0x204d8
jmp 0x204bc
movl 0x80(%rsp), %eax
subl $0x1, %eax
je 0x204e2
jmp 0x204ca
movl 0x80(%rsp), %eax
subl $0x2, %eax
je 0x204ec
jmp 0x204f6
movb $0x1, 0xbd(%rsp)
jmp 0x20539
movb $0x2, 0xbd(%rsp)
jmp 0x20539
movb $0x3, 0xbd(%rsp)
jmp 0x20539
movq 0x100(%rsp), %rax
movq 0x10(%rax), %rsi
movq 0xc0(%rsp), %rdx
movq 0xd0(%rsp), %rax
movzbl 0xc(%rax), %ecx
sarl $0x4, %ecx
movq 0x100(%rsp), %rax
movq 0x20(%rax), %r8
movl $0x37, %edi
movb $0x0, %al
callq 0x8c00
movb $0x1, 0xbd(%rsp)
movzbl 0xbd(%rsp), %eax
cmpl $0x1, %eax
jne 0x20611
movq 0x128(%rsp), %rax
movq %rax, 0x58(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x60(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0x68(%rsp)
movl 0x10c(%rsp), %edi
movq 0xd0(%rsp), %rsi
addq $0x4, %rsi
callq 0x8060
cltq
movq %rax, 0x70(%rsp)
movb 0xbf(%rsp), %al
movb %al, 0x7d(%rsp)
movb 0x10b(%rsp), %al
movb %al, 0x7e(%rsp)
movb 0xbe(%rsp), %al
movb %al, 0x7f(%rsp)
movl 0x10c(%rsp), %edi
movq 0xd0(%rsp), %rsi
addq $0x8, %rsi
callq 0x8060
movq 0x58(%rsp), %rdi
movq 0x60(%rsp), %rsi
movq 0x68(%rsp), %rdx
movq 0x70(%rsp), %r8
movb 0x7d(%rsp), %r9b
movb 0x7e(%rsp), %r11b
movb 0x7f(%rsp), %r10b
xorl %ecx, %ecx
movzbl %r9b, %r9d
movzbl %r11b, %r11d
movl %r11d, (%rsp)
movzbl %r10b, %r10d
movl %r10d, 0x8(%rsp)
movl %eax, 0x10(%rsp)
callq 0x100b0
jmp 0x206e9
movq 0x128(%rsp), %rax
movq %rax, 0x30(%rsp)
movq 0xd8(%rsp), %rax
movq %rax, 0x38(%rsp)
movq 0xc0(%rsp), %rax
movq %rax, 0x40(%rsp)
movl 0x10c(%rsp), %edi
movq 0xd0(%rsp), %rsi
addq $0x4, %rsi
callq 0x8060
cltq
movq %rax, 0x48(%rsp)
movb 0xbf(%rsp), %al
movb %al, 0x55(%rsp)
movb 0x10b(%rsp), %bl
movb 0xbe(%rsp), %al
movb %al, 0x56(%rsp)
movb 0xbd(%rsp), %al
movb %al, 0x57(%rsp)
movl 0x10c(%rsp), %edi
movq 0xd0(%rsp), %rsi
addq $0x8, %rsi
callq 0x8060
movq 0x30(%rsp), %rdi
movq 0x38(%rsp), %rsi
movq 0x40(%rsp), %rdx
movq 0x48(%rsp), %r8
movb 0x55(%rsp), %r9b
movb 0x56(%rsp), %r11b
movb 0x57(%rsp), %r10b
xorl %ecx, %ecx
movzbl %r9b, %r9d
movzbl %bl, %ebx
movl %ebx, (%rsp)
movzbl %r11b, %r11d
movl %r11d, 0x8(%rsp)
movzbl %r10b, %r10d
movl %r10d, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movl $0x1, 0x20(%rsp)
callq 0xfd00
jmp 0x206eb
jmp 0x20142
addq $0x130, %rsp            # imm = 0x130
popq %rbx
retq
nopl (%rax)