Introduced in 5.0 u10 b01 and 6.0 b80
There are several problems in the code
1) libraries with EM_SPARC and EM_SPARC32PLUS in e_machine field of .so header are compatible. In fact Sun Studio on v9 machine generates by default EM_SPARC32PLUS library and gcc generates EM_SPARC libraries for 32-bit targets. This was causing the redicules output message: Can't load Sparc 32-bit .so on a Sparc 32-bit platform.
Same token: there is a potential problem with EM_386 and EM_486.
2) There may me many reasons why dlopen failed. The old code only checks if file exists, may be opened and if e_machine field matches current architecture and then assumes that architecture is not right. This overlooks any other reasons why library could not be opened. The code should compare if the architecture is right fo this library and if it is - report what dlerror() reported.
3) Code should evaluate little endian/big endian field of .so head. Otherwise examining elf_head may not be done correctly (byte order).
4) In version 6.0 and 7.0
bool failed_to_read_elf_head= (sizeof(elf_head)==
(os::read(file_descriptor, &elf_head,sizeof(elf_head)))) ;
(::read(file_descriptor, &elf_head,sizeof(elf_head)))) ;
Webrevs with the fix: