patchelf

  • https://github.com/NixOS/patchelf

PatchELF is a simple utility for modifying existing ELF executables and
libraries. In particular, it can do the following:

  • Change the dynamic loader (“ELF interpreter”) of executables:

    $ patchelf --set-interpreter /lib/my-ld-linux.so.2 my-program
    
  • Change the RPATH of executables and libraries:

    $ patchelf --set-rpath /opt/my-libs/lib:/other-libs my-program
    
  • Shrink the RPATH of executables and libraries:

    $ patchelf --shrink-rpath my-program
    

    This removes from the RPATH all directories that do not contain a
    library referenced by DT_NEEDED fields of the executable or library.
    For instance, if an executable references one library libfoo.so, has
    an RPATH /lib:/usr/lib:/foo/lib, and libfoo.so can only be found
    in /foo/lib, then the new RPATH will be /foo/lib.

    In addition, the --allowed-rpath-prefixes option can be used for
    further rpath tuning. For instance, if an executable has an RPATH
    /tmp/build-foo/.libs:/foo/lib, it is probably desirable to keep
    the /foo/lib reference instead of the /tmp entry. To accomplish
    that, use:

    $ patchelf --shrink-rpath --allowed-rpath-prefixes /usr/lib:/foo/lib my-program
    
  • Remove declared dependencies on dynamic libraries (DT_NEEDED
    entries):

    $ patchelf --remove-needed libfoo.so.1 my-program
    

    This option can be given multiple times.

  • Add a declared dependency on a dynamic library (DT_NEEDED):

    $ patchelf --add-needed libfoo.so.1 my-program
    

    This option can be give multiple times.

  • Replace a declared dependency on a dynamic library with another one
    (DT_NEEDED):

    $ patchelf --replace-needed liboriginal.so.1 libreplacement.so.1 my-program
    

    This option can be give multiple times.

  • Change SONAME of a dynamic library:

    $ patchelf --set-soname libnewname.so.3.4.5 path/to/libmylibrary.so.1.2.3
    

Compiling and Testing

Via Autotools

./bootstrap.sh
./configure
make
make check
sudo make install

Via Nix

You can build with Nix in several ways.

  1. Building via nix build will produce the result in ./result/bin/patchelf. If you would like to build patchelf with musl try nix build .#patchelf-musl

  2. You can launch a development environment with nix develop and follow the autotools steps above. If you would like to develop with musl try nix develop .#musl

Author

Copyright 2004-2019 Eelco Dolstra edolstra@gmail.com.

License

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or (at
your option) any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see http://www.gnu.org/licenses/.

Release History

0.14.5 (February 21, 2022):

  • fix faulty version in 0.14.4

0.14.4 (February 21, 2022):

  • Several test fixes to fix patchelf test suite on openbsd by @klemensn
  • Allow multiple modifications in same call by @fzakaria in https://github.com/NixOS/patchelf/pull/361
  • Add support to build with musl by @fzakaria in https://github.com/NixOS/patchelf/pull/362
  • Fix typo: s/folllow/follow/ by @bjornfor in https://github.com/NixOS/patchelf/pull/366
  • mips: fix incorrect polarity on dyn_offset; closes #364 by @a-m-joseph in https://github.com/NixOS/patchelf/pull/365

0.14.3 (December 05, 2021):

  • this release adds support for static, pre-compiled patchelf binaries

0.14.2 (November 29, 2021):

  • make version number in tarball easier to use for packagers

0.14.1 (November 28, 2021):

  • build fix: add missing include

0.14 (November 27, 2021):

Changes compared to 0.13:

  • Bug fixes:

    • Fix corrupted library names when using --replace-needed multiple times
    • Fix setting an empty rpath
    • Don’t try to parse .dynamic section of type NOBITS
    • Fix use-after-free in normalizeNoteSegments
    • Correct EINTR handling in writeFile
    • MIPS: Adjust PT_MIPS_ABIFLAGS segment and DT_MIPS_RLD_MAP_REL dynamic section if present
    • Fix binaries without .gnu.hash section
  • Support loongarch architecture
  • Remove limits on output file size for elf files
  • Allow reading rpath from file
  • Requires now C++17 for building

0.13.1 (November 27, 2021):

  • Bug fixes:

    • fix setting empty rpath
    • use memcpy instead of strcpy to set rpath
    • Don’t try to parse .dynamic section of type NOBITS
    • fix use-after-free in normalizeNoteSegments
    • correct EINTR handling in writeFile
    • Adjust PT_MIPS_ABIFLAGS segment if present
    • Adjust DT_MIPS_RLD_MAP_REL dynamic section entry if present
    • fix binaries without .gnu.hash section

0.13 (August 5, 2021):

  • New --add-rpath flag.

  • Bug fixes.

0.12 (August 27, 2020):

  • New --clear-symbol-version flag.

  • Better support for relocating NOTE sections/segments.

  • Improved the default section alignment choice.

  • Bug fixes.

0.11 (June 9, 2020):

  • New --output flag.

  • Some bug fixes.

0.10 (March 28, 2019):

  • Many bug fixes. Please refer to the Git commit log:

    https://github.com/NixOS/patchelf/commits/master

    This release has contributions from Adam Trhoň, Benjamin Hipple,
    Bernardo Ramos, Bjørn Forsman, Domen Kožar, Eelco Dolstra, Ezra
    Cooper, Felipe Sateler, Jakub Wilk, James Le Cuirot, Karl Millar,
    Linus Heckemann, Nathaniel J. Smith, Richard Purdie, Stanislav
    Markevich and Tuomas Tynkkynen.

0.9 (February 29, 2016):

  • Lots of new features. Please refer to the Git commit log:

    https://github.com/NixOS/patchelf/commits/master

    This release has contributions from Aaron D. Marasco, Adrien
    Devresse, Alexandre Pretyman, Changli Gao, Chingis Dugarzhapov,
    darealshinji, David Sveningsson, Eelco Dolstra, Felipe Sateler,
    Jeremy Sanders, Jonas Kuemmerlin, Thomas Tuegel, Tuomas Tynkkynen,
    Vincent Danjean and Vladimír Čunát.

0.8 (January 15, 2014):

  • Fix a segfault caused by certain illegal entries in symbol tables.

0.7 (January 7, 2014):

  • Rewrite section indices in symbol tables. This for instance allows
    gdb to show proper backtraces.

  • Added `–remove-needed’ option.

0.6 (November 7, 2011):

  • Hacky support for executables created by the Gold linker.

  • Support segments with an alignment of 0 (contributed by Zack
    Weinberg).

  • Added a manual page (contributed by Jeremy Sanders
    jeremy@jeremysanders.net).

0.5 (November 4, 2009):

  • Various bugfixes.

  • `–force-rpath’ now deletes the DT_RUNPATH if it is present.

0.4 (June 4, 2008):

  • Support for growing the RPATH on dynamic libraries.

  • IA-64 support (not tested) and related 64-bit fixes.

  • FreeBSD support.

  • --set-rpath', –shrink-rpath’ and --print-rpath' now prefer DT_RUNPATH over DT_RPATH, which is obsolete. When updating, if both are present, both are updated. If only DT_RPATH is present, it is converted to DT_RUNPATH unless –force-rpath’ is specified. If
    neither is present, a DT_RUNPATH is added unless `–force-rpath’ is
    specified, in which case a DT_RPATH is added.

0.3 (May 24, 2007):

  • Support for 64-bit ELF binaries (such as on x86_64-linux).

  • Support for big-endian ELF binaries (such as on powerpc-linux).

  • Various bugfixes.

0.2 (January 15, 2007):

  • Provides a hack to get certain programs (such as the
    Belastingaangifte 2005) to work.

0.1 (October 11, 2005):

  • Initial release.

patchelf: https://github.com/NixOS/patchelf相关推荐

  1. 一步一步指引你在Windows7上配置编译使用Caffe(https://github.com/fengbingchun/Caffe_Test)

    之前写过几篇关于Caffe源码在Windows764位上配置编译及使用过程,只是没有把整个工程放到网上,最近把整个工程整理清理了下,把它放到了GitHub上.下面对这个工程的使用作几点说明: 1.   ...

  2. 1 sec on Large Judge (java): https://github.com/l...

    1 sec on Large Judge (java): https://github.com/leoyonn/leetcode/blob/master/src/q029_substring_of_a ...

  3. https://github.com/fendouai/Awesome-Chatbot

    https://github.com/fendouai/Awesome-Chatbot

  4. github push报 Unable to access ‘https://github.com/xxxx/xxxx.git/‘: OpenSSL SSL_read: Connection was

    idea操作git时 报 Unable to access 'https://github.com/xxxx/xxxx.git/': OpenSSL SSL_read: Connection was ...

  5. ESP32彩屏应用开源了https://github.com/wireless-tag-cn/lv_port_esp32

    号外.号外-- 久久等候的ESP32彩屏终于开源了 https://github.com/wireless-tag-cn/lv_port_esp32 启明云端是国内乐鑫最高级别的核心合作伙伴,年初推出 ...

  6. git remote add Mycat https://github.com/MyCATApache/Mycat-Server.git

    git remote add Mycat https://github.com/MyCATApache/Mycat-Server.git 这个命令总是忘记

  7. unable to access ‘https://github.com/***.git‘: OpenSSL SSL_read: Connection was reset, errno 10054

    Git提交项目报错: unable to access 'https://github.com/***.git': OpenSSL SSL_read: Connection was reset, er ...

  8. fatal: unable to access ‘https://github.com/***.git/‘: OpenSSL SSL_read: Connection was reset, errno

    写了点code,想交到GitHub,结果报了个错. fatal: unable to access 'https://github.com/koking0/Algorithm.git/': OpenS ...

  9. fatal: unable to access ‘https://github.com/PanJiaChen/vue-element-admin.git/‘: OpenSSL SSL_read: Co

    将git clone https://github.com/PanJiaChen/vue-element-admin.git 中的https改为git即可. 例:git clone git://git ...

最新文章

  1. 【C++20】vs2019使用modules的实际操作
  2. cordova指定版本_Cordova 基本命令 以及如何添加,删除插件
  3. Kubernetes探针踩坑记
  4. wps表格粗线和细线区别_详解论文中的表格技术
  5. Vue.js 循环语句
  6. 程序员的基础和解决问题的思维很重要
  7. JAVA常见命名规范
  8. mysql的update和case when同步使用
  9. iOS 抓包工具限免,速度下载!【附使用教程】
  10. 常见计算机主机内部硬件设备,计算机硬件组成详解
  11. 突破IP限制动态替换代理ip。
  12. 太原用计算机单位的工资,太原个税计算器_太原税后月薪|工资计算器_太原个人所得税查询 - Tax518...
  13. dell idrac 复位_重置DELL R630 iDRAC访问密码
  14. ZigBee 3.0实战教程-Silicon Labs EFR32+EmberZnet-3-04:模板工程创建/编译/下载-Application
  15. 四步修改Linux ip地址
  16. Java实验4-1【数组下标越界异常处理】
  17. 线性单节锂电充电IC
  18. linux内核内存屏障,从硬件引申出内存屏障,带你深入了解Linux内核RCU
  19. LeetCode - 263 - Ugly Number
  20. 一次当晋级评委的经历

热门文章

  1. OKCC呼叫中心系统平台是什么?
  2. 85、弱电工程网络由基础到深入知识集锦
  3. 017-000-121正常驴血清中英文说明
  4. 关于Windows 10企业评估版
  5. 多线程与高并发(马士兵)
  6. 史上最全的厦门英语角!赶紧收藏啦!
  7. iphone新旧手机数据传输已取消_OPPO 将推全新概念手机/可折叠 iPhone 已在测试生产中...
  8. javascript做的一个根据table中某个td的值为日期时的倒计时
  9. 电源电路(稳压器部分)以及驱动电路
  10. 明基BenQ“蓝朋友”激光商务投影机正式发售