// File: /workspace/github_c_makefile_star2_O2/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 0x8dc3
pushq %rbp
pushq %r15
pushq %r14
pushq %r13
pushq %r12
pushq %rbx
pushq %rax
movq %rdi, %rbx
leaq 0x1771e(%rip), %rdi     # 0x20297
pushq $0x8
popq %rsi
pushq $0x1
popq %rdx
callq 0x5280
leaq 0x138(%rbx), %r13
leaq 0x1c0(%rbx), %r12
movq %r12, (%rsp)
movq (%r13), %r13
cmpq $0x0, (%r13)
je 0x8ca8
cmpw $0x0, 0x80(%r13)
js 0x8b96
movq 0x10(%r13), %r14
cmpb $0x8, 0x39(%r14)
movq 0x90(%rbx), %rdi
jne 0x8bda
movq 0x10(%r14), %rdx
movq 0x18(%r13), %rcx
leaq 0x176cf(%rip), %rsi     # 0x202a0
xorl %eax, %eax
callq 0x5180
jmp 0x8bec
movq 0x18(%r13), %rdx
leaq 0x176c6(%rip), %rsi     # 0x202ab
xorl %eax, %eax
callq 0x5180
cmpb $0x4, 0x39(%r14)
je 0x8c8a
movq %r12, %r14
movb $0x20, %r12b
movq (%r14), %r14
cmpq $0x0, (%r14)
je 0x8c6e
leaq 0x60(%r14), %rbp
movq (%rbp), %rbp
cmpq $0x0, (%rbp)
je 0x8bfd
cmpq %r13, 0x10(%rbp)
jne 0x8c0a
movq 0x20(%rbp), %r15
movq 0x220(%rbx), %rsi
movq %r15, %rdi
callq 0x5160
testl %eax, %eax
je 0x8c0a
movq 0x228(%rbx), %rsi
movq %r15, %rdi
callq 0x5160
testl %eax, %eax
je 0x8c0a
movq 0x90(%rbx), %rdi
movzbl %r12b, %edx
movq 0x30(%rbp), %r8
movq 0x48(%rbp), %r9
leaq 0x17652(%rip), %rsi     # 0x202b1
movq %r15, %rcx
xorl %eax, %eax
callq 0x5180
movb $0x2c, %r12b
jmp 0x8c0a
cmpb $0x2c, %r12b
movq (%rsp), %r12
jne 0x8c8a
movq 0x90(%rbx), %rcx
leaq 0x178f2(%rip), %rdi     # 0x20578
pushq $0x5
jmp 0x8c9a
movq 0x90(%rbx), %rcx
leaq 0x17628(%rip), %rdi     # 0x202c0
pushq $0xf
popq %rsi
pushq $0x1
popq %rdx
callq 0x5280
jmp 0x8b96
movq 0x90(%rbx), %rcx
leaq 0x1761a(%rip), %rdi     # 0x202d0
pushq $0x24
popq %rsi
pushq $0x1
popq %rdx
callq 0x5280
leaq 0x155ef(%rip), %r13     # 0x1e2b7
pushq $0x2
popq %r14
movq %r12, %rbp
leaq 0x17664(%rip), %r12     # 0x2033a
movq (%rbp), %rbp
cmpq $0x0, (%rbp)
je 0x8db5
movq 0x48(%rbp), %r8
testq %r8, %r8
jne 0x8d0e
movq 0x80(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x8d0e
movq 0xb0(%rbp), %rax
cmpq $0x0, (%rax)
jne 0x8d0e
testb $0x2, 0x24(%rbp)
je 0x8cd6
movq 0x90(%rbx), %rdi
movq 0x18(%rbp), %rcx
movq 0x38(%rbp), %rdx
leaq 0x175d1(%rip), %rsi     # 0x202f5
xorl %eax, %eax
callq 0x5180
movq 0x50(%rbp), %rdx
movq %rbp, %r15
cmpq 0x48(%rbp), %rdx
jae 0x8d4d
movq 0x90(%rbx), %rdi
leaq 0x175e4(%rip), %rsi     # 0x2032a
xorl %eax, %eax
callq 0x5180
movq 0x90(%rbx), %rcx
movq %r13, %rdi
movq %r14, %rsi
pushq $0x1
popq %rdx
callq 0x5280
leaq 0x60(%r15), %rbp
movq (%rbp), %rbp
cmpq $0x0, (%rbp)
je 0x8dad
movq 0x10(%rbp), %rdi
testq %rdi, %rdi
je 0x8d66
callq 0xcec5
testl %eax, %eax
jne 0x8d66
movq 0x90(%rbx), %rdi
movq 0x30(%rbp), %rdx
movq 0x48(%rbp), %rcx
addq %rdx, %rcx
movq 0x10(%rbp), %rax
movq 0x20(%rbp), %r9
movq 0x18(%rax), %r8
movq %r12, %rsi
xorl %eax, %eax
callq 0x5180
jmp 0x8d66
movq %r15, %rbp
jmp 0x8cd6
addq $0x8, %rsp
popq %rbx
popq %r12
popq %r13
popq %r14
popq %r15
popq %rbp
retq