Hi, everyone,
An urgent problem: 
I just cross compile the OpenSSL 0.9.7 under linux by mipsel-linux-gcc for
MIPS R3000, no error occur during the compiling process.
But, when I put the result lib to the hard platform, the openssl routines
can not be carried out and “segment fault” occurs.
Why? Does the OpenSSL not support the MIPS? 
The program works on X86, such as Linux in Vmware. The program crash on the
first call to transcend. The demo ssl in openssl directory also crash.
How should I do to cross compile for MIPS R3000? Some info The debug info
during the process is :
==============
GNU gdb 6.3
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain
conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "--host=mipsel-linux
--target=mipsel-linux-uclibc".
(gdb) core core.186
Core was generated by `./drmCli'.
Program terminated with signal 11, Segmentation fault.
#0  0x0044cdac in EVP_des_cbc ()
(gdb) where
#0  0x0044cdac in EVP_des_cbc ()
#1  0x00427b4c in SSL_library_init ()
#2  0x00427b4c in SSL_library_init ()
#3  0x00400cd0 in transend (properlistInfo=0x100383f0 "",
    acIP=0x574f50 "192.168.18.155", acPORT=1111) at main.c:93
#4  0x00402a70 in cliskthread () at main.c:770
#5  0x004eac48 in pthread_start_thread ()
#6  0x00527c20 in __thread_start ()
Previous frame inner to this frame (corrupt stack?)
(gdb)
ulimit -c unlimited
mipsel-linux-gdb drmCli
core core.123
where
==================
The transend function is:
void transend(char *properlistInfo,const char* acIP,int acPORT) {
 
/*---------------------------------------------------------------------- */
  //char P[2000];
  struct ProperTable p;
  struct ProperTable *pp;
  pp = &p; 
  
  int err;
  int sd;
  struct sockaddr_in sa;
  SSL_CTX* ctx;
  SSL*     ssl;
  X509*    server_cert;
  char*    str;
  char     buf2 [4096];
  char*    bufp;
  bufp = buf2;
  SSL_METHOD *meth;
         /*-------------------------------------------------*/
         //memset(P,0,sizeof(P));
         //i = propertable_gen(type,userid,pid,data,pp);
         pp = (struct ProperTable *)properlistInfo;          
          printf("transend p.Type=%x\n",(*pp).Type);
   printf("transend p.UserID=%x\n",(*pp).UserID);
   printf("transend p.PID=%x\n",(*pp).PID);
   printf("transend p.Lenth=%d\n",(*pp).Lenth);
   printf("transend p.Data=%s\n",(*pp).Data);
/*----------------------------------------------------------------*/
         SSLeay_add_ssl_algorithms();
  meth = SSLv2_client_method();
  SSL_load_error_strings();
  ctx = SSL_CTX_new (meth);                        CHK_NULL(ctx);
  CHK_SSL(err);
  
  /* ----------------------------------------------- */
  /* Create a socket and connect to server using normal socket calls. */
  
  sd = socket (AF_INET, SOCK_STREAM, 0);       CHK_ERR(sd, "socket");
 
  memset (&sa, '\0', sizeof(sa));
  sa.sin_family      = AF_INET;
 // sa.sin_addr.s_addr = inet_addr ("127.0.0.1");   /* Server IP */
//    sa.sin_addr.s_addr = inet_addr ("10.64.104.168");   /*Server IP */
         sa.sin_addr.s_addr = inet_addr (acIP);
//  sa.sin_port        = htons     (1111);          /* Server Port number */
   sa.sin_port = htons(acPORT);          /* Server Port number */
  
  err = connect(sd, (struct sockaddr*) &sa,sizeof(sa));       CHK_ERR(err,
"connect");

  /* ----------------------------------------------- */
  /* Now we have TCP conncetion. Start SSL negotiation. */
  
  ssl = SSL_new (ctx);                         CHK_NULL(ssl);    
  SSL_set_fd (ssl, sd);
  err = SSL_connect (ssl);                     CHK_SSL(err);
    
  /* Following two steps are optional and not required for
     data exchange to be successful. */
  
  /* Get the cipher - opt */

  printf ("SSL connection using %s\n", SSL_get_cipher (ssl));
  
  /* Get server's certificate (note: beware of dynamic allocation) - opt */

  server_cert = SSL_get_peer_certificate (ssl);       CHK_NULL(server_cert);
  printf ("Server certificate:\n");
  
  str = X509_NAME_oneline (X509_get_subject_name (server_cert),0,0);
  CHK_NULL(str);
  printf ("\t subject: %s\n", str);
  OPENSSL_free (str);

  str = X509_NAME_oneline (X509_get_issuer_name  (server_cert),0,0);
  CHK_NULL(str);
  printf ("\t issuer: %s\n", str);
  OPENSSL_free (str);

  /* We could do all sorts of certificate verification stuff here before
     deallocating the certificate. */

  X509_free (server_cert);
  
  /* --------------------------------------------------- */
  /* DATA EXCHANGE - Send a message and receive a reply. */

  //err = SSL_write (ssl, pp, sizeof(*pp));  CHK_SSL(err);
  //err = SSL_write (ssl, properlistInfo, strlen(properlistInfo));
CHK_SSL(err);
  //print properlistInfo

  err = SSL_write (ssl, properlistInfo, sizeof(struct ProperTable));
CHK_SSL(err);
  err = SSL_read (ssl, buf2, sizeof(buf2) - 1);
CHK_SSL(err);
  buf2[err] = '\0';
  printf ("Got %d chars:'%s'\n", err, buf2);

 
  
  SSL_shutdown (ssl);  /* send SSL/TLS close_notify */

  /* Clean up. */

  close (sd);
  SSL_free (ssl);
  SSL_CTX_free (ctx);
  printf("transend return!\n");
//  return 0;
}
=============
The main.c line 39 is:
transend(protablebuf,"192.168.1.101",1111);
where the protablebuf is a pointer to a struct ProperTable struct
ProperTable
 {            
   u1byte Type;
   u2byte UserID;
   u2byte PID;
   u2byte Lenth;                 
   char Data[1024];
 };
==============
The OpenSSL Cross-Compile Configure process:

Edit the Configure file of OpenSSL source code file package.

Add the following variable to “my %table”:

"linux-mipsel", "mipsel-linux-gcc:-mtune=r3000 -mips2 -DTERMIO -O3
-fomit-frame-pointer
-Wall::-D_REENTRANT::-ldl::${no_asm}:dlfcn:linux-shared:-fPIC::.so.\$(SHLIB_
MAJOR).\$(SHLIB_MINOR)",

Save the Configure file, then execute the following command:

./Configure linux-mipsel no-asm --prefix=/tmp
make
make install

cp -a --reply=yes openssl/ /home/tjy/sunplus/sp1000/mipsel-linux/include/
==================
The CA-Client Makefile as following:

DualModeClient:main.o aes.o aesmode.o scramble.o signal.o decode_pat.o
decode_pmt.o descramble_deecm.o descriptor.o dvbPatpsi.o dvbPmtpsi.o
ecmdistill.o pat.o pmt.o propertable.o psi.o
        mipsel-linux-gcc -Wall -g -L/home/clear_media_files/openssl  main.o
aes.o aesmode.o scramble.o signal.o decode_pat.o decode_pmt.o
descramble_deecm.o descriptor.o dvbPatpsi.o dvbPmtpsi.o ecmdistill.o pat.o
pmt.o propertable.o psi.o  -o DualModeClient -lssl -lcrypto -ldl -lm �C
lpthread -static
main.o:main.c cliframe.h ssl_cli.h signal.h
        mipsel-linux-gcc -Wall -g -c main.c
aes.o:aes.c aes.h
        mipsel-linux-gcc -Wall -g -c aes.c
aesmode.o:aesmode.c aesmode.h aes.h
        mipsel-linux-gcc -Wall -g -c aesmode.c
scramble.o:scramble.c scramble.h
        mipsel-linux-gcc -Wall -g -c scramble.c
signal.o:signal.c  
        mipsel-linux-gcc -Wall -g -c signal.c
decode_pat.o:decode_pat.c config.h dvbpsi.h psi.h pat.h
        mipsel-linux-gcc -Wall -g -c decode_pat.c
decode_pmt.o:decode_pmt.c config.h dvbpsi.h psi.h pat.h
        mipsel-linux-gcc -Wall -g -c decode_pmt.c
descramble_deecm.o:descramble_deecm.c aesmode.h scramble.h client.h
        mipsel-linux-gcc -Wall -g -c descramble_deecm.c
descriptor.o:descriptor.c descriptor.h config.h dvbpsi.h
        mipsel-linux-gcc -Wall -g -c descriptor.c
dvbPatpsi.o:dvbPatpsi.c config.h dvbpsi.h dvbpsi_private.h psi.h
        mipsel-linux-gcc -Wall -g -c dvbPatpsi.c
dvbPmtpsi.o:dvbPmtpsi.c config.h dvbpsi.h dvbpsi_private.h psi.h
        mipsel-linux-gcc -Wall -g -c dvbPmtpsi.c
ecmdistill.o:ecmdistill.c ecmdistill.h
        mipsel-linux-gcc -Wall -g -c ecmdistill.c
pat.o:pat.c config.h dvbpsi.h dvbpsi_private.h psi.h pat.h pat_private.h
        mipsel-linux-gcc -Wall -g -c pat.c
pmt.o:pmt.c config.h dvbpsi.h dvbpsi_private.h psi.h pmt.h pmt_private.h
        mipsel-linux-gcc -Wall -g -c pmt.c
propertable.o:propertable.c propertable.h
        mipsel-linux-gcc -Wall -g -c propertable.c
psi.o:psi.c psi.h config.h dvbpsi.h dvbpsi_private.h
        mipsel-linux-gcc -Wall -g -c psi.c
.PHONY:clean
clean:
        -rm -f DualModeClient *.o *.bak *.ts
=============

Expect for reply!!!, if need other information about the program, please
told me. Thanks.
______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       openssl-dev@openssl.org
Automated List Manager                           [EMAIL PROTECTED]


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       openssl-dev@openssl.org
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to