Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support new feature: add export symbol prefix #256

Merged
merged 1 commit into from
Jul 25, 2022

Conversation

wa5i
Copy link
Contributor

@wa5i wa5i commented Jul 16, 2022

If the parameter --symbol-prefix=BABA_ is configured, the prefix BABA_ will be
added to the exported symbols of dynamic libraries (libssl.so, libcrypto.so)
and static libraries (libssl.a, libcrypto.a), and then the corresponding macros
are used to conversion (in file: include/openssl/symbol_prefix.h) to keep the
interface compatible.

Checklist
  • 增加或更新了必要的文档(包括readthedocs上)
  • 增加或更新了必要的测试用例
  • 对于重要修改,更新了CHANGES文件
  • 当前修改存在对已有API参数或返回值的改变
  • 当前修改存在对旧版本功能的兼容性改变(如网络协议或密码算法)

Copy link
Member

@dongbeiouba dongbeiouba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1.已经在头文件中声明的符号,就不用在新加的头文件中重复声明了。
2.增加的头文件如果只用于符号搜所的话,而不会用于include,那就没必要搞成.h文件,是不是可以改成.txt文件?类似于util下missingssl.txt,然后只要把函数名放到里面即可,不需要完整的函数声明。符号搜所时从这个文件中找就好了,这样.c文件不用修改,.h文件也不用增加

crypto/local.h Outdated
# endif
uint32_t _armv7_tick(void);

void OPENSSL_cpuid_setup(void);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include/internal/cryptlib.h已经声明了OPENSSL_cpuid_setup()

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include/internal/cryptlib.h已经声明了OPENSSL_cpuid_setup()

已删

ssl/s3_enc.c Outdated
@@ -37,7 +37,7 @@ static int ssl3_generate_key_block(SSL *s, unsigned char *km, int num)
EVP_MD_CTX_set_flags(m5, EVP_MD_CTX_FLAG_NON_FIPS_ALLOW);
for (i = 0; (int)i < num; i += MD5_DIGEST_LENGTH) {
k++;
if (k > sizeof(buf)) {
if (k >= sizeof(buf)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k等于sizeof(buf)有啥问题?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

k等于sizeof(buf)有啥问题?

是之前我本地编译器报错临时修改的,忘记恢复了。我删掉

"os_toebcdic" => 1,
"ebcdic2ascii" => 1,
"ascii2ebcdic" => 1,
"HWSM4_set_encrypt_key" => 1,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥HWSM4_相关的函数要ignore?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

为啥HWSM4_相关的函数要ignore?

已适配和删除

util/mk_symbol_prefix.pl Outdated Show resolved Hide resolved
util/mk_symbol_prefix.pl Outdated Show resolved Hide resolved
@@ -30,7 +30,7 @@ int MD5_Init(MD5_CTX *c)
return 1;
}

#ifndef md5_block_data_order
#ifndef ASM_md5_block_data_order
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成如果未定义ASM_md5_block_data_order则定义md5_block_data_order,跟原意不一样了

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成如果未定义ASM_md5_block_data_order则定义md5_block_data_order,跟原意不一样了

因为 symbol_prefix.h 会定义宏 md5_block_data_order,会导致这里不会被展开,而 ASM_md5_block_data_order 已经在 md5_local.h 跟原来的 md5_block_data_order 一起定义了,没有改变原意;
image

@@ -30,7 +30,7 @@ int MD4_Init(MD4_CTX *c)
return 1;
}

#ifndef md4_block_data_order
#ifndef ASM_md4_block_data_order
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成如果未定义ASM_md4_block_data_order则定义md4_block_data_order,跟原意不一样了

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

改成如果未定义ASM_md4_block_data_order则定义md4_block_data_order,跟原意不一样了

整个仓库除了 symbol_prefix.h 外没有 #define md4_block_data_order 的地方,所以也没有定义 ASM_md4_block_data_order,原意不变,因为 symbol_prefix.h 已经定义了宏 md4_block_data_order,如果不修改则这段代码不会被展开。

@wa5i
Copy link
Contributor Author

wa5i commented Jul 20, 2022

1.已经在头文件中声明的符号,就不用在新加的头文件中重复声明了。 2.增加的头文件如果只用于符号搜所的话,而不会用于include,那就没必要搞成.h文件,是不是可以改成.txt文件?类似于util下missingssl.txt,然后只要把函数名放到里面即可,不需要完整的函数声明。符号搜所时从这个文件中找就好了,这样.c文件不用修改,.h文件也不用增加

目前加这个还只是适配历史遗留的在.c 文件中声明的函数和全局变量,以后新增的函数和全局变量会尽量在自己的头文件中声明,也会自动被 perl 脚本解析,.h 文件本来就是用来放声明的地方,即使被 include 也可以(只是目前为了减少 diff,没有把声明的地方删除后 include 该文件),单独搞一个类似 missingssl.txt 的文件反而比较重。

Copy link
Member

@dongbeiouba dongbeiouba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

对齐问题

util/perl/OpenSSL/Symbol.pm Outdated Show resolved Hide resolved
util/perl/OpenSSL/Symbol.pm Outdated Show resolved Hide resolved
util/perl/OpenSSL/Symbol.pm Outdated Show resolved Hide resolved
util/perl/OpenSSL/Symbol.pm Outdated Show resolved Hide resolved
If the parameter --symbol-prefix=BABA_ is configured, the prefix BABA_ will be
added to the exported symbols of dynamic libraries (libssl.so, libcrypto.so)
and static libraries (libssl.a, libcrypto.a), and then the corresponding macros
are used to conversion (in file: include/openssl/symbol_prefix.h) to keep the
interface compatible.
Copy link
Member

@dongbeiouba dongbeiouba left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@InfoHunter InfoHunter merged commit 6f471fb into Tongsuo-Project:8.3-stable Jul 25, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants