loadlibrary icon indicating copy to clipboard operation
loadlibrary copied to clipboard

Segmentation fault at fixup_reloc

Open tiagoporsch opened this issue 3 years ago • 3 comments

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.

tiagoporsch avatar Oct 17 '22 18:10 tiagoporsch

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: @.***>

cube0x8 avatar Oct 17 '22 20:10 cube0x8

Of course. Here it is. SeedNKeyXcp.zip

tiagoporsch avatar Oct 17 '22 20:10 tiagoporsch

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.

tiagoporsch avatar Oct 17 '22 22:10 tiagoporsch