Skip to content

Use readelf to calculate SONAME of dependencies#15308

Open
madebr wants to merge 1 commit intolibsdl-org:mainfrom
madebr:use-readelf-for-soname
Open

Use readelf to calculate SONAME of dependencies#15308
madebr wants to merge 1 commit intolibsdl-org:mainfrom
madebr:use-readelf-for-soname

Conversation

@madebr
Copy link
Copy Markdown
Contributor

@madebr madebr commented Apr 3, 2026

On the Windows platform, use the dll in the import library (used for libusb)
On ELF platforms, parse the output of readelf -d
On other unix platforms (or if readelf failes), keep the classic approach.

Description

Existing Issue(s)

For #8620

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}")
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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?

@madebr madebr force-pushed the use-readelf-for-soname branch from c4330db to 96ec8ae Compare April 6, 2026 23:29
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.

1 participant