$objdump -h main.omain.o: file format elf32-i386Sections: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解决方法@H_301_15@ 我假设2 ** 2表示22或4字节对齐,而2 ** 0表示没有(一个字节)对齐.
此值来自ELF节标题的sh_addralign字段. ELF specification州(强调我的):
sh_addralign
Some sections have address alignment constraints. For example,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 0,modulo the value of
sh_addralign. Currently,only 0 and positive integral powers of two are allowed.
Values 0 and 1 mean the section has no alignment constraints.
作为Ray Toal mentioned,由于对齐必须是2的幂,所以只有objdump将这个值用2 ** x表示法表示为2的幂才有意义.
请注意,在某些语言中,例如Python和FORTRAN,**是幂或取幂运算符.
看看objdump.c
,我们看到:
static voIDdump_section_header (bfd *abfd,asection *section,voID *ignored ATTRIBUTE_UNUSED){ // ... printf (" %08lx 2**%u",(unsigned long) section->filepos,bfd_get_section_alignment (abfd,section));
并在objdump.h
:
#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;总结
以上是内存溢出为你收集整理的c – 在objdump的输出中,2 ** 2和2 ** 0的“Algn”是什么意思?全部内容,希望文章能够帮你解决c – 在objdump的输出中,2 ** 2和2 ** 0的“Algn”是什么意思?所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)