LOOS+0 is PT_SCE_RELA
LOOS+0xfffff01 is PT_SCE_LIBVERSION
Offsets of segments here is not in ascending order and the same mapping used in SELF container.
But current implementation of elf_injector tool implicitly relies on ascending order of offsets when applying offset correction.
In my case when offsets of 2-nd PT_LOAD and 1-st PT_SCE_RELA were corrected, writing compressed PT_SCE_LIBVERSION segment could overwrite already written PT_LOAD/PT_SCE_RELA segments.
I implemented sorting of compressed segments by offsets before computing offset correction.
Here's structure of ELF segments in the file I was working with:
Program Headers: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align LOAD 0x0000e0 0x81000000 0x00000000 0x234c04 0x234c04 R E 0x10 LOAD 0x234cf0 0x81235000 0x00000000 0x0be60 0x3c918 RW 0x10 LOOS+0 0x242ce0 0x00000000 0x00000000 0x59040 0x00000 0x10 LOOS+0 0x29bd20 0x00000000 0x00000000 0x02d3c 0x00000 0x10 LOOS+0xfffff01 0x240b50 0x00000000 0x00000000 0x02186 0x00000 0x10
LOOS+0 is PT_SCE_RELA LOOS+0xfffff01 is PT_SCE_LIBVERSION
Offsets of segments here is not in ascending order and the same mapping used in SELF container. But current implementation of elf_injector tool implicitly relies on ascending order of offsets when applying offset correction. In my case when offsets of 2-nd PT_LOAD and 1-st PT_SCE_RELA were corrected, writing compressed PT_SCE_LIBVERSION segment could overwrite already written PT_LOAD/PT_SCE_RELA segments.
I implemented sorting of compressed segments by offsets before computing offset correction.