Only one hash style in embedded Linux. What for?

I am trying to create a rootfs embedded software package with OpenAmbedded Arago . Unfortunately, the software package includes ready-made shared libraries. As far as I understand, Arago builds the entire Linux distribution with --hash-style=gnu , while these shared libraries were created with --hash-style=sysv , I suspect. At least the build stops with the problem "No GNU_HASH in ELF binary error."

I understand what hashes are for. But I think, I don’t understand how they are used when the system works.

Why do we need one hash style for all ELFs in the system? Why can't the dynamic linker determine the hash style on the fly and just use it?

+6
source share
2 answers

The dynamic linker can and does compute the kind of hash table ("sysv" or "gnu") present in the ELF, and works accordingly.

Unfortunately, you see that gnu hash section support was NOT ported to an earlier version of the dynamic linker used on your system.

A similar situation exists when binaries created for RHEL5 / FC6 do NOT work with RHEL4 / FC5 .


Why is .gnu.hash incompatible with .hash (sysv)?

Generating ELF using the gnu hash section imposes certain restrictions (additional rules) on the construction of a table of dynamic symbols.

Using the GNU hash, the dynamic symbol table is divided into two parts. The first part accepts characters that can be excluded from the hash table. GNU's anger does not impose any specific order for the characters in this part of the dynamic symbol table.

The second part of the dynamic symbol table accepts the characters available from the hash table. These characters must be sorted by increasing the (hash% nbuckets) value using the GNU hash function described above. The number of hash codes (nbuckets) is recorded in the hash section of the GNU file, described below. As a result, the characters that will be found in the same hash chain are contiguous in memory, which leads to increased cache performance.

Link: blogs.oracle.com/ali/entry/gnu_hash_elf_sections

+3
source

I had a problem with the same No GNU_HASH in the ELF binary with my Yocto Arago build, but it turned out that my Makefile application did not use $(LDFLAGS) , which is specified by the Yocto string and contains -Wl,--hash-style=gnu among other important things.

I mention this because this question is the best search result for this error message and this may help other people.

+2
source

Source: https://habr.com/ru/post/921771/


All Articles