// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/t_vobj.c
// Function: read_section
static void read_section(struct GlobalVars *gv,struct ObjectUnit *u,
                         uint32_t index,struct vobj_symbol *vsyms,int nsyms)
{
  struct Section *s;
  lword dsize,fsize;
  int nrelocs;
  uint8_t type = ST_DATA;
  uint8_t prot = SP_READ;
  uint8_t flags = 0;
  uint8_t align,*data;
  char *attr;
  char *name = p;
  struct Reloc *last_reloc;
  int last_sym = -1;
  lword last_offs;
  uint16_t last_bpos = INVALID;

  skip_string();  /* section name */
  for (attr=p; *attr; attr++) {
    switch (tolower((unsigned char)*attr)) {
      case 'w': prot |= SP_WRITE; break;
      case 'x': prot |= SP_EXEC; break;
      case 'c': type = ST_CODE; break;
      case 'd': type = ST_DATA; break;
      case 'u': type = ST_UDATA; flags |= SF_UNINITIALIZED; break;
      case 'a': flags |= SF_ALLOC;
    }
  }
  skip_string();
  read_number();                  /* ignore flags */
  align = (uint8_t)lshiftcnt(read_number());
  dsize = read_number();          /* total size of section */
  nrelocs = (int)read_number();   /* number of relocation entries */
  fsize = read_number();          /* size in file, without 0-bytes */

  if (type == ST_UDATA) {
    data = NULL;
  }
  else if (dsize > fsize) {       /* recreate 0-bytes at end of section */
    data = alloczero((size_t)dsize);
    memcpy(data,p,(size_t)fsize);
  }
  else
    data = p;

  /* create and add section */
  p += fsize;
  s = add_section(u,name,data,(unsigned long)dsize,type,flags,prot,align,0);
  s->id = index;

  /* create relocations and unkown symbol references for this section */
  for (last_reloc=NULL,last_offs=-1; nrelocs>0; nrelocs--) {
    struct Reloc *r;
    char *xrefname = NULL;
    lword offs,mask,addend;
    uint16_t bpos,bsiz;
    uint8_t flags;
    int sym_idx;

    /* read one relocation entry */
    type = (uint8_t)read_number();
    offs = read_number();
    bpos = (uint16_t)read_number();
    bsiz = (uint16_t)read_number();
    mask = read_number();
    addend = read_number();
    sym_idx = (int)read_number() - 1;  /* symbol index */
    flags = 0;

    if (type>R_NONE && type<=LAST_STANDARD_RELOC &&
        offs>=0 && bsiz<=(sizeof(lword)<<3) &&
        sym_idx>=0 && sym_idx<nsyms) {
      if (vsyms[sym_idx].type == LABSYM) {
        xrefname = NULL;
        index = vsyms[sym_idx].sec;
      }
      else if (vsyms[sym_idx].type == IMPORT) {
        xrefname = vsyms[sym_idx].name;
        if (vsyms[sym_idx].flags & WEAK)
          flags |= RELF_WEAK;  /* undefined weak symbol */
        index = 0;
      }
      else {
        /* VOBJ relocation not supported */
        error(115,getobjname(u),fff[u->lnkfile->format]->tname,
              (int)type,(lword)offs,(int)bpos,(int)bsiz,(lword)mask,
              vsyms[sym_idx].name,(int)vsyms[sym_idx].type);
      }

      if (sym_idx==last_sym && offs==last_offs && bpos==last_bpos &&
          last_reloc!=NULL) {
        r = last_reloc;
      }
      else {
        r = newreloc(gv,s,xrefname,NULL,index,(unsigned long)offs,type,addend);
        r->flags |= flags;
        last_reloc = r;
        last_offs = offs;
        last_bpos = bpos;
        last_sym = sym_idx;
      }

      addreloc(s,r,bpos,bsiz,mask);

      /* make sure that section reflects the addend for other formats */
      writesection(gv,data+(uint32_t)offs,r,addend);
    }

    else if (type != R_NONE) {
      /* VOBJ relocation not supported */
      error(115,getobjname(u),fff[u->lnkfile->format]->tname,
            (int)type,(lword)offs,(int)bpos,(int)bsiz,(lword)mask,
            (sym_idx>=0&&sym_idx<nsyms) ? vsyms[sym_idx].name : "?",
            (sym_idx>=0&&sym_idx<nsyms) ? (int)vsyms[sym_idx].type : 0);
    }
  }
}

// Assembly:
pushq %rbx
subq $0x130, %rsp            # imm = 0x130
movq %rdi, 0x128(%rsp)
movq %rsi, 0x120(%rsp)
movl %edx, 0x11c(%rsp)
movq %rcx, 0x110(%rsp)
movl %r8d, 0x10c(%rsp)
movb $0x2, 0xeb(%rsp)
movb $0x1, 0xea(%rsp)
movb $0x0, 0xe9(%rsp)
movq 0x12fb2(%rip), %rax     # 0x45090
movq %rax, 0xd0(%rsp)
movl $0xffffffff, 0xc4(%rsp) # imm = 0xFFFFFFFF
movw $0xffff, 0xb6(%rsp)     # imm = 0xFFFF
callq 0x31fe0
movq 0x12f89(%rip), %rax     # 0x45090
movq %rax, 0xd8(%rsp)
movq 0xd8(%rsp), %rax
cmpb $0x0, (%rax)
je 0x321d9
movq 0xd8(%rsp), %rax
movzbl (%rax), %edi
callq 0x5190
addl $-0x61, %eax
movl %eax, %ecx
movq %rcx, 0x70(%rsp)
subl $0x17, %eax
ja 0x321be
movq 0x70(%rsp), %rax
leaq 0x60f5(%rip), %rcx      # 0x38240
movslq (%rcx,%rax,4), %rax
addq %rcx, %rax
jmpq *%rax
movzbl 0xea(%rsp), %eax
orl $0x2, %eax
movb %al, 0xea(%rsp)
jmp 0x321be
movzbl 0xea(%rsp), %eax
orl $0x4, %eax
movb %al, 0xea(%rsp)
jmp 0x321be
movb $0x1, 0xeb(%rsp)
jmp 0x321be
movb $0x2, 0xeb(%rsp)
jmp 0x321be
movb $0x3, 0xeb(%rsp)
movzbl 0xe9(%rsp), %eax
orl $0x2, %eax
movb %al, 0xe9(%rsp)
jmp 0x321be
movzbl 0xe9(%rsp), %eax
orl $0x1, %eax
movb %al, 0xe9(%rsp)
jmp 0x321c0
movq 0xd8(%rsp), %rax
addq $0x1, %rax
movq %rax, 0xd8(%rsp)
jmp 0x3210f
callq 0x31fe0
callq 0x31ef0
callq 0x31ef0
movq %rax, %rdi
callq 0x88c0
movb %al, 0xe8(%rsp)
callq 0x31ef0
movq %rax, 0xf8(%rsp)
callq 0x31ef0
movl %eax, 0xec(%rsp)
callq 0x31ef0
movq %rax, 0xf0(%rsp)
movzbl 0xeb(%rsp), %eax
cmpl $0x3, %eax
jne 0x32238
movq $0x0, 0xe0(%rsp)
jmp 0x3228e
movq 0xf8(%rsp), %rax
cmpq 0xf0(%rsp), %rax
jle 0x3227d
movq 0xf8(%rsp), %rdi
callq 0x7290
movq %rax, 0xe0(%rsp)
movq 0xe0(%rsp), %rdi
movq 0x12e22(%rip), %rsi     # 0x45090
movq 0xf0(%rsp), %rdx
callq 0x5170
jmp 0x3228c
movq 0x12e0c(%rip), %rax     # 0x45090
movq %rax, 0xe0(%rsp)
jmp 0x3228e
movq 0xf0(%rsp), %rax
addq 0x12df3(%rip), %rax     # 0x45090
movq %rax, 0x12dec(%rip)     # 0x45090
movq 0x120(%rsp), %rdi
movq 0xd0(%rsp), %rsi
movq 0xe0(%rsp), %rdx
movq 0xf8(%rsp), %rcx
movb 0xeb(%rsp), %r8b
movb 0xe9(%rsp), %r9b
movb 0xea(%rsp), %al
xorl %r10d, %r10d
movzbl %r8b, %r8d
movzbl %r9b, %r9d
movzbl %al, %eax
movl %eax, (%rsp)
movzbl 0xe8(%rsp), %eax
movl %eax, 0x8(%rsp)
movl $0x0, 0x10(%rsp)
callq 0x12660
movq %rax, 0x100(%rsp)
movl 0x11c(%rsp), %ecx
movq 0x100(%rsp), %rax
movl %ecx, 0x28(%rax)
movq $0x0, 0xc8(%rsp)
movq $-0x1, 0xb8(%rsp)
cmpl $0x0, 0xec(%rsp)
jle 0x32849
movq $0x0, 0xa0(%rsp)
callq 0x31ef0
movb %al, 0xeb(%rsp)
callq 0x31ef0
movq %rax, 0x98(%rsp)
callq 0x31ef0
movw %ax, 0x86(%rsp)
callq 0x31ef0
movw %ax, 0x84(%rsp)
callq 0x31ef0
movq %rax, 0x90(%rsp)
callq 0x31ef0
movq %rax, 0x88(%rsp)
callq 0x31ef0
subl $0x1, %eax
movl %eax, 0x7c(%rsp)
movb $0x0, 0x83(%rsp)
movzbl 0xeb(%rsp), %eax
cmpl $0x0, %eax
jle 0x326df
movzbl 0xeb(%rsp), %eax
cmpl $0x10, %eax
jg 0x326df
cmpq $0x0, 0x98(%rsp)
jl 0x326df
movzwl 0x84(%rsp), %eax
cmpq $0x40, %rax
ja 0x326df
cmpl $0x0, 0x7c(%rsp)
jl 0x326df
movl 0x7c(%rsp), %eax
cmpl 0x10c(%rsp), %eax
jge 0x326df
movq 0x110(%rsp), %rax
movslq 0x7c(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x1, 0x8(%rax)
jne 0x3245a
movq $0x0, 0xa0(%rsp)
movq 0x110(%rsp), %rax
movslq 0x7c(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x10(%rax), %eax
movl %eax, 0x11c(%rsp)
jmp 0x3257a
movq 0x110(%rsp), %rax
movslq 0x7c(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
cmpl $0x2, 0x8(%rax)
jne 0x324d4
movq 0x110(%rsp), %rax
movslq 0x7c(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, 0xa0(%rsp)
movq 0x110(%rsp), %rax
movslq 0x7c(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0xc(%rax), %eax
andl $0x40, %eax
cmpl $0x0, %eax
je 0x324c4
movzbl 0x83(%rsp), %eax
orl $0x1, %eax
movb %al, 0x83(%rsp)
movl $0x0, 0x11c(%rsp)
jmp 0x32578
movq 0x120(%rsp), %rdi
callq 0x8f00
movq %rax, %rsi
movq 0x120(%rsp), %rax
movq 0x10(%rax), %rax
movzbl 0x38(%rax), %eax
movl %eax, %ecx
leaq 0xd533(%rip), %rax      # 0x3fa30
movq (%rax,%rcx,8), %rax
movq (%rax), %rdx
movzbl 0xeb(%rsp), %ecx
movq 0x98(%rsp), %r8
movzwl 0x86(%rsp), %r9d
movzwl 0x84(%rsp), %ebx
movq 0x90(%rsp), %r11
movq 0x110(%rsp), %rax
movslq 0x7c(%rsp), %rdi
shlq $0x5, %rdi
addq %rdi, %rax
movq (%rax), %r10
movq 0x110(%rsp), %rax
movslq 0x7c(%rsp), %rdi
shlq $0x5, %rdi
addq %rdi, %rax
movl 0x8(%rax), %eax
movl $0x73, %edi
movl %ebx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movb $0x0, %al
callq 0x8c00
jmp 0x3257a
movl 0x7c(%rsp), %eax
cmpl 0xc4(%rsp), %eax
jne 0x325cd
movq 0x98(%rsp), %rax
cmpq 0xb8(%rsp), %rax
jne 0x325cd
movzwl 0x86(%rsp), %eax
movzwl 0xb6(%rsp), %ecx
cmpl %ecx, %eax
jne 0x325cd
cmpq $0x0, 0xc8(%rsp)
je 0x325cd
movq 0xc8(%rsp), %rax
movq %rax, 0xa8(%rsp)
jmp 0x32675
movq 0x128(%rsp), %rdi
movq 0x100(%rsp), %rsi
movq 0xa0(%rsp), %rdx
movl 0x11c(%rsp), %r8d
movq 0x98(%rsp), %r9
movb 0xeb(%rsp), %r10b
movq 0x88(%rsp), %rax
xorl %ecx, %ecx
movzbl %r10b, %r10d
movl %r10d, (%rsp)
movq %rax, 0x8(%rsp)
callq 0x10850
movq %rax, 0xa8(%rsp)
movzbl 0x83(%rsp), %edx
movq 0xa8(%rsp), %rax
movzbl 0x39(%rax), %ecx
orl %edx, %ecx
movb %cl, 0x39(%rax)
movq 0xa8(%rsp), %rax
movq %rax, 0xc8(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0xb8(%rsp)
movw 0x86(%rsp), %ax
movw %ax, 0xb6(%rsp)
movl 0x7c(%rsp), %eax
movl %eax, 0xc4(%rsp)
movq 0x100(%rsp), %rdi
movq 0xa8(%rsp), %rsi
movw 0x86(%rsp), %cx
movw 0x84(%rsp), %ax
movq 0x90(%rsp), %r8
movzwl %cx, %edx
movzwl %ax, %ecx
callq 0x109b0
movq 0x128(%rsp), %rdi
movq 0xe0(%rsp), %rsi
movq 0x98(%rsp), %rax
movl %eax, %eax
addq %rax, %rsi
movq 0xa8(%rsp), %rdx
movq 0x88(%rsp), %rcx
callq 0x110c0
jmp 0x32831
movzbl 0xeb(%rsp), %eax
cmpl $0x0, %eax
je 0x3282f
movq 0x120(%rsp), %rdi
callq 0x8f00
movq %rax, 0x40(%rsp)
movq 0x120(%rsp), %rax
movq 0x10(%rax), %rax
movzbl 0x38(%rax), %eax
movl %eax, %ecx
leaq 0xd315(%rip), %rax      # 0x3fa30
movq (%rax,%rcx,8), %rax
movq (%rax), %rax
movq %rax, 0x48(%rsp)
movzbl 0xeb(%rsp), %eax
movl %eax, 0x54(%rsp)
movq 0x98(%rsp), %rax
movq %rax, 0x58(%rsp)
movzwl 0x86(%rsp), %eax
movl %eax, 0x60(%rsp)
movzwl 0x84(%rsp), %eax
movl %eax, 0x64(%rsp)
movq 0x90(%rsp), %rax
movq %rax, 0x68(%rsp)
cmpl $0x0, 0x7c(%rsp)
jl 0x32797
movl 0x7c(%rsp), %eax
cmpl 0x10c(%rsp), %eax
jge 0x32797
movq 0x110(%rsp), %rax
movslq 0x7c(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movq (%rax), %rax
movq %rax, 0x38(%rsp)
jmp 0x327a5
leaq 0x5b4a(%rip), %rax      # 0x382e8
movq %rax, 0x38(%rsp)
jmp 0x327a5
movq 0x38(%rsp), %rax
movq %rax, 0x30(%rsp)
cmpl $0x0, 0x7c(%rsp)
jl 0x327e0
movl 0x7c(%rsp), %eax
cmpl 0x10c(%rsp), %eax
jge 0x327e0
movq 0x110(%rsp), %rax
movslq 0x7c(%rsp), %rcx
shlq $0x5, %rcx
addq %rcx, %rax
movl 0x8(%rax), %eax
movl %eax, 0x2c(%rsp)
jmp 0x327e8
xorl %eax, %eax
movl %eax, 0x2c(%rsp)
jmp 0x327e8
movq 0x30(%rsp), %r10
movq 0x68(%rsp), %r11
movl 0x64(%rsp), %ebx
movl 0x60(%rsp), %r9d
movq 0x58(%rsp), %r8
movl 0x54(%rsp), %ecx
movq 0x48(%rsp), %rdx
movq 0x40(%rsp), %rsi
movl 0x2c(%rsp), %eax
movl $0x73, %edi
movl %ebx, (%rsp)
movq %r11, 0x8(%rsp)
movq %r10, 0x10(%rsp)
movl %eax, 0x18(%rsp)
movb $0x0, %al
callq 0x8c00
jmp 0x32831
jmp 0x32833
movl 0xec(%rsp), %eax
addl $-0x1, %eax
movl %eax, 0xec(%rsp)
jmp 0x32337
addq $0x130, %rsp            # imm = 0x130
popq %rbx
retq
nopw %cs:(%rax,%rax)
nopl (%rax)