tech-toolchain archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: fixing libffi on NetBSD



On Sun, Jan 29, 2017 at 12:25:30AM +0100, Thomas Klausner wrote:
> I've made a package for the latest GIT head in wip/libffi-git and
> opened an upstream bug report about this, see
> https://github.com/libffi/libffi/issues/294

It seems to not map its trampoline page executable, but I don't see
exactly where the code sets up the proper protection.

Reading symbols from ./a.out...done.
(gdb) run
Starting program: /usr/pkgobj/wip/libffi-git/work/libffi/testsuite/libffi.call/a.out 

Program received signal SIGSEGV, Segmentation fault.
0x00007f7ff7b01050 in ?? ()
(gdb) bt
#0  0x00007f7ff7b01050 in ?? ()
#1  0x0000000000400e90 in main () at closure_fn0.c:82
(gdb) up
#1  0x0000000000400e90 in main () at closure_fn0.c:82
82        res = (*((closure_test_type0)code))
(gdb) p code
$1 = (void *) 0x7f7ff7b01050
(gdb) x/16i 0x7f7ff7b01050
   0x7f7ff7b01050:      lea    -0x7(%rip),%r10        # 0x7f7ff7b01050
   0x7f7ff7b01057:      jmpq   *0x3(%rip)        # 0x7f7ff7b01060
   0x7f7ff7b0105d:      nopl   (%rax)

The call for that mapping is likely libffi/src/closures.c:

      kt =
        vm_remap (mach_task_self (), &trampoline_page, PAGE_MAX_SIZE, 0x0, FALSE,
                  mach_task_self (), trampoline_page_template, FALSE,   
                  &cur_prot, &max_prot, VM_INHERIT_SHARE);

but I can't find the vm_remap() function.

Martin


Home | Main Index | Thread Index | Old Index