gdb/jit: fix jit-reader linetable integrity
Checks
Context |
Check |
Description |
linaro-tcwg-bot/tcwg_gdb_build--master-aarch64 |
success
|
Build passed
|
Commit Message
The custom linetable functionality in GDB's JIT Interface has been broken
since commit 1acc9dca423f78e44553928f0de839b618c13766.
In that commit, linetables were made independent from the objfile, which
requires objfile->section_offsets to be initialized. However, section_offsets
were never initialized in objfiles generated by GDB's JIT Interface
with custom jit-readers, leading to GDB crashes when stepping into JITed code
blocks with the following command already executed:
jit-reader-load libmygdbjitreader.so
This patch fixes the issue by initializing the minimum section_offsets required
for linetable parsing procedures.
---
gdb/jit.c | 2 ++
1 file changed, 2 insertions(+)
Comments
Sorry, forgot to put a v2 in the title, please ignore this one.
On 2024/12/23 00:31, Yang Liu wrote:
> The custom linetable functionality in GDB's JIT Interface has been broken
> since commit 1acc9dca423f78e44553928f0de839b618c13766.
>
> In that commit, linetables were made independent from the objfile, which
> requires objfile->section_offsets to be initialized. However, section_offsets
> were never initialized in objfiles generated by GDB's JIT Interface
> with custom jit-readers, leading to GDB crashes when stepping into JITed code
> blocks with the following command already executed:
>
> jit-reader-load libmygdbjitreader.so
>
> This patch fixes the issue by initializing the minimum section_offsets required
> for linetable parsing procedures.
> ---
> gdb/jit.c | 2 ++
> 1 file changed, 2 insertions(+)
>
> diff --git a/gdb/jit.c b/gdb/jit.c
> index 77d41bf86ba..21c17c145c9 100644
> --- a/gdb/jit.c
> +++ b/gdb/jit.c
> @@ -665,6 +665,8 @@ jit_object_close_impl (struct gdb_symbol_callbacks *cb,
>
> objfile *objfile = objfile::make (nullptr, current_program_space,
> objfile_name.c_str (), OBJF_NOT_FILENAME);
> + objfile->section_offsets.push_back (0);
> + objfile->sect_index_text = 0;
> objfile->per_bfd->gdbarch = priv_data->gdbarch;
>
> for (gdb_symtab &symtab : obj->symtabs)
@@ -665,6 +665,8 @@ jit_object_close_impl (struct gdb_symbol_callbacks *cb,
objfile *objfile = objfile::make (nullptr, current_program_space,
objfile_name.c_str (), OBJF_NOT_FILENAME);
+ objfile->section_offsets.push_back (0);
+ objfile->sect_index_text = 0;
objfile->per_bfd->gdbarch = priv_data->gdbarch;
for (gdb_symtab &symtab : obj->symtabs)