c – 在objdump的输出中,2 ** 2和2 ** 0的“Algn”是什么意思?
这在下面的文件中意味着什么? 2 ** 2和2 ** 0
$objdump -h main.o main.o: file format elf32-i386 Sections: Idx Name Size VMA LMA File off Algn 0 .text 0000000b 00000000 00000000 00000034 2**2 CONTENTS,ALLOC,LOAD,READONLY,CODE 1 .data 00000000 00000000 00000000 00000040 2**2 CONTENTS,DATA 2 .bss 00000000 00000000 00000000 00000040 2**2 ALLOC 3 .note.GNU-stack 00000000 00000000 00000000 00000040 2**0 CONTENTS,CODE 解决方法
我假设2 ** 2表示22或4字节对齐,而2 ** 0表示没有(一个字节)对齐.
此值来自ELF节标题的sh_addralign字段. ELF specification州(强调我的):
作为Ray Toal mentioned,由于对齐必须是2的幂,所以只有objdump将这个值用2 ** x表示法表示为2的幂才有意义. 请注意,在某些语言中,例如Python和FORTRAN,**是幂或取幂运算符. 看看 static void dump_section_header (bfd *abfd,asection *section,void *ignored ATTRIBUTE_UNUSED) { // ... printf (" %08lx 2**%u",(unsigned long) section->filepos,bfd_get_section_alignment (abfd,section)); 并在 #define bfd_get_section_alignment(bfd,ptr) ((ptr)->alignment_power + 0) bfd的alignment_power成员是: /* The alignment requirement of the section,as an exponent of 2 - e.g.,3 aligns to 2^3 (or 8). */ unsigned int alignment_power; (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |