// File: /workspace/github_c_makefile_star2_O3/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 0xec46
movq 0x18(%rbx), %rax
cmpq $0x0, (%rax)
jne 0x741a
movl $0x6, %edi
xorl %eax, %eax
callq 0x6f14
cmpl $0x0, 0x244(%rbx)
je 0x743a
leaq 0x1ad35(%rip), %rax     # 0x2215f
movq %rax, 0x220(%rbx)
leaq 0x1ad2e(%rip), %rax     # 0x22166
jmp 0x747e
movzbl 0x50(%rbx), %eax
leaq 0x27d3b(%rip), %rcx     # 0x2f180
movq (%rcx,%rax,8), %rdx
movq 0x88(%rdx), %rdx
testq %rdx, %rdx
leaq 0x1ad05(%rip), %rsi     # 0x2215f
cmovneq %rdx, %rsi
movq %rsi, 0x220(%rbx)
movq (%rcx,%rax,8), %rax
movq 0x90(%rax), %rcx
testq %rcx, %rcx
leaq 0x1acec(%rip), %rax     # 0x22166
cmovneq %rcx, %rax
movq %rax, 0x228(%rbx)
movq 0xa0(%rbx), %rcx
testq %rcx, %rcx
je 0x74a7
leaq 0x1acd7(%rip), %rdi     # 0x2216f
movl $0x11, %esi
movl $0x1, %edx
callq 0x5270
movq %rbx, 0x8(%rsp)
movq 0x18(%rbx), %r14
cmpq $0x0, (%r14)
je 0x7730
movq 0x8(%rsp), %rax
addq $0x120, %rax            # imm = 0x120
movq %rax, 0x18(%rsp)
leaq 0x2b91f(%rip), %r15     # 0x32df0
cmpl $0x0, 0x18(%r14)
je 0x7590
movq 0x10(%r14), %r12
movq %r12, %rdi
callq 0x50e0
cmpq $0x3ef, %rax            # imm = 0x3EF
ja 0x75af
cmpl $0x0, 0x1c(%r14)
je 0x752e
leaq 0x20(%rsp), %rbx
movq %rbx, %rdi
leaq 0x1af51(%rip), %rsi     # 0x2245b
movq %r12, %rdx
xorl %eax, %eax
callq 0x5250
movl 0x20(%r14), %edx
movq 0x8(%rsp), %rdi
movq %rbx, %rsi
callq 0xa2c1
testq %rax, %rax
jne 0x758b
movq 0x10(%r14), %r12
movq 0x8(%rsp), %rbx
leaq 0x20(%rsp), %r13
movq %r13, %rdi
leaq 0x1af22(%rip), %rsi     # 0x22464
movq %r12, %rdx
xorl %eax, %eax
callq 0x5250
movq %rbx, %rdi
movq %r13, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xa2c1
testq %rax, %rax
jne 0x758b
movq 0x10(%r14), %rdx
movq %r13, %rdi
leaq 0x1aefd(%rip), %rsi     # 0x2246c
xorl %eax, %eax
callq 0x5250
movq %rbx, %rdi
movq %r13, %rsi
movl $0xffffffff, %edx       # imm = 0xFFFFFFFF
callq 0xa2c1
testq %rax, %rax
je 0x75af
movq %rax, %r13
jmp 0x75e2
movq 0x10(%r14), %rdi
callq 0x676b
movq 0x10(%r14), %rsi
testq %rax, %rax
je 0x75d3
movq %rax, %r13
movq %r15, %rdi
callq 0x5080
jmp 0x75e2
movq 0x10(%r14), %rcx
movl $0x400, %esi            # imm = 0x400
movq %r15, %rdi
leaq 0x1abbf(%rip), %rdx     # 0x22181
xorl %eax, %eax
callq 0x5100
movl $0x8, %edi
movq %r15, %rsi
jmp 0x75d8
movl $0x8, %edi
xorl %eax, %eax
callq 0x6f14
xorl %r13d, %r13d
movq -0x8(%r13), %r12
movq %r15, %rdi
callq 0x6850
movq %rax, %rbp
leaq 0x27b88(%rip), %r15     # 0x2f180
movq (%r15), %rax
movl $0x0, 0x14(%rsp)
xorl %ebx, %ebx
testq %rax, %rax
je 0x762a
movl 0x18(%r14), %ecx
movq %rbp, %rdi
movq %r13, %rsi
movq %r12, %rdx
callq *0x20(%rax)
testl %eax, %eax
jne 0x763b
movq 0x8(%r15), %rax
addq $0x8, %r15
incb %bl
jmp 0x7605
movl $0xb, %edi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x6f14
jmp 0x7648
cmpl $-0x1, %eax
je 0x771c
movl %eax, 0x14(%rsp)
movq 0x8(%rsp), %rdx
movb 0x202(%rdx), %al
movq (%r15), %rcx
movb 0xaa(%rcx), %cl
testb %al, %al
js 0x767f
testb %cl, %cl
sets %dl
cmpb %cl, %al
sete %al
orb %dl, %al
jne 0x7685
movl $0x3d, %edi
movq %rbp, %rsi
xorl %eax, %eax
callq 0x6f14
jmp 0x7685
movb %cl, 0x202(%rdx)
movl $0x40, %edi
callq 0x6638
movq %rax, %rbp
leaq 0x2b757(%rip), %rdi     # 0x32df0
callq 0x669d
movq %rax, 0x10(%rbp)
movq %rax, %rdi
callq 0x6850
movq %rax, 0x18(%rbp)
movq %r13, 0x28(%rbp)
movq %r12, 0x30(%rbp)
movb %bl, 0x38(%rbp)
movl 0x14(%rsp), %edx
movb %dl, 0x39(%rbp)
movzwl 0x24(%r14), %eax
movw %ax, 0x3a(%rbp)
movq 0x8(%rsp), %rbx
movq 0xa0(%rbx), %rdi
testq %rdi, %rdi
je 0x7703
movq (%r15), %rax
movq (%rax), %rcx
movslq %edx, %rax
leaq 0x275a6(%rip), %rdx     # 0x2ec90
movq (%rdx,%rax,8), %r8
leaq 0x1aa91(%rip), %rsi     # 0x22186
leaq 0x2b6f4(%rip), %rdx     # 0x32df0
xorl %eax, %eax
callq 0x5180
movq (%r15), %rax
movq %rbx, %rdi
movq %rbp, %rsi
callq *0x28(%rax)
movq 0x18(%rsp), %rdi
movq %rbp, %rsi
callq 0x6729
movq (%r14), %r14
cmpq $0x0, (%r14)
leaq 0x2b6c6(%rip), %r15     # 0x32df0
jne 0x74d1
movq 0x8(%rsp), %r15
cmpb $0x0, 0x202(%r15)
jns 0x776c
movzbl 0x50(%r15), %eax
leaq 0x27a35(%rip), %rcx     # 0x2f180
movq (%rcx,%rax,8), %rax
movb 0xaa(%rax), %al
movb %al, 0x202(%r15)
testb %al, %al
jns 0x776c
callq 0x690b
movb %al, 0x202(%r15)
movq %r15, %rdi
callq 0xb9e1
movq 0xb8(%r15), %rbx
testq %rbx, %rbx
je 0x786f
leaq 0x138(%r15), %r14
movq 0x138(%r15), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x77aa
movq 0x20(%rax), %r13
cmpq $0x0, (%r13)
movq %rcx, %rax
je 0x7792
jmp 0x77bb
leaq 0x1ad22(%rip), %rdi     # 0x224d3
xorl %r13d, %r13d
xorl %eax, %eax
callq 0x52b0
leaq 0x1ad4d(%rip), %rsi     # 0x2250f
leaq 0x2be37(%rip), %r15     # 0x33600
movl $0x4, %ecx
movq 0x8(%rsp), %rbp
movq %rbp, %rdi
movq %r15, %rdx
callq 0xbf37
movq %rax, %r12
orb $0x1, 0x80(%rax)
movq 0x20(%r13), %rsi
movl $0x4, %ecx
movq %rax, %rdi
movq %r15, %rdx
callq 0xc0a9
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 0x6729
movq %r14, %rdi
movq %r12, %rsi
callq 0x6729
movq 0x8(%rbx), %rdx
movq %rbp, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq $0x0
pushq $0x0
callq 0xb13c
addq $0x10, %rsp
movq %r15, %rdi
movq %rax, %rsi
xorl %edx, %edx
movl $0x20, %ecx
movq $-0x1, %r8
callq 0xb1f1
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x782f
addq $0x428, %rsp            # imm = 0x428
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq