This is the mail archive of the
binutils@sources.redhat.com
mailing list for the binutils project.
RE: using libbfd for reading procedure information and hidden data in the text segment
- From: Kugan Vivekanandarajah <kuganv at gmail dot com>
- To: binutils at sources dot redhat dot com
- Date: Tue, 5 Jul 2005 17:06:30 +0800
- Subject: RE: using libbfd for reading procedure information and hidden data in the text segment
- References: <4217037d05070423044d787a85@mail.gmail.com> <22080b0a05070500583ad1e38f@mail.gmail.com> <4217037d050705015572f450ea@mail.gmail.com>
- Reply-to: Kugan Vivekanandarajah <kuganv at gmail dot com>
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