Skip to content

Commit

Permalink
Don't directly include zend_jit_gdb.c
Browse files Browse the repository at this point in the history
Compile the file separately and only include a header. There doesn't
seem to be a good reason to directly include the C file here, and
this ensures that there are no symbol clashes (see GH-7197).
  • Loading branch information
nikic committed Jun 28, 2021
1 parent b11785c commit 0e932f7
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ext/opcache/config.m4
Expand Up @@ -40,7 +40,7 @@ if test "$PHP_OPCACHE" != "no"; then

if test "$PHP_OPCACHE_JIT" = "yes"; then
AC_DEFINE(HAVE_JIT, 1, [Define to enable JIT])
ZEND_JIT_SRC="jit/zend_jit.c jit/zend_jit_vm_helpers.c"
ZEND_JIT_SRC="jit/zend_jit.c jit/zend_jit_gdb.c jit/zend_jit_vm_helpers.c"

dnl Find out which ABI we are using.
case $host_alias in
Expand Down
2 changes: 1 addition & 1 deletion ext/opcache/jit/zend_jit.c
Expand Up @@ -678,7 +678,7 @@ static int zend_jit_add_veneer(dasm_State *Dst, void *buffer, uint32_t ins, int
#include "jit/zend_jit_helpers.c"
#include "jit/zend_jit_disasm.c"
#ifndef _WIN32
# include "jit/zend_jit_gdb.c"
# include "jit/zend_jit_gdb.h"
# include "jit/zend_jit_perf_dump.c"
#endif
#ifdef HAVE_OPROFILE
Expand Down
17 changes: 9 additions & 8 deletions ext/opcache/jit/zend_jit_gdb.c
Expand Up @@ -23,6 +23,7 @@

#define HAVE_GDB

#include "zend_jit_gdb.h"
#include "zend_elf.h"
#include "zend_gdb.h"

Expand Down Expand Up @@ -484,12 +485,12 @@ static void zend_gdbjit_buildobj(zend_gdbjit_ctx *ctx, uint32_t sp_offset, uint3
ZEND_ASSERT(ctx->objsize < sizeof(zend_gdbjit_obj));
}

static int zend_jit_gdb_register(const char *name,
const zend_op_array *op_array,
const void *start,
size_t size,
uint32_t sp_offset,
uint32_t sp_adjustment)
int zend_jit_gdb_register(const char *name,
const zend_op_array *op_array,
const void *start,
size_t size,
uint32_t sp_offset,
uint32_t sp_adjustment)
{
zend_gdbjit_ctx ctx;

Expand All @@ -504,13 +505,13 @@ static int zend_jit_gdb_register(const char *name,
return zend_gdb_register_code(&ctx.obj, ctx.objsize);
}

static int zend_jit_gdb_unregister(void)
int zend_jit_gdb_unregister(void)
{
zend_gdb_unregister_all();
return 1;
}

static void zend_jit_gdb_init(void)
void zend_jit_gdb_init(void)
{
#if 0
/* This might enable registration of all JIT-ed code, but unfortunately,
Expand Down
37 changes: 37 additions & 0 deletions ext/opcache/jit/zend_jit_gdb.h
@@ -0,0 +1,37 @@
/*
+----------------------------------------------------------------------+
| Zend JIT |
+----------------------------------------------------------------------+
| Copyright (c) The PHP Group |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| https://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| license@php.net so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Authors: Dmitry Stogov <dmitry@php.net> |
| Xinchen Hui <laruence@php.net> |
+----------------------------------------------------------------------+
*/

#ifndef HAVE_ZEND_JIT_GDB_H
#define HAVE_ZEND_JIT_GDB_H

#include "zend_compile.h"

#define HAVE_GDB

int zend_jit_gdb_register(const char *name,
const zend_op_array *op_array,
const void *start,
size_t size,
uint32_t sp_offset,
uint32_t sp_adjustment);

int zend_jit_gdb_unregister(void);
void zend_jit_gdb_init(void);

#endif /* HAVE_ZEND_JIT_GDB_H */

0 comments on commit 0e932f7

Please sign in to comment.