What does "Algn" 2 ** 2 and 2 ** 0 mean in objdump output?

What does this mean in the bottom file? 2**2and2**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, ALLOC, LOAD, DATA
  2 .bss          00000000  00000000  00000000  00000040  2**2
                  ALLOC
  3 .note.GNU-stack 00000000  00000000  00000000  00000040  2**0
                  CONTENTS, READONLY, CODE
+3
source share
1 answer

I would suggest that it 2**2means 2 2 or alignment of 4 bytes, and 2**0means the absence of (one byte) alignment.

This value comes from the sh_addralignheader field of the ELF section. ELF specification states (primary focus):

sh_addralign . , , . sh_addr 0, sh_addralign. 0 . 0 1 , .

, , , objdump 2**x.

, , Python FORTRAN, ** - .


objdump.c, :

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));

objdump.h:

#define bfd_get_section_alignment(bfd, ptr) ((ptr)->alignment_power + 0)

alignment_power bfd:

/* The alignment requirement of the section, as an exponent of 2 -
   e.g., 3 aligns to 2^3 (or 8). */

unsigned int alignment_power;

+7

All Articles