> > layout_section() called this: > > static long get_offset(unsigned long *size, Elf_Shdr *sechdr) > { > long ret; > > ret = ALIGN(*size, sechdr->sh_addralign ?: 1); > *size = ret + sechdr->sh_size; > return ret; > } > > From header: > > typedef struct { > Elf32_Word sh_name; > Elf32_Word sh_type; > Elf32_Word sh_flags; > Elf32_Addr sh_addr; > Elf32_Off sh_offset; > Elf32_Word sh_size; > Elf32_Word sh_link; > Elf32_Word sh_info; > Elf32_Word sh_addralign; > Elf32_Word sh_entsize; > } Elf32_Shdr; > > typedef struct elf64_shdr { > Elf64_Word sh_name; /* Section name, index in string tbl */ > Elf64_Word sh_type; /* Type of section */ > Elf64_Xword sh_flags; /* Miscellaneous section attributes */ > Elf64_Addr sh_addr; /* Section virtual addr at execution */ > Elf64_Off sh_offset; /* Section file offset */ > Elf64_Xword sh_size; /* Size of section in bytes */ > Elf64_Word sh_link; /* Index of another section */ > Elf64_Word sh_info; /* Additional section information */ > Elf64_Xword sh_addralign; /* Section alignment */ > Elf64_Xword sh_entsize; /* Entry size if section holds table */ > } Elf64_Shdr; > > Which I think is responsible for the alignment of the section in memory. > > Two thing: memory offset and file offset - u have to distinguish > between the two. fileoffset no alignment, but memory yes. So in > loading process, some empty spaces have to inserted. > > sechdr->sh_size==> this is physical file offset (from byte 0 of the file). > ret --> ****I THINK**** is trying to round up the current *size value > to the next alignment value, and then add this > Thanks, Peter for the wonderful explanation. I was curious how I would find the start and end of a section in memory of ".data" section. From the code, I believe it is sechdr->sh_addr (start). How to reach the end(in memory) since the field sechdr->sh_size is physical as per your explanation? Regards, Asim -- To unsubscribe from this list: send an email with "unsubscribe kernelnewbies" to ecartis@xxxxxxxxxxxx Please read the FAQ at http://kernelnewbies.org/FAQ