1
[Nr] Name              Type            Addr     Off    Size   ES Flg Lk Inf Al
[ 1] .text             PROGBITS        00000000 000034 00002a 00  AX  0   0  4

上記の通り0x34番地から始まるセグメントですが、Alが4なので2**4では割り切れません。

つまり: 0x34 % 16 != 0.だから、.text セグメントのアドレスが 16 の整数倍から始まらない理由を尋ねたいと思います。

4

1 に答える 1

1

セクション ヘッダーの構造体は次のようになります。

typedef struct {
   uint32_t   sh_name;
   uint32_t   sh_type;
   uint32_t   sh_flags;
   Elf32_Addr sh_addr;
   Elf32_Off  sh_offset;
   uint32_t   sh_size;
   uint32_t   sh_link;
   uint32_t   sh_info;
   uint32_t   sh_addralign;
   uint32_t   sh_entsize;
} Elf32_Shdr;

したがって、Al列の下に表示されるのはsh_addralignです。elf manpageからそのメンバーの説明を見てみましょう:

sh_addralign
             Some sections have address alignment constraints.  If a
             section holds a doubleword, the system must ensure
             doubleword alignment for the entire section.  That is, the
             value of sh_addr must be congruent to zero, modulo the
             value of sh_addralign.  Only zero and positive integral
             powers of two are allowed.  Values of zero or one mean the
             section has no alignment constraints.

TL;DRAl :列に表示されている配置制約はAddr(ゼロであるため、このケースでは配置されています) 用であり、 用ではありませんOff。つまり、イメージがメモリにロードされるアドレスのアライメント制約であり、ELF ファイルにイメージが格納されている場所ではありません。

于 2013-05-24T06:31:59.670 に答える