How to debug without having debug section in an executable ?

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

How to debug without having debug section in an executable ?

ashwani raina
Hi

    I am facing a problem  as explained below :

1. My project is to convert PE (user created dynamic link libraries on
windows) to ELF (shared object on linux ). When i convert a Dll
providing some functionalities like some file operations . But when an
application (executable not a shared object or library) converted from
PE to ELF, having usage of symbols in it but defined in shared object
which i have created and converted,  is executed it doesnot find the
symbol .

2. I also checked for the DT_NEEDED field of the application it
includes my library but still i dont know whether library is loaded .
After that i tried to debug in an indirect way because i dont have
considered DEBUG section . I found that library is loaded but linker
is unable to load section table from the library.


1.    I think this is the problem but i want to know the solution .Please help!
2.   If u think there is something wrong other than this please let me know !
3.   How can i debug the executable without having DEBUG section in
the finally mapped
     ELF format?
4.   When the segmentation fault comes , using core dump  i get the
address art which the
     fault occurs i.e.,  0x0073c224 but this address goes beyond the
virtual address of the
     executable . So which instruction to debug i dont know ?



--
regards
ashwani
---
It is by logic that we prove but by intuition that we discover.......
Reply | Threaded
Open this post in threaded view
|

Re: How to debug without having debug section in an executable ?

Ian Lance Taylor
ashwani raina <[hidden email]> writes:

> 1. My project is to convert PE (user created dynamic link libraries on
> windows) to ELF (shared object on linux ). When i convert a Dll
> providing some functionalities like some file operations . But when an
> application (executable not a shared object or library) converted from
> PE to ELF, having usage of symbols in it but defined in shared object
> which i have created and converted,  is executed it doesnot find the
> symbol .

I'm not completely sure, but it is probably possible to convert a DLL
from PE to ELF for the x86 architecture.  But you will have to
completely rewrite the DLL.  You will have to extract the import and
export tables and convert them to the ELF dynamic symbol table, in the
.dynsym and .dynstr sections.  You will have to translate the
relocation tables.  You will have to build the ELF dynamic symbol hash
table, and you will have to build the ELF dynamic information
(DT_NEEDED, etc.).  You will have to use the imported symbols to build
an ELF procedure linkage table and a global offset table.

For this project you are going to have to have a complete
understanding of what both a PE DLL and an ELF shared library look
like.  It's not a simple task.

BFD isn't going to help you very much with this job.

I don't know the answer to your specific questions.  It could be any
number of different things.

Good luck.

Ian
Reply | Threaded
Open this post in threaded view
|

RE: How to debug without having debug section in an executable ?

Dave Korn
On 03 February 2006 04:35, Ian Lance Taylor wrote:

> ashwani raina <[hidden email]> writes:
>
>> 1. My project is to convert PE (user created dynamic link libraries on
>> windows) to ELF (shared object on linux ). When i convert a Dll
>> providing some functionalities like some file operations . But when an
>> application (executable not a shared object or library) converted from
>> PE to ELF, having usage of symbols in it but defined in shared object
>> which i have created and converted,  is executed it doesnot find the
>> symbol .
>
> I'm not completely sure, but it is probably possible to convert a DLL
> from PE to ELF for the x86 architecture.  But you will have to completely
> rewrite the DLL.  You will have to extract the import and export tables
> and convert them to the ELF dynamic symbol table, in the .dynsym and
> .dynstr sections.  You will have to translate the relocation tables.  You
> will have to build the ELF dynamic symbol hash table, and you will have
> to build the ELF dynamic information (DT_NEEDED, etc.).  You will have to
> use the imported symbols to build an ELF procedure linkage table and a
> global offset table.        


  The really difficult bit is going to be converting all the windows API calls in the .code section into linux syscalls that do the
equivalent file operations, isn't it?


    cheers,
      DaveK
--
Can't think of a witty .sigline today....

Reply | Threaded
Open this post in threaded view
|

Re: How to debug without having debug section in an executable ?

Bernd Jendrissek
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Fri, Feb 03, 2006 at 01:24:36PM -0000, Dave Korn wrote:
> The really difficult bit is going to be converting all the windows API
> calls in the .code section into linux syscalls that do the equivalent
> file operations, isn't it?

- --dynamic-linker=/usr/lib/wine/ld-wine.so -L /usr/lib/wine -lmsvcrt etc.?

(Not that I've checked if ld-wine.so or whatever actually exists but it
could, no?)

- --
Q: Why does this scheme have so many keys?
A: We added them as the need arose.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2 (GNU/Linux)
Comment: Please fetch my new key 804177F8 from hkp://wwwkeys.eu.pgp.net/

iD8DBQFD43ZCwyMv24BBd/gRAqloAKCCNSn+/mRN9ZX/RJ3vdnon4OlQigCgoapV
Cr2rXDCPCtm9SbOu0WFw9bk=
=2nR7
-----END PGP SIGNATURE-----