C Objects and Finding Unresolved Symbols
22 Dec
Posted by admin
in c programming
One of the issues when cross-compiling is time. As a developer I find that it really sucks after you waited for a program to compile, installed it and executed it to only find out.. its broken.
Before transfering it and installing it, there are two easy ways to see if there are undefined symbols: nm and readelf.
nm produces something like the following:
- 000002dc T DNP3ObjInit
- U DynamicPreprocessorFatalMessage
- U __ctype_b
- U _dpd
- U calloc
- U strcmp
- U strtok_r
- dnp3_map.o:
- 00000000 t $a
- 00000058 t $a
- 000000a8 t $a
- 00000054 t $d
- 000000a4 t $d
- 000000f4 t $d
- 00000000 r $d
- 00000000 T DNP3FuncIsDefined
- 000000a8 T DNP3FuncStrToCode
- 00000058 T DNP3IndStrToCode
- 00000080 r func_map
- 00000000 r indication_map
- U strcmp
readelf -s YourObject produces something like the following:
- ymbol table '.dynsym' contains 43 entries:
- Num: Value Size Type Bind Vis Ndx Name
- 0: 00000000 0 NOTYPE LOCAL DEFAULT UND
- 1: 00000da8 0 SECTION LOCAL DEFAULT 8
- 2: 00000e94 0 SECTION LOCAL DEFAULT 10
- 3: 00003570 0 SECTION LOCAL DEFAULT 11
- 4: 00003588 0 SECTION LOCAL DEFAULT 12
- 5: 0000460c 0 SECTION LOCAL DEFAULT 13
- 6: 0000c610 0 SECTION LOCAL DEFAULT 14
- 7: 0000c618 0 SECTION LOCAL DEFAULT 15
- 8: 0000c620 0 SECTION LOCAL DEFAULT 16
- 9: 0000c750 0 SECTION LOCAL DEFAULT 19
- 10: 0000c768 0 SECTION LOCAL DEFAULT 20
- 11: 00000000 0 NOTYPE GLOBAL DEFAULT UND _dpd
- 12: 00000000 116 FUNC GLOBAL DEFAULT UND strtok_r
- 13: 00000000 0 NOTYPE GLOBAL DEFAULT UND DynamicPreprocessorFatalM
- 14: 00000000 4 OBJECT GLOBAL DEFAULT UND __ctype_b
Comments
Post new comment