Operations 16 min read

Run Newer glibc Binaries on Old CentOS 6 Without Upgrading glibc

This guide explains why a third‑party program compiled against glibc 2.14/2.17 fails on CentOS 6, how to inspect the ELF symbol versions with objdump and readelf, and how to patch the binary using a hex editor and patchelf so it can run with the system's older glibc.

Liangxu Linux
Liangxu Linux
Liangxu Linux
Run Newer glibc Binaries on Old CentOS 6 Without Upgrading glibc

Many Linux users encounter glibc compatibility errors when executing third‑party binaries that were built on newer distributions; on a CentOS 6 64‑bit system the program may report GLIBC_2.17 not found or GLIBC_2.14 not found because the system ships with glibc 2.12.

Problem analysis

Running ldd tester shows the binary depends on /lib64/libc.so.6 with missing version symbols. Using objdump -T tester | grep GLIBC_2.1.* reveals the required symbols:

[root@centos6-dev ~]# objdump -T tester | grep GLIBC_2.1.*
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.14  memcpy
0000000000000000      DF *UND*  0000000000000000  GLIBC_2.17  clock_gettime

The system's glibc provides memcpy at version 2.2.5 and does not implement clock_gettime directly; the latter is supplied by librt.so.1 at version 2.2.5.

Inspecting ELF symbol version tables

Using readelf -sV tester we can view the dynamic symbol table and the .gnu.version and .gnu.version_r sections. The relevant excerpts are:

[root@centos6-dev ~]# readelf -sV tester
... 
Num: Value Size Type Bind Vis Ndx Name
  11: 0000000000000000 0 FUNC GLOBAL DEFAULT UND memcpy@GLIBC_2.14 (5)
  67: 0000000000000000 0 FUNC GLOBAL DEFAULT UND clock_gettime@GLIBC_2.17 (16)
...
Version needs section '.gnu.version_r' contains 6 entries:
 0x0010: Name: GLIBC_2.3  Flags: none  Version: 17
 0x00e0: Name: GLIBC_2.2.5  Flags: none  Version: 16
 0x0130: Name: GLIBC_2.2.5  Flags: none  Version: 5

The .gnu.version table maps each dynamic symbol to a two‑byte version index; the .gnu.version_r table (Elfxx_Vernaux structures) lists the actual library version strings and their hash values.

Modifying the ELF to use older symbols

Because the binary only needs the older implementations, we can edit the .gnu.version_r entries with a hex editor. The entries for GLIBC_2.14 and GLIBC_2.17 are located at offsets 0x05d9b8 and 0x05d9b8 respectively. By replacing their vna_hash with the hash of GLIBC_2.2.5 (0x09691A75) and keeping the vna_other value consistent, the loader will resolve the symbols to the older versions.

After saving the changes, re‑run readelf -sV tester to confirm that the version needs now point to GLIBC_2.2.5.

Adding missing library with patchelf

Since clock_gettime is not present in the old libc.so.6, we add a dependency on librt.so.1 using the Patchelf utility (available from the NixOS project):

[root@centos6-dev ~]# patchelf --add-needed librt.so.1 tester

Now the binary loads librt.so.1 at runtime, providing the required clock_gettime implementation.

Verification

Running ldd tester after the modifications shows the new dependency and no glibc version errors:

linux-vdso.so.1 =>  (0x00007fff c17ee000)
    librt.so.1 => /lib64/librt.so.1 (0x00007f7f84d ca000)
    libpthread.so.0 => /lib64/libpthread.so.0 (0x00007f7f84bad000)
    libOpenCL.so.1 => /usr/lib64/libOpenCL.so.1 (0x00007f7f8498f000)
    libdl.so.2 => /lib64/libdl.so.2 (0x00007f7f8478b000)
    libm.so.6 => /lib64/libm.so.6 (0x00007f7f84507000)
    libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007f7f842f1000)
    libc.so.6 => /lib64/libc.so.6 (0x00007f7f83f5d000)
    /lib64/ld-linux-x86-64.so.2 (0x00007f7f84fd2000)

The program now starts without glibc version complaints, demonstrating a practical way to run newer binaries on older Linux distributions without a risky system‑wide glibc upgrade.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

elfglibcbinary compatibilitycentos6patchelf
Liangxu Linux
Written by

Liangxu Linux

Liangxu, a self‑taught IT professional now working as a Linux development engineer at a Fortune 500 multinational, shares extensive Linux knowledge—fundamentals, applications, tools, plus Git, databases, Raspberry Pi, etc. (Reply “Linux” to receive essential resources.)

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.