[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
non-const variable from shared library gets placed in read-only section
From: |
Norton Allen |
Subject: |
non-const variable from shared library gets placed in read-only section |
Date: |
Tue, 29 Mar 2005 15:14:41 -0500 |
User-agent: |
Mozilla Thunderbird 0.8 (Windows/20040913) |
Problem:
non-const variable exported from shared library gets placed in
read-only section.
Environment:
cygwin 1.3.15
gcc 3.3.1, 3.3.3 and 3.4.1
ld 2.15.94
libxml2-2.6.18
scrollkeeper-0.3.14
Details:
The variable xmlFree is defined in libxml2 and referenced by a
program in the scrollkeeper distribution.
After preprocessing the scrollkeeper source, the pertinent definitions
are:
typedef void ( *xmlFreeFunc)(void *mem);
extern xmlFreeFunc xmlFree;
so xmlFree is a function pointer (and is *not* declared to
be const). In the libxml libraries, xmlFree shows up in
the writable data segment:
Cygwin> nm /bin/cygxml2-2.dll | grep 'xmlFree$'
100df1b0 D _xmlFree
Cygwin> nm /usr/lib/libxml2.dll.a | grep 'xmlFree$'
00000000 I __imp__xmlFree
00000000 I __nm__xmlFree
Cygwin> nm /usr/lib/libxml2.a | grep '^[^ ].*xmlFree$'
00000000 D _xmlFree
But in the executable, xmlFree shows up in the read-only
.text section:
Cygwin> objdump -h scrollkeeper-tree-separate.exe
scrollkeeper-tree-separate.exe: file format pei-i386
Sections:
Idx Name Size VMA LMA File off Algn
0 .text 00001db4 00401000 00401000 00000400 2**4
CONTENTS, ALLOC, LOAD, READONLY, CODE, DATA
1 .data 00000010 00403000 00403000 00002200 2**4
CONTENTS, ALLOC, LOAD, DATA
2 .bss 00000080 00404000 00404000 00000000 2**4
ALLOC
3 .idata 000006b0 00405000 00405000 00002400 2**2
CONTENTS, ALLOC, LOAD, DATA
4 .stab 000031f8 00406000 00406000 00002c00 2**2
CONTENTS, READONLY, DEBUGGING, NEVER_LOAD, EXCLUDE
5 .stabstr 0000e36f 0040a000 0040a000 00005e00 2**0
CONTENTS, READONLY, DEBUGGING, NEVER_LOAD, EXCLUDE
Cygwin> grep 'xmlFree$' sk.map
0x00402480 _xmlFree
0x00405184 __imp__xmlFree
The problem does not occur when linking against the static library.
Can anyone hazard a guess as to what is going on?
-Norton Allen
allen.vcf
Description: Vcard
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- non-const variable from shared library gets placed in read-only section,
Norton Allen <=