English 中文(简体)
query on unix executables
原标题:

This might be a basic question but i wanted to ask since i am not aware about it.

if i have a binary file which was was created on HP-UX and suddenly i take this binary file on linux or let s say in any other platform like AIX or sun solaris and if i want to check about the details of the binary as to in which platform it was developed,how could i do it on any platform ?or is there a generic way doit it on all the flavour s of unix?

最佳回答

The file command gives you some information about any file, not only executables.

On executables, it gives results such as:

MS Windows PE 32-bit Intel 80386 console executable not relocatable

or

ELF 32-bit MSB executable, SPARC, version 1 (SYSV), statically linked, not stripped

问题回答

Depending on how it was configured, binutils objdump can be used on a wide variety of binary formats.

$ objdump -f flex/bin/flashplayer

flex/bin/flashplayer:     file format elf32-i386
architecture: i386, flags 0x00000112:
EXEC_P, HAS_SYMS, D_PAGED
start address 0x0804fb20

$ objdump -f flex/bin/adl
In archive flex/bin/adl:

flex/bin/adl:powerpc:common:     file format mach-o-be
architecture: powerpc:common, flags 0x00000012:
EXEC_P, HAS_SYMS
start address 0x00001c88


flex/bin/adl:i386:     file format mach-o-i386
architecture: i386, flags 0x00000012:
EXEC_P, HAS_SYMS
start address 0x00001e64

$ objdump -f flex/bin/adl.exe

flex/bin/adl.exe:     file format pei-i386
architecture: i386, flags 0x0000012f:
HAS_RELOC, EXEC_P, HAS_LINENO, HAS_DEBUG, HAS_LOCALS, D_PAGED
start address 0x004014c0

That s a Linux x86 ELF binary, a fat PPC and x86 Mach-O binary, and a Windows executable, just to give some examples.





相关问题
Generate assembler code from C file in linux

I would like to know how to generate assembler code from a C program using Unix. I tried the gcc: gcc -c file.c I also used firstly cpp and then try as but I m getting errors. I m trying to build an ...

Function to create the array by reading the file

I am creating scripts which will store the contents of pipe delimited file. Each column is stored in a separate array. I then read the information from the arrays and process it. There are 20 pipe ...

Compare characters at the end of the string C++

This program supposed to find command line arguments entered on Unix which ends with “.exe”. For some reason it doesn t work. Here is the code: int main( int argc, char* argv[] ) { for ( int ...

Batch Job Dependencies Using Open Source/Free Software

I run a large data warehouse plant where we have a lot of nightly jobs running concerruently however many have dependencies on a extract or data load process before they start. Currently we use an ...

Writing application for both Unix and Windows

I ll write a program for Interactive UNIX (http://en.wikipedia.org/wiki/INTERACTIVE_UNIX). But in a year it will be ported to Windows. I ll write it in ANSI C and/or SH-script. When it runs on Windows ...

Development Environment in Windows [closed]

What are your recommendations for setting up a development environment in Windows, especially when not using an IDE. I am attempting to familiarize myself with Windows, and I feel a bit lost. What ...

热门标签