// File: /workspace/github_c_makefile_star2_O2/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 $0x418, %rsp            # imm = 0x418
movq %rdi, %r14
callq 0xe398
movq 0x18(%r14), %rax
cmpq $0x0, (%rax)
jne 0x7177
pushq $0x6
popq %rdi
xorl %eax, %eax
callq 0x6c19
cmpl $0x0, 0x244(%r14)
je 0x7198
leaq 0x18fe7(%rip), %rax     # 0x2016f
movq %rax, 0x220(%r14)
leaq 0x18fe0(%rip), %rax     # 0x20176
jmp 0x71dd
movzbl 0x50(%r14), %eax
leaq 0x27fec(%rip), %rcx     # 0x2f190
movq (%rcx,%rax,8), %rdx
movq 0x88(%rdx), %rdx
testq %rdx, %rdx
leaq 0x18fb6(%rip), %rsi     # 0x2016f
cmovneq %rdx, %rsi
movq %rsi, 0x220(%r14)
movq (%rcx,%rax,8), %rax
movq 0x90(%rax), %rcx
testq %rcx, %rcx
leaq 0x18f9d(%rip), %rax     # 0x20176
cmovneq %rcx, %rax
movq %rax, 0x228(%r14)
movq 0xa0(%r14), %rcx
testq %rcx, %rcx
je 0x7202
leaq 0x18f88(%rip), %rdi     # 0x2017f
pushq $0x11
popq %rsi
pushq $0x1
popq %rdx
callq 0x5280
leaq 0x18(%r14), %rbx
movq %r14, (%rsp)
leaq 0x120(%r14), %rax
movq %rax, 0x8(%rsp)
movq (%rbx), %rbx
cmpq $0x0, (%rbx)
je 0x7488
cmpl $0x0, 0x18(%rbx)
movq (%rsp), %r15
je 0x7281
movq 0x10(%rbx), %r14
movq %r14, %rdi
callq 0x50e0
cmpq $0x3ef, %rax            # imm = 0x3EF
ja 0x731c
cmpl $0x0, 0x1c(%rbx)
je 0x72b8
leaq 0x10(%rsp), %r12
movq %r12, %rdi
leaq 0x19211(%rip), %rsi     # 0x2046b
movq %r14, %rdx
xorl %eax, %eax
callq 0x5260
movl 0x20(%rbx), %edx
movq %r15, %rdi
movq %r12, %rsi
callq 0x9d90
testq %rax, %rax
jne 0x7310
movq 0x10(%rbx), %r14
jmp 0x72bd
movq 0x10(%rbx), %rdi
callq 0x6456
movq 0x10(%rbx), %rsi
testq %rax, %rax
je 0x72aa
movq %rax, %rbp
leaq 0x2bf43(%rip), %r14     # 0x331e0
movq %r14, %rdi
callq 0x5080
jmp 0x734c
pushq $0x8
popq %rdi
xorl %eax, %eax
callq 0x6c19
xorl %ebp, %ebp
jmp 0x7313
leaq 0x10(%rsp), %r12
movq %r12, %rdi
leaq 0x191ad(%rip), %rsi     # 0x20474
movq %r14, %rdx
xorl %eax, %eax
callq 0x5260
movq %r15, %rdi
movq %r12, %rsi
pushq $-0x1
popq %r14
movl %r14d, %edx
callq 0x9d90
testq %rax, %rax
jne 0x7310
movq 0x10(%rbx), %rdx
movq %r12, %rdi
leaq 0x19186(%rip), %rsi     # 0x2047c
xorl %eax, %eax
callq 0x5260
movq %r15, %rdi
movq %r12, %rsi
movl %r14d, %edx
callq 0x9d90
testq %rax, %rax
je 0x731c
movq %rax, %rbp
leaq 0x2bec6(%rip), %r14     # 0x331e0
jmp 0x734c
movq 0x10(%rbx), %rcx
movl $0x400, %esi            # imm = 0x400
leaq 0x2beb4(%rip), %r14     # 0x331e0
movq %r14, %rdi
leaq 0x18e5b(%rip), %rdx     # 0x20191
xorl %eax, %eax
callq 0x5100
pushq $0x8
popq %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x6c19
xorl %ebp, %ebp
movq -0x8(%rbp), %r13
movq %r14, %rdi
callq 0x6533
movq %rax, %r14
xorl %r15d, %r15d
leaq 0x27e2b(%rip), %rax     # 0x2f190
movq (%rax,%r15,8), %rax
testq %rax, %rax
je 0x7394
movl 0x18(%rbx), %ecx
movq %r14, %rdi
movq %rbp, %rsi
movq %r13, %rdx
callq *0x20(%rax)
testl %eax, %eax
jne 0x7386
incq %r15
jmp 0x735e
movl %eax, %r12d
cmpl $-0x1, %eax
je 0x7216
jmp 0x73a4
xorl %r12d, %r12d
pushq $0xb
popq %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x6c19
movq (%rsp), %rdx
movb 0x202(%rdx), %al
leaq 0x27ddb(%rip), %rcx     # 0x2f190
movq (%rcx,%r15,8), %rcx
movb 0xaa(%rcx), %cl
testb %al, %al
js 0x73e0
testb %cl, %cl
sets %dl
cmpb %cl, %al
sete %al
orb %dl, %al
jne 0x73e6
pushq $0x3d
popq %rdi
movq %r14, %rsi
xorl %eax, %eax
callq 0x6c19
jmp 0x73e6
movb %cl, 0x202(%rdx)
pushq $0x40
popq %rdi
callq 0x6340
movq %rax, %r14
leaq 0x2bde8(%rip), %rdi     # 0x331e0
callq 0x63a1
movq %rax, 0x10(%r14)
movq %rax, %rdi
callq 0x6533
movq %rax, 0x18(%r14)
movq %rbp, 0x28(%r14)
movq %r13, 0x30(%r14)
movb %r15b, 0x38(%r14)
movb %r12b, 0x39(%r14)
movzwl 0x24(%rbx), %eax
movw %ax, 0x3a(%r14)
movq (%rsp), %r13
movq 0xa0(%r13), %rdi
testq %rdi, %rdi
leaq 0x27d55(%rip), %rbp     # 0x2f190
je 0x7468
movq (%rbp,%r15,8), %rax
movq (%rax), %rcx
movslq %r12d, %rax
leaq 0x27841(%rip), %rdx     # 0x2ec90
movq (%rdx,%rax,8), %r8
leaq 0x18d3c(%rip), %rsi     # 0x20196
leaq 0x2bd7f(%rip), %rdx     # 0x331e0
xorl %eax, %eax
callq 0x5180
movq (%rbp,%r15,8), %rax
movq %r13, %rdi
movq %r14, %rsi
callq *0x28(%rax)
movq 0x8(%rsp), %rdi
movq %r14, %rsi
callq 0x6414
jmp 0x7216
movq (%rsp), %r13
cmpb $0x0, 0x202(%r13)
jns 0x74c3
movzbl 0x50(%r13), %eax
leaq 0x27cee(%rip), %rcx     # 0x2f190
movq (%rcx,%rax,8), %rax
movb 0xaa(%rax), %al
movb %al, 0x202(%r13)
testb %al, %al
jns 0x74c3
callq 0x65e9
movb %al, 0x202(%r13)
movq %r13, %rdi
callq 0xb426
movq 0xb8(%r13), %rbx
testq %rbx, %rbx
je 0x75c0
leaq 0x138(%r13), %r14
movq 0x138(%r13), %rax
movq (%rax), %rcx
testq %rcx, %rcx
je 0x7501
movq 0x20(%rax), %rbp
cmpq $0x0, (%rbp)
movq %rcx, %rax
je 0x74e9
jmp 0x7511
leaq 0x18fdb(%rip), %rdi     # 0x204e3
xorl %ebp, %ebp
xorl %eax, %eax
callq 0x6b2c
leaq 0x19007(%rip), %rsi     # 0x2051f
leaq 0x2c4d1(%rip), %r15     # 0x339f0
pushq $0x4
popq %r12
movq %r13, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0xb906
movq %rax, %r13
orb $0x1, 0x80(%rax)
movq 0x20(%rbp), %rsi
movq %rax, %rdi
movq %r15, %rdx
movq %r12, %rcx
callq 0xba41
movq %rax, %r15
movb 0x2c(%rbp), %al
movb %al, 0x2c(%r15)
movb 0x2e(%rbp), %al
movb %al, 0x2e(%r15)
movb 0x2d(%rbp), %al
movb %al, 0x2d(%r15)
leaq 0x20(%r13), %rdi
movq %r15, %rsi
callq 0x6414
movq %r14, %rdi
movq %r13, %rsi
movq (%rsp), %r12
callq 0x6414
pushq $0x20
popq %rbp
pushq $-0x1
popq %r14
movq 0x8(%rbx), %rdx
movq %r12, %rdi
movq %r15, %rsi
xorl %ecx, %ecx
xorl %r8d, %r8d
xorl %r9d, %r9d
pushq $0x0
pushq $0x0
callq 0xabec
addq $0x10, %rsp
movq %r15, %rdi
movq %rax, %rsi
xorl %edx, %edx
movl %ebp, %ecx
movq %r14, %r8
callq 0xac9f
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x7587
addq $0x418, %rsp            # imm = 0x418
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq