// File: /workspace/github_c_makefile_star2_O3/deplinenoise[P]vlink/linker.c
// Function: linker_mapfile
void linker_mapfile(struct GlobalVars *gv)
/* print section mapping, when desired */
{
  if (gv->map_file) {
    struct ObjectUnit *obj;
    struct Section *sec;
    struct LinkedSection *ls;

    /* print file names and the new addresses of their sections */
    fprintf(gv->map_file,"\nFiles:\n");

    for (obj=(struct ObjectUnit *)gv->selobjects.first;
         obj->n.next!=NULL; obj=(struct ObjectUnit *)obj->n.next) {
      struct LinkFile *lfile = obj->lnkfile;
      char sep = ' ';

      if (!(obj->flags & OUF_SCRIPT)) {
        if (lfile->type == ID_LIBARCH)
          fprintf(gv->map_file,"  %s (%s):",lfile->pathname,obj->objname);
        else
          fprintf(gv->map_file,"  %s:",obj->objname);

        if (lfile->type != ID_SHAREDOBJ) {
          for (ls=(struct LinkedSection *)gv->lnksec.first;
               ls->n.next!=NULL; ls=(struct LinkedSection *)ls->n.next) {
            for (sec=(struct Section *)ls->sections.first;
                 sec->n.next!=NULL; sec=(struct Section *)sec->n.next) {
              if (sec->obj == obj) {  /* section came from this object? */
                if (strcmp(sec->name,gv->common_sec_name) &&
                    strcmp(sec->name,gv->scommon_sec_name)) {
                  fprintf(gv->map_file,"%c %s %lx(%lx)",sep,sec->name,
                          sec->va,sec->size);
                  sep = ',';
                }
              }
            }
          }
        }

        if (sep == ',')  /* any sections listed? */
          fprintf(gv->map_file," hex\n");
        else
          fprintf(gv->map_file,"  symbols only\n"); /* empty or shared obj. */
      }
    }

    /* print section mappings */
    fprintf(gv->map_file,"\n\nSection mapping (numbers in hex):\n");

    for (ls=(struct LinkedSection *)gv->lnksec.first;
         ls->n.next!=NULL; ls=(struct LinkedSection *)ls->n.next) {
      if (!(ls->size==0 && listempty(&ls->relocs) &&
            listempty(&ls->symbols) && !(ls->ld_flags & LSF_PRESERVE))) {
        fprintf(gv->map_file,"------------------------------\n"
                "  %08lx %s  (size %lx",ls->copybase,ls->name,ls->size);
        if (ls->filesize < ls->size)
          fprintf(gv->map_file,", allocated %lx",ls->filesize);
        fprintf(gv->map_file,")\n");
  
        for (sec=(struct Section *)ls->sections.first;
             sec->n.next!=NULL; sec=(struct Section *)sec->n.next) {
          if (sec->obj!=NULL && !is_ld_script(sec->obj)) {
            fprintf(gv->map_file,"           %08lx - %08lx %s(%s)\n",
                    sec->va,sec->va+sec->size,sec->obj->objname,sec->name);
          }
        }
      }
    }
  }
}

// Assembly:
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
subq $0x18, %rsp
movq %rdi, 0x8(%rsp)
movq 0x90(%rdi), %rcx
testq %rcx, %rcx
je 0x92d3
leaq 0x19260(%rip), %rdi     # 0x22287
movl $0x8, %esi
movl $0x1, %edx
callq 0x5270
movq 0x8(%rsp), %rbx
movq 0x138(%rbx), %r14
cmpq $0x0, (%r14)
je 0x91af
leaq 0x1925d(%rip), %r15     # 0x222b0
movq 0x8(%rsp), %rbp
cmpw $0x0, 0x80(%r14)
js 0x91a2
movq %rbx, %rax
movq 0x10(%r14), %rbx
cmpb $0x8, 0x39(%rbx)
movq 0x90(%rax), %rdi
jne 0x9093
movq 0x10(%rbx), %rdx
movq 0x18(%r14), %rcx
leaq 0x19206(%rip), %rsi     # 0x22290
xorl %eax, %eax
callq 0x5180
jmp 0x90a5
movq 0x18(%r14), %rdx
leaq 0x191fd(%rip), %rsi     # 0x2229b
xorl %eax, %eax
callq 0x5180
cmpb $0x4, 0x39(%rbx)
movq 0x8(%rsp), %rbx
je 0x9189
movq 0x1c0(%rbx), %rcx
movq (%rcx), %rax
testq %rax, %rax
je 0x9189
movb $0x20, %r15b
movq %rcx, 0x10(%rsp)
movq 0x60(%rcx), %r13
movq (%r13), %rbx
testq %rbx, %rbx
jne 0x9135
jmp 0x914e
movq 0x20(%r13), %r12
movq 0x220(%rbp), %rsi
movq %r12, %rdi
callq 0x5160
testl %eax, %eax
je 0x913b
movq 0x228(%rbp), %rsi
movq %r12, %rdi
callq 0x5160
testl %eax, %eax
je 0x913b
movq 0x90(%rbp), %rdi
movzbl %r15b, %edx
movq 0x30(%r13), %r8
movq 0x48(%r13), %r9
leaq 0x1917f(%rip), %rsi     # 0x222a1
movq %r12, %rcx
xorl %eax, %eax
callq 0x5180
movq (%r13), %rbx
movb $0x2c, %r15b
jmp 0x913b
cmpq %r14, 0x10(%r13)
je 0x90de
movq %rbx, %r13
movq (%rbx), %rbx
testq %rbx, %rbx
jne 0x9135
movq 0x10(%rsp), %rax
movq (%rax), %rax
movq %rax, %rcx
movq (%rax), %rax
testq %rax, %rax
jne 0x90ca
cmpb $0x2c, %r15b
movq 0x8(%rsp), %rbx
leaq 0x19143(%rip), %r15     # 0x222b0
jne 0x9189
movq 0x90(%rbx), %rcx
movl $0x5, %esi
movl $0x1, %edx
leaq 0x193e1(%rip), %rdi     # 0x22568
jmp 0x919d
movq 0x90(%rbx), %rcx
movl $0xf, %esi
movl $0x1, %edx
movq %r15, %rdi
callq 0x5270
movq (%r14), %r14
cmpq $0x0, (%r14)
jne 0x9058
movq 0x90(%rbx), %rcx
leaq 0x19103(%rip), %rdi     # 0x222c0
movl $0x24, %esi
movl $0x1, %edx
callq 0x5270
movq 0x1c0(%rbx), %rbp
cmpq $0x0, (%rbp)
je 0x92d3
leaq 0x19100(%rip), %r14     # 0x222e5
leaq 0x1912e(%rip), %r15     # 0x2231a
leaq 0x170c4(%rip), %r12     # 0x202b7
leaq 0x19130(%rip), %r13     # 0x2232a
movq 0x48(%rbp), %r8
testq %r8, %r8
jne 0x9233
movq 0x80(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x9233
movq 0xb0(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x9233
testb $0x2, 0x24(%rbp)
jne 0x9233
movq (%rbp), %rbp
cmpq $0x0, (%rbp)
jne 0x91fa
jmp 0x92d3
movq 0x8(%rsp), %rbx
movq 0x90(%rbx), %rdi
movq 0x18(%rbp), %rcx
movq 0x38(%rbp), %rdx
movq %r14, %rsi
xorl %eax, %eax
callq 0x5180
movq 0x50(%rbp), %rdx
cmpq 0x48(%rbp), %rdx
jae 0x926c
movq 0x90(%rbx), %rdi
movq %r15, %rsi
xorl %eax, %eax
callq 0x5180
movq 0x90(%rbx), %rcx
movl $0x2, %esi
movl $0x1, %edx
movq %r12, %rdi
callq 0x5270
movq 0x60(%rbp), %rbx
cmpq $0x0, (%rbx)
je 0x9223
movq 0x10(%rbx), %rdi
testq %rdi, %rdi
je 0x92ce
callq 0xd68c
testl %eax, %eax
jne 0x92ce
movq 0x8(%rsp), %rax
movq 0x90(%rax), %rdi
movq 0x30(%rbx), %rdx
movq 0x48(%rbx), %rcx
addq %rdx, %rcx
movq 0x10(%rbx), %rax
movq 0x20(%rbx), %r9
movq 0x18(%rax), %r8
movq %r13, %rsi
xorl %eax, %eax
callq 0x5180
movq (%rbx), %rbx
jmp 0x9289
addq $0x18, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq