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

LTO: Check if symbol exists in closure before trying to copy it when externalizing #123

Open
giulianobelinassi opened this issue Aug 22, 2024 · 0 comments
Labels
bug Something isn't working enhancement New feature or request

Comments

@giulianobelinassi
Copy link
Collaborator

When a library is compiled with LTO (-flto, link time optimization), we can not simply copy the symbol if it is not found in the debuginfo because the symbol may have been inlined and is not available in the current compilation unit.

An example of this is the symbol ssl3_release_read_buffer of libssl.so.1.1 on Factory repository. When extracting symbol ssl3_read_n of ssl/record/rec_layer_s3.c, the symbol ssl3_release_read_buffer is not externalized because the SymbolExternalizer correctly decides it was inlined, but since there is no body of this function in the compilation unit it just copies the prototype, which is incorrect.

Command line:

clang-extract -DCE_EXTRACT_FUNCTIONS=ssl3_read_n -DCE_OUTPUT_FILE=/tmp/out.c   -I. -Iinclude -fPIC -pthread -m64 -Wa,--noexecstack -Wall -O3 -O2 -Wall -U_FORTIFY_SOURCE -fstack-protector-strong -funwind-tables -fasynchronous-unwind-tables -fstack-clash-protection -Werror=return-type -flto=auto -g -fpatchable-function-entry=16,14 -fdump-ipa-clones -Wa,--noexecstack -fno-common -Wall -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_PIC -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAESNI_ASM -DVPAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DOPENSSLDIR="\"/etc/ssl\"" -DENGINESDIR="\"/usr/lib64/engines-1.1\"" -DNDEBUG -D_FORTIFY_SOURCE=3 -DTERMIO -DPURIFY -D_GNU_SOURCE -DOPENSSL_NO_BUF_FREELISTS -DSYSTEM_CIPHERS_FILE="\"/etc/crypto-policies/back-ends/openssl.config\"" -MMD -MF ssl/record/rec_layer_s3.d.tmp -MT ssl/record/rec_layer_s3.o -c -o ssl/record/rec_layer_s3.o ssl/record/rec_layer_s3.c
@giulianobelinassi giulianobelinassi added bug Something isn't working enhancement New feature or request labels Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant