[so] mingw

Octavian Purdila so@atlantis.cs.pub.ro
Fri, 28 Nov 2003 07:32:20 +0200


On Thu, 27 Nov 2003 11:27:49 +0200, Ovidiu Platon 
<ovidiupl@microsoft-lab.pub.ro> wrote:

> Teoretic, ai putea sa compilezi cu MinGW, dar sa legi fisierul tau 
> obiect de libc si msvcrt (runtimeul de C din Visual Studio) - n-am idee

Executabilele generate de MinGW nu folosesc libc ci msvcrt. De aia ii si 
zice minimalistic,
pentru ca este portat doar compilatorul.

C:\>type a.c
#include <stdlib.h>


int main()
{
         srand(123); rand();
         return 0;
}


C:\>objdump -p a.exe

a.exe:     file format pei-i386

Characteristics 0x207
         relocations stripped
         executable
         line numbers stripped
         debugging information removed

Time/Date               Fri Nov 28 07:29:29 2003

ImageBase               00400000
SectionAlignment        00001000
FileAlignment           00000200
MajorOSystemVersion     4
MinorOSystemVersion     0
MajorImageVersion       1
MinorImageVersion       0
MajorSubsystemVersion   4
MinorSubsystemVersion   0
Win32Version            00000000
SizeOfImage             00005000
SizeOfHeaders           00000400
CheckSum                0000fc40
Subsystem               00000003        (Windows CUI)
DllCharacteristics      00000000
SizeOfStackReserve      00200000
SizeOfStackCommit       00001000
SizeOfHeapReserve       00100000
SizeOfHeapCommit        00001000
LoaderFlags             00000000
NumberOfRvaAndSizes     00000010

The Data Directory
Entry 0 00000000 00000000 Export Directory [.edata (or where ever we found 
it)]
Entry 1 00004000 0000028c Import Directory [parts of .idata]
Entry 2 00000000 00000000 Resource Directory [.rsrc]
Entry 3 00000000 00000000 Exception Directory [.pdata]
Entry 4 00000000 00000000 Security Directory
Entry 5 00000000 00000000 Base Relocation Directory [.reloc]
Entry 6 00000000 00000000 Debug Directory
Entry 7 00000000 00000000 Description Directory
Entry 8 00000000 00000000 Special Directory
Entry 9 00000000 00000000 Thread Storage Directory [.tls]
Entry a 00000000 00000000 Load Configuration Directory
Entry b 00000000 00000000 Bound Import Directory
Entry c 00000000 00000000 Import Address Table Directory
Entry d 00000000 00000000 Delay Import Directory
Entry e 00000000 00000000 Reserved
Entry f 00000000 00000000 Reserved

There is an import table in .idata at 0x404000

The Import Tables (interpreted .idata section contents)
  vma:            Hint    Time      Forward  DLL       First
                  Table   Stamp     Chain    Name      Thunk
  00004000       00004040 00000000 00000000 00004230 000040a4

         DLL Name: KERNEL32.dll
         vma:  Hint/Ord Member-Name Bound-To
         4104        0  AddAtomA
         4110      131  ExitProcess
         4120      148  FindAtomA
         412c      193  GetAtomNameA
         413c      660  SetUnhandledExceptionFilter

  00004014       0000405c 00000000 00000000 00004280 000040c0

         DLL Name: msvcrt.dll
vma:  Hint/Ord Member-Name Bound-To
         415c       39  __getmainargs
         416c       59  __p__environ
         417c       61  __p__fmode
         418c       78  __set_app_type
         41a0      118  _cexit
         41ac      169  _fileno
         41b8      222  _iob
         41c0      336  _onexit
         41cc      373  _setmode
         41d8      510  abort
         41e0      517  atexit
         41ec      552  free
         41f4      603  malloc
         4200      624  rand
         4208      633  signal
         4214      638  srand

  00004028       00000000 00000000 00000000 00000000 00000000



tavi