HI-TECH C Symbol File Format Introduction The symbol files produced by the HI-TECH linker using the -h option are ascii files, organized as one symbol per line. Other lines provide information about modules etc. Global Symbols The first part of the file comprises global symbols, i.e symbols visible throughout the entire program. Each line has the symbol name, a space then one or two hex numbers separated by a space. The first hex number is the link value of the symbol, i.e. the value that will be substituted whenever the symbol is referenced in the code. If the symbol is absolute, this will be the only number on the line. If a second value appears, this is the difference between the link and load addresses of the symbol. The load address of a symbol is the address at which it appears in the code image produced by the linker. If the link and load addresses are the same, this value will be zero. Some examples: _main 100 0 This line defines a symbol _main (note that the C compiler prepends an underscore to all C symbols) with a link address of 100 hex and the same load address. _bios_ram 0 400 This symbol has a link address of 0, and a load address of 400 hex. In the context of an 8086 processor this would be interpreted as a segemented address of 40:0 (the load address is a linear address). Psect Limits Within the global symbols will appear some symbols generated by the linker which give information about the limits of psects (program sections, sometimes called segments). Every psect in the program will have at least two symbols defined for it. The names of these symbols are formed by prepending the strings __L and __H to the psect name. The values of these are the low and high bounds of the psect respectively. For example, the psect "text" would have the symbols __Ltext and __Htext defined. These may appear as follows: __Ltext 100 0 __Htext 157 0 This specifies that the text psect starts at 100 hex and has a length of 57 hex bytes. Its load and link addresses are the same. Another example: __Lbss 560 270 __Hbss 840 270 This indicates that the bss psect starts at 560 hex and extends to 83F hex. Note the non-zero second number. This means that the link and load addresses are different. In 8086 real mode the segmented address 27:560 could be used to refer to the base of this bss psect (though numerous other addresses would also refer to the same location). If the link and load addresses for a psect are different, there will also be another symbol defined, formed by prefixing __B to the psect name. This symbol will be given a value equal to the load address of the psect less the base of the psect. In the above example, __Bbss would be set to 270. Local Symbols The end of the global symbol list is flagged by the line %locals All symbols after this line are local symbols, i.e. they are visible only to the module in which they are defined. Symbol lines will generally be the same in form as global symbols, i.e. a name followed by one or two hex numbers. In addition, lines will appear with a file name and no hex numbers, e.g. fred.obj would appear immediately before the symbols defined in the module fred. Within the module fred there will be one or more source files. The names of these source files may also appear, e.g. fred.obj fred.c _fred 0 A0 _bill 140 A0 george.c _george 276 A0 This example indicates that the source file fred.c defined the two symbols _fred and _bill, then included another file george.c which defined the symbol _george. Absolute symbols may also appear in the local symbol area. The order of symbols and modules is preserved. Line Numbers If line numbers are included in the object code, these appear in the same form as described above, but the symbol name is a number, e.g. fred.obj fred.c 10 4 D0 11 8 D0 12 10 D0 defines a module fred.obj, derived from the file fred.c, and with lines 10, 11 and 12 producing code. The addresses are the addresses of the first executable code from that line. A Full Example An example is given here of a small C source file, and the resultant symbol file and link map. The C source is test.c, as follows: #include #include static int fred; main() { fred = 23; putch('x'); return 1; } The resultant symbol file is: _main E01C 0 _exit E019 0 start E000 0 __Hbss 8006 0 __Lbss 8004 0 _getch E06D 0 _kbhit E063 0 _putch E047 0 __Hdata E093 0 __Ldata E093 0 __Htemp 8004 0 __Ltemp 8000 0 __Htext E093 0 _getche E084 0 __Ltext E000 0 __Hstack 8800 0 __Lstack 8800 0 __Hvectors 10000 0 __Lvectors 0 0 _init_uart E031 0 %locals test.c 6 E01C 0 7 E01E 0 8 E024 0 9 E029 0 10 E02E 0 _fred 8004 0 ctemp 8000 0 The link map generated at the same time is: Linker command line: -w80 -z -H -Mmap -ptext=0e000h,data,temp=08000h,bss,stack=08800h \ -o/usr/tmp/eaaa20022 /usr/hitech/lib/crt09.obj \ test.obj \ /usr/hitech/lib/09libc.lib Machine type is 6809 /usr/hitech/lib/crt09.obj vectors 0 0 10000 text E000 E000 1C test.obj text E01C E01C 15 bss 8004 8004 2 temp 8000 8000 4 /usr/hitech/lib/09libc.lib getch.obj text E031 E031 62 temp 8000 8000 4 TOTAL Name Link Load Length vectors 0 0 10000 text E000 E000 93 bss 8004 8004 2 temp 8000 8000 4 SEGMENTS Name Load Length Selector text 00E000 000093 E000 temp 008000 000006 8000 stack 008800 000000 8800 Symbol Table __Hbss bss 08006 __Hdata data 0E093 __Hstack stack 08800 __Htemp temp 08004 __Htext text 0E093 __Hvectors vectors 10000 __Lbss bss 08004 __Ldata data 0E093 __Lstack stack 08800 __Ltemp temp 08000 __Ltext text 0E000 __Lvectors vectors 00000 _exit text 0E019 _getch text 0E06D _getche text 0E084 _init_uart text 0E031 _kbhit text 0E063 _main text 0E01C _putch text 0E047 start text 0E000