delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2006/01/24/10:08:43

X-Spam-Check-By: sourceware.org
Message-ID: <43D642EE.8030900@hones.org.uk>
Date: Tue, 24 Jan 2006 15:08:30 +0000
From: Cliff Hones <cliff AT hones DOT org DOT uk>
User-Agent: Mozilla Thunderbird 1.0 (Windows/20041206)
MIME-Version: 1.0
To: cygwin AT cygwin DOT com
Subject: Re: Need information about data and bss segment address access in cygwin
References: <43D0D06C DOT 3010906 AT hones DOT org DOT uk> <SERRANOIv6EybqfAj810000023c AT SERRANO DOT CAM DOT ARTIMI DOT COM> <46ca01fa0601232209i54db2a6dg159b822e025da446 AT mail DOT gmail DOT com> <46ca01fa0601232319h4811acbcxe1df02c65dd4a7b4 AT mail DOT gmail DOT com>
In-Reply-To: <46ca01fa0601232319h4811acbcxe1df02c65dd4a7b4@mail.gmail.com>
X-Spam-Score: -2.5 (--)
X-IsSubscribed: yes
Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sourceware.org/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sourceware.org/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com

[Note  TOP posting is not the preferred way on this group.  I can't be bothered
to reformat it all - so look back on the thread for the full context.]

Sudhahar wrote:
>>Thanks Cliff/Dave. I could not find the code where the dll data/bss
>>segments address are updated in cygwin. But in the fork code we are
>>doing a copy for all linked and loaded dlls data/bss segments by
>>giving the address as
>>for (dll *d = dlls.istart (DLL_LINK); d; d = dlls.inext ())
>>    {
>>      debug_printf ("copying data/bss of a linked dll");
>>      if (!fork_copy (pi, "linked dll data/bss", d->p.data_start, d->p.data_end,
>>                                                 d->p.bss_start, d->p.bss_end,
>>                                                 NULL))
>>        goto cleanup;
>>    }
>>and
>> for (dll *d = dlls.istart (DLL_LOAD); d; d = dlls.inext ())
>>        {
>>          debug_printf ("copying data/bss for a loaded dll");
>>          if (!fork_copy (pi, "loaded dll data/bss", d->p.data_start, d->p.data_end,
>>                                                     d->p.bss_start, d->p.bss_end,
>>                                                     NULL))
>>            goto cleanup;
>>        }
>>
>>And also please let me know if there exist any document which gives
>>some idea about this.

Brian Dessent wrote:
> There is no code to update them.  As the other replies have already
> said, they act like labels and are established by the linker via the
> linker script.  When the program runs, they contain the address, that's
> it.  The values in the per_process struct are filled in by the startup
> code in _cygwin_crt0_common.cc.
>
> The 'ld' manual, section 3.5.3.

Sudahar wrote:
> Brian,
>       From your comments I understand that dll data/bss segment
> address is same as that of process data/bss segment
> address(data_start, data_end, bss_start and bss_end) when the process
> is loaded. Is that right

[I am not 100% confident I'm right her, but...] Each cygwin dll has its own
separate data and bss segments, and the linker generates _data_start__ etc
symbols for the dll when the dll is linked, just as it does for a normal
.exe.  The dll initialisation code, which you will find in
winsup/cygwin/dcrt0.cc, copies the addresses of these symbols into
the dll structures (d->...) which is used during fork as you quoted above.

Hope that helps.

-- Cliff


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


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