From: Frank T. <fra...@ts...> - 2015-02-11 18:23:28
|
Dear all, I am facing an issue while adding a new section to an existing ELF binary for the ARM platform. For some reason the already contained dynamic section of the ELF binary is somehow assigned to the wrong segment after updating the ELF binary (elf_update). If the command "readelf -l" is used on the unmodified ELF binary (shared object), it results in the following output: --------------------- readelf -l mylib.so Header: Typ Offset VirtAdr PhysAdr DateiGr SpeiGr Flg Ausr. EXIDX 0x127b3c 0x00127b3c 0x00127b3c 0x01490 0x01490 R 0x4 PHDR 0x000034 0x00000034 0x00000034 0x00140 0x00140 R E 0x4 INTERP 0x126e2c 0x00126e2c 0x00126e2c 0x00014 0x00014 R 0x4 LOAD 0x000000 0x00000000 0x00000000 0x12c23c 0x12c23c R E 0x8000 LOAD 0x12c6cc 0x001346cc 0x001346cc 0x02748 0x04ecc RW 0x8000 DYNAMIC 0x12df28 0x00135f28 0x00135f28 0x000d8 0x000d8 RW 0x4 NOTE 0x000174 0x00000174 0x00000174 0x00020 0x00020 R 0x4 TLS 0x12c6cc 0x001346cc 0x001346cc 0x00008 0x0004c R 0x4 GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x4 GNU_RELRO 0x12c6cc 0x001346cc 0x001346cc 0x01934 0x01934 R 0x1 ... 00 .ARM.exidx 01 02 .interp 03 .note.ABI-tag .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_d .gnu.version_r .rel.dyn .rel.plt .plt .text __libc_freeres_fn __libc_thread_freeres_fn .rodata .interp .ARM.extab .ARM.exidx .eh_frame .hash 04 .tdata __libc_subfreeres __libc_atexit __libc_thread_subfreeres .data.rel.ro .dynamic .got .data .bss 05 .dynamic 06 .note.ABI-tag 07 .tdata .tbss 08 09 .tdata __libc_subfreeres __libc_atexit __libc_thread_subfreeres .data.rel.ro .dynamic --------------------- After adding the new section and updating the ELF binary, the command raises the warning '.dynamic section is not contained within the dynamic segment' and the output is as follows: --------------------- readelf -l mylib.so Header: Typ Offset VirtAdr PhysAdr DateiGr SpeiGr Flg Ausr. EXIDX 0x127b3c 0x00127b3c 0x00127b3c 0x01490 0x01490 R 0x4 PHDR 0x000034 0x00000034 0x00000034 0x00140 0x00140 R E 0x4 INTERP 0x126e2c 0x00126e2c 0x00126e2c 0x00014 0x00014 R 0x4 LOAD 0x000000 0x00000000 0x00000000 0x12c23c 0x12c23c R E 0x8000 LOAD 0x12c6cc 0x001346cc 0x001346cc 0x02748 0x04ecc RW 0x8000 DYNAMIC 0x12df28 0x00135f28 0x00135f28 0x000d8 0x000d8 RW 0x4readelf: Warning: the .dynamic section is not contained within the dynamic segment NOTE 0x000174 0x00000174 0x00000174 0x00020 0x00020 R 0x4 TLS 0x12c6cc 0x001346cc 0x001346cc 0x00008 0x0004c R 0x4 GNU_STACK 0x000000 0x00000000 0x00000000 0x00000 0x00000 RW 0x4 GNU_RELRO 0x12c6cc 0x001346cc 0x001346cc 0x01934 0x01934 R 0x1 ... 00 .ARM.exidx 01 02 .interp 03 .note.ABI-tag .gnu.hash .dynsym .dynstr .gnu.version .gnu.version_d .gnu.version_r .rel.dyn .rel.plt .plt .text __libc_freeres_fn __libc_thread_freeres_fn .rodata .interp .ARM.extab .ARM.exidx .eh_frame .hash 04 .dynamic .got .data .bss .ARM.attributes .shstrtab 05 06 .note.ABI-tag 07 .tbss 08 09 .dynamic --------------------- In contrast to the original file the ELF section '.dynamic', which should be contained within segment no 5 (DYNAMIC), is contained within segment no 4 (LOAD). Some other sections even seem to be mixed up or missing compared to the original ELF binary. As a result all programs using this library are crashing. Any hints? Regards, Frank |