HP-UX HB v13.00 Ch-11 - Software Development

HP-UX Handbook Rev 13.00 Page 51 (of 101)
Chapter 11 Software Development
October 29, 2013
Static Information
file(1)
The file(1) command tries to determine the type of a file by checking magic(4) numbers. On
ascii files it analyzes the first lines and tries to guess a programming language, if any.
If you have compiled a C program named a.out which was compiled from a source file named
x.c, and which unfortunately aborted with a coredump, file(1) will give an output similar to
the following:
$ file x.c x.o a.out core
On PA:
x.c: c program text
x.o: PA-RISC2.0 relocatable object
a.out: PA-RISC2.0 shared executable dynamically linked not stripped
core: core file from 'a.out' - received SIGBUS
On IA:
x.c: c program text
x.o: ELF-32 relocatable object file - IA64
a.out: ELF-32 executable object file - IA64
core: ELF-32 core file - IA64 from 'a.out' - received SIGBUS
The output for the core file is epecially interesting, because it provides information on what
happened. It tells you:
Which program generated the core file
Why the core file was generated (which signal was received)
file(1) belongs to the unix core commands.
what(1)
what(1) can be used to find out the version of a file. It belongs to SCCS. Every file shipped by
HP that requires versioning contains a text that can be printed by the what(1) command. A
what-string can be added to any file. It is simply a character string that starts with "@(#)" to be
recognized by what(1).
If you add the line
char ident[] = "@(#) x.c version 0.1 from Jan 04 2002";
to a C program source file, compile and run it, the what string will be in every file created from
it, even in a coredump: