harmony-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "chunrong lai" <chunrong...@gmail.com>
Subject Re: [general] How to deal with global/static variables in a static library while linking?
Date Mon, 01 Sep 2008 04:24:17 GMT
 Maybe you can try  #pragma   data_seg.
 Thanks.


On 9/1/08, Ligang Wang <wanglg9711@gmail.com> wrote:
>
> Hi, all,
>
>
> I encountered a problem after adding some code into DRLVM. The following is
> a simplified example for the problem:
>
> In static library A, there is a header file A.h and a C file A.c.
>
>
> In A.h:
> extern function1();
>
>
> In A.c:
>
> (static) var;   // a static or global variable
>
> Function1()
>
> {
>
> ……
>
> Function2();
>
> ……
>
> }
>
> Function2()
>
> {
>
> Access var;
>
> }
>
>
>
> Several DLLs include A.h and call function1. And the final executable uses
> all these DLLs.
>
>
>
> The question here is, will each DLL allocate a memory unit for var? And
> what
> memory address will each DLL reference for var? Is there any difference
> between the static case and global case for the memory allocation problem?
>
>
> Actually in Harmony library A is the port module and those DLLs stand for
> vmcore, gc_gen, JNI, etc. While debugging I found that a static variable I
> defined in the port module has different addresses when accessed from
> different DLLs. Changing it to a global variable has no impact on this.
>
> Anyone can help me? Thanks in advance.
>
> Regards,
> Ligang
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message