より大きな問題を理解しようとしている間、私は少しテストを実行しています。これが私のテスト環境です:
head.h:
#define MAX_BUFSIZE 500
typedef struct {
int head;
int tail;
int status;
int active;
void * dev[MAX_BUFSIZE];
char free[MAX_BUFSIZE];
int count;
} msg_fifo_t;
extern msg_fifo_t TxBufx[];
extern msg_fifo_t Rx_Buf[];
test.c:
#include <stdio.h>
#include "head.h"
//msg_fifo_t TxBufx[10]; // This is the important line
int main(int argc, char * argv[])
{
// This part isn't really important...
printf("Hello Test\n");
return 0;
}
そこで、これらのファイルを使用して3つのテストを実行し、取得したサイズを確認しました-
テスト#1(上記のコード):
> gcc -Os test.c
> ls -al a.out
-rwxrwxr-x 1 mike mike 7158 Jan 17 11:13 a.out
> size a.out
text data bss dec hex filename
1170 256 8 1434 59a a.out
テスト#2(「重要な」行のコメントを外す):
> gcc -Os test.c
> ls -al a.out
-rwxrwxr-x 1 mike mike 7181 Jan 17 11:14 a.out
> size a.out
text data bss dec hex filename
1170 256 25208 26634 680a a.out
テスト#3(「重要な」行のコメントを外し、TxBufx
サイズを100に変更します)
> gcc -Os test.c
> ls -al a.out
-rwxrwxr-x 1 mike mike 7181 Jan 17 11:14 a.out
> size a.out
text data bss dec hex filename
1170 256 252008 253434 3ddfa a.out
だから今私の質問:
bssサイズは、実行可能ファイルの「サイズ」とはほとんど関係がないように見えます(
ls -al
コマンドから報告されたとおり)-誰かが私にそれがなぜであるかを説明できますか?その特性はコンパイラ/リンカー/またはプラットフォームに固有ですか?
size
ここで何が起こっているのかを理解するよりも優れたツールはありますか?(私の実行可能ファイルである7181バイトを実際に構成しているのは何ですか?)