Trouble is that in shared library context there is a huge class of data 
which even if declared const will not be shared. Those are reference 
relocations. For example consider this:

const struct { int id; const char *description; } table = {...};

Would the 'table' be shared? If compiled with PIC flag of course? 
Unfortunately no, because 'description' member constitute a relocation, 
which is to be resolved by *run-time* linker and can't be placed to 
read-only segment. What would help in this situation? To split structure 
members to two tables, so that at least id-s will be shared? To replace 
'description' with offset in some other table computable at compile 
time? Yes, yes, at the cost of code modification. But what about 
pre-link? At least some contemporary Linuxen do offer shared object 
pre-link, when relocations get re[!]-resolved by run-time linker only if 
given shared object module can not be placed at pre-linked base address. 
So that if the matter discussed in this ticket is of greater concern, do 
use pre-link!

But above doesn't mean that we say no to constifications. Even more 
elaborate methods are being implemented, see for example 
http://cvs.openssl.org/chngview?cn=16578 and 
http://cvs.openssl.org/chngview?cn=16522. Thanks for suggestions. A.


______________________________________________________________________
OpenSSL Project                                 http://www.openssl.org
Development Mailing List                       [email protected]
Automated List Manager                           [EMAIL PROTECTED]

Reply via email to