diff options
author | pg <pg@yandex-team.com> | 2025-02-12 10:51:53 +0300 |
---|---|---|
committer | pg <pg@yandex-team.com> | 2025-02-12 11:12:16 +0300 |
commit | fdebd34b580c0027c5fd658f8591736840f41ad5 (patch) | |
tree | 2582409f65282fc3da23aa1762a67e41006415eb /contrib | |
parent | 68ee082e0346a833fb5a5dcead60e46e8801c52b (diff) | |
download | ydb-fdebd34b580c0027c5fd658f8591736840f41ad5.tar.gz |
simplify after
commit_hash:4d91c6379cf9f4b3a49a60b7500e1d8f809ad712
Diffstat (limited to 'contrib')
-rw-r--r-- | contrib/libs/openssl/ar.pyplugin | 73 | ||||
-rw-r--r-- | contrib/libs/openssl/redef.h | 2 | ||||
-rw-r--r-- | contrib/libs/openssl/ya.make | 11 |
3 files changed, 79 insertions, 7 deletions
diff --git a/contrib/libs/openssl/ar.pyplugin b/contrib/libs/openssl/ar.pyplugin new file mode 100644 index 0000000000..29d7e55c30 --- /dev/null +++ b/contrib/libs/openssl/ar.pyplugin @@ -0,0 +1,73 @@ +#!/usr/bin/env python3 + +from __future__ import print_function + +import os +import sys +import subprocess + + +def run(*args): + return subprocess.check_output(list(args), shell=False).strip() + + +def gen_renames_1(d): + for l in d.split('\n'): + l = l.strip() + + if ' ' in l: + yield l.split(' ')[-1] + + +def have_prefix(l, p): + for x in l: + if not x.startswith(p): + return False + + return True + + +def gen_renames_2(p, d): + l = list(gen_renames_1(d)) + a = have_prefix(l, '_') + + for s in l: + if 'asan_globals' in s: + continue + + if s in ['HMAC', 'SHA1', 'SHA256', 'SHA256', 'SHA512', 'RC4', 'MD5', 'SHA384']: + continue + + if a and s[1:] in ['HMAC', 'SHA1', 'SHA256', 'SHA256', 'SHA512', 'RC4', 'MD5', 'SHA384']: + continue + + if a: + yield s + ' _' + p + s[1:] + else: + yield s + ' ' + p + s + + +def gen_renames(p, d): + return '\n'.join(gen_renames_2(p, d)).strip() + '\n' + + +def rename_syms(where, ret): + p = 'v1_' + + # find symbols to rename + syms = run(where + 'llvm-nm', '--extern-only', '--defined-only', '-A', ret) + + # prepare rename plan + renames = gen_renames(p, syms) + tmp = ret + '.syms' + + with open(tmp, 'w') as f: + f.write(renames) + + # rename symbols + run(where + 'llvm-objcopy', '--redefine-syms=' + tmp, ret) + os.unlink(tmp) + + +if __name__ == '__main__': + rename_syms(os.path.dirname(sys.argv[3]) + '/', sys.argv[1]) diff --git a/contrib/libs/openssl/redef.h b/contrib/libs/openssl/redef.h index 2044bcacf0..259b2124fd 100644 --- a/contrib/libs/openssl/redef.h +++ b/contrib/libs/openssl/redef.h @@ -1,6 +1,6 @@ #pragma once -#if !defined(OPENSSL_BUILD) && !defined(_MSC_VER) && !defined(OPENSSL_DONT_ADD_VERSION_PREFIX) +#if !defined(OPENSSL_BUILD) && defined(OPENSSL_RENAME_SYMBOLS) #define a2d_ASN1_OBJECT v1_a2d_ASN1_OBJECT #define a2i_ASN1_ENUMERATED v1_a2i_ASN1_ENUMERATED #define a2i_ASN1_INTEGER v1_a2i_ASN1_INTEGER diff --git a/contrib/libs/openssl/ya.make b/contrib/libs/openssl/ya.make index 7d8ecf86fb..70c95e4732 100644 --- a/contrib/libs/openssl/ya.make +++ b/contrib/libs/openssl/ya.make @@ -48,12 +48,11 @@ ADDINCL( CFLAGS(-DOPENSSL_BUILD=1) -IF (EXPORT_CMAKE) - CFLAGS(GLOBAL -DOPENSSL_DONT_ADD_VERSION_PREFIX) -ENDIF() - -IF (MAPSMOBI_BUILD_TARGET) - CFLAGS(GLOBAL -DOPENSSL_DONT_ADD_VERSION_PREFIX) +IF (EXPORT_CMAKE OR OS_WINDOWS OR MAPSMOBI_BUILD_TARGET) + # DO NOT RENAME +ELSE() + AR_PLUGIN(ar) + CFLAGS(GLOBAL -DOPENSSL_RENAME_SYMBOLS=1) ENDIF() IF (NOT EXPORT_CMAKE OR NOT OPENSOURCE_REPLACE_OPENSSL) |