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

📄 mips-tfile.c

📁 gcc库的原代码,对编程有很大帮助.
💻 C
📖 第 1 页 / 共 5 页
字号:
/* Update the symbol table (the .T file) in a MIPS object to   contain debugging information specified by the GNU compiler   in the form of comments (the mips assembler does not support   assembly access to debug information).   Copyright (C) 1991, 1993, 1994. 1995 Free Software Foundation, Inc.   Contributed by Michael Meissner, meissner@osf.org   This file is part of GNU CC.GNU CC is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe Free Software Foundation; either version 2, or (at your option)any later version.GNU CC is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See theGNU General Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU CC; see the file COPYING.  If not, write tothe Free Software Foundation, 59 Temple Place - Suite 330,Boston, MA 02111-1307, USA.  *//* Here is a brief description of the MIPS ECOFF symbol table.  The   MIPS symbol table has the following pieces:	Symbolic Header	    |	    +--	Auxiliary Symbols	    |	    +--	Dense number table	    |	    +--	Optimizer Symbols	    |	    +--	External Strings	    |	    +--	External Symbols	    |	    +--	Relative file descriptors	    |	    +--	File table		    |		    +--	Procedure table		    |		    +--	Line number table		    |		    +--	Local Strings		    |		    +--	Local Symbols   The symbolic header points to each of the other tables, and also   contains the number of entries.  It also contains a magic number   and MIPS compiler version number, such as 2.0.   The auxiliary table is a series of 32 bit integers, that are   referenced as needed from the local symbol table.  Unlike standard   COFF, the aux.  information does not follow the symbol that uses   it, but rather is a separate table.  In theory, this would allow   the MIPS compilers to collapse duplicate aux. entries, but I've not   noticed this happening with the 1.31 compiler suite.  The different   types of aux. entries are:    1)	dnLow: Low bound on array dimension.    2)	dnHigh: High bound on array dimension.    3)	isym: Index to the local symbol which is the start of the	function for the end of function first aux. entry.    4)	width: Width of structures and bitfields.    5)	count: Count of ranges for variant part.    6)	rndx: A relative index into the symbol table.  The relative	index field has two parts: rfd which is a pointer into the	relative file index table or ST_RFDESCAPE which says the next	aux. entry is the file number, and index: which is the pointer	into the local symbol within a given file table.  This is for	things like references to types defined in another file.    7)	Type information: This is like the COFF type bits, except it	is 32 bits instead of 16; they still have room to add new	basic types; and they can handle more than 6 levels of array,	pointer, function, etc.  Each type information field contains	the following structure members:	    a)	fBitfield: a bit that says this is a bitfield, and the		size in bits follows as the next aux. entry.	    b)	continued: a bit that says the next aux. entry is a		continuation of the current type information (in case		there are more than 6 levels of array/ptr/function).	    c)	bt: an integer containing the base type before adding		array, pointer, function, etc. qualifiers.  The		current base types that I have documentation for are:			btNil		-- undefined 			btAdr		-- address - integer same size as ptr			btChar		-- character 			btUChar		-- unsigned character 			btShort		-- short 			btUShort	-- unsigned short 			btInt		-- int 			btUInt		-- unsigned int 			btLong		-- long 			btULong		-- unsigned long 			btFloat		-- float (real) 			btDouble	-- Double (real) 			btStruct	-- Structure (Record) 			btUnion		-- Union (variant) 			btEnum		-- Enumerated 			btTypedef	-- defined via a typedef isymRef 			btRange		-- subrange of int 			btSet		-- pascal sets 			btComplex	-- fortran complex 			btDComplex	-- fortran double complex 			btIndirect	-- forward or unnamed typedef 			btFixedDec	-- Fixed Decimal 			btFloatDec	-- Float Decimal 			btString	-- Varying Length Character String 			btBit		-- Aligned Bit String 			btPicture	-- Picture			btVoid		-- Void (MIPS cc revision >= 2.00)	    d)	tq0 - tq5: type qualifier fields as needed.  The		current type qualifier fields I have documentation for		are:			tqNil		-- no more qualifiers 			tqPtr		-- pointer 			tqProc		-- procedure 			tqArray		-- array 			tqFar		-- 8086 far pointers 			tqVol		-- volatile    The dense number table is used in the front ends, and disappears by   the time the .o is created.   With the 1.31 compiler suite, the optimization symbols don't seem   to be used as far as I can tell.   The linker is the first entity that creates the relative file   descriptor table, and I believe it is used so that the individual   file table pointers don't have to be rewritten when the objects are   merged together into the program file.   Unlike COFF, the basic symbol & string tables are split into   external and local symbols/strings.  The relocation information   only goes off of the external symbol table, and the debug   information only goes off of the internal symbol table.  The   external symbols can have links to an appropriate file index and   symbol within the file to give it the appropriate type information.   Because of this, the external symbols are actually larger than the   internal symbols (to contain the link information), and contain the   local symbol structure as a member, though this member is not the   first member of the external symbol structure (!).  I suspect this   split is to make strip easier to deal with.   Each file table has offsets for where the line numbers, local   strings, local symbols, and procedure table starts from within the   global tables, and the indexs are reset to 0 for each of those   tables for the file.   The procedure table contains the binary equivalents of the .ent   (start of the function address), .frame (what register is the   virtual frame pointer, constant offset from the register to obtain   the VFP, and what register holds the return address), .mask/.fmask   (bitmask of saved registers, and where the first register is stored   relative to the VFP) assembler directives.  It also contains the   low and high bounds of the line numbers if debugging is turned on.   The line number table is a compressed form of the normal COFF line   table.  Each line number entry is either 1 or 3 bytes long, and   contains a signed delta from the previous line, and an unsigned   count of the number of instructions this statement takes.   The local symbol table contains the following fields:    1)	iss: index to the local string table giving the name of the	symbol.    2)	value: value of the symbol (address, register number, etc.).    3)	st: symbol type.  The current symbol types are:	    stNil	  -- Nuthin' special	    stGlobal	  -- external symbol	    stStatic	  -- static	    stParam	  -- procedure argument	    stLocal	  -- local variable	    stLabel	  -- label	    stProc	  -- External Procedure	    stBlock	  -- beginning of block	    stEnd	  -- end (of anything)	    stMember	  -- member (of anything)	    stTypedef	  -- type definition	    stFile	  -- file name	    stRegReloc	  -- register relocation	    stForward	  -- forwarding address	    stStaticProc  -- Static procedure	    stConstant	  -- const    4)	sc: storage class.  The current storage classes are:	    scText	  -- text symbol	    scData	  -- initialized data symbol	    scBss	  -- un-initialized data symbol	    scRegister	  -- value of symbol is register number	    scAbs	  -- value of symbol is absolute	    scUndefined   -- who knows?	    scCdbLocal	  -- variable's value is IN se->va.??	    scBits	  -- this is a bit field	    scCdbSystem	  -- value is IN debugger's address space	    scRegImage	  -- register value saved on stack	    scInfo	  -- symbol contains debugger information	    scUserStruct  -- addr in struct user for current process	    scSData	  -- load time only small data	    scSBss	  -- load time only small common	    scRData	  -- load time only read only data	    scVar	  -- Var parameter (fortranpascal)	    scCommon	  -- common variable	    scSCommon	  -- small common	    scVarRegister -- Var parameter in a register	    scVariant	  -- Variant record	    scSUndefined  -- small undefined(external) data	    scInit	  -- .init section symbol    5)	index: pointer to a local symbol or aux. entry.   For the following program:	#include <stdio.h>	main(){		printf("Hello World!\n");		return 0;	}   Mips-tdump produces the following information:      Global file header:       magic number             0x162       # sections               2       timestamp                645311799, Wed Jun 13 17:16:39 1990       symbolic header offset   284       symbolic header size     96       optional header          56       flags                    0x0      Symbolic header, magic number = 0x7009, vstamp = 1.31:          Info                      Offset      Number       Bytes       ====                      ======      ======      =====          Line numbers                 380           4           4 [13]       Dense numbers                  0           0           0       Procedures Tables            384           1          52       Local Symbols                436          16         192       Optimization Symbols           0           0           0       Auxiliary Symbols            628          39         156       Local Strings                784          80          80       External Strings             864         144         144       File Tables                 1008           2         144       Relative Files                 0           0           0       External Symbols            1152          20         320      File #0, "hello2.c"          Name index  = 1          Readin      = No       Merge       = No         Endian      = LITTLE       Debug level = G2         Language    = C       Adr         = 0x00000000          Info                       Start      Number        Size      Offset       ====                       =====      ======        ====      ======       Local strings                  0          15          15         784       Local symbols                  0           6          72         436       Line numbers                   0          13          13         380       Optimization symbols           0           0           0           0       Procedures                     0           1          52         384       Auxiliary symbols              0          14          56         628       Relative Files                 0           0           0           0       There are 6 local symbols, starting at 436	Symbol# 0: "hello2.c"	    End+1 symbol  = 6	    String index  = 1	    Storage class = Text        Index  = 6	    Symbol type   = File        Value  = 0	Symbol# 1: "main"	    End+1 symbol  = 5	    Type          = int	    String index  = 10	    Storage class = Text        Index  = 12	    Symbol type   = Proc        Value  = 0	Symbol# 2: ""	    End+1 symbol  = 4	    String index  = 0	    Storage class = Text        Index  = 4	    Symbol type   = Block       Value  = 8	Symbol# 3: ""	    First symbol  = 2	    String index  = 0	    Storage class = Text        Index  = 2	    Symbol type   = End         Value  = 28	Symbol# 4: "main"	    First symbol  = 1	    String index  = 10	    Storage class = Text        Index  = 1	    Symbol type   = End         Value  = 52	Symbol# 5: "hello2.c"	    First symbol  = 0	    String index  = 1	    Storage class = Text        Index  = 0	    Symbol type   = End         Value  = 0    There are 14 auxiliary table entries, starting at 628.	* #0               0, [   0/      0], [ 0 0:0 0:0:0:0:0:0]	* #1              24, [  24/      0], [ 6 0:0 0:0:0:0:0:0]	* #2               8, [   8/      0], [ 2 0:0 0:0:0:0:0:0]	* #3              16, [  16/      0], [ 4 0:0 0:0:0:0:0:0]	* #4              24, [  24/      0], [ 6 0:0 0:0:0:0:0:0]	* #5              32, [  32/      0], [ 8 0:0 0:0:0:0:0:0]	* #6              40, [  40/      0], [10 0:0 0:0:0:0:0:0]	* #7              44, [  44/      0], [11 0:0 0:0:0:0:0:0]	* #8              12, [  12/      0], [ 3 0:0 0:0:0:0:0:0]	* #9              20, [  20/      0], [ 5 0:0 0:0:0:0:0:0]	* #10             28, [  28/      0], [ 7 0:0 0:0:0:0:0:0]	* #11             36, [  36/      0], [ 9 0:0 0:0:0:0:0:0]	  #12              5, [   5/      0], [ 1 1:0 0:0:0:0:0:0]	  #13             24, [  24/      0], [ 6 0:0 0:0:0:0:0:0]    There are 1 procedure descriptor entries, starting at 0.	Procedure descriptor 0:	    Name index   = 10          Name          = "main"	    .mask 0x80000000,-4        .fmask 0x00000000,0	    .frame $29,24,$31	    Opt. start   = -1          Symbols start = 1	    First line # = 3           Last line #   = 6	    Line Offset  = 0           Address       = 0x00000000	There are 4 bytes holding line numbers, starting at 380.	    Line           3,   delta     0,   count  2	    Line           4,   delta     1,   count  3	    Line           5,   delta     1,   count  2	    Line           6,   delta     1,   count  6   File #1, "/usr/include/stdio.h"    Name index  = 1          Readin      = No    Merge       = Yes        Endian      = LITTLE    Debug level = G2         Language    = C    Adr         = 0x00000000    Info                       Start      Number        Size      Offset    ====                       =====      ======        ====      ======    Local strings                 15          65          65         799    Local symbols                  6          10         120         508    Line numbers                   0           0           0         380    Optimization symbols           0           0           0           0    Procedures                     1           0           0         436    Auxiliary symbols             14          25         100         684    Relative Files                 0           0           0           0    There are 10 local symbols, starting at 442	Symbol# 0: "/usr/include/stdio.h"	    End+1 symbol  = 10	    String index  = 1	    Storage class = Text        Index  = 10	    Symbol type   = File        Value  = 0	Symbol# 1: "_iobuf"	    End+1 symbol  = 9	    String index  = 22	    Storage class = Info        Index  = 9	    Symbol type   = Block       Value  = 20	Symbol# 2: "_cnt"	    Type          = int	    String index  = 29	    Storage class = Info        Index  = 4	    Symbol type   = Member      Value  = 0	Symbol# 3: "_ptr"

⌨️ 快捷键说明

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