1826322 Members
3748 Online
109692 Solutions
New Discussion

Is it 32 or 64?

 
SOLVED
Go to solution
devshlom
Regular Advisor

Is it 32 or 64?

Hi,
I'm working on HP-UX hpux B.11.23 RISC.
I'm creating some exe and shared libs.
Currently my system works on 64bit (I know that by running getconf $KERNEL_BITS
Is there any way/command such that I can get info about the specific executable or sl? (on all the other env, i can do it with the "file" command.

tx,
s
14 REPLIES 14
devshlom
Regular Advisor

Re: Is it 32 or 64?

Hi again,
I've read this:
http://unix.derkeiler.com/Mailing-Lists/HP-UX-Admin/2005-03/0019.html
Is it true when I run "file" on executable and get "PA-RISC2.0" then it's 64?

tx.
Vivek Bhatia
Trusted Contributor

Re: Is it 32 or 64?

Hi Dev,

Run a below command to check the bit

file Library_path

Regards,
Vivek

Re: Is it 32 or 64?

It's telling you its a PA-RISC rather than IA64 binary/library and yes is 64-bit.

When this binary runs, it will run run in the ARIES translation environment...

for more info see:

http://www.hp.com/go/aries

For native IA64 binaries, they will be marked as 64 or 32 bit from thye file command.

HTH

Duncan

I am an HPE Employee
Accept or Kudo
Dennis Handly
Acclaimed Contributor

Re: Is it 32 or 64?

>Is it true when I run "file" on executable and get "PA-RISC2.0" then it's 64?

No, not always. It has to say "LP64":
/stand/vmunix: ELF-64 executable object file - PA-RISC 2.0 (LP64)
/usr/lib/libc.sl: PA-RISC2.0 shared library -not stripped
devshlom
Regular Advisor

Re: Is it 32 or 64?

by the way,
when in my code I print "sizeof(long)" I accpect to get 8 if this is a 64bit, but I got 4.
what do you think? Is it even good check at all?

s.
devshlom
Regular Advisor

Re: Is it 32 or 64?

Hi Dennis,
long time... tx for the answer.
anyway, do you have some documentation for this (the LP64...)?

tx.
Dennis Handly
Acclaimed Contributor
Solution

Re: Is it 32 or 64?

>when in my code I print "sizeof(long)" I expect to get 8 if this is a 64bit, but I got 4.

If you want to compile with 64 bit, you need to use +DD64, for HP's compilers. The default is 32 bit.

>do you have some documentation for this (the LP64)?

What type of documentation? Porting or aC++ compiler options?
http://h21007.www2.hp.com/portal/site/dspp/menuitem.863c3e4cbcdc3f3515b49c108973a801/?ciid=2308852bcbe02110852bcbe02110275d6e10RCRD
devshlom
Regular Advisor

Re: Is it 32 or 64?

actually I'm just looking for some official documentation for what you said:
1. default is 32bit
2. 64bit only when "file " command rerurns LP64 in its output.

(I must have a reference to some HP official documentation...)

tx in advance.
s
devshlom
Regular Advisor

Re: Is it 32 or 64?

pls note that I'm using gcc compiler and not ac++

s.
James R. Ferguson
Acclaimed Contributor

Re: Is it 32 or 64?

Hi:

> actually I'm just looking for some official documentation for what you said:
1. default is 32bit
2. 64bit only when "file " command rerurns LP64 in its output.

If you look at the examples titled "PA-32 and IPF 32-bit mode example" and "PA-64 and IPF 64-bit mode example" in the Linker guide or in the Programmers guide:

http://docs.hp.com/en/14640/OnlineHelp/linkerdifferencesiapa.htm

http://docs.hp.com/en/B3901-90024/B3901-90024.pdf

...you can clearly see the you must use '+DD64' to create a 64-bit object. You will also see the +DD Data Module default is explicitly ILP32 mode.

Regards!

...JRF...



Steven E. Protter
Exalted Contributor

Re: Is it 32 or 64?

Shalom,

That is easy. 11.23 is a PA-RISC 64 bit only OS.

It is fully compatible with 32 bit applications.

The what, which and file command are going to reflect not the OS but how the file was compiled, created.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
James R. Ferguson
Acclaimed Contributor

Re: Is it 32 or 64?

Hi (again):

> actually I'm just looking for some official documentation for what you said:
2. 64bit only when "file " command rerurns LP64 in its output.

As noted several times, the 'file' command interprets this by examining a snippet of the file's contents and the contents of '/etc/magic':

http://docs.hp.com/en/B2355-60130/file.1.html

You might find it instructive to do:

# grep -E "PA|LP|EL" /etc/magic

...along with a 'file' command against your various executables.

Regards!

...JRF...
Dennis Handly
Acclaimed Contributor

Re: Is it 32 or 64?

>JRF: Y=$(( $Y+1 ))

You can "improve" these by removing the "$" by putting everything in (( )):
(( Y += 1 ))
Dennis Handly
Acclaimed Contributor

Re: Is it 32 or 64?

(Oops ignore my bogus reply to JRF above.)

>I'm just looking for some official documentation for what you said:
>1. default is 32bit

http://docs.hp.com/en/14487/options.htm#opt+DDdata_model
(gcc follows the HP-UX default.)

>2. 64bit only when "file " command returns LP64 in its output.

You aren't going to find this. About the best that can be done is the elfdump -f output:
$ elfdump -f /usr/lib/pa20_64/libc.sl
/usr/lib/pa20_64/libc.sl:
*** ELF Header ***
Class: ELF-64

It says "64" what more do you need?

>pls note that I'm using gcc compiler and not aC++

Then there is no official documentation.
For PA, you have to install separate 32 and 64 bit gcc compilers. For IPF, you can use -milp32 or -mlp64:
$ gcc -milp32 hi.c
$ file a.out
a.out: ELF-32 executable object file - IA64
$ gcc -mlp64 hi.c
$ file a.out
a.out: ELF-64 executable object file - IA64