xref: /openbsd-src/lib/libcrypto/hidden/README (revision 303eb4507d0dcd376c190077416c20d186749a70)
1ec6848bcSbeckThe goals:
2ec6848bcSbeck1) calls from inside libcrypto to other libcrypto functions should
3ec6848bcSbeck   be via identifiers that are of hidden visibility and -- to avoid
4ec6848bcSbeck   confusion or conflicts -- are in the reserved namespace.  By
5ec6848bcSbeck   doing this these calls are protected from being overridden by
6ec6848bcSbeck   applications and on many platforms can avoid creation or use of
7ec6848bcSbeck   GOT or PLT  entries.  I've chosen a prefix of "_lcry_" for this.
8ec6848bcSbeck   Note that these symbols aren't in the dynamic symbol table of the
9ec6848bcSbeck   libcrypto.so shared library...but they are visible in the static
10ec6848bcSbeck   library.
11ec6848bcSbeck
12ec6848bcSbeck2) calls from libssl to symbols in libcrypto should be via identifiers
13ec6848bcSbeck   which won't be accidentally overridden by the application, libc,
14ec6848bcSbeck   other random crypto libraries that are pulled in, etc.  I've
15ec6848bcSbeck   chosen a prefix of "_libre_" for this.
16ec6848bcSbeck
17ec6848bcSbeckThese will not be declared directly; instead, the gcc "asm labels"
18ec6848bcSbeckextension will be used rename the function.  In order to actually
19ec6848bcSbeckset up the desired asm labels, we use these in the internal .h
20ec6848bcSbeckfiles:
21ec6848bcSbeck
22ec6848bcSbeck   LCRYPTO_USED(x)	Symbols used both internally and externally
23ec6848bcSbeck	In builds of libcrypto, this makes gcc convert use of x to
24ec6848bcSbeck	use _libre_x instead.  In other builds that use these headers,
25ec6848bcSbeck	it makes gcc convert use of x to use _libre_x instead.  Use
26ec6848bcSbeck	LCRYPTO_ALIAS(x) to create the external aliases.
27ec6848bcSbeck	ex: LCRYPTO_USED(SSL_get_verify_mode)
28ec6848bcSbeck
29ec6848bcSbeck   LCRYPTO_UNUSED(x)	Symbols that are not used internally or by libssl
30ec6848bcSbeck	No renaming is done.  In builds of libcrypto, the symbol
31ec6848bcSbeck	is marked as deprecated to detect unintentional use of such
32*303eb450Stobhe	a symbol, so that it can be marked as used going forward.
33ec6848bcSbeck	ex: LCRYPTO_UNUSED(SSL_CIPHER_get_name)
34ec6848bcSbeck
35ec6848bcSbeckFinally, to create the expected aliases, we use these in the .c files
36ec6848bcSbeckwhere the definitions are:
37ec6848bcSbeck   LCRYPTO_ALIAS(x)
38ec6848bcSbeck	This defines both x and _libre_x as strong aliases for _lcry_x.
39ec6848bcSbeck	Match uses of this with uses of LCRYPTO_USED()
40ec6848bcSbeck	ex: LCRYPTO_ALIAS(SSL_get_verify_mode)
41