// File: /workspace/github_c_makefile_star2_O0/deplinenoise[P]vlink/linker.c
// Function: linker_load
void linker_load(struct GlobalVars *gv)
/* load all objects and libraries into memory, identify their */
/* format, then read all symbols and convert into internal format */
{
  struct InputFile *ifn;
  struct LinkFile *lf;
  uint8_t *objptr;
  const char *objname;
  unsigned long objlen;
  int i,ff;

  init_ld_script(gv);       /* pre-parse linker script, when available */
  if (listempty(&gv->inputlist))
    error(6);  /* no input files */

  if (gv->use_ldscript) {
    gv->common_sec_name = "COMMON";
    gv->scommon_sec_name = ".scommon";
  }
  else {
    gv->common_sec_name = fff[gv->dest_format]->bssname ?
                          fff[gv->dest_format]->bssname : "COMMON";
    gv->scommon_sec_name = fff[gv->dest_format]->sbssname ?
                           fff[gv->dest_format]->sbssname : ".scommon";
  }

  if (gv->trace_file)
    fprintf(gv->trace_file,"\nLoading files:\n\n");

  for (ifn=(struct InputFile *)gv->inputlist.first;
       ifn->n.next!=NULL; ifn=(struct InputFile *)ifn->n.next) {
    if (ifn->lib) {
      if (!(objptr = (uint8_t *)maplibrary(gv,ifn))) {
        snprintf(namebuf,FNAMEBUFSIZE,"-l%s",ifn->name);
        error(8,namebuf);  /* cannot open -lxxx */
      }
    }
    else {
      if (objptr = (uint8_t *)mapfile(ifn->name))
        strcpy(namebuf,ifn->name);
      else
        error(8,ifn->name);  /* cannot open xxx */
    }
    objlen = *(size_t *)(objptr - sizeof(size_t));
    objname = base_name(namebuf);

    /* determine the object's file format */
    for (i=0,ff=ID_UNKNOWN; fff[i]; i++) {
      if ((ff = (fff[i]->identify)((char *)objname,objptr,objlen,ifn->lib))
          != ID_UNKNOWN)
        break;
    }
    if (ff == ID_UNKNOWN)
      error(11,objname);  /* File format not recognized */

    if (ff != ID_IGNORE) {
      /* use endianess of first object read */
      if (gv->endianess < 0)
        gv->endianess = fff[i]->endianess;
      else if (fff[i]->endianess>=0 && gv->endianess!=fff[i]->endianess)
        error(61,objname);  /* endianess differs from previous objects */

      /* create new link file node */
      lf = (struct LinkFile *)alloc(sizeof(struct LinkFile));
      lf->pathname = allocstring(namebuf);
      lf->filename = base_name(lf->pathname);
      lf->data = objptr;
      lf->length = objlen;
      lf->format = (uint8_t)i;
      lf->type = (uint8_t)ff;
      lf->flags = ifn->flags;
      if (gv->trace_file)
        fprintf(gv->trace_file,"%s (%s %s)\n",namebuf,fff[i]->tname,
                                              filetypes[ff]);

      /* read the file and convert into internal format */
      fff[i]->readconv(gv,lf);
      addtail(&gv->linkfiles,&lf->n);
    }
  }

  if (gv->endianess < 0) {
    /* When endianess is still unknown, after reading all input files,
       we take the it from the destination format. */
    gv->endianess = fff[gv->dest_format]->endianess;

    /* The destination format didn't define the endianess either?
       Then guess by using the host endianess. */
    if (gv->endianess < 0)
      gv->endianess = host_endianess();
  }

  collect_constructors(gv); /* scan for con-/destructor functions */
  add_undef_syms(gv);       /* put syms. marked as undef. into 1st sec. */
}

// Assembly:
subq $0x48, %rsp
movq %rdi, 0x40(%rsp)
movq 0x40(%rsp), %rdi
callq 0x16c20
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rax
cmpq $0x0, (%rax)
jne 0x954e
movl $0x6, %edi
movb $0x0, %al
callq 0x8c00
movq 0x40(%rsp), %rax
cmpl $0x0, 0x244(%rax)
je 0x9587
movq 0x40(%rsp), %rax
leaq 0x2bbef(%rip), %rcx     # 0x35157
movq %rcx, 0x220(%rax)
movq 0x40(%rsp), %rax
leaq 0x2bbe3(%rip), %rcx     # 0x3515e
movq %rcx, 0x228(%rax)
jmp 0x964a
movq 0x40(%rsp), %rax
movzbl 0x50(%rax), %eax
movl %eax, %ecx
leaq 0x36497(%rip), %rax     # 0x3fa30
movq (%rax,%rcx,8), %rax
cmpq $0x0, 0x88(%rax)
je 0x95cb
movq 0x40(%rsp), %rax
movzbl 0x50(%rax), %eax
movl %eax, %ecx
leaq 0x36477(%rip), %rax     # 0x3fa30
movq (%rax,%rcx,8), %rax
movq 0x88(%rax), %rax
movq %rax, 0x8(%rsp)
jmp 0x95d9
leaq 0x2bb85(%rip), %rax     # 0x35157
movq %rax, 0x8(%rsp)
jmp 0x95d9
movq 0x8(%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x220(%rax)
movq 0x40(%rsp), %rax
movzbl 0x50(%rax), %eax
movl %eax, %ecx
leaq 0x36434(%rip), %rax     # 0x3fa30
movq (%rax,%rcx,8), %rax
cmpq $0x0, 0x90(%rax)
je 0x962d
movq 0x40(%rsp), %rax
movzbl 0x50(%rax), %eax
movl %eax, %ecx
leaq 0x36414(%rip), %rax     # 0x3fa30
movq (%rax,%rcx,8), %rax
movq 0x90(%rax), %rax
movq %rax, (%rsp)
jmp 0x963a
leaq 0x2bb2a(%rip), %rax     # 0x3515e
movq %rax, (%rsp)
jmp 0x963a
movq (%rsp), %rcx
movq 0x40(%rsp), %rax
movq %rcx, 0x228(%rax)
movq 0x40(%rsp), %rax
cmpq $0x0, 0xa0(%rax)
je 0x9673
movq 0x40(%rsp), %rax
movq 0xa0(%rax), %rdi
leaq 0x2bafb(%rip), %rsi     # 0x35167
movb $0x0, %al
callq 0x5150
movq 0x40(%rsp), %rax
movq 0x18(%rax), %rax
movq %rax, 0x38(%rsp)
movq 0x38(%rsp), %rax
cmpq $0x0, (%rax)
je 0x9992
movq 0x38(%rsp), %rax
cmpl $0x0, 0x18(%rax)
je 0x96ed
movq 0x40(%rsp), %rdi
movq 0x38(%rsp), %rsi
callq 0x9a10
movq %rax, 0x28(%rsp)
cmpq $0x0, %rax
jne 0x96eb
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rcx
leaq 0x3aafb(%rip), %rdi     # 0x441c0
movl $0x400, %esi            # imm = 0x400
leaq 0x2baa8(%rip), %rdx     # 0x35179
movb $0x0, %al
callq 0x50e0
movl $0x8, %edi
leaq 0x3aadc(%rip), %rsi     # 0x441c0
movb $0x0, %al
callq 0x8c00
jmp 0x9734
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x7570
movq %rax, 0x28(%rsp)
cmpq $0x0, %rax
je 0x971d
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rsi
leaq 0x3aaaa(%rip), %rdi     # 0x441c0
callq 0x5060
jmp 0x9732
movq 0x38(%rsp), %rax
movq 0x10(%rax), %rsi
movl $0x8, %edi
movb $0x0, %al
callq 0x8c00
jmp 0x9734
movq 0x28(%rsp), %rax
movq -0x8(%rax), %rax
movq %rax, 0x18(%rsp)
leaq 0x3aa77(%rip), %rdi     # 0x441c0
callq 0x7700
movq %rax, 0x20(%rsp)
movl $0x0, 0x14(%rsp)
movl $0x0, 0x10(%rsp)
movslq 0x14(%rsp), %rcx
leaq 0x362c1(%rip), %rax     # 0x3fa30
cmpq $0x0, (%rax,%rcx,8)
je 0x97bd
movslq 0x14(%rsp), %rcx
leaq 0x362ae(%rip), %rax     # 0x3fa30
movq (%rax,%rcx,8), %rax
movq 0x20(%rax), %rax
movq 0x20(%rsp), %rdi
movq 0x28(%rsp), %rsi
movq 0x18(%rsp), %rdx
movq 0x38(%rsp), %rcx
movl 0x18(%rcx), %ecx
callq *%rax
movl %eax, 0x10(%rsp)
cmpl $0x0, %eax
je 0x97ae
jmp 0x97bd
jmp 0x97b0
movl 0x14(%rsp), %eax
addl $0x1, %eax
movl %eax, 0x14(%rsp)
jmp 0x9763
cmpl $0x0, 0x10(%rsp)
jne 0x97d5
movq 0x20(%rsp), %rsi
movl $0xb, %edi
movb $0x0, %al
callq 0x8c00
cmpl $-0x1, 0x10(%rsp)
je 0x997e
movq 0x40(%rsp), %rax
movsbl 0x202(%rax), %eax
cmpl $0x0, %eax
jge 0x9814
movslq 0x14(%rsp), %rcx
leaq 0x36233(%rip), %rax     # 0x3fa30
movq (%rax,%rcx,8), %rax
movb 0xaa(%rax), %cl
movq 0x40(%rsp), %rax
movb %cl, 0x202(%rax)
jmp 0x986a
movslq 0x14(%rsp), %rcx
leaq 0x36210(%rip), %rax     # 0x3fa30
movq (%rax,%rcx,8), %rax
movsbl 0xaa(%rax), %eax
cmpl $0x0, %eax
jl 0x9868
movq 0x40(%rsp), %rax
movsbl 0x202(%rax), %eax
movslq 0x14(%rsp), %rdx
leaq 0x361e8(%rip), %rcx     # 0x3fa30
movq (%rcx,%rdx,8), %rcx
movsbl 0xaa(%rcx), %ecx
cmpl %ecx, %eax
je 0x9868
movq 0x20(%rsp), %rsi
movl $0x3d, %edi
movb $0x0, %al
callq 0x8c00
jmp 0x986a
movl $0x40, %edi
callq 0x71f0
movq %rax, 0x30(%rsp)
leaq 0x3a940(%rip), %rdi     # 0x441c0
callq 0x72d0
movq %rax, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x10(%rax)
movq 0x30(%rsp), %rax
movq 0x10(%rax), %rdi
callq 0x7700
movq %rax, %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x18(%rax)
movq 0x28(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x28(%rax)
movq 0x18(%rsp), %rcx
movq 0x30(%rsp), %rax
movq %rcx, 0x30(%rax)
movl 0x14(%rsp), %eax
movb %al, %cl
movq 0x30(%rsp), %rax
movb %cl, 0x38(%rax)
movl 0x10(%rsp), %eax
movb %al, %cl
movq 0x30(%rsp), %rax
movb %cl, 0x39(%rax)
movq 0x38(%rsp), %rax
movw 0x24(%rax), %cx
movq 0x30(%rsp), %rax
movw %cx, 0x3a(%rax)
movq 0x40(%rsp), %rax
cmpq $0x0, 0xa0(%rax)
je 0x9948
movq 0x40(%rsp), %rax
movq 0xa0(%rax), %rdi
movslq 0x14(%rsp), %rcx
leaq 0x36114(%rip), %rax     # 0x3fa30
movq (%rax,%rcx,8), %rax
movq (%rax), %rcx
movslq 0x10(%rsp), %rdx
leaq 0x36071(%rip), %rax     # 0x3f9a0
movq (%rax,%rdx,8), %r8
leaq 0x2b844(%rip), %rsi     # 0x3517e
leaq 0x3a87f(%rip), %rdx     # 0x441c0
movb $0x0, %al
callq 0x5150
movslq 0x14(%rsp), %rcx
leaq 0x360dc(%rip), %rax     # 0x3fa30
movq (%rax,%rcx,8), %rax
movq 0x28(%rax), %rax
movq 0x40(%rsp), %rdi
movq 0x30(%rsp), %rsi
callq *%rax
movq 0x40(%rsp), %rdi
addq $0x120, %rdi            # imm = 0x120
movq 0x30(%rsp), %rsi
callq 0x7470
jmp 0x9980
movq 0x38(%rsp), %rax
movq (%rax), %rax
movq %rax, 0x38(%rsp)
jmp 0x9681
movq 0x40(%rsp), %rax
movsbl 0x202(%rax), %eax
cmpl $0x0, %eax
jge 0x99ef
movq 0x40(%rsp), %rax
movzbl 0x50(%rax), %eax
movl %eax, %ecx
leaq 0x3607b(%rip), %rax     # 0x3fa30
movq (%rax,%rcx,8), %rax
movb 0xaa(%rax), %cl
movq 0x40(%rsp), %rax
movb %cl, 0x202(%rax)
movq 0x40(%rsp), %rax
movsbl 0x202(%rax), %eax
cmpl $0x0, %eax
jge 0x99ed
callq 0x7890
movb %al, %cl
movq 0x40(%rsp), %rax
movb %cl, 0x202(%rax)
jmp 0x99ef
movq 0x40(%rsp), %rdi
callq 0x11a30
movq 0x40(%rsp), %rdi
callq 0x9b80
addq $0x48, %rsp
retq
nopl (%rax,%rax)