// File: /workspace/github_c_makefile_star2_O1/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:
movq 0x90(%rdi), %rcx
testq %rcx, %rcx
je 0x928c
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x19284(%rip), %rdi     # 0x22297
movl $0x8, %esi
movl $0x1, %edx
callq 0x5270
movq 0x138(%rbx), %r14
cmpq $0x0, (%r14)
je 0x9167
leaq 0x19286(%rip), %r12     # 0x222c0
cmpw $0x0, 0x80(%r14)
js 0x915a
movq 0x10(%r14), %r15
cmpb $0x8, 0x39(%r15)
movq 0x90(%rbx), %rdi
jne 0x9073
movq 0x10(%r15), %rdx
movq 0x18(%r14), %rcx
leaq 0x19236(%rip), %rsi     # 0x222a0
xorl %eax, %eax
callq 0x5180
jmp 0x9085
movq 0x18(%r14), %rdx
leaq 0x1922d(%rip), %rsi     # 0x222ab
xorl %eax, %eax
callq 0x5180
cmpb $0x4, 0x39(%r15)
je 0x9141
movq 0x1c0(%rbx), %rbp
cmpq $0x0, (%rbp)
je 0x9141
movb $0x20, %r15b
movq 0x60(%rbp), %r13
cmpq $0x0, (%r13)
je 0x910f
cmpq %r14, 0x10(%r13)
je 0x90bc
movq (%r13), %r13
jmp 0x90a9
movq 0x20(%r13), %r12
movq 0x220(%rbx), %rsi
movq %r12, %rdi
callq 0x5160
testl %eax, %eax
je 0x90b6
movq 0x228(%rbx), %rsi
movq %r12, %rdi
callq 0x5160
testl %eax, %eax
je 0x90b6
movq 0x90(%rbx), %rdi
movzbl %r15b, %edx
movq 0x30(%r13), %r8
movq 0x48(%r13), %r9
leaq 0x191b1(%rip), %rsi     # 0x222b1
movq %r12, %rcx
xorl %eax, %eax
callq 0x5180
movb $0x2c, %r15b
jmp 0x90b6
movq (%rbp), %rbp
cmpq $0x0, (%rbp)
jne 0x90a5
cmpb $0x2c, %r15b
leaq 0x1919b(%rip), %r12     # 0x222c0
jne 0x9141
movq 0x90(%rbx), %rcx
movl $0x5, %esi
movl $0x1, %edx
leaq 0x19439(%rip), %rdi     # 0x22578
jmp 0x9155
movq 0x90(%rbx), %rcx
movl $0xf, %esi
movl $0x1, %edx
movq %r12, %rdi
callq 0x5270
movq (%r14), %r14
cmpq $0x0, (%r14)
jne 0x903a
movq 0x90(%rbx), %rcx
leaq 0x1915b(%rip), %rdi     # 0x222d0
movl $0x24, %esi
movl $0x1, %edx
callq 0x5270
movq 0x1c0(%rbx), %rbp
cmpq $0x0, (%rbp)
je 0x927e
leaq 0x19158(%rip), %r14     # 0x222f5
leaq 0x1711e(%rip), %r12     # 0x202c2
leaq 0x1918f(%rip), %r13     # 0x2233a
movq 0x48(%rbp), %r8
testq %r8, %r8
jne 0x91e4
movq 0x80(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x91e4
movq 0xb0(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x91e4
testb $0x2, 0x24(%rbp)
jne 0x91e4
movq (%rbp), %rbp
cmpq $0x0, (%rbp)
jne 0x91ab
jmp 0x927e
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 0x921c
movq 0x90(%rbx), %rdi
leaq 0x19115(%rip), %rsi     # 0x2232a
xorl %eax, %eax
callq 0x5180
movq 0x90(%rbx), %rcx
movl $0x2, %esi
movl $0x1, %edx
movq %r12, %rdi
callq 0x5270
movq 0x60(%rbp), %r15
cmpq $0x0, (%r15)
je 0x91d4
movq 0x10(%r15), %rdi
testq %rdi, %rdi
je 0x9279
callq 0xd7a0
testl %eax, %eax
jne 0x9279
movq 0x90(%rbx), %rdi
movq 0x30(%r15), %rdx
movq 0x48(%r15), %rcx
addq %rdx, %rcx
movq 0x10(%r15), %rax
movq 0x20(%r15), %r9
movq 0x18(%rax), %r8
movq %r13, %rsi
xorl %eax, %eax
callq 0x5180
movq (%r15), %r15
jmp 0x9239
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq