tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

ELF load sections



Hi,

I'm trying to speed up the exec path. I notice that for programs, the data
the kernel is interested in is usually in the first page of the binary:

# readelf -l /bin/sh                      

Elf file type is EXEC (Executable file)
Entry point 0x8049d90
There are 7 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  PHDR           0x000034 0x08048034 0x08048034 0x000e0 0x000e0 R E 0x4
  INTERP         0x000114 0x08048114 0x08048114 0x00013 0x00013 R   0x1
      [Requesting program interpreter: /libexec/ld.elf_so]
  LOAD           0x000000 0x08048000 0x08048000 0x1abbc 0x1abbc R E 0x1000
  LOAD           0x01b000 0x08063000 0x08063000 0x004bc 0x01bac RW  0x1000
  DYNAMIC        0x01b014 0x08063014 0x08063014 0x000c8 0x000c8 RW  0x4
  NOTE           0x000128 0x08048128 0x08048128 0x00018 0x00018 R   0x4
  NOTE           0x000140 0x08048140 0x08048140 0x00014 0x00014 R   0x4

It's explained by this comment:

http://nxr.netbsd.org/source/xref/gnu/dist/binutils/ld/emultempl/elf32.em#1375

However for the dyanmic linker and shared libraries (which don't have an
.interp section), they are at the end of the file:

# readelf -l /libexec/ld.elf_so                                                 
                                                                                
              

Elf file type is DYN (Shared object file)
Entry point 0x2730
There are 5 program headers, starting at offset 52

Program Headers:
  Type           Offset   VirtAddr   PhysAddr   FileSiz MemSiz  Flg Align
  LOAD           0x000000 0x00000000 0x00000000 0x0baf0 0x0baf0 R E 0x1000
  LOAD           0x00bb00 0x0000cb00 0x0000cb00 0x00b88 0x0138c RW  0x1000
  DYNAMIC        0x00c4f8 0x0000d4f8 0x0000d4f8 0x00078 0x00078 RW  0x4
  NOTE           0x00bac4 0x0000bac4 0x0000bac4 0x00018 0x00018 R   0x4
  NOTE           0x00badc 0x0000badc 0x0000badc 0x00014 0x00014 R   0x4

Does anyone know what's going on there?

Thanks,
Andrew


Home | Main Index | Thread Index | Old Index