delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2013/06/11/05:15:16

X-Authentication-Warning: delorie.com: mail set sender to djgpp-bounces using -f
X-Received: by 10.224.86.200 with SMTP id t8mr9159884qal.0.1370940621525;
Tue, 11 Jun 2013 01:50:21 -0700 (PDT)
X-Received: by 10.49.0.81 with SMTP id 17mr679166qec.16.1370940621509; Tue, 11
Jun 2013 01:50:21 -0700 (PDT)
Newsgroups: comp.os.msdos.djgpp
Date: Tue, 11 Jun 2013 01:50:21 -0700 (PDT)
Complaints-To: groups-abuse AT google DOT com
Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=95.27.195.43; posting-account=nu_e-AoAAACYQOcAKQ31NWF_OGDHFEO_
NNTP-Posting-Host: 95.27.195.43
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f941b346-d6ba-4d9e-b5c4-ef8dc898e433@googlegroups.com>
Subject: Incorrect compilation
From: Vasya Pupkin <tamarafedotova01 AT gmail DOT com>
Injection-Date: Tue, 11 Jun 2013 08:50:21 +0000
Bytes: 6151
Lines: 138
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
X-MIME-Autoconverted: from quoted-printable to 8bit by delorie.com id r5B9F1AW006139
Reply-To: djgpp AT delorie DOT com

I am trying to compile Watt-32 for DJGPP 2.04.
Source code was downloaded from: http://home.broadpark.no/~gvanem/
Compilation was made according to the instruction in the "install" file.
And in the end, I have a strange problem.
Library Watt-32 contains file "pcpkt.c".
This file contains function "pkt_release".
There is it's source code:

/**
 * Release the pkt-driver.
 *
 * Might be called from exception/signal handler.
 * To make sure the driver is released, use a destructor in addition
 * to rundown function and sock_exit(). This will be called even if
 * _exit() is called.
 */
#ifdef __WATCOMC__
#pragma aux pkt_release loadds;
#endif

#ifdef __GNUC__
#define DTOR __attribute__((destructor))
#else
#define DTOR
#endif

int DTOR pkt_release (void)
{
  DISABLE();

  if (_pkt_inf)
  {
    /* Don't do this by default. It may cause some (RealTek)
     * packet-drivers to fail all further upcalls.
     */
    if (pkt_do_reset)
       pkt_reset_handle (_pkt_inf->handle);
    pkt_release_handle (_pkt_inf->handle);
  }

/* !! pkt_interrupt = 0; */

  /**
   * \todo We might be called between 1st and 2nd packet-driver
   *       upcall. Need to wait for 2nd upcall to finish or else
   *       freeing the RMCB too early could cause a crash or a
   *       stuck PKTDRVR.
   */

#if (DOSX) && !defined(USE_FAST_PKT)
  unlock_code_and_data(); /* unlock before freeing */
  release_callback();
#endif

#if (DOSX) && defined(USE_FAST_PKT)
  release_real_mem();
#endif

  if (_pkt_inf && !_watt_fatal_error)
     free (_pkt_inf);

  _pkt_inf = NULL;  /* drop anything still in the queue */

  ENABLE();
  return (1);
}

Macroses DISABLE() and ENABLE() are defined as

    #define ENABLE()      __asm__ __volatile__ ("sti")
    #define DISABLE()     __asm__ __volatile__ ("cli")

Compilation command:
gcc -O2 -g -gcoff -I. -I../inc -W -Wall -fno-strength-reduce -ffast-math  -o djgpp/pcpkt.o -c pcpkt.c

After compiling in the object file "pcpkt.o" in place of this procedure is a completely meaningless code.
Here is the result of disassembling this procedure after compilation (made by IDA):


.text:00000D15                ; _______________ S U B R O U T I N E _______________________________________
.text:00000D15
.text:00000D15
.text:00000D15                                public _pkt_release
.text:00000D15                _pkt_release    proc near               ; CODE XREF: _pkt_eth_init+691p
.text:00000D15                                                        ; _pkt_eth_init+8E9p
.text:00000D15                                                        ; DATA XREF: ...
.text:00000D15 70 6B                          jo      short near ptr loc_0_D7E+4
.text:00000D17 74 5F                          jz      short near ptr loc_0_D77+1
.text:00000D19 73 65                          jnb     short near ptr loc_0_D7E+2
.text:00000D1B 6E                             outsb
.text:00000D1C 64 00 74 78 20                 add     fs:[eax+edi*2+20h], dh
.text:00000D21 3D 3D 20 70 6B                 cmp     eax, 6B70203Dh
.text:00000D26 74 5F                          jz      short loc_0_D87
.text:00000D28 74 78                          jz      short near ptr loc_0_DA1+1
.text:00000D2A 5F                             pop     edi
.text:00000D2B 62 75 66                       bound   esi, [ebp+66h]
.text:00000D2E 28 29                          sub     [ecx], ch
.text:00000D30 00 8D 76 00 41+                add     [ebp+73410076h], cl
.text:00000D36 79 6E                          jns     short loc_0_DA6
.text:00000D38 63 20                          arpl    [eax], sp
.text:00000D3A 54                             push    esp
.text:00000D3B 78 20                          js      short loc_0_D5D
.text:00000D3D 66 61                          popaw
.text:00000D3F 69 6C 65 64 2E+                imul    ebp, [ebp+64h], 6552202Eh
.text:00000D47 74 72                          jz      short loc_0_DBB
.text:00000D49 79 69                          jns     short near ptr loc_0_DB3+1
.text:00000D4B 6E                             outsb
.text:00000D4C 67 20 69 6E                    and     [bx+di+6Eh], ch
.text:00000D50 20 73 79                       and     [ebx+79h], dh
.text:00000D53 6E                             outsb
.text:00000D54 63 20                          arpl    [eax], sp
.text:00000D56 6D                             ins     dword ptr es:[edi], dx
.text:00000D57 6F                             outsd
.text:00000D58                                db      64h, 65h
.text:00000D58 64 65 2E 0A 00                 or      al, cs:[eax]
.text:00000D5D
.text:00000D5D                loc_0_D5D:                              ; CODE XREF: _pkt_release+26j
.text:00000D5D 8D 76 00                       lea     esi, [esi+0]
.text:00000D5D                _pkt_release    endp

Can someone explain the reason of this phenomenon and specify ways of its elimination?


- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019