taviso / loadlibrary

Porting Windows Dynamic Link Libraries to Linux
GNU General Public License v2.0
4.34k stars 378 forks source link

Segmentation fault at fixup_reloc #115

Open tiagoporsch opened 1 year ago

tiagoporsch commented 1 year ago

Hello, I'm trying to load a very simple DLL that just contains some string manipulation functions, however when I attempt to run my program it segfaults with

pelinker (fixup_reloc:390): fixup_block=0xf7f4c000, image=0xf7f48000
pelinker (fixup_reloc:391): fixup_block info: 1000 84
Segmentation fault

This is the all the code that runs before the segmentation fault:

struct pe_image image = {
    .entry  = NULL,
    .name   = "engine/SeedNKeyXcp.dll",
};
if (!pe_load_library(image.name, &image.image, &image.size))
    return 1;
link_pe_images(&image, 1);

How could I go about debugging this? Thank you.

cube0x8 commented 1 year ago

Can you share you DLL? It would make it easier to debug.

On Mon, 17 Oct 2022, 21:22 tiagoporsch, @.***> wrote:

Hello, I'm trying to load a very simple DLL that just contains some string manipulation functions, however when I attempt to run my program it segfaults with

pelinker (fixup_reloc:390): fixup_block=0xf7f4c000, image=0xf7f48000 pelinker (fixup_reloc:391): fixup_block info: 1000 84 Segmentation fault

This is the all the code that runs before the segmentation fault:

struct pe_image image = { .entry = NULL, .name = "engine/SeedNKeyXcp.dll", }; if (!pe_load_library(image.name, &image.image, &image.size)) return 1; link_pe_images(&image, 1);

How could I go about debugging this? Thank you.

— Reply to this email directly, view it on GitHub https://github.com/taviso/loadlibrary/issues/115, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABGW4SP3RQ74AK6VXSWC3ATWDWKOPANCNFSM6AAAAAARHKPHOQ . You are receiving this because you are subscribed to this thread.Message ID: @.***>

tiagoporsch commented 1 year ago

Of course. Here it is. SeedNKeyXcp.zip

tiagoporsch commented 1 year ago

I've fixed this issue by opening the DLL as O_RDWR and mapping it as PROT_READ | PROT_WRITE, in the function pe_load_library. However, I don't think this is the correct solution, as a segfault now occurs when I attempt to call a function from this DLL.