⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 map.c

📁 CC386 is a general-purpose 32-bit C compiler. It is not an optimizing compiler but given that the co
💻 C
📖 第 1 页 / 共 2 页
字号:
/* 
   Copyright 1994-2003 Free Software Foundation, Inc.

   This program is free software; you can redistribute it and/or modify
   it under the terms of the GNU General Public License as published by
   the Free Software Foundation; either version 2 of the License, or
   (at your option) any later version.

   This program is distributed in the hope that it will be useful,
   but WITHOUT ANY WARRANTY; without even the implied warranty of
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   GNU General Public License for more details.

   You should have received a copy of the GNU General Public License
   along with this program; if not, write to the Free Software
   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
   02111-1307, USA.  

   You may contact the author at:

   mailto::camille@bluegrass.net

   or by snail mail at:

   David Lindauer
   850 Washburn Ave Apt 99
   Louisville, KY 40222
*/
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <dos.h>
#include <time.h>

#include "langext.h"
#include "defines.h"
#include "types.h"
#include "subs.h"
#include "globals.h"
/*                                 MAP.C                                   */

/*+-------------------------------------------------------------------------+
  |                                                                         |
  |                               link_map                                  |
  |                                                                         |
  +-------------------------------------------------------------------------+*/
void link_map()
BeginDeclarations
file_info_ptr                          file;
#define File                           (*file)
group_entry_ptr                        grp;
#define Grp                            (*grp)
bit_16                                 i;
lseg_ptr                               lseg;
#define Lseg                           (*lseg)
lseg_ptr                               last_location_lseg;
public_entry_ptr                       pub;
#define Pub                            (*pub)
segment_entry_ptr                      seg;
#define Seg                            (*seg)
bit_32                                 stop_address;
EndDeclarations
BeginCode
 map_start_time = Now;
 If lst_file_list.first IsNull
  Then  /*  No map file to be created. */
   return;
  EndIf;
 file_open_for_write(lst_file_list.first);
 print("\n");
 print(" Start   Stop    Length Name                   Class\n");
 TraverseList(segment_list, seg)
  BeginTraverse
   stop_address = Seg.address+Seg.length;
   If Seg.length Exceeds 0L
    Then
     stop_address--;
    EndIf;
   print(" %06lXH %06lXH %06lXH %-22s %-22s\n",
         Seg.address,
         stop_address,
         Seg.length,
         unmangle((*Seg.segment_name).symbol),
         (*Seg.class_name).symbol);
  EndTraverse;

 If map.set IsTrue
  Then
   If First(group_list) IsNotNull
    Then
     print("\n");
     print(" Origin     Group\n");
     TraverseList(group_list, grp)
      BeginTraverse
       If Grp.first_segment IsNull
        Then
         print(" FLAT       %s\n",
             (*Grp.group_name).symbol);
        Else
         print(" %06X:%1X   %s\n",
             CanonicFrame((*Grp.first_segment).address),
             Bit_16((*Grp.first_segment).address & 0xFL),
             (*Grp.group_name).symbol);
       EndIf;
      EndTraverse;
    EndIf;

     public_sort_array = (public_entry_ptr_array)
                          allocate_memory(
                           Bit_32(sizeof(public_entry_ptr)) *
                            Bit_32(MAX_PUBLICS_IN_LIBRARY));
   n_publics_to_sort = 0;
   TraverseList(external_list, pub)
    BeginTraverse
     LoopIf(Pub.type_entry IsNot internal);
     public_sort_array[n_publics_to_sort++] = pub;
    EndTraverse;
   TraverseList(lib_file_list, file)
    BeginTraverse
     TraverseList(File.external_list, pub)
      BeginTraverse
       LoopIf(Pub.type_entry IsNot internal);
       public_sort_array[n_publics_to_sort++] = pub;
      EndTraverse;
    EndTraverse;
   If n_publics_to_sort Exceeds 0
    Then
     sort_publics_by_name(0, n_publics_to_sort-1);
     print("\n");
     print("  Address             Publics by Name\n");
     print("\n");
     For i=0; i LessThan n_publics_to_sort; i++
      BeginFor
       pub = public_sort_array[i];
       If pefile.val IsTrue Or lxfile.val IsTrue Or lefile.val IsTrue
        Then
         print(" %06x:%06x  ",0,public_target_address(pub)) ;
        Else
         print(" %06X:%06X  ",
             CanonicFrame(public_frame_address(pub)),
                    public_target_address(pub) -
                    public_frame_address(pub));
        EndIf ;
       If Pub.Internal.lseg IsNull
        Then
         print("Abs  ");
        Else
         print("     ");
        EndIf;
       print("%s\n", unmangle(Pub.symbol));
      EndFor;
     sort_publics_by_value(0, n_publics_to_sort-1);
     print("\n");
     print("  Address             Publics by Value\n");
     print("\n");
     For i=0; i LessThan n_publics_to_sort; i++
      BeginFor
       pub = public_sort_array[i];
       If pefile.val IsTrue Or lxfile.val IsTrue Or lefile.val IsTrue
        Then
         print(" %06x:%06x  ",0,public_target_address(pub)) ;
        Else
         print(" %06X:%06X  ",
             CanonicFrame(public_frame_address(pub)),
                    public_target_address(pub) -
                    public_frame_address(pub));
        EndIf ;
       If Pub.Internal.lseg IsNull
        Then
         print("Abs  ");
        Else
         print("     ");
        EndIf;
       print("%s\n", unmangle(Pub.symbol));
      EndFor;
    EndIf;


   print("\n");
   If start_address_found IsTrue
    Then
     print("Program entry point at %06X:%06X\n",
            initial_CS,
            initial_IP);
    EndIf;
  EndIf;

 If detail_level.val Exceeds 0
  Then
   print("\n");
   print("Next Uninitialized Byte(%05lX), EXE header Relocation Items(%u)\n",
         highest_uninitialized_byte,
         n_relocation_items);
   print("\n");
   print("Segment order expression:\n");
   print("\t\"%s\"\n", String(ordering.val));
   TraverseList(segment_list, seg)
    BeginTraverse
     print("\n");
     print("Segment(%s) Class(%s)",
           unmangle((*Seg.segment_name).symbol),
           (*Seg.class_name).symbol);
     If Seg.owning_group IsNotNull
      Then
       print(" Group(%s)",
             (*(*Seg.owning_group).group_name).symbol);
      EndIf;
     print(" Combine(%s)\n",
           combine_text[Seg.combine]);
     print("\tStart(%06lX) Length(%06lX) Next Uninitialized Byte(%06lX)\n",
           Seg.address,
           Seg.length,
           Seg.highest_uninitialized_byte);
     If detail_level.val Exceeds 1
      Then
       TraverseList(Seg.lsegs, lseg)
        BeginTraverse
         LoopIf(Lseg.length IsZero);
         print("\n");
         print("File(%s) Next Uninitialized Byte(%06lX)\n",
               (*Lseg.file).filename,
               Lseg.highest_uninitialized_byte+Lseg.address);
         print("\tModule(%s) Address(%06lX) Length(%06lX) Align(%s)\n",
               (*Lseg.tmodule).symbol,
               Lseg.address,
               Lseg.length,
               align_text[Lseg.align]);
         If (detail_level.val Exceeds 2)             AndIf 
            (Lseg.align IsNot absolute_segment)      AndIf
            (Seg.combine IsNot blank_common_combine)
          Then
           map_memory(Lseg.data, Lseg.address, Lseg.length);
          EndIf;
        EndTraverse;
      EndTraverse;
    EndIf;
   If (detail_level.val Exceeds 3) AndIf (exefile IsTrue)
    Then
     print("\n");
     print("EXE file header:\n");
     map_memory(BytePtr(exe_header), 0L, exe_header_size);
    EndIf;
   If detail_level.val Exceeds 4
    Then
     last_location_lseg = Null;
     print("\n");
     print("Fixups:\n");
	 fixup_temp = fixup_list ;
     While fixup_temp IsNotNull
      BeginWhile
       If (*fixup_temp).rec_typ IsNot FIXUPP_record
        Then
		 fixup_temp = (*fixup_temp).next ;
         ContinueLoop;
        Else
		 far_move(Addr(fixup),(*fixup_temp).data,(*fixup_temp).rec_len) ;
        EndIf;
       If last_location_lseg IsNot (*fixup_temp).lseg
        Then
         lseg = (*fixup_temp).lseg;
         seg  = Lseg.segment;
         print("\n");
         print("Fixups for File(%s), Module(%s), Segment(%s)\n",
               (*Lseg.file).filename,
               (*Lseg.tmodule).symbol,
               unmangle((*Seg.segment_name).symbol));
        EndIf;
       last_location_lseg = (*fixup_temp).lseg;
       print("\tLocation(%05lX) Type(%s) Mode(%s)\n",
             (*(*fixup_temp).lseg).address +
              Bit_32((*fixup_temp).offset),
             type_text[fixup.location_type],
             mode_text[fixup.mode]);
       print("\t\tFrame(");
       Using fixup.frame_method
        BeginCase
         When 0:
          lseg = (lseg_ptr) fixup.frame_referent;
          seg  = Lseg.segment;
          print("Seg(%s)", unmangle((*Seg.segment_name).symbol));
          break;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -