Can I change 'rpath' in an already compiled binary?

后端 未结 4 1883
伪装坚强ぢ
伪装坚强ぢ 2020-11-28 19:05

I have an old executable that\'s scheduled for the scrap heap, but it\'s not there yet. It relies on some libs that have been removed from my environment, but I have some st

4条回答
  •  有刺的猬
    2020-11-28 19:31

    There is a more universal tool than chrpath called patchelf. It was originally created for use in making packages for Nix and NixOS (packaging system and a GNU/Linux distribution).

    In case there is no rpath in a binary (here called rdsamp), chrpath fails:

    chrpath -r '$ORIGIN/../lib64' rdsamp 
    rdsamp: no rpath or runpath tag found.
    

    On the other hand,

    patchelf --set-rpath '$ORIGIN/../lib64' rdsamp
    

    succeeds just fine.

提交回复
热议问题