serge1 / ELFIO

ELFIO - ELF (Executable and Linkable Format) reader and producer implemented as a header only C++ library
http://serge1.github.io/ELFIO
MIT License
720 stars 155 forks source link

segmentation fault running example writer output #35

Closed zaitera closed 4 years ago

zaitera commented 5 years ago

G++ version 7.4 (tested on 8.4 too) Ubuntu version 16.04 (tested on 19 too) After

./configure

and

make

when i run ./writer from examples then

chmod +x hello_i386_32 

and always get segmentation fault when i run ./hello_i386_32 Any clues ?

labm1997 commented 5 years ago

In my computer I had to change all occurrences of 0x08048000 address to 0x08049000 and of 0x08048020 to 0x0804a000. Furthermore, I had to change 0x10 .data set_align size to 0x1000. As all addresses changed, I had to change the mov ecx,msg instruction to '\xB9', '\x00', '\xa0', '\x04', '\x08'

zaitera commented 5 years ago

I noticed these differences But then how can we guarantee portability to run the elf generator on other computers?

labm1997 commented 5 years ago

I don't know, I doing the same work as you. Let's hope it will work at Bruno's computer. I've seen in ELFIO documentation: "The elfio library takes care of the resulting binary file layout calculation. It does this on base of the provided memory image addresses and sizes. It is the user's responsibility to provide correct values for these parameters. Please refer to your OS (other execution environment or loader) manual for specific requirements related to executable ELF file attributes and/or mapping."

serge1 commented 5 years ago

Hi, I have tried to reproduce the issue on a system with the same compiler and Ubuntu versions and could not reproduce the issue. Would you please confirm that i386 32-bit support was installed on your Ubuntu system.