Skip to content

cmELF: Get correct section count for large ELF binaries

Jacob Hatch requested to merge hatchjl/cmake:large-elf into master

Update cmELF.cxx to get correct section count for ELF binaries with more than 65536 sections. Fixes file(RPATH_CHANGE) for such files.

https://refspecs.linuxbase.org/elf/gabi4+/ch4.sheader.html

e_shnum normally tells how many entries the section header table contains. If the number of sections is greater than or equal to SHN_LORESERVE (0xff00), e_shnum has the value SHN_UNDEF (0) and the actual number of section header table entries is contained in the sh_size field of the section header at index 0 (otherwise, the sh_size member of the initial entry contains 0).

Calculates the section number by adding e_shnum and sections[0].sh_size.

Fixes: #24877 (closed)
Topic-rename: file-RPATH-large-ELF

Edited by Brad King

Merge request reports