This is the mail archive of the binutils@sourceware.cygnus.com mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

using relocs in disassembler



   Hello again.  Been a while since I last posted.  I've converted objdump
and the i386 disassembler to return scheme values, but ignoring relocs
(both static and dynamic).  Now that I've got that part  basically
working, I'd like to try and incorporate the relocation information, since
I'm using this for writing a decompiler which I want to use on shared
libraries (besides a lot of code being in shared libraries, they have the
extra advantage of retaining a lot of symbol information).
    The way I plan on doing this is to change the disassembler to check
for the presence of relocs affecting an operand of the current
instruction.  Now that I'm familiar with the guts of the i386
disassembler, I don't think this will be too difficult.  Anyway, I think I
have a grip on how to deal with static relocs, but not with dynamic
relocs.  First let me see if my assumption about static relocs can be
verified: a reloc affects at most one immediate operand of an
instruction.  Thus I don't need to worry about the size of a reloc, I can
just let the disassembler get the operand as normal, and then just ignore
it (except for the size).  
   Now, I guess my question also applies to some static relocs: when a
reloc appears in data, how can I tell how much data is taken up by the
reloc, and exactly what I should replace it with.  I'm guessing, if it's
data, the data would become a pointer to the symbol (or the value of the
symbol).  
   Anyway, dynamic relocs aren't very well documented in the bfd manual
(at least the last version I got).  Nor are the various types of relocs
(e.g BFD_RELOC_386_JUMP_SLOT).
   Detecting dynamic relocs in data will be done in objdump.c code, so I
can probably bring that back to binutils' objdump.c.  Do dynamic relocs
appear as in code, or just data?

Lynn




Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]