I'm hitting an issue where some test infrastructure is setting LD_LIBRARY_PATH to a list that contains both 32-bit and 64-bit libraries because it is unsure whether the code under test is going to execute 32-bit or 64-bit processes or both. When using musl the dynamic loader takes the first library with a matching name and then fails to load it if it is for the wrong elf class. The attached patch verifies the elf machine and class when searching the path list, continuing the search if a valid elf header with an incorrect machine or class is found.