// File: /workspace/github_c_makefile_star2_O1/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:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x428, %rsp            # imm = 0x428
movq %rdi, %rbx
callq 0xed7b
movq 0x18(%rbx), %rax
cmpq $0x0, (%rax)
jne 0x7449
movl $0x6, %edi
xorl %eax, %eax
callq 0x6f84
cmpl $0x0, 0x244(%rbx)
je 0x7469
leaq 0x1ad16(%rip), %rax     # 0x2216f
movq %rax, 0x220(%rbx)
leaq 0x1ad0f(%rip), %rax     # 0x22176
jmp 0x74ad
movzbl 0x50(%rbx), %eax
leaq 0x27d0c(%rip), %rcx     # 0x2f180
movq (%rcx,%rax,8), %rdx
movq 0x88(%rdx), %rdx
testq %rdx, %rdx
leaq 0x1ace6(%rip), %rsi     # 0x2216f
cmovneq %rdx, %rsi
movq %rsi, 0x220(%rbx)
movq (%rcx,%rax,8), %rax
movq 0x90(%rax), %rcx
testq %rcx, %rcx
leaq 0x1accd(%rip), %rax     # 0x22176
cmovneq %rcx, %rax
movq %rax, 0x228(%rbx)
movq 0xa0(%rbx), %rcx
testq %rcx, %rcx
je 0x74d6
leaq 0x1acb8(%rip), %rdi     # 0x2217f
movl $0x11, %esi
movl $0x1, %edx
callq 0x5270
movq %rbx, (%rsp)
movq 0x18(%rbx), %r15
cmpq $0x0, (%r15)
je 0x77cd
movq (%rsp), %rax
addq $0x120, %rax            # imm = 0x120
movq %rax, 0x18(%rsp)
leaq 0x2b8f2(%rip), %r12     # 0x32df0
leaq 0x27c7b(%rip), %rbx     # 0x2f180
leaq 0x8(%rbx), %rax
movq %rax, 0x10(%rsp)
leaq 0x20(%rsp), %rbp
cmpl $0x0, 0x18(%r15)
je 0x75a4
movq 0x10(%r15), %r14
movq %r14, %rdi
callq 0x50e0
cmpq $0x3ef, %rax            # imm = 0x3EF
ja 0x7600
cmpl $0x0, 0x1c(%r15)
je 0x756a
movq %rbp, %rdi
leaq 0x1af24(%rip), %rsi     # 0x2246b
movq %r14, %rdx
xorl %eax, %eax
callq 0x5250
movl 0x20(%r15), %edx
movq (%rsp), %rdi
movq %rbp, %rsi
callq 0xa3c1
testq %rax, %rax
jne 0x75fb
movq 0x10(%r15), %rdx
movq %rbp, %rdi
leaq 0x1aefc(%rip), %rsi     # 0x22474
xorl %eax, %eax
callq 0x5250
movq (%rsp), %rbx
movq %rbx, %rdi
movq %rbp, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xa3c1
testq %rax, %rax
je 0x75ca
movq %rax, %r13
leaq 0x27bde(%rip), %rbx     # 0x2f180
jmp 0x7603
movq 0x10(%r15), %rdi
callq 0x679f
movq 0x10(%r15), %rsi
testq %rax, %rax
je 0x75c3
movq %rax, %r13
movq %r12, %rdi
callq 0x5080
jmp 0x7634
movl $0x8, %edi
jmp 0x762a
movq 0x10(%r15), %rdx
movq %rbp, %rdi
leaq 0x1aea4(%rip), %rsi     # 0x2247c
xorl %eax, %eax
callq 0x5250
movq %rbx, %rdi
movq %rbp, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xa3c1
testq %rax, %rax
leaq 0x27b87(%rip), %rbx     # 0x2f180
je 0x7600
movq %rax, %r13
jmp 0x7603
xorl %r13d, %r13d
testq %r13, %r13
jne 0x7634
movq 0x10(%r15), %rcx
movl $0x400, %esi            # imm = 0x400
movq %r12, %rdi
leaq 0x1ab76(%rip), %rdx     # 0x22191
xorl %eax, %eax
callq 0x5100
movl $0x8, %edi
movq %r12, %rsi
xorl %eax, %eax
callq 0x6f84
xorl %r13d, %r13d
movq -0x8(%r13), %r14
movq %r12, %rdi
callq 0x6884
movq %rax, %rbp
movq (%rbx), %rax
testq %rax, %rax
movq %r14, 0x8(%rsp)
je 0x7670
movl 0x18(%r15), %ecx
movq %rbp, %rdi
movq %r13, %rsi
movq %r14, %rdx
callq *0x20(%rax)
testl %eax, %eax
je 0x778c
movl %eax, %r14d
xorl %r12d, %r12d
jmp 0x7676
xorl %r12d, %r12d
xorl %r14d, %r14d
cmpl $-0x1, %r14d
je 0x776a
testl %r14d, %r14d
jne 0x7694
movl $0xb, %edi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x6f84
movq (%rsp), %rdx
movb 0x202(%rdx), %al
movq (%rbx), %rcx
movb 0xaa(%rcx), %cl
testb %al, %al
js 0x76ca
testb %cl, %cl
sets %dl
cmpb %cl, %al
sete %al
orb %dl, %al
jne 0x76d0
movl $0x3d, %edi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x6f84
jmp 0x76d0
movb %cl, 0x202(%rdx)
movl $0x40, %edi
callq 0x6668
movq %rax, %rbp
leaq 0x2b70c(%rip), %rdi     # 0x32df0
callq 0x66cd
movq %rax, 0x10(%rbp)
movq %rax, %rdi
callq 0x6884
movq %rax, 0x18(%rbp)
movq %r13, 0x28(%rbp)
movq 0x8(%rsp), %rax
movq %rax, 0x30(%rbp)
movb %r12b, 0x38(%rbp)
movb %r14b, 0x39(%rbp)
movzwl 0x24(%r15), %eax
movw %ax, 0x3a(%rbp)
movq (%rsp), %r12
movq 0xa0(%r12), %rdi
testq %rdi, %rdi
je 0x7751
movq (%rbx), %rax
movq (%rax), %rcx
movslq %r14d, %rax
leaq 0x27558(%rip), %rdx     # 0x2ec90
movq (%rdx,%rax,8), %r8
leaq 0x1aa53(%rip), %rsi     # 0x22196
leaq 0x2b6a6(%rip), %rdx     # 0x32df0
xorl %eax, %eax
callq 0x5180
movq (%rbx), %rax
movq %r12, %rdi
movq %rbp, %rsi
callq *0x28(%rax)
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
callq 0x6759
movq (%r15), %r15
cmpq $0x0, (%r15)
leaq 0x2b678(%rip), %r12     # 0x32df0
leaq 0x27a01(%rip), %rbx     # 0x2f180
leaq 0x20(%rsp), %rbp
jne 0x7513
jmp 0x77cd
movb $0x1, %al
movq 0x10(%rsp), %rcx
movl %eax, %r12d
movq %rcx, %rbx
movq (%rcx), %rax
testq %rax, %rax
je 0x7673
movl 0x18(%r15), %ecx
movq %rbp, %rdi
movq %r13, %rsi
movq 0x8(%rsp), %rdx
callq *0x20(%rax)
movl %eax, %r14d
leal 0x1(%r12), %eax
leaq 0x8(%rbx), %rcx
testl %r14d, %r14d
je 0x7793
jmp 0x7676
movq (%rsp), %r15
cmpb $0x0, 0x202(%r15)
jns 0x7808
movzbl 0x50(%r15), %eax
leaq 0x27999(%rip), %rcx     # 0x2f180
movq (%rcx,%rax,8), %rax
movb 0xaa(%rax), %al
movb %al, 0x202(%r15)
testb %al, %al
jns 0x7808
callq 0x693f
movb %al, 0x202(%r15)
movq %r15, %rdi
callq 0xbab4
movq 0xb8(%r15), %rbx
testq %rbx, %rbx
je 0x790f
leaq 0x138(%r15), %r14
movq 0x138(%r15), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x7846
movq 0x20(%rax), %r13
cmpq $0x0, (%r13)
movq %rcx, %rax
je 0x782e
jmp 0x7849
xorl %r13d, %r13d
testq %r13, %r13
jne 0x785c
leaq 0x1ac8e(%rip), %rdi     # 0x224e3
xorl %eax, %eax
callq 0x52b0
leaq 0x1acbc(%rip), %rsi     # 0x2251f
leaq 0x2bd96(%rip), %r15     # 0x33600
movl $0x4, %ecx
movq (%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rdx
callq 0xbfe9
movq %rax, %r12
orb $0x1, 0x80(%rax)
movq 0x20(%r13), %rsi
movl $0x4, %ecx
movq %rax, %rdi
movq %r15, %rdx
callq 0xc156
movq %rax, %r15
movb 0x2c(%r13), %al
movb %al, 0x2c(%r15)
movb 0x2e(%r13), %al
movb %al, 0x2e(%r15)
movb 0x2d(%r13), %al
movb %al, 0x2d(%r15)
leaq 0x20(%r12), %rdi
movq %r15, %rsi
callq 0x6759
movq %r14, %rdi
movq %r12, %rsi
callq 0x6759
movq 0x8(%rbx), %rdx
movq %rbp, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq $0x0
pushq $0x0
callq 0xb202
addq $0x10, %rsp
movq %r15, %rdi
movq %rax, %rsi
xorl %edx, %edx
movl $0x20, %ecx
movq $-0x1, %r8
callq 0xb2b7
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x78cf
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq