Go to the first, previous, next, last section, table of contents.

Encoding for the structure of the program

The path and name of the source file


The first stabs in the .s file contain the name and path of the source file that was compiled to produce the .s file. This information is contained in two records of stab type N_SO (100).

   .stabs "path_name", N_SO, NIL, NIL, Code_address_of_program_start
   .stabs "file_name:", N_SO, NIL, NIL, Code_address_of_program_start
2  .stabs "/cygint/s1/users/jcm/play/",100,0,0,Ltext0
3  .stabs "hello.c",100,0,0,Ltext0
4       .text
5  Ltext0:

Line Numbers


The start of source lines is represented by the N_SLINE (68) stab type.

.stabn N_SLINE, NIL, line, address

line is a source line number; address represents the code address for the start of that source line.

27 _main:
28 .stabn 68,0,4,LM1
29 LM1:
30      !#PROLOGUE# 0


Symbol Descriptors:
f (local), F (global)

Procedures are described by the N_FUN stab type. The symbol descriptor for a procedure is `F' if the procedure is globally scoped and `f' if the procedure is static (locally scoped).

The N_FUN stab representing a procedure is located immediately following the code of the procedure. The N_FUN stab is in turn directly followed by a group of other stabs describing elements of the procedure. These other stabs describe the procedure's parameters, its block local variables and its block structure.

48      ret
49      restore

The .stabs entry after this code fragment shows the name of the procedure (main); the type descriptor desc (F, for a global procedure); a reference to the predefined type int for the return type; and the starting address of the procedure.

Here is an exploded summary (with whitespace introduced for clarity), followed by line 50 of our sample assembly output, which has this form:

.stabs "name:
        desc  (global proc `F')
        return_type_ref  (int)
       ",N_FUN, NIL, NIL,
50 .stabs "main:F1",36,0,0,_main

Block Structure


The program's block structure is represented by the N_LBRAC (left brace) and the N_RBRAC (right brace) stab types. The following code range, which is the body of main, is labeled with `LBB2:' at the beginning and `LBE2:' at the end.

37 LBB2:
38      sethi %hi(LC0),%o1
39      or %o1,%lo(LC0),%o0
40      call _printf,0
41      nop
42 .stabn 68,0,6,LM3
43 LM3:
44 LBE2:

The N_LBRAC and N_RBRAC stabs that describe the block scope of the procedure are located after the N_FUNC stab that represents the procedure itself. The N_LBRAC uses the LBB2 label as the code address in its value field, and the N_RBRAC uses LBE2.

50 .stabs "main:F1",36,0,0,_main
   .stabn N_LBRAC, NIL, NIL, left-brace-address
   .stabn N_RBRAC, NIL, NIL, right-brace-address
51 .stabn 192,0,0,LBB2
52 .stabn 224,0,0,LBE2

Go to the first, previous, next, last section, table of contents.