LIEF icon indicating copy to clipboard operation
LIEF copied to clipboard

Failed when modifying `ld.so`

Open Yangff opened this issue 2 years ago • 1 comments

Describe the bug Just parse and write ld.so cause it stops to work

To Reproduce

[yangff@Yangff-Laptop tests]$ cp /lib64/ld-linux-x86-64.so.2 ./ld.so
[yangff@Yangff-Laptop tests]$ python
Python 3.10.4 (main, Mar 23 2022, 23:05:40) [GCC 11.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import lief
>>> lief.parse('ld.so').write('ld1.so')
>>> exit()
[yangff@Yangff-Laptop tests]$ chmod +x ./ld1.so
[yangff@Yangff-Laptop tests]$ ./ld1.so
Inconsistency detected by ld.so: ../sysdeps/x86_64/dl-machine.h: 534: elf_machine_rela_relative: Assertion `ELFW(R_TYPE) (reloc->r_info) == R_X86_64_RELATIVE' failed!

Expected behavior

[yangff@Yangff-Laptop tests]$ ./ld.so
./ld.so: missing program name
Try './ld.so --help' for more information.

Environment (please complete the following information):

  • WSL2 with archlinux, ld.so (GNU libc) stable release version 2.35.
  • ELF
  • LIEF commit version: 0.12.1-c7b3ce3b

Additional context Add any other context about the problem here.

Yangff avatar Jul 03 '22 20:07 Yangff

Modifying ld.so is challenging :)

romainthomas avatar Jul 14 '22 13:07 romainthomas