Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/boringssl.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Langley <agl@chromium.org>2014-06-24 22:15:12 +0400
committerAdam Langley <agl@chromium.org>2014-06-24 22:15:12 +0400
commit30eda1d2b80b8a943d3fb792f623a232646b0dbc (patch)
tree6faa0f073d3b9adde864dd5cb041ddbd17c793ef /crypto/cpu-intel.c
parent95463b311df79a60e48ad6c6f49a16995e617ae9 (diff)
Include some build fixes for OS X.
Apart from the obvious little issues, this also works around a (seeming) libtool/linker: a.c defines a symbol: int kFoo; b.c uses it: extern int kFoo; int f() { return kFoo; } compile them: $ gcc -c a.c $ gcc -c b.c and create a dummy main in order to run it, main.c: int f(); int main() { return f(); } this works as expected: $ gcc main.c a.o b.o but, if we make an archive: $ ar q lib.a a.o b.o and use that: $ gcc main.c lib.a Undefined symbols for architecture x86_64 "_kFoo", referenced from: _f in lib.a(b.o) (It doesn't matter what order the .o files are put into the .a) Linux and Windows don't seem to have this problem. nm on a.o shows that the symbol is of type "C", which is a "common symbol"[1]. Basically the linker will merge multiple common symbol definitions together. If ones makes a.c read: int kFoo = 0; Then one gets a type "D" symbol - a "data section symbol" and everything works just fine. This might actually be a libtool bug instead of an ld bug: Looking at `xxd lib.a | less`, the __.SYMDEF SORTED index at the beginning of the archive doesn't contain an entry for kFoo unless initialised. Change-Id: I4cdad9ba46e9919221c3cbd79637508959359427
Diffstat (limited to 'crypto/cpu-intel.c')
-rw-r--r--crypto/cpu-intel.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/crypto/cpu-intel.c b/crypto/cpu-intel.c
index cda80ea6..bc3148f5 100644
--- a/crypto/cpu-intel.c
+++ b/crypto/cpu-intel.c
@@ -66,7 +66,14 @@
#include <stdio.h>
#include <inttypes.h>
-uint32_t OPENSSL_ia32cap_P[4];
+/* This value must be explicitly initialised to zero in order to work around a
+ * bug in libtool or the linker on OS X.
+ *
+ * If not initialised then it becomes a "common symbol". When put into an
+ * archive, linking on OS X will fail to resolve common symbols. By
+ * initialising it to zero, it becomes a "data symbol", which isn't so
+ * affected. */
+uint32_t OPENSSL_ia32cap_P[4] = {0};
/* OPENSSL_ia32_cpuid is defined in cpu-x86_64-asm.pl. */
extern uint64_t OPENSSL_ia32_cpuid(uint32_t*);