This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Windows shared libraries limitation


Here is the problem. The auto-import feature for non scalar syms works only
if the syms are the DATA section. So for constant arrays this not working.
The following simple example will not work properly:

clib.c:

const char arr[] = "azertyazertyazertyazertyazertyazertyazertyazertyazerty";

$ gcc -shared -o clib.dll clib.c

main.c:

#include <stdio.h>

extern const char arr[];

int main (void)
{
  int k;

  for (k=0; k<6; k++)
    printf ("arr[%d]=%c\n", k, arr[k]);
}

$ gcc -o main main.c clib.dll
$ ./main
arr[0]=ÿ
arr[1]=%
arr[2]=à
arr[3]=`
arr[4]=@
arr[5]=

Of course the obvious fix is to remove the "const" attribute. But this is not
a general solution. The problem occurs, for example, in the standard Ada
libraries where it is not an option to change a constant to a variable (the
spec are part of the standard).

Is there a solution with the current GCC ?

If not a solution would be to add an option to GCC for force all such syms
into the DATA section.

Thoughts ?

Let me know if there is a more appropriate mailing-list to discuss this issue.

Thanks,
Pascal.

-- 

--|------------------------------------------------------
--| Pascal Obry                           Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--|         http://perso.wanadoo.fr/pascal.obry
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595


--
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/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]