提交 2c90784a 编写于 作者: R Richard Henderson

tcg: Allow the debug_frame data structure to be constant

Adjust the FDE to point to the code_buffer after we've copied it
to the image, rather than requiring that the backend set it prior.
This allows the backend to use read-only storage for its data.
Signed-off-by: NRichard Henderson <rth@twiddle.net>
上级 011209e1
...@@ -86,8 +86,14 @@ typedef struct QEMU_PACKED { ...@@ -86,8 +86,14 @@ typedef struct QEMU_PACKED {
uintptr_t func_len; uintptr_t func_len;
} DebugFrameFDEHeader; } DebugFrameFDEHeader;
typedef struct QEMU_PACKED {
DebugFrameCIE cie;
DebugFrameFDEHeader fde;
} DebugFrameHeader;
static void tcg_register_jit_int(void *buf, size_t size, static void tcg_register_jit_int(void *buf, size_t size,
void *debug_frame, size_t debug_frame_size) const void *debug_frame,
size_t debug_frame_size)
__attribute__((unused)); __attribute__((unused));
/* Forward declarations for functions declared and used in tcg-target.c. */ /* Forward declarations for functions declared and used in tcg-target.c. */
...@@ -2777,7 +2783,8 @@ static int find_string(const char *strtab, const char *str) ...@@ -2777,7 +2783,8 @@ static int find_string(const char *strtab, const char *str)
} }
static void tcg_register_jit_int(void *buf_ptr, size_t buf_size, static void tcg_register_jit_int(void *buf_ptr, size_t buf_size,
void *debug_frame, size_t debug_frame_size) const void *debug_frame,
size_t debug_frame_size)
{ {
struct __attribute__((packed)) DebugInfo { struct __attribute__((packed)) DebugInfo {
uint32_t len; uint32_t len;
...@@ -2915,10 +2922,10 @@ static void tcg_register_jit_int(void *buf_ptr, size_t buf_size, ...@@ -2915,10 +2922,10 @@ static void tcg_register_jit_int(void *buf_ptr, size_t buf_size,
uintptr_t buf = (uintptr_t)buf_ptr; uintptr_t buf = (uintptr_t)buf_ptr;
size_t img_size = sizeof(struct ElfImage) + debug_frame_size; size_t img_size = sizeof(struct ElfImage) + debug_frame_size;
DebugFrameHeader *dfh;
img = g_malloc(img_size); img = g_malloc(img_size);
*img = img_template; *img = img_template;
memcpy(img + 1, debug_frame, debug_frame_size);
img->phdr.p_vaddr = buf; img->phdr.p_vaddr = buf;
img->phdr.p_paddr = buf; img->phdr.p_paddr = buf;
...@@ -2946,6 +2953,11 @@ static void tcg_register_jit_int(void *buf_ptr, size_t buf_size, ...@@ -2946,6 +2953,11 @@ static void tcg_register_jit_int(void *buf_ptr, size_t buf_size,
img->di.fn_low_pc = buf; img->di.fn_low_pc = buf;
img->di.fn_high_pc = buf + buf_size; img->di.fn_high_pc = buf + buf_size;
dfh = (DebugFrameHeader *)(img + 1);
memcpy(dfh, debug_frame, debug_frame_size);
dfh->fde.func_start = buf;
dfh->fde.func_len = buf_size;
#ifdef DEBUG_JIT #ifdef DEBUG_JIT
/* Enable this block to be able to debug the ELF image file creation. /* Enable this block to be able to debug the ELF image file creation.
One can use readelf, objdump, or other inspection utilities. */ One can use readelf, objdump, or other inspection utilities. */
...@@ -2973,7 +2985,8 @@ static void tcg_register_jit_int(void *buf_ptr, size_t buf_size, ...@@ -2973,7 +2985,8 @@ static void tcg_register_jit_int(void *buf_ptr, size_t buf_size,
and implement the internal function we declared earlier. */ and implement the internal function we declared earlier. */
static void tcg_register_jit_int(void *buf, size_t size, static void tcg_register_jit_int(void *buf, size_t size,
void *debug_frame, size_t debug_frame_size) const void *debug_frame,
size_t debug_frame_size)
{ {
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册