如何避免二进制文件中的STT_GNU_IFUNC符号? [英] How to avoid STT_GNU_IFUNC symbols in your binary?

查看:531
本文介绍了如何避免二进制文件中的STT_GNU_IFUNC符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要部署到Red Hat 4.1.2框(其中包含gcc 4.1.2)。我在Ubuntu 11.10上使用GCC 4.6.1进行开发。不幸的是,我的构建过程创建的一些二进制文件在RedHat机器上不可用。原因似乎是ABI的变化,根据另一个Stackoverflow问题是由于引入了STT_GNU_IFUNC符号。有没有办法阻止导出任何这样的符号,以便我的二进制文件可以使用旧的ABI?我使用nm在我的二进制文件中查找任何我类型的符号,但没有找到。



我问这个是因为我的其他二进制文件以及一些第三方我构建的库(tbb,boost)不使用新的ABI,因此可以在RedHat机器上正常运行。

希望很明显。一般来说,UNIX系统支持向后二进制兼容性(在旧计算机上构建的二进制文件继续运行)一个更新的),但不是相反。你不能指望在新系统上构建的二进制文件在较旧的系统上运行。 STT_GNU_IFUNC 只是您遇到的许多问题的第一步。



如果您需要在较旧的机器上构建二进制文件,请参阅 < a> document。

曾经有过apgcc:用于制作可移植二进制文件的GCC包装器,使它变得很容易(它是从上面引用的),但似乎是(



最简单的选择是建立在一台旧机器上(我曾经在RedHat 6.2上构建过,所产生的二进制文件到处都是

另一个相对简单的选项是构建在 chroot 中,再次使用来自旧版本的工具和库(例如RH-6.2)。


I need to deploy to a Red Hat 4.1.2 box (which has gcc 4.1.2). I use GCC 4.6.1 on Ubuntu 11.10 for development. Unfortunately some of the binaries that my build process creates are not usable on the RedHat machine. The reason seems to be an ABI change, which according to another Stackoverflow question resulted from the introduction of STT_GNU_IFUNC symbols. Is there a way to prevent exporting any such symbols so that my binary can use the old ABI? I used nm to look for any symbols of "i" type on my binary but found none.

I ask this because some of my other binaries as well as some 3rd party libs I build (tbb, boost) are not using the new ABI and so run fine on the RedHat machine.

Hope that is clear. Thanks in advance.

解决方案

In general, UNIX systems support backward binary compatibility (a binary built on an old machine continues to run on a newer one), but not the reverse. You can't expect a binary built on a new system to run on an older one. STT_GNU_IFUNC is only the first of many problems you'll encounter.

If you need to build a binary on a newer machine that will run on an older one, see this document.

There used to be "apgcc: A GCC wrapper to make portable binaries" that made this easy (it's referenced from above), but it appears to be gone ;-(

The easiest option is to build on an old machine (I used to build on RedHat 6.2, and the resulting binary ran everywhere). You don't have to actually run RH-6.2 on a physical machine, just bring it up in a VM.

The other relatively easy option is to build in a chroot, again using tools and libraries from an old distribution (e.g. RH-6.2).

这篇关于如何避免二进制文件中的STT_GNU_IFUNC符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆