1 From: b...@arklinux.org (Bernhard Rosenkraenzer)
2 Newsgroups: mailing.openssl.dev
3 Subject: Re: OpenSSL breaks with gcc 4.2
4 Date: Thu, 9 Nov 2006 01:56:49 +0800 (CST)
5 Organization: NCTU CSIE FreeBSD Server
6 Message-ID: <eit5p1$4mi$1@FreeBSD.csie.nctu.edu.tw>
8 On Tuesday, 7. November 2006 15:54, Dr. Stephen Henson wrote:
9 > On Tue, Nov 07, 2006, Bernhard Rosenkraenzer wrote:
10 > > gcc 4.2 no longer allows function casting - which is used rather heavily
11 > > by openssl. (To make things worse, it compiles but inserts abort()
12 > > statements resulting in app crashes).
14 > Ugh, I would've thought that flagging a compiliation error would make more
15 > sense rather that outputting bad code...
17 Agreed... Unfortunately sometimes gcc developers' decisions make much sense
18 from the point of the compiler implementor than from that of someone actually
21 > > Is there a fix to make OpenSSL compatible with gcc 4.2/4.3 yet?
23 > No there isn't yet, some technique will be needed to make this still work
24 > by tweaking some of the macros. Does casting a function to (void *) first
25 > then the function cast work?
27 Yes, but only in a really really ugly way.
28 I've attached a patch that make it compile (and work), but I can't say I like
30 I've tried all sorts of other things (like putting the void* cast directly
31 into the defines, or even adding a (char*) cast and running +1-1 type
32 arithmetics on it), but gcc's optimizer is too smart and throws it away, and
33 errors out just as if it wasn't there), but the attached patch is the only
36 I hope someone can come up with a better idea...
38 --- openssl-0.9.8d/crypto/asn1/asn1.h.ark 2006-11-08 19:03:36.000000000 +0100
39 +++ openssl-0.9.8d/crypto/asn1/asn1.h 2006-11-08 19:32:10.000000000 +0100
42 /* Used to implement other functions */
43 void *ASN1_dup(i2d_of_void *i2d, d2i_of_void *d2i, char *x);
44 +static void * __attribute__((unused)) __ASN1_dup=(void *)openssl_fcast(ASN1_dup);
45 #define ASN1_dup_of(type,i2d,d2i,x) \
46 - ((type *(*)(I2D_OF(type),D2I_OF(type),type *))openssl_fcast(ASN1_dup))(i2d,d2i,x)
47 + ((type *(*)(I2D_OF(type),D2I_OF(type),type *))__ASN1_dup)(i2d,d2i,x)
48 #define ASN1_dup_of_const(type,i2d,d2i,x) \
49 - ((type *(*)(I2D_OF_const(type),D2I_OF(type),type *))openssl_fcast(ASN1_dup))(i2d,d2i,x)
50 + ((type *(*)(I2D_OF_const(type),D2I_OF(type),type *))__ASN1_dup)(i2d,d2i,x)
52 void *ASN1_item_dup(const ASN1_ITEM *it, void *x);
54 #ifndef OPENSSL_NO_FP_API
55 void *ASN1_d2i_fp(void *(*xnew)(void), d2i_of_void *d2i, FILE *in, void **x);
56 +static void * __attribute__((unused)) __ASN1_d2i_fp=(void *)openssl_fcast(ASN1_d2i_fp);
57 #define ASN1_d2i_fp_of(type,xnew,d2i,in,x) \
58 - ((type *(*)(type *(*)(void),D2I_OF(type),FILE *,type **))openssl_fcast(ASN1_d2i_fp))(xnew,d2i,in,x)
59 + ((type *(*)(type *(*)(void),D2I_OF(type),FILE *,type **))__ASN1_d2i_fp)(xnew,d2i,in,x)
60 void *ASN1_item_d2i_fp(const ASN1_ITEM *it, FILE *in, void *x);
61 int ASN1_i2d_fp(i2d_of_void *i2d,FILE *out,void *x);
62 +static void * __attribute__((unused)) __ASN1_i2d_fp=(void *)openssl_fcast(ASN1_i2d_fp);
63 #define ASN1_i2d_fp_of(type,i2d,out,x) \
64 - ((int (*)(I2D_OF(type),FILE *,type *))openssl_fcast(ASN1_i2d_fp))(i2d,out,x)
65 + ((int (*)(I2D_OF(type),FILE *,type *))__ASN1_i2d_fp)(i2d,out,x)
66 #define ASN1_i2d_fp_of_const(type,i2d,out,x) \
67 - ((int (*)(I2D_OF_const(type),FILE *,type *))openssl_fcast(ASN1_i2d_fp))(i2d,out,x)
68 + ((int (*)(I2D_OF_const(type),FILE *,type *))__ASN1_i2d_fp)(i2d,out,x)
69 int ASN1_item_i2d_fp(const ASN1_ITEM *it, FILE *out, void *x);
70 int ASN1_STRING_print_ex_fp(FILE *fp, ASN1_STRING *str, unsigned long flags);
74 #ifndef OPENSSL_NO_BIO
75 void *ASN1_d2i_bio(void *(*xnew)(void), d2i_of_void *d2i, BIO *in, void **x);
76 +static void * __attribute__((unused)) __ASN1_d2i_bio=(void *)openssl_fcast(ASN1_d2i_bio);
77 #define ASN1_d2i_bio_of(type,xnew,d2i,in,x) \
78 - ((type *(*)(type *(*)(void),D2I_OF(type),BIO *,type **))openssl_fcast(ASN1_d2i_bio))(xnew,d2i,in,x)
79 + ((type *(*)(type *(*)(void),D2I_OF(type),BIO *,type **))__ASN1_d2i_bio)(xnew,d2i,in,x)
80 void *ASN1_item_d2i_bio(const ASN1_ITEM *it, BIO *in, void *x);
81 int ASN1_i2d_bio(i2d_of_void *i2d,BIO *out, unsigned char *x);
82 +static void * __attribute__((unused)) __ASN1_i2d_bio=(void *)openssl_fcast(ASN1_i2d_bio);
83 #define ASN1_i2d_bio_of(type,i2d,out,x) \
84 - ((int (*)(I2D_OF(type),BIO *,type *))openssl_fcast(ASN1_i2d_bio))(i2d,out,x)
85 + ((int (*)(I2D_OF(type),BIO *,type *))__ASN1_i2d_bio)(i2d,out,x)
86 #define ASN1_i2d_bio_of_const(type,i2d,out,x) \
87 - ((int (*)(I2D_OF_const(type),BIO *,const type *))openssl_fcast(ASN1_i2d_bio))(i2d,out,x)
88 + ((int (*)(I2D_OF_const(type),BIO *,const type *))__ASN1_i2d_bio)(i2d,out,x)
89 int ASN1_item_i2d_bio(const ASN1_ITEM *it, BIO *out, void *x);
90 int ASN1_UTCTIME_print(BIO *fp,ASN1_UTCTIME *a);
91 int ASN1_GENERALIZEDTIME_print(BIO *fp,ASN1_GENERALIZEDTIME *a);
93 void *ASN1_item_unpack(ASN1_STRING *oct, const ASN1_ITEM *it);
94 ASN1_STRING *ASN1_pack_string(void *obj, i2d_of_void *i2d,
95 ASN1_OCTET_STRING **oct);
96 +static void * __attribute__((unused)) __ASN1_pack_string=(void *)openssl_fcast(ASN1_pack_string);
97 #define ASN1_pack_string_of(type,obj,i2d,oct) \
98 - ((ASN1_STRING *(*)(type *,I2D_OF(type),ASN1_OCTET_STRING **))openssl_fcast(ASN1_pack_string))(obj,i2d,oct)
99 + ((ASN1_STRING *(*)(type *,I2D_OF(type),ASN1_OCTET_STRING **))__ASN1_pack_string)(obj,i2d,oct)
100 ASN1_STRING *ASN1_item_pack(void *obj, const ASN1_ITEM *it, ASN1_OCTET_STRING **oct);
102 void ASN1_STRING_set_default_mask(unsigned long mask);
103 --- openssl-0.9.8d/crypto/ocsp/ocsp.h.ark 2006-11-08 19:28:48.000000000 +0100
104 +++ openssl-0.9.8d/crypto/ocsp/ocsp.h 2006-11-08 19:29:47.000000000 +0100
107 ASN1_STRING *ASN1_STRING_encode(ASN1_STRING *s, i2d_of_void *i2d,
108 void *data, STACK_OF(ASN1_OBJECT) *sk);
109 +static void * __attribute__((unused)) __ASN1_STRING_encode=(void *)openssl_fcast(ASN1_STRING_encode);
110 #define ASN1_STRING_encode_of(type,s,i2d,data,sk) \
111 -((ASN1_STRING *(*)(ASN1_STRING *,I2D_OF(type),type *,STACK_OF(ASN1_OBJECT) *))openssl_fcast(ASN1_STRING_encode))(s,i2d,data,sk)
112 +((ASN1_STRING *(*)(ASN1_STRING *,I2D_OF(type),type *,STACK_OF(ASN1_OBJECT) *))__ASN1_STRING_encode)(s,i2d,data,sk)
114 X509_EXTENSION *OCSP_crlID_new(char *url, long *n, char *tim);
116 --- openssl-0.9.8d/crypto/pem/pem.h.ark 2006-11-08 19:09:51.000000000 +0100
117 +++ openssl-0.9.8d/crypto/pem/pem.h 2006-11-08 19:43:45.000000000 +0100
118 @@ -220,19 +220,22 @@
119 #define IMPLEMENT_PEM_read_fp(name, type, str, asn1) \
120 type *PEM_read_##name(FILE *fp, type **x, pem_password_cb *cb, void *u)\
122 -return(((type *(*)(D2I_OF(type),char *,FILE *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read))(d2i_##asn1, str,fp,x,cb,u)); \
123 +static void *__PEM_ASN1_read=(void *)openssl_fcast(PEM_ASN1_read); \
124 +return(((type *(*)(D2I_OF(type),char *,FILE *,type **,pem_password_cb *,void *))__PEM_ASN1_read)(d2i_##asn1, str,fp,x,cb,u)); \
127 #define IMPLEMENT_PEM_write_fp(name, type, str, asn1) \
128 int PEM_write_##name(FILE *fp, type *x) \
130 -return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \
131 +static void *__PEM_ASN1_write=(void *)openssl_fcast(PEM_ASN1_write); \
132 +return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))__PEM_ASN1_write)(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \
135 #define IMPLEMENT_PEM_write_fp_const(name, type, str, asn1) \
136 int PEM_write_##name(FILE *fp, const type *x) \
138 -return(((int (*)(I2D_OF_const(type),const char *,FILE *, const type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \
139 +static void *__PEM_ASN1_write=(void *)openssl_fcast(PEM_ASN1_write); \
140 +return(((int (*)(I2D_OF_const(type),const char *,FILE *, const type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))__PEM_ASN1_write)(i2d_##asn1,str,fp,x,NULL,NULL,0,NULL,NULL)); \
143 #define IMPLEMENT_PEM_write_cb_fp(name, type, str, asn1) \
145 unsigned char *kstr, int klen, pem_password_cb *cb, \
148 - return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \
149 + static void *__PEM_ASN1_write=(void *)openssl_fcast(PEM_ASN1_write); \
150 + return(((int (*)(I2D_OF(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))__PEM_ASN1_write)(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \
153 #define IMPLEMENT_PEM_write_cb_fp_const(name, type, str, asn1) \
155 unsigned char *kstr, int klen, pem_password_cb *cb, \
158 - return(((int (*)(I2D_OF_const(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write))(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \
159 + static void *__PEM_ASN1_write=(void *)openssl_fcast(PEM_ASN1_write); \
160 + return(((int (*)(I2D_OF_const(type),const char *,FILE *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))__PEM_ASN1_write)(i2d_##asn1,str,fp,x,enc,kstr,klen,cb,u)); \
164 @@ -256,33 +261,38 @@
165 #define IMPLEMENT_PEM_read_bio(name, type, str, asn1) \
166 type *PEM_read_bio_##name(BIO *bp, type **x, pem_password_cb *cb, void *u)\
168 -return(((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read_bio))(d2i_##asn1, str,bp,x,cb,u)); \
169 +static void *__PEM_ASN1_read_bio=(void *)openssl_fcast(PEM_ASN1_read_bio); \
170 +return(((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))__PEM_ASN1_read_bio)(d2i_##asn1, str,bp,x,cb,u)); \
173 #define IMPLEMENT_PEM_write_bio(name, type, str, asn1) \
174 int PEM_write_bio_##name(BIO *bp, type *x) \
176 -return(((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \
177 +static void *__PEM_ASN1_write_bio=(void *)openssl_fcast(PEM_ASN1_write_bio); \
178 +return(((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))__PEM_ASN1_write_bio)(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \
181 #define IMPLEMENT_PEM_write_bio_const(name, type, str, asn1) \
182 int PEM_write_bio_##name(BIO *bp, const type *x) \
184 -return(((int (*)(I2D_OF_const(type),const char *,BIO *,const type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \
185 +static void *__PEM_ASN1_write_bio=(void *)openssl_fcast(PEM_ASN1_write_bio); \
186 +return(((int (*)(I2D_OF_const(type),const char *,BIO *,const type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))__PEM_ASN1_write_bio)(i2d_##asn1,str,bp,x,NULL,NULL,0,NULL,NULL)); \
189 #define IMPLEMENT_PEM_write_cb_bio(name, type, str, asn1) \
190 int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
191 unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
193 - return(((int (*)(I2D_OF(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \
194 + static void *__PEM_ASN1_write_bio=(void *)openssl_fcast(PEM_ASN1_write_bio); \
195 + return(((int (*)(I2D_OF(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))__PEM_ASN1_write_bio)(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \
198 #define IMPLEMENT_PEM_write_cb_bio_const(name, type, str, asn1) \
199 int PEM_write_bio_##name(BIO *bp, type *x, const EVP_CIPHER *enc, \
200 unsigned char *kstr, int klen, pem_password_cb *cb, void *u) \
202 - return(((int (*)(I2D_OF_const(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \
203 + static void *__PEM_ASN1_write_bio=(void *)openssl_fcast(PEM_ASN1_write_bio); \
204 + return(((int (*)(I2D_OF_const(type),const char *,BIO *,type *,const EVP_CIPHER *,unsigned char *,int,pem_password_cb *,void *))__PEM_ASN1_write_bio)(i2d_##asn1,str,bp,x,enc,kstr,klen,cb,u)); \
207 #define IMPLEMENT_PEM_write(name, type, str, asn1) \
208 @@ -545,13 +555,15 @@
209 pem_password_cb *cb, void *u);
210 void * PEM_ASN1_read_bio(d2i_of_void *d2i, const char *name, BIO *bp,
211 void **x, pem_password_cb *cb, void *u);
212 +static void * __attribute__((unused)) __PEM_ASN1_read_bio=(void *)openssl_fcast(PEM_ASN1_read_bio);
213 #define PEM_ASN1_read_bio_of(type,d2i,name,bp,x,cb,u) \
214 -((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))openssl_fcast(PEM_ASN1_read_bio))(d2i,name,bp,x,cb,u)
215 +((type *(*)(D2I_OF(type),const char *,BIO *,type **,pem_password_cb *,void *))__PEM_ASN1_read_bio)(d2i,name,bp,x,cb,u)
216 int PEM_ASN1_write_bio(i2d_of_void *i2d,const char *name,BIO *bp,char *x,
217 const EVP_CIPHER *enc,unsigned char *kstr,int klen,
218 pem_password_cb *cb, void *u);
219 +static void * __attribute__((unused)) __PEM_ASN1_write_bio=(void *)openssl_fcast(PEM_ASN1_write_bio);
220 #define PEM_ASN1_write_bio_of(type,i2d,name,bp,x,enc,kstr,klen,cb,u) \
221 - ((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))openssl_fcast(PEM_ASN1_write_bio))(i2d,name,bp,x,enc,kstr,klen,cb,u)
222 + ((int (*)(I2D_OF(type),const char *,BIO *,type *, const EVP_CIPHER *,unsigned char *,int, pem_password_cb *,void *))__PEM_ASN1_write_bio)(i2d,name,bp,x,enc,kstr,klen,cb,u)
224 STACK_OF(X509_INFO) * PEM_X509_INFO_read_bio(BIO *bp, STACK_OF(X509_INFO) *sk, pem_password_cb *cb, void *u);
225 int PEM_X509_INFO_write_bio(BIO *bp,X509_INFO *xi, EVP_CIPHER *enc,
227 ______________________________________________________________________
228 OpenSSL Project http://www.openssl.org
229 Development Mailing List openssl-...@openssl.org
230 Automated List Manager majord...@openssl.org