Subject: reinitialization of global varriables in .sbss section across calls on MIPS
To: None <tech-userlevel@netbsd.org, netbsd-users@netbsd.org,>
From: sushant mathur <sushant.iet@gmail.com>
List: netbsd-bugs
Date: 06/17/2006 17:55:23
------=_Part_97276_12279103.1150547123427
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Hi,

i am facing one problem On MIPS-netbsd regarding reinitialization of sbss
section

If in one shared library you have some global varriables and if they are
part of .sbss section
Then when any function is called in that shared library from main program
and if it update those varriables then this updated should be refelected to
the subsequent calls to any function in that shared library

But I am facing one problem if i declared some global varriables and in
first call to that function I assign those varriables some value ,but when i
come back from that shared library to main and then later if i call some
another functions from that library then the pointers are getting
reinitialized to the initial values.

By debugging the problem i found that all these varriables are part of .sbss
sections

So is this the problem with mips that whatever varriables are part of .sbss
sections, are not persisting across calls to the shared library???


Pseudo Code:
============

foo.c
=========

static int tmp=10;
int xxx() {
....
tmp = 15;
print(tmp);
..
}

int yyy()
{

print(tmp);

}

=============
tst1.c
int main() {

call xxx();

sleep(10);

call yyy();

}
==================

output:
15
10


NOTE:please CC to me as i am not the member of this mailing list

------=_Part_97276_12279103.1150547123427
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

<div>Hi,<br><br>i am facing one problem On MIPS-netbsd regarding reinitialization of sbss<br>section<br><br>If in one shared library you have some global varriables and if they are<br>part of .sbss section<br>Then when any function is called in that shared library from main program
<br>and if it update those varriables then this updated should be refelected to<br>the subsequent calls to any function in that shared library<br><br>But I am facing one problem if i declared some global varriables and in
<br>first call to that function I assign those varriables some value ,but when i<br>come back from that shared library to main and then later if i call some<br>another functions from that library then the pointers are getting
<br>reinitialized to the initial values.<br><br>By debugging the problem i found that all these varriables are part of .sbss<br>sections<br><br>So is this the problem with mips that whatever varriables are part of .sbss<br>
sections, are not persisting across calls to the shared library???<br><br><br>Pseudo Code:<br>============<br><br>foo.c<br>=========<br><br>static int tmp=10;<br>int xxx() {<br>.....<br>tmp = 15;<br>print(tmp);<br>...<br>
}<br><br>int yyy()<br>{<br><br>print(tmp);<br><br>}<br><br>=============<br>tst1.c<br>int main() {<br><br>call xxx();<br><br>sleep(10);<br><br>call yyy();<br><br>}<br>==================<br><br>output:<br>15<br>10<br>&nbsp;</div>

<div>&nbsp;</div>
<div>NOTE:please CC to me as i am not the member of this mailing list</div>
<div>&nbsp;</div>

------=_Part_97276_12279103.1150547123427--