next up previous
Next: Extracting Information from Intermediate Up: Two Pass Design of Previous: Two Pass Design of

Resolving References

  The programmers normally code their applications by defining symbols in the program in various sections (.text, .data etc.). The basic purpose that these symbols serve is to associate a name with a location in one of the sections. The programmer can then refer to these locations using symbol names.

In the ELF file, there is a relocation section (.rel.text or .rela.text). This section provides relocation information with respect to the .text section in most of the relocatable object files. When the assembler encounters a symbol, say in the .text section, it creates an entry in the relocation section which associates the occurrence (the offset at which the symbol reference occurred in the relocatable object file and not the location of the actual symbol itself) with the symbol table entry of the symbol. In some cases the assembler may even associate the occurrence with the symbol table entry of the section with respect to which the symbol is defined and include the offset of the symbol as the addend in the reference location. This primarily happens for static variables whose information is not exported at the link time. Both these cases may arise and need to be handled separately.

Now, when some instruction uses a reference which can be a symbol, the disassembler needs to resolve the occurrence of the reference and use the symbol-name. In the best case, the name used could be the same as the original symbol name. While resolving a reference to a location, we normally proceed to determine if there is an entry in the relocation table corresponding to the occurrence, in which case it is enough to resolve whether the entry refers to an object (global data item) or to a section (global-static item). In the former case, the name is available in the symbol table itself. In the later case, we need to generate a name for the symbol, but only after ensuring that no other name has already been generated for that symbol.


next up previous
Next: Extracting Information from Intermediate Up: Two Pass Design of Previous: Two Pass Design of

Nihal chand Jain (9711113)
Fri Jan 15 11:17:08 IST 1999