Message "error while loading shared libraries: /lib64/libc.so.6: ELF file OS ABI invalid" appearing

Environment

  • Red Hat Enterprise Linux 5/6

Issue

  • After invoking a program, the following error is printed on the screen:

Raw

error while loading shared libraries: <library_path>: ELF file OS ABI invalid
  • What means "ELF file OS ABI invalid"?
  • While applying the latest patches, why the messages are printed on screen?

Raw

getent: error while loading shared libraries: /lib64/libc.so.6: ELF file OS ABI invalid
warning: /etc/pam.d/system-auth created as /etc/pam.d/system-auth.rpmnew
warning: /etc/security/access.conf created as /etc/security/access.conf.rpmnew
warning: /etc/security/limits.conf created as /etc/security/limits.conf.rpmnew
/bin/sh: error while loading shared libraries: /lib64/libc.so.6: ELF file OS ABI invalid
Error in PREIN scriptlet in rpm package udev-095-14.29.el5.x86_64
error: %pre(udev-095-14.29.el5.x86_64) scriptlet failed, exit status 127
error:   install: %pre scriptlet failed (2), skipping udev-095-14.29.el5
/bin/sh: error while loading shared libraries: /lib64/libc.so.6: ELF file OS ABI invalid
Error in PREIN scriptlet in rpm package initscripts-8.45.42-1.el5_8.1.x86_64
error: %pre(initscripts-8.45.42-1.el5_8.1.x86_64) scriptlet failed, exit status 127
error:   install: %pre scriptlet failed (2), skipping initscripts-8.45.42-1.el5_8.1
/bin/sh: error while loading shared libraries: /lib64/libc.so.6: ELF file OS ABI invalid
Error in PREIN scriptlet in rpm package hal-0.5.8.1-64.el5.x86_64
error: %pre(hal-0.5.8.1-64.el5.x86_64) scriptlet failed, exit status 127
error:   install: %pre scriptlet failed (2), skipping hal-0.5.8.1-64.el5
/bin/sh: error while loading shared libraries: /lib64/libc.so.6: ELF file OS ABI invalid
Error in PREIN scriptlet in rpm package pm-utils-0.99.3-14.el5.x86_64
error: %pre(pm-utils-0.99.3-14.el5.x86_64) scriptlet failed, exit status 127
error:   install: %pre scriptlet failed (2), skipping pm-utils-0.99.3-14.el5

Resolution

  • Replace the shared library with a version compatible with the current version of the Operating System.
  • Remove the third party library which is causing the problem. Contact its application vendor for the same.
  • If third party application using its own dynamic linker cannot run with the above error, it's possible that it could not find the correct dynamic linker. If there is a dynamic linker, which can be used with the application, in any directories of LD_LIBRARY_PATH, it uses the linker and it's possible that it doesn't find the correct library. Check the path in LD_LIBRARY_PATH is valid to run the application. Delete the directory including the wrong linker which can run with the application.

Root Cause

  • The application being executed is trying to load a shared library using an incompatible Application Binary Interface (ABI), with the current RHEL version. The ABI describes the interface between an application and the operating system or another application, and is responsible for details like data types, sizes, function calling conventions, binary format of object-files, and some other details.
  • It is not always possible to load the same library or run the same application in different major versions of the Red Hat Enterprise Linux, since that ABIs can not be compatible between these versions. Red Hat provides a compatibility policy related to the application binary interface between versions which covers the compatibility policy in details.
  • The policy specification and the another information about compatibility can be found at https://access.redhat.com/home into the "Developer Guide" documentation under each RHEL version.

Diagnostic Steps

  • While patching a server from RHEL 5.6 to 5.9, it looks like /lib64/libc.so.6 is symlinked to /lib64/libc-2.5.so. When applying the patch, the link is changed to /lib64/libc-2.12.so. As yum continues to update, multiple errors begin to get thrown for libc as follows.

Raw

getent: error while loading shared libraries: /lib64/libc.so.6: ELF file OS ABI invalid
warning: /etc/pam.d/system-auth created as /etc/pam.d/system-auth.rpmnew
warning: /etc/security/access.conf created as /etc/security/access.conf.rpmnew
warning: /etc/security/limits.conf created as /etc/security/limits.conf.rpmnew
/bin/sh: error while loading shared libraries: /lib64/libc.so.6: ELF file OS ABI invalid
Error in PREIN scriptlet in rpm package udev-095-14.29.el5.x86_64
error: %pre(udev-095-14.29.el5.x86_64) scriptlet failed, exit status 127
error:   install: %pre scriptlet failed (2), skipping udev-095-14.29.el5
/bin/sh: error while loading shared libraries: /lib64/libc.so.6: ELF file OS ABI invalid
Error in PREIN scriptlet in rpm package initscripts-8.45.42-1.el5_8.1.x86_64
error: %pre(initscripts-8.45.42-1.el5_8.1.x86_64) scriptlet failed, exit status 127
error:   install: %pre scriptlet failed (2), skipping initscripts-8.45.42-1.el5_8.1
/bin/sh: error while loading shared libraries: /lib64/libc.so.6: ELF file OS ABI invalid
Error in PREIN scriptlet in rpm package hal-0.5.8.1-64.el5.x86_64
error: %pre(hal-0.5.8.1-64.el5.x86_64) scriptlet failed, exit status 127
error:   install: %pre scriptlet failed (2), skipping hal-0.5.8.1-64.el5
/bin/sh: error while loading shared libraries: /lib64/libc.so.6: ELF file OS ABI invalid
Error in PREIN scriptlet in rpm package pm-utils-0.99.3-14.el5.x86_64
error: %pre(pm-utils-0.99.3-14.el5.x86_64) scriptlet failed, exit status 127
error:   install: %pre scriptlet failed (2), skipping pm-utils-0.99.3-14.el5
  • The library file /lib64/libc-2.12.so is not compatible with Red Hat Enterprise Linux and not shipped by Red Hat.

Raw

[root@example ~]# ls -l /lib64/libc.so.6
lrwxrwxrwx 1 root root 11 Jul 31 17:06 /lib64/libc.so.6 -> libc-2.5.so

[root@example ~]# ls -l /lib64/libc-2.5.so
-rwxr-xr-x 1 root root 1722232 May 17 12:55 /lib64/libc-2.5.so

[root@example ~]# ls -l /lib64/libc-2.12.so
ls: /lib64/libc-2.12.so: No such file or directory

[root@example ~]# yum whatprovides "/lib64/libc-2.12.so"
Loaded plugins: product-id, rhnplugin, security, subscription-manager
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
This system is receiving updates from RHN Classic or RHN Satellite.
rhel-x86_64-server-5                                                                                                    | 1.3 kB     00:00     
rhel-x86_64-server-5/primary                                                                                            | 5.8 MB     00:00     
rhel-x86_64-server-5                                                                                                               15343/15343
rhel-x86_64-server-cluster-5                                                                                            | 1.3 kB     00:00     
rhel-x86_64-server-cluster-5/primary                                                                                    |  26 kB     00:00     
rhel-x86_64-server-cluster-5                                                                                                           205/205
rhel-x86_64-server-cluster-storage-5                                                                                    | 1.3 kB     00:00     
rhel-x86_64-server-scalefs-5                                                                                            | 1.1 kB     00:00     
Importing additional filelist information
rhel-x86_64-server-5/filelists                                                                                          |  43 MB     00:01     
rhel-x86_64-server-5                                                                                                               15343/15343
rhel-x86_64-server-cluster-5/filelists                                                                                  | 3.2 MB     00:00     
rhel-x86_64-server-cluster-5                                                                                                           205/205
rhel-x86_64-server-cluster-storage-5/filelists                                                                          |  99 kB     00:00     
rhel-x86_64-server-cluster-storage-5                                                                                                   225/225
rhel-x86_64-server-scalefs-5/filelists                                                                                  | 1.3 kB     00:00     
rhel-x86_64-server-scalefs-5                                                                                                               5/5
No Matches found
  • The links get changed because ldconfig is called up during yum update process.

Raw

[root@example ~]# strace -o /tmp/strace.out.yum yum update
[root@example ~]# grep -i ldconfig /tmp/strace.out.yum
write(31, "/sbin/ldconfig\nfreetype\nx86_64\n0"..., 4096) = 4096
write(31, ".49\n6.el6\n1\n/sbin/ldconfig\nlibai"..., 4096) = 4096
write(44, "/sbin/ldconfig\nexit 0", 21) = 21
write(45, "/sbin/ldconfig\n[ -e /etc/blkid.t"..., 164) = 164
open("/usr/share/man/man8/ldconfig_selinux.8.gz;523deb25", O_WRONLY|O_CREAT|O_TRUNC, 0666) = 46
lstat("/usr/share/man/man8/ldconfig_selinux.8.gz", {st_mode=S_IFREG|0644, st_size=1335, ...}) = 0
rename("/usr/share/man/man8/ldconfig_selinux.8.gz;523deb25", "/usr/share/man/man8/ldconfig_selinux.8.gz") = 0
chown("/usr/share/man/man8/ldconfig_selinux.8.gz", 0, 0) = 0
chmod("/usr/share/man/man8/ldconfig_selinux.8.gz", 0644) = 0
utime("/usr/share/man/man8/ldconfig_selinux.8.gz", [2013/06/25-14:37:49, 2013/06/25-14:37:49]) = 0
write(46, "/sbin/ldconfig\n# create certific"..., 100) = 100
write(46, "/sbin/ldconfig", 14)         = 14
write(42, "/sbin/ldconfig >/dev/null 2>/dev"..., 37) = 37
write(42, "/sbin/ldconfig\n\n# Automatically "..., 93) = 93
lstat("/usr/share/man/man8/ldconfig_selinux.8.gz", {st_mode=S_IFREG|0644, st_size=1335, ...}) = 0
write(42, "/sbin/ldconfig", 14)         = 14
  • The third party application may use the linker provided by the vender, and it doesn't use the linker (like /lib/ld-linux.so.2 and /lib64/ld-linux-x86_64.so.2) provided by Red Hat. In that case,
    the output of ldd may not show the libraries linked actually by the application, since ldd doesn't know the linker provided by the vendor. So, use strace to check which library is linked dynamically with such a application. Also, check which linker is used by the application with readelf -l .

Raw

# readelf -l /bin/ls |grep interpreter
      [Requesting program interpreter: /lib64/ld-linux-x86-64.so.2]
遇到 "error while loading shared libraries: /lib64/libm.so.6: invalid ELF header" 这个错误,通常表示操作系统在尝试加载一个动态链接库(shared library)时,发现该库文件的头部信息不正确或不符合预期的ELF(Executable and Linkable Format)标准。 1. **ELF头错误**:这可能是因为文件损坏,可能是由于文件传输过程中数据丢失,或者是库文件本身的问题,比如被意外修改或使用了不兼容的工具生成。 2. **版本或架构不匹配**:如果系统的库文件和正在运行的程序不是同一个架构(如32位和64位),或者库文件的版本不兼容,也会导致此错误。 3. **安装或更新问题**:有时候软件包管理器更新或安装过程出现问题,可能导致系统找不到正确的libm.so.6库文件。 4. **清理缓存**:如果之前卸载或更新过某些软件,可能导致旧的或不兼容的库文件残留,清理缓存或者重新安装软件可能会解决问题。 为了解决这个问题,你可以按照以下步骤进行排查: - **检查文件完整性**:尝试从可靠的源重新下载并安装libm.so.6库。 - **确认依赖**:确保你的应用程序依赖的库版本与系统中安装的版本相匹配。 - **更新或回滚系统**:如果是系统级别的问题,考虑更新或回滚到一个已知稳定版本。 - **使用修复工具**:有些Linux发行版提供了修复ELF头错误的工具,比如Ubuntu的`dpkg`或`apt-get`。 - **重启系统**:有时重启系统可以帮助解决临时的系统缓存问题。 如果你不确定如何操作,建议查阅具体的操作系统文档,或者寻求专业的技术支持。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值