6

.data と .bss のアラインメントは、4 バイトの場合もあれば 32 バイトの場合もあります。例 1: 以下の出力の最後の列によると、bss とデータのアラインメントは 32 バイトです。

bash-3.00$ readelf --sections libmodel.so
There are 39 section headers, starting at offset 0x1908a63c:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
...
  [25] .data             PROGBITS        01e221e0 1e211e0 26ca54 00  WA  0   0 32
  [26] .bss              NOBITS          0208ec40 208dc34 374178 00  WA  0   0 32
...

例 2: 以下の出力によると、アラインメント os .data および .bss は 4 バイトです。

bash-3.00$ readelf --sections ./a.out
There are 28 section headers, starting at offset 0x78c:

Section Headers:
  [Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
...
  [22] .data             PROGBITS        0804956c 00056c 000034 00  WA  0   0  4
  [23] .bss              NOBITS          080495a0 0005a0 000004 00  WA  0   0  4
...

.bss と .data のアラインメントは何によって決定されますか? 4 バイトの場合と 32 バイトの場合があるのはなぜですか?

4

4 に答える 4

0

There's a really nice book, that will give you a great understanding of not only your question, but everything related to it.

The website of the book is here

Chapter n. 7 is the one you are looking for.

I don't know if you want a straight answer, or a more sophisticated one, but I hope it helps.

于 2015-12-18T13:39:43.350 に答える