Use readelf to calculate SONAME of dependencies#15308
Open
madebr wants to merge 1 commit intolibsdl-org:mainfrom
Open
Use readelf to calculate SONAME of dependencies#15308madebr wants to merge 1 commit intolibsdl-org:mainfrom
madebr wants to merge 1 commit intolibsdl-org:mainfrom
Conversation
madebr
commented
Apr 6, 2026
Comment on lines
+187
to
+199
| if(EXISTS "${LIBRARY}") | ||
| find_program(READELF_BIN NAMES readelf) | ||
| if(READELF_BIN) | ||
| execute_process(COMMAND "${READELF_BIN}" -d "${LIBRARY}" RESULTS_VARIABLE readelf_result OUTPUT_VARIABLE readelf_output) | ||
| if(readelf_result EQUAL 0 AND readelf_output) | ||
| string(REGEX MATCH "\\(SONAME\\).*\\[([0-9A-Za-z_.-]+)\\]" soname "${readelf_output}") | ||
| if(soname) | ||
| set(result "${CMAKE_MATCH_1}") | ||
| endif() | ||
| endif() | ||
| endif() | ||
| endif() | ||
| message(DEBUG "elf_read_soname(\"${LIBRARY}\") -> ${SONAME}") |
Contributor
Author
There was a problem hiding this comment.
As long as readelf from binutils is translated well, this should work.
Tested with French (LC_ALL=fr_FR) and Cyrillic language (LC_ALL=ru_RU)
@smcv What's your opinion on this?
c4330db to
96ec8ae
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On the Windows platform, use the dll in the import library (used for libusb)
On ELF platforms, parse the output of
readelf -dOn other unix platforms (or if readelf failes), keep the classic approach.
Description
Existing Issue(s)
For #8620