Operating System - Linux
1828355 Members
3233 Online
109976 Solutions
New Discussion

Re: Which command can be used to check a executable file's static memory size?

 
SOLVED
Go to solution
MA Qiang
Regular Advisor

Which command can be used to check a executable file's static memory size?

Thanks.
7 REPLIES 7
Bill Hassell
Honored Contributor
Solution

Re: Which command can be used to check a executable file's static memory size?

Beleive it or not, the command is called size. As in:

size /usr/bin/fbackup

You can also get details with chatr:

chatr /usr/bin/frecover


Bill Hassell, sysadmin
MA Qiang
Regular Advisor

Re: Which command can be used to check a executable file's static memory size?

What is the unit of section sizes?
Dennis Handly
Acclaimed Contributor

Re: Which command can be used to check a executable file's static memory size?

>What is the unit of section sizes?

If you read size(1), you'll see it's in decimal bytes, unless you use -x for hex.
MA Qiang
Regular Advisor

Re: Which command can be used to check a executable file's static memory size?

I have a c program:
> cat testmem.c
#include

void main()
{
float b[67106210];
b[1]=20.0;
printf("%f\n", b[1]);
}

The array size is about 67106210*4=268,424,840Bytest.

After compiled (cc testmem.c -o testmem.out'), I got testmem.out.

> size testmem.out
text data bss dec hex filename
7662 128 84 7874 1ec2 testmem.out

> size -x testmem.out
text data bss dec hex filename
0x1dee 0x80 0x54 7874 1ec2 testmem.out

How to find 268,424,840 in the output of size?
Dennis Handly
Acclaimed Contributor

Re: Which command can be used to check a executable file's static memory size?

>How to find 268,424,840 in the output of size?

You can't. That isn't a "static" size since auto variables are allocated on the stack. If you move it to file scope, you'll see it.

>void main()

This is illegal, it must be "int main()".
MA Qiang
Regular Advisor

Re: Which command can be used to check a executable file's static memory size?

I modified the source:
#include

float b[67108863];

int main()
{
b[1]=20.0;
printf("%f\n", b[1]);
return 1;
}

then I got the output of size:
> size testmem.out
text data bss dec hex filename
7650 128 268435556 268443334 10001ec6 testmem.out

Thanks.
Dennis Handly
Acclaimed Contributor

Re: Which command can be used to check a executable file's static memory size?

>return 1;

To return success, you return 0.

If you really want to know the frame sizes, you could look at:
/usr/ccs/bin/odump -unwind a.out
(You take the hex size and multiply by 8.)

For ELF files:
/usr/ccs/bin/elfdump -U a.out
(For PA64, hex size * 8. For IPF, it doesn't appear to be listed and you would have to disassemble the code.)