📄 lineno.html
字号:
<!doctype html public "-//w3c//dtd html 4.0 transitional//en">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251">
<meta name="GENERATOR" content="Mozilla/4.61 [en] (Win95; I) [Netscape]">
<title>COFF: Line Numbers</title>
</head>
<body>
<center><table BORDER=0 CELLSPACING=0 CELLPADDING=3 WIDTH="100%" >
<tr>
<td ALIGN=LEFT VALIGN=TOP BGCOLOR="#FFCC99"><b><font face="itc avant garde gothic,helvetica,arial">
<a href="/" target="_top">www.delorie.com</a>/<a href="/djgpp/" target="_top">djgpp</a>/<a href="/djgpp/doc/" target="_top">doc</a>/<a href="/djgpp/doc/coff/" target="_top">coff</a>/lineno.html</font></b></td>
<td ALIGN=RIGHT VALIGN=TOP BGCOLOR="#FFCC99"><b><font face="itc avant garde gothic,helvetica,arial">
<a href="/search/">search</a></font></b></td>
</tr>
</table></center>
<center><b><font size=-1>COFF: Line Numbers</font></b></center>
<pre>typedef struct {
union {
unsigned long <b>l_symndx</b>; /* function name symbol index */
unsigned long <b>l_paddr</b>; /* address of line number */
} l_addr;
unsigned short <b>l_lnno</b>; /* line number */
} <b>LINENO</b>;</pre>
<i>Warning:</i> This structure's size is not a multiple of four. When reading
from file, it is strongly recommended that either (1) you read each entry
in a loop, reading <tt>LINESZ</tt> bytes each time, or allocate a block
of memory and calculate a pointer to each entry you need by multiplying
by <tt>LINESZ</tt>. In no case should you assume that array addressing
or <tt>sizeof(LINENO)</tt> will be useful.
<p>Each executable section has its own line number table. Each function
in that section is numbered independently, with the start of the function
(the line with the opening brace) numbered as line one for that function.
Each function in the line number table will have one entry where <b><tt>l_lnno</tt></b>
is zero and the symbol table entry for the function is in <b><tt>l_symndx</tt></b>.
This entry is followed by entries for each line of the function, with
<b><tt>l_lnno</tt></b>
set to the function-relative line number (<tt>1..N</tt>) and <b><tt>l_paddr</tt></b>
set to the address of the first assembler codes for that line.
<p>To figure out absolute line numbers, you must look in <a href="symtab.html">the
symbol table</a> for the function, find the "beginning of function" symbol
(type <tt>C_FCN</tt>, usually right after the function's <tt>C_EXT</tt>
or <tt>C_STAT</tt> symbol) where the absolute line number for the function
(equivalent to line one in the line number table's scheme) is stored (in
<tt>AUXENT.x_sym.x_misc.x_lnsz.x_lnno</tt>),
and add that to the relative line numbers in the table.
<p>The trick to getting line numbers right is to remember that the lines
of the source file start at one (the first line in the file is line one)
<i>and</i> functions are numbered starting at one also. When you add them
up, you get one too many ones, so you must then subtract one to get the
right line number.
<table BORDER=0 CELLSPACING=0 CELLPADDING=3 WIDTH="100%" >
<tr>
<td ALIGN=LEFT VALIGN=TOP BGCOLOR="#FFCC99"><b><font face="itc avant garde gothic,helvetica,arial">
<a href="/users/dj/" target="_top">webmaster</a>
<a href="/donations.html" target="_top">donations</a>
<a href="/store/books/" target="_top">bookstore</a></font></b></td>
<td ALIGN=RIGHT VALIGN=TOP BGCOLOR="#FFCC99"><b><font face="itc avant garde gothic,helvetica,arial">
<a href="/" target="_top">delorie
software</a>
<a href="/privacy.html" target="_top">privacy</a></font></b></td>
</tr>
<tr>
<td ALIGN=LEFT VALIGN=TOP BGCOLOR="#FFCC99"><b><font face="itc avant garde gothic,helvetica,arial">
<a href="/copyright.html" target="_top">Copyright
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -