using libbfd for reading procedure information and hidden data in the text segment
Kugan Vivekanandarajah
kuganv@gmail.com
Tue Jul 5 09:06:00 GMT 2005
Thanks ravi for the information.
> > 1. By reading the symbol information can I tell whether it is a
> > function or not.
>
> In ELF (at least) - yes.
yes, i am using it with ELF format binaries.
what i am doing now is as follows:
for all the symols in the symbol table i check the followng. If all
are satisfide i assume it to be a procedure symbol. Is that right ALL
THE TIME.
addr_t pc = bfd_asymbol_value (symbol);
if (!(bfd_get_section_flags (bfd, bfd_get_section (symbol)) & SEC_CODE)) {
// Not in a text section, so not a procedure.
//
return 0;
}
else if (!((_text_start <= pc && pc < _text_end))) {
// Out of text segment, so not a procedure.
//
return 0;
}
else if (symbol->flags & BSF_DEBUGGING) {
// Debugging record is not a procedure.
//
return 0;
}
else if (bfd_asymbol_value (symbol) % 4 != 0) {
// Data blocks sometimes are not word aligned
//
return 0;
}
In addition, i have also came to know that for some local procedures,
symbol table does not maintain symbol informations. Thus can not be
identfied. Is there any way i can identify them.
Thanks,
--
Kugan Vivekanandarajah
Graduate Student
www.ntu.edu.sg/home5/pm2096207
Mobile: +65 90014504
More information about the Binutils
mailing list