免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1962 | 回复: 0
打印 上一主题 下一主题

Tips for Running Linux Binaries on FreeBSD [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-01-10 08:17 |只看该作者 |倒序浏览
Tips for Running Linux Binaries on FreeBSD

Running Linux Binaries in FreeBSD should be simple as long as the linux
compatibility package is installed.
This can be checked by:
pkg_info | grep linux
One version of this is:
linux_base-7.1_2    The base set of packages needed in Linux mode
There's an option to turn on in /etc/rc.conf, as well:
linux_enable="YES"
In general, these things should already be installed/setup as part of the basic
FreeBSD install.
The binary should be statically compiled, if you're creating it from scratch on
a linux system, using the -static compile flag.
If you run the file and see an error message like the following, then this page is
all about how to fix it. If the problem is something else, there's a great FAQ page
at www.FreeBSD.org that describes the reasons behind some of these things in greater
detail. See the handbook.
Error message:
goldberg.cs.unc.edu(vanosdol)> ./prog.e
ELF binary type "0" not known.
Abort
Find the Binary Type of the Executable
To find out what type the file is, execute this command:
readelf -e prog.e
The output will look like this:
ELF Header:
  Magic:   7f 45 4c 46 01 01 01 03 00 00 00 00 00 00 00 00
  Class:                             ELF32
  Data:                              2's complement, little endian
  Version:                           1 (current)
  OS/ABI:                            UNIX - Linux
  ABI Version:                       0
  Type:                              EXEC (Executable file)
  Machine:                           Intel 80386
  Version:                           0x1
  Entry point address:               0x80480e0
  Start of program headers:          52 (bytes into file)
  Start of section headers:          758872 (bytes into file)
  Flags:                             0x0
  Size of this header:               52 (bytes)
  Size of program headers:           32 (bytes)
  Number of program headers:         3
  Size of section headers:           40 (bytes)
  Number of section headers:         22
  Section header string table index: 19
.... (cut) ..
The line that says: Version:   UNIX - Linux is the line you're interested in.
Find Out What Executable Types are Supported
brandelf -l
The output will look like this:
known ELF types are: FreeBSD(9) Linux(3) Solaris(6) SVR4(0)
So, in this cause the Linux type IS compatible. If you statically compile this on
swan.cs.unc.edu, for example, you will have an unsupported type in the output above,
and you'll need to change the type of the executable.
Change the Executable Type, if Necessary

To change the type of the executable to one of the above recognized types, execute
the following
brandelf -t Linux prog.e
The executable type will then be recognized and it will execute on the target FreeBSD
machine.
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/21862/showart_1786128.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP