Where is the ELF moving information located?

Quoting “linkers and loaders” in the “Loaders” section

"moving the load time is much easier than moving the link time, because the whole program moves as a unit. [...] After reading the program in memory, the loader copes moving the elements in the object file and correcting the memory location indicated by the points"

Perhaps I misunderstood this point, and this is only in some architectures, but my question is: where in the ELF format it is indicated which elements should be moved during loading? How can I find this list?

+4
source share
1 answer

ELF. readelf --sections, , , REL . readelf --relocs. :

$ readelf --relocs /bin/ls

Relocation section '.rela.dyn' at offset 0x16c8 contains 5 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
00000061afd8  000c00000006 R_X86_64_GLOB_DAT 0000000000000000 __gmon_start__ + 0
00000061b540  006d00000005 R_X86_64_COPY     000000000061b540 optind + 0
00000061b548  006e00000005 R_X86_64_COPY     000000000061b548 optarg + 0
00000061b550  006a00000005 R_X86_64_COPY     000000000061b550 stderr + 0
00000061b560  006600000005 R_X86_64_COPY     000000000061b560 stdout + 0

Relocation section '.rela.plt' at offset 0x1740 contains 99 entries:
  Offset          Info           Type           Sym. Value    Sym. Name + Addend
00000061b000  000100000007 R_X86_64_JUMP_SLO 0000000000000000 strcoll + 0
00000061b008  000200000007 R_X86_64_JUMP_SLO 0000000000000000 mktime + 0
...

.rela.dyn , , .rela.plt , . , , . , PIC , -PIC-.

+6

Source: https://habr.com/ru/post/1546687/


All Articles