Subject: Re: cooperation of cygwin and NuTCracker ??
From: "Frank Moehle" <[email-masked]>
To: Earnie Boyd <[email-masked]>, Heribert Dahms <[email-masked]>
Cc: [email-masked]
Date: Thu, 12 Oct 2000 13:21:43 +0200

Earnie Boyd wrote:
> 
> I don't know NuTCracker but I do see a problem.
> > LIBRARIES = -l<our own stuff.a> -lm
> >
> 
> The problem is that you've use -lm.  Currently the libm.a is a symbolic link to
> libcygwin.a and ld can't manage the same library with different names.  Remove
> the -lm and see if that helps.

I removed the -lm line, but i still get the crash from the DLL that uses
NuTCracker.

Heribert Dahms wrote:
> maybe you could create a separate, small executable using
> NuTCracker which does interprocess communication to a
> cygwin executable via sockets or files?

Sorry Heribert, I do not have access to the NuTCracker development tools.
Anyway, using IPC by socket or file communication is not involved into my
problem. There are not even different processes, just dynamic libraries.

The point is that we have this DLL which from an _external_ product
that needs/uses the NuTCracker enviroment. We need to do direct functions calls 
into this DLL from a console application that is build using cygwin,
and we need return values.

To those of you who never heard about this "NuTCracker" thing:
NuTCracker is "another" unix porting enviroment similar to cygwin.
But it is also possible to port X11 application with NuTCracker,
and it's also more expensive :-(

Back to my problem:
Now i have to sides, which both have different POSIX implementations.

My hope is that these implementations do not interfere with each other,
something like this

   our code +            |      anaport.dll (external)
     cygwin1.dll   [DLL border]     +
(printf, malloc, etc)    |      NutCracker libc

In fact, i do not even know if such a "DLL borderline" exists on NT.
Is there some mechanism that allows a library to only export
certain functions, and use some other external stuff privately only?

Using "objdump -p" on the external DLL, i get a huge number of lines,
starting with the one quoted below (second dump).
What i understand is that the DLL needs a lot of "standard"
function like printf, malloc, etc from another DLL called "nutlibc4.dll".
Does this interfere with the function from cygwin1.dll, which our program is 
compiled against ??

btw, we are using cygwin 1.1.4

Thanks for any hints,

	Frank.

------------------------------------------------------------------------
$ objdump -p our_program.exe

our_program.exe:     file format pei-i386

Characteristics 0x7
	relocations stripped
	executable
	line numbers stripped

Time/Date		Wed Oct 11 15:39:50 2000

ImageBase		00400000
SectionAlignment	00001000
FileAlignment		00000200
MajorOSystemVersion	4
MinorOSystemVersion	0
MajorImageVersion	1
MinorImageVersion	0
MajorSubsystemVersion	4
MinorSubsystemVersion	0
Win32Version		00000000
SizeOfImage		0008d000
SizeOfHeaders		00000400
CheckSum		00000000
Subsystem		00000003	(Windows CUI)
DllCharacteristics	00000000
SizeOfStackReserve	02000000
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 00032000 000008b4 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 0x432000

The Import Tables (interpreted .idata section contents)
 vma:            Hint    Time      Forward  DLL       First
                 Table   Stamp     Chain    Name      Thunk
 00032000	00032054 00000000 00000000 00032824 000321a0

	DLL Name: cygwin1.dll
	vma:  Hint/Ord Member-Name
	322e8	    0  __assert
	322f4	    6  __errno
	32300	   24  __main
	3230c	   92  _ctype_
	32318	  531  atoi
	32320	  540  calloc
	3232c	  556  close
	32334	  568  ctime
	3233c	  594  cygwin_internal
	32350	  611  dll_crt0__FP11per_process
	3236c	  638  exit
	32374	  648  fclose
	32380	  656  fflush
	3238c	  660  fgets
	32394	  661  fileno
	323a0	  669  fopen
	323a8	  672  fprintf
	323b4	  675  fread
	323bc	  676  free
	323c4	  680  fscanf
	323d0	  681  fseek
	323d8	  689  fwrite
	323e4	  695  getc
	323ec	  701  getenv
	323f8	  710  gethostname
	32408	  735  getuid
	32414	  765  isatty
	32420	  812  malloc
	3242c	  820  memcpy
	32438	  823  mkdir
	32440	  842  open
	32448	  852  pow
	32450	  854  printf
	3245c	  884  qsort
	32464	  893  realloc
	32470	  993  sprintf
	3247c	  998  sscanf
	32488	 1002  strcat
	32494	 1003  strchr
	324a0	 1004  strcmp
	324ac	 1006  strcpy
	324b8	 1008  strdup
	324c4	 1011  strlen
	324d0	 1015  strncmp
	324dc	 1016  strncpy
	324e8	 1018  strrchr
	324f4	 1022  strstr
	32500	 1025  strtok
	3250c	 1036  system
	32518	 1051  time
	32520	 1089  write
	The Import Address Table is identical

 00032014	00032128 00000000 00000000 00032834 00032274

	DLL Name: KERNEL32.dll
	vma:  Hint/Ord Member-Name
	32528	  290  GetModuleHandleA
	The Import Address Table is identical

 00032028	00032134 00000000 00000000 000328a8 00032280

	DLL Name: anaport.dll
	vma:  Hint/Ord Member-Name
	3253c	    0  stmm_close_session
	32554	    1  stmm_get_ac
	32564	    2  stmm_get_activity_parameters
	32584	    5  stmm_get_ch
	32594	    6  stmm_get_cm
	325a4	    7  stmm_get_cn
	325b4	    8  stmm_get_co
	325c4	    9  stmm_get_di
	325d4	   10  stmm_get_el
	325e4	   12  stmm_get_ev
	325f4	   14  stmm_get_id_type
	32608	   17  stmm_get_module_info
	32620	   20  stmm_get_scope_modules
	3263c	   21  stmm_get_st
	3264c	   22  stmm_get_used_affected
	32668	   24  stmm_list_add_element
	32680	   26  stmm_list_create
	32694	   30  stmm_list_first_element
	326b0	   31  stmm_list_get_elm_value
	326cc	   32  stmm_list_get_ith_element
	326e8	   34  stmm_list_length
	326fc	   35  stmm_list_next_element
	32718	   38  stmm_open_session
	3272c	   42  stmm_rpn_to_string
	32744	   43  stmm_which_chart
	The Import Address Table is identical

 0003203c	00000000 00000000 00000000 00000000 00000000

------------------------------------------------------------------------

(sorry for this long quote, i do not know with part ist important)
-------------------------------------------------------------------------
$ objdump -p /cygdrive/c/stmm/misc/ANAPORT/anaport.dll

/cygdrive/c/stmm/misc/ANAPORT/anaport.dll:     file format pei-i386

Characteristics 0x2102
	executable
	32 bit words
	DLL

Time/Date		Wed Dec 22 15:45:43 1999

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

The Data Directory
Entry 0 00568af0 00000510 Export Directory [.edata (or where ever we found it)]
Entry 1 006d7000 00000078 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 006d8000 0003714c Base Relocation Directory [.reloc]
Entry 6 00559000 00000070 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 006d73a0 00000328 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 0x106d7000

The Import Tables (interpreted .idata section contents)
 vma:            Hint    Time      Forward  DLL       First
                 Table   Stamp     Chain    Name      Thunk
 006d7000	006d7394 00000000 00000000 006d76e6 006d76bc

	DLL Name: utillibstm_dll.dll
	vma:  Hint/Ord Member-Name
	6d76da	    2  NT_mkdir
	6d76c8	    0  NT_create_file
	The Import Address Table is identical

 006d7014	006d7078 00000000 00000000 006d76fa 006d73a0

	DLL Name: LMGR326B.dll
	vma:  Hint/Ord Member-Name
	80000039	   57
	80000021	   33
	8000002b	   43
	80000031	   49
	8000002c	   44
	80000022	   34
	80000034	   52
	8000003d	   61
	80000027	   39
	8000003b	   59
	80000041	   65
	The Import Address Table is identical

 006d7028	006d70a8 00000000 00000000 006d7d06 006d73d0

	DLL Name: nutlibc4.dll
	vma:  Hint/Ord Member-Name
	6d7a8e	  293  getuid
	6d7ad6	  559  sigaddset
	6d7ae2	  562  sigemptyset
	6d7708	   63  ___NutEnableFinish
	6d771e	   62  ___NutEnableExceptionFilter
	6d773c	  114  _except_handler3
	6d7750	  414  printf
	6d775a	  265  getenv
	6d7764	  488  putenv
	6d776e	   51  _NutWIN32getenv
	6d7780	  596  strcpy
	6d778a	  601  strlen
	6d7794	  593  strchr
	6d779e	  592  strcat
	6d77a8	  154  chdir
	6d77b0	  582  sprintf
	6d77ba	  227  fprintf
	6d77c4	  118  _iob
	6d77cc	  236  fscanf
	6d77d6	  116  _ftol
	6d77de	  136  atoi
	6d77e6	  594  strcmp
	6d77f0	  371  memcpy
	6d77fa	  609  strrchr
	6d7804	  262  getcwd
	6d780e	   84  ___NutSysErrList
	6d7822	   67  ___NutErrno
	6d7830	  375  mkdir
	6d7838	  587  sscanf
	6d7842	  283  getppid
	6d784c	  606  strncpy
	6d7856	  516  rindex
	6d7860	  206  fclose
	6d786a	  379  mktemp
	6d7874	  307  index
	6d787c	  224  fopen
	6d7884	  665  unlink
	6d788e	  212  fflush
	6d7898	  139  bcopy
	6d78a0	  297  getwd
	6d78a8	  103  __p__pctype
	6d78b6	  605  strncmp
	6d78c0	  218  fgets
	6d78c8	  588  stat
	6d78d0	  513  rewind
	6d78da	  214  fgetc
	6d78e2	  612  strstr
	6d78ec	  641  tempnam
	6d78f6	  607  strpbrk
	6d7900	  580  sleep
	6d7908	   38  _NutPathToWin32
	6d791a	  135  atof
	6d7922	  649  toupper
	6d792c	  648  tolower
	6d7936	  611  strspn
	6d7940	  133  asctime
	6d794a	  351  localtime
	6d7956	  230  fputs
	6d795e	  614  strtok
	6d7968	  628  system
	6d7972	  202  exit
	6d797a	  155  chmod
	6d7982	  359  malloc
	6d798c	  144  calloc
	6d7996	    4  ??2@YAPAXI@Z
	6d79a6	    5  ??3@YAXPAX@Z
	6d79b6	  120  _purecall
	6d79c2	  234  free
	6d79ca	  505  realloc
	6d79d4	  320  islower
	6d79de	  143  bzero
	6d79e6	  129  abs
	6d79ec	  493  qsort
	6d79f4	  313  isalpha
	6d79fe	  128  abort
	6d7a06	  643  time
	6d7a0e	  161  closedir
	6d7a1a	  501  readdir
	6d7a24	  404  opendir
	6d7a2e	  517  rmdir
	6d7a36	  243  ftell
	6d7a3e	   99  __getc
	6d7a48	  237  fseek
	6d7a50	  141  bsearch
	6d7a5a	  616  strtol
	6d7a64	  570  signal
	6d7a6e	  104  __putc
	6d7a78	  287  getpwuid
	6d7a84	  266  geteuid
	6d7c96	  366  mbtowc
	6d7a98	  282  getpid
	6d7aa2	  255  fwrite
	6d7aac	  723  write
	6d7ab4	   39  _NutPathToWin32FS
	6d7ac8	  591  strcasecmp
	6d7cc0	  360  mblen
	6d7cc8	  540  setlocale
	6d7af0	  573  sigprocmask
	6d7afe	  686  waitpid
	6d7b08	  354  longjmp
	6d7b12	  597  strcspn
	6d7b1c	  310  ioctl
	6d7b24	  675  vfprintf
	6d7b30	  158  clearerr
	6d7b3c	  229  fputc
	6d7b44	  233  fread
	6d7b4c	  403  open
	6d7b54	  164  creat
	6d7b5c	  160  close
	6d7b64	  500  read
	6d7b6c	  285  getpwnam
	6d7b78	  512  rename
	6d7b82	  670  utime
	6d7b8a	  138  bcmp
	6d7b92	  272  getgroups
	6d7b9e	  408  pause
	6d7ba6	  561  sigdelset
	6d7bb2	   29  _NutForkExeclp
	6d7bc4	  341  kill
	6d7bcc	  115  _exit
	6d7bd4	  131  alarm
	6d7bdc	  225  fork
	6d7be4	  589  statfs
	6d7bee	  166  ctime
	6d7bf6	  292  gettimeofday
	6d7c06	   85  ___NutSysNErr
	6d7c16	  123  _setjmp3
	6d7c22	  527  select
	6d7c2c	  315  isatty
	6d7c36	  413  popen
	6d7c3e	  409  pclose
	6d7c48	  365  mbstowcs
	6d7c54	  372  memmove
	6d7c5e	  373  memset
	6d7c68	  504  readv
	6d7c70	  724  writev
	6d7c7a	  207  fcntl
	6d7c82	  130  access
	6d7c8c	  713  wctomb
	6d7d40	   59  ___NutAtExitStaticCDone
	6d7ca0	  709  wcstombs
	6d7cac	  102  __p___mb_cur_max
	6d7f6c	  357  lseek
	6d7f64	  242  fsync
	6d7cd4	  370  memcmp
	6d7cde	  509  regfree
	6d7ce8	  508  regexec
	6d7cf2	  506  regcomp
	6d7cfc	  663  ungetc
	6d7d14	   64  ___NutEnablePrep1
	6d7d28	   57  ___NutAtExitRegister
	6d7d5a	   70  ___NutInitTerm
	6d7d6c	   56  ___NutAtExitInitBlock
	6d7d84	   71  ___NutIsForkedChild
	6d7d9a	   73  ___NutMarkDllMain
	6d7dae	   78  ___NutPrepareOptionBlock
	6d7dca	   93  ___NutValidateDllLoadAddress
	6d7dea	   82  ___NutRegisterModule
	6d7e02	   58  ___NutAtExitRunBlock
	6d7e1a	   92  ___NutUnregisterModule
	6d7e34	   79  ___NutProcDetachValidate
	6d7e50	   23  _NutDisableThreadLibraryCalls
	The Import Address Table is identical

 006d703c	006d7334 00000000 00000000 006d7ec2 006d765c

	DLL Name: nutlibm4.dll
	vma:  Hint/Ord Member-Name
	6d7e70	   52  fabs
	6d7ea0	   42  cos
	6d7e78	   93  sqrt
	6d7e80	   30  atan
	6d7e88	   17  ___NutHUGE_VAL
	6d7e9a	   89  sin
	6d7ea6	   95  tan
	6d7eac	   22  acos
	6d7eb4	   72  log10
	6d7ebc	   81  pow
	The Import Address Table is identical

 006d7050	006d7360 00000000 00000000 006d7f56 006d7688

	DLL Name: nutsock4.dll
	vma:  Hint/Ord Member-Name
	6d7eec	   55  socket
	6d7ed0	   11  gethostname
	6d7ede	   53  setsockopt
	6d7f42	   27  htons
	6d7ef6	    3  connect
	6d7f00	    9  gethostbyname
	6d7f10	   19  getservbyname
	6d7f20	   16  getprotobyname
	6d7f32	    8  gethostbyaddr
	6d7f4a	   28  inet_addr
	6d7f74	   41  ntohl
	6d7f7c	   42  ntohs
	The Import Address Table is identical

 006d7064	00000000 00000000 00000000 00000000 00000000

There is an export table in .rdata at 0x10568af0

The Export Tables (interpreted .rdata section contents)

Export Flags 			0
Time/Date stamp 		3860f227
Major/Minor 			0/0
Name 				00568cda anaport.dll
Ordinal Base 			1
Number in:
	Export Address Table 		0000002d
	[Name Pointer/Ordinal] Table	0000002d
Table Addresses
	Export Address Table 		00568b18
	Name Pointer Table 		00568bcc
	Ordinal Table 			00568c80

Export Address Table -- Ordinal Base 1
	[   0] +base[   1] 2bbd Export RVA
	[   1] +base[   2] 2b10 Export RVA
	[   2] +base[   3] 12c0 Export RVA
	[   3] +base[   4] 1772 Export RVA
.... 
..[MegaLines like the above one]..
....

---------------------------------------------------------

-- 
=======================================================================
         Frank Moehle                              | Understanding is a
Work   : Uni Oldenburg,Computer Architecture Group | three-edged sword.
Inhouse: frankm@haydn                              | (Vorlon saying)
DOMAIN : [email-masked]  +-------------------
-----------------------------------------------------------------------
****            Its how you DO it, not how you don't.              ****

--
Want to unsubscribe from this list?
Send a message to [email-masked]