|
|
a5e32e |
From d9947f2dc0c2cd812f8e64380d5f6f53705a5280 Mon Sep 17 00:00:00 2001
|
|
|
a5e32e |
From: Mark Wielaard <mark@klomp.org>
|
|
|
a5e32e |
Date: Tue, 19 Jan 2021 04:12:33 +0100
|
|
|
a5e32e |
Subject: [PATCH 6/6] debugedit: Handle DWARF-5 debug_line and debug_line_str.
|
|
|
a5e32e |
|
|
|
a5e32e |
Handle the new DWARF5 .debug_line tables and the new DW_FORM_line_strp.
|
|
|
a5e32e |
DWARF5 tables are handled separately from the earlier tables. They
|
|
|
a5e32e |
will never change size, but they do need updates to the .debug_str
|
|
|
a5e32e |
or .debug_line_str references.
|
|
|
a5e32e |
|
|
|
a5e32e |
Based on a patch from Jan Kratochvil <jan.kratochvil@redhat.com>
|
|
|
a5e32e |
---
|
|
|
a5e32e |
tools/debugedit.c | 471 ++++++++++++++++++++++++++++++++++++++++------
|
|
|
a5e32e |
1 file changed, 410 insertions(+), 61 deletions(-)
|
|
|
a5e32e |
|
|
|
a5e32e |
diff --git a/tools/debugedit.c b/tools/debugedit.c
|
|
|
a5e32e |
index be5fee85b..d6a0058e9 100644
|
|
|
a5e32e |
--- a/tools/debugedit.c
|
|
|
a5e32e |
+++ b/tools/debugedit.c
|
|
|
a5e32e |
@@ -103,6 +103,8 @@ static bool need_string_replacement = false;
|
|
|
a5e32e |
/* Whether we need to do any updates of the string indexes (DW_FORM_strp)
|
|
|
a5e32e |
in debug_info for string indexes. */
|
|
|
a5e32e |
static bool need_strp_update = false;
|
|
|
a5e32e |
+/* Likewise for DW_FORM_line_strp. */
|
|
|
a5e32e |
+static bool need_line_strp_update = false;
|
|
|
a5e32e |
/* If the debug_line changes size we will need to update the
|
|
|
a5e32e |
DW_AT_stmt_list attributes indexes in the debug_info. */
|
|
|
a5e32e |
static bool need_stmt_update = false;
|
|
|
a5e32e |
@@ -192,7 +194,7 @@ typedef struct
|
|
|
a5e32e |
const char *filename;
|
|
|
a5e32e |
int lastscn;
|
|
|
a5e32e |
size_t phnum;
|
|
|
a5e32e |
- struct strings strings;
|
|
|
a5e32e |
+ struct strings debug_str, debug_line_str;
|
|
|
a5e32e |
struct debug_lines lines;
|
|
|
a5e32e |
GElf_Shdr shdr[0];
|
|
|
a5e32e |
} DSO;
|
|
|
a5e32e |
@@ -553,10 +555,11 @@ setup_relbuf (DSO *dso, debug_section *sec, int *reltype)
|
|
|
a5e32e |
/* Relocations against section symbols are uninteresting in REL. */
|
|
|
a5e32e |
if (dso->shdr[i].sh_type == SHT_REL && sym.st_value == 0)
|
|
|
a5e32e |
continue;
|
|
|
a5e32e |
- /* Only consider relocations against .debug_str, .debug_line
|
|
|
a5e32e |
- and .debug_abbrev. */
|
|
|
a5e32e |
+ /* Only consider relocations against .debug_str, .debug_line,
|
|
|
a5e32e |
+ .debug_line_str, and .debug_abbrev. */
|
|
|
a5e32e |
if (sym.st_shndx != debug_sections[DEBUG_STR].sec
|
|
|
a5e32e |
&& sym.st_shndx != debug_sections[DEBUG_LINE].sec
|
|
|
a5e32e |
+ && sym.st_shndx != debug_sections[DEBUG_LINE_STR].sec
|
|
|
a5e32e |
&& sym.st_shndx != debug_sections[DEBUG_ABBREV].sec)
|
|
|
a5e32e |
continue;
|
|
|
a5e32e |
rela.r_addend += sym.st_value;
|
|
|
a5e32e |
@@ -768,6 +771,7 @@ no_memory:
|
|
|
a5e32e |
|| (form > DW_FORM_flag_present
|
|
|
a5e32e |
&& !(form == DW_FORM_ref_sig8
|
|
|
a5e32e |
|| form == DW_FORM_data16
|
|
|
a5e32e |
+ || form == DW_FORM_line_strp
|
|
|
a5e32e |
|| form == DW_FORM_implicit_const
|
|
|
a5e32e |
|| form == DW_FORM_addrx
|
|
|
a5e32e |
|| form == DW_FORM_loclistx
|
|
|
a5e32e |
@@ -1049,17 +1053,20 @@ string_find_entry (struct strings *strings, size_t old_idx)
|
|
|
a5e32e |
a replacement file string has been recorded for it, otherwise
|
|
|
a5e32e |
returns false. */
|
|
|
a5e32e |
static bool
|
|
|
a5e32e |
-record_file_string_entry_idx (struct strings *strings, size_t old_idx)
|
|
|
a5e32e |
+record_file_string_entry_idx (bool line_strp, DSO *dso, size_t old_idx)
|
|
|
a5e32e |
{
|
|
|
a5e32e |
+ struct strings *strings = line_strp ? &dso->debug_line_str : &dso->debug_str;
|
|
|
a5e32e |
bool ret = false;
|
|
|
a5e32e |
struct stridxentry *entry = string_find_new_entry (strings, old_idx);
|
|
|
a5e32e |
if (entry != NULL)
|
|
|
a5e32e |
{
|
|
|
a5e32e |
- if (old_idx >= debug_sections[DEBUG_STR].size)
|
|
|
a5e32e |
- error (1, 0, "Bad string pointer index %zd", old_idx);
|
|
|
a5e32e |
+ debug_section *sec = &debug_sections[line_strp
|
|
|
a5e32e |
+ ? DEBUG_LINE_STR : DEBUG_STR];
|
|
|
a5e32e |
+ if (old_idx >= sec->size)
|
|
|
a5e32e |
+ error (1, 0, "Bad string pointer index %zd (%s)", old_idx, sec->name);
|
|
|
a5e32e |
|
|
|
a5e32e |
Strent *strent;
|
|
|
a5e32e |
- const char *old_str = (char *)debug_sections[DEBUG_STR].data + old_idx;
|
|
|
a5e32e |
+ const char *old_str = (char *)sec->data + old_idx;
|
|
|
a5e32e |
const char *file = skip_dir_prefix (old_str, base_dir);
|
|
|
a5e32e |
if (file == NULL)
|
|
|
a5e32e |
{
|
|
|
a5e32e |
@@ -1103,15 +1110,18 @@ record_file_string_entry_idx (struct strings *strings, size_t old_idx)
|
|
|
a5e32e |
base_dir with dest_dir, just records the existing string associated
|
|
|
a5e32e |
with the index. */
|
|
|
a5e32e |
static void
|
|
|
a5e32e |
-record_existing_string_entry_idx (struct strings *strings, size_t old_idx)
|
|
|
a5e32e |
+record_existing_string_entry_idx (bool line_strp, DSO *dso, size_t old_idx)
|
|
|
a5e32e |
{
|
|
|
a5e32e |
+ struct strings *strings = line_strp ? &dso->debug_line_str : &dso->debug_str;
|
|
|
a5e32e |
struct stridxentry *entry = string_find_new_entry (strings, old_idx);
|
|
|
a5e32e |
if (entry != NULL)
|
|
|
a5e32e |
{
|
|
|
a5e32e |
- if (old_idx >= debug_sections[DEBUG_STR].size)
|
|
|
a5e32e |
- error (1, 0, "Bad string pointer index %zd", old_idx);
|
|
|
a5e32e |
+ debug_section *sec = &debug_sections[line_strp
|
|
|
a5e32e |
+ ? DEBUG_LINE_STR : DEBUG_STR];
|
|
|
a5e32e |
+ if (old_idx >= sec->size)
|
|
|
a5e32e |
+ error (1, 0, "Bad string pointer index %zd (%s)", old_idx, sec->name);
|
|
|
a5e32e |
|
|
|
a5e32e |
- const char *str = (char *)debug_sections[DEBUG_STR].data + old_idx;
|
|
|
a5e32e |
+ const char *str = (char *)sec->data + old_idx;
|
|
|
a5e32e |
Strent *strent = strtab_add_len (strings->str_tab,
|
|
|
a5e32e |
str, strlen (str) + 1);
|
|
|
a5e32e |
if (strent == NULL)
|
|
|
a5e32e |
@@ -1244,13 +1254,28 @@ get_line_table (DSO *dso, size_t off, struct line_table **table)
|
|
|
a5e32e |
|
|
|
a5e32e |
/* version */
|
|
|
a5e32e |
t->version = read_16 (ptr);
|
|
|
a5e32e |
- if (t->version != 2 && t->version != 3 && t->version != 4)
|
|
|
a5e32e |
+ if (t->version != 2 && t->version != 3 && t->version != 4 && t->version != 5)
|
|
|
a5e32e |
{
|
|
|
a5e32e |
error (0, 0, "%s: DWARF version %d unhandled", dso->filename,
|
|
|
a5e32e |
t->version);
|
|
|
a5e32e |
return false;
|
|
|
a5e32e |
}
|
|
|
a5e32e |
|
|
|
a5e32e |
+ if (t->version >= 5)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ /* address_size */
|
|
|
a5e32e |
+ assert (ptr_size != 0);
|
|
|
a5e32e |
+ if (ptr_size != read_8 (ptr))
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ error (0, 0, "%s: .debug_line address size differs from .debug_info",
|
|
|
a5e32e |
+ dso->filename);
|
|
|
a5e32e |
+ return false;
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+
|
|
|
a5e32e |
+ /* segment_selector_size */
|
|
|
a5e32e |
+ (void) read_8 (ptr);
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+
|
|
|
a5e32e |
/* header_length */
|
|
|
a5e32e |
unsigned char *endprol = ptr + 4;
|
|
|
a5e32e |
t->header_length = read_32 (ptr);
|
|
|
a5e32e |
@@ -1343,7 +1368,9 @@ edit_dwarf2_line (DSO *dso)
|
|
|
a5e32e |
|
|
|
a5e32e |
linedata->d_size = dso->lines.debug_lines_len;
|
|
|
a5e32e |
linedata->d_buf = dso->lines.line_buf;
|
|
|
a5e32e |
+ debug_sections[DEBUG_LINE].data = linedata->d_buf;
|
|
|
a5e32e |
debug_sections[DEBUG_LINE].size = linedata->d_size;
|
|
|
a5e32e |
+ debug_sections[DEBUG_LINE].elf_data = linedata;
|
|
|
a5e32e |
|
|
|
a5e32e |
/* Make sure the line tables are sorted on the old index. */
|
|
|
a5e32e |
qsort (dso->lines.table, dso->lines.used, sizeof (struct line_table),
|
|
|
a5e32e |
@@ -1483,9 +1510,10 @@ edit_dwarf2_line (DSO *dso)
|
|
|
a5e32e |
}
|
|
|
a5e32e |
}
|
|
|
a5e32e |
|
|
|
a5e32e |
-/* Record or adjust (according to phase) DW_FORM_strp. */
|
|
|
a5e32e |
+/* Record or adjust (according to phase) DW_FORM_strp or DW_FORM_line_strp. */
|
|
|
a5e32e |
static void
|
|
|
a5e32e |
-edit_strp (DSO *dso, unsigned char *ptr, int phase, bool handled_strp)
|
|
|
a5e32e |
+edit_strp (DSO *dso, bool line_strp, unsigned char *ptr, int phase,
|
|
|
a5e32e |
+ bool handled_strp)
|
|
|
a5e32e |
{
|
|
|
a5e32e |
unsigned char *ptr_orig = ptr;
|
|
|
a5e32e |
|
|
|
a5e32e |
@@ -1500,15 +1528,18 @@ edit_strp (DSO *dso, unsigned char *ptr, int phase, bool handled_strp)
|
|
|
a5e32e |
if (! handled_strp)
|
|
|
a5e32e |
{
|
|
|
a5e32e |
size_t idx = do_read_32_relocated (ptr);
|
|
|
a5e32e |
- record_existing_string_entry_idx (&dso->strings, idx);
|
|
|
a5e32e |
+ record_existing_string_entry_idx (line_strp, dso, idx);
|
|
|
a5e32e |
}
|
|
|
a5e32e |
}
|
|
|
a5e32e |
- else if (need_strp_update) /* && phase == 1 */
|
|
|
a5e32e |
+ else if (line_strp
|
|
|
a5e32e |
+ ? need_line_strp_update : need_strp_update) /* && phase == 1 */
|
|
|
a5e32e |
{
|
|
|
a5e32e |
struct stridxentry *entry;
|
|
|
a5e32e |
size_t idx, new_idx;
|
|
|
a5e32e |
+ struct strings *strings = (line_strp
|
|
|
a5e32e |
+ ? &dso->debug_line_str : &dso->debug_str);
|
|
|
a5e32e |
idx = do_read_32_relocated (ptr);
|
|
|
a5e32e |
- entry = string_find_entry (&dso->strings, idx);
|
|
|
a5e32e |
+ entry = string_find_entry (strings, idx);
|
|
|
a5e32e |
new_idx = strent_offset (entry->entry);
|
|
|
a5e32e |
do_write_32_relocated (ptr, new_idx);
|
|
|
a5e32e |
}
|
|
|
a5e32e |
@@ -1759,6 +1790,254 @@ read_dwarf4_line (DSO *dso, unsigned char *ptr, char *comp_dir,
|
|
|
a5e32e |
return true;
|
|
|
a5e32e |
}
|
|
|
a5e32e |
|
|
|
a5e32e |
+/* Called by read_dwarf5_line first for directories and then file
|
|
|
a5e32e |
+ names as they both have the same format. */
|
|
|
a5e32e |
+static bool
|
|
|
a5e32e |
+read_dwarf5_line_entries (DSO *dso, unsigned char **ptrp,
|
|
|
a5e32e |
+ struct line_table *table, int phase,
|
|
|
a5e32e |
+ char ***dirs, int *ndir,
|
|
|
a5e32e |
+ const char *entry_name)
|
|
|
a5e32e |
+{
|
|
|
a5e32e |
+ /* directory_entry_format_count */
|
|
|
a5e32e |
+ /* file_name_entry_format_count */
|
|
|
a5e32e |
+ unsigned format_count = read_8 (*ptrp);
|
|
|
a5e32e |
+
|
|
|
a5e32e |
+ unsigned char *formats = *ptrp;
|
|
|
a5e32e |
+
|
|
|
a5e32e |
+ /* directory_entry_format */
|
|
|
a5e32e |
+ /* file_name_entry_format */
|
|
|
a5e32e |
+ for (unsigned formati = 0; formati < format_count; ++formati)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ read_uleb128 (*ptrp);
|
|
|
a5e32e |
+ read_uleb128 (*ptrp);
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+
|
|
|
a5e32e |
+ /* directories_count */
|
|
|
a5e32e |
+ /* file_names_count */
|
|
|
a5e32e |
+ unsigned entry_count = read_uleb128 (*ptrp);
|
|
|
a5e32e |
+
|
|
|
a5e32e |
+ bool collecting_dirs = dest_dir && phase == 0 && *dirs == NULL;
|
|
|
a5e32e |
+ bool writing_files = dest_dir && phase == 0 && *dirs != NULL;
|
|
|
a5e32e |
+ if (collecting_dirs)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ *ndir = entry_count;
|
|
|
a5e32e |
+ *dirs = malloc (entry_count * sizeof (char *));
|
|
|
a5e32e |
+ if (*dirs == NULL)
|
|
|
a5e32e |
+ error (1, errno, "%s: Could not allocate debug_line dirs",
|
|
|
a5e32e |
+ dso->filename);
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+
|
|
|
a5e32e |
+ /* directories */
|
|
|
a5e32e |
+ /* file_names */
|
|
|
a5e32e |
+ for (unsigned entryi = 0; entryi < entry_count; ++entryi)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ char *dir = NULL;
|
|
|
a5e32e |
+ char *file = NULL;;
|
|
|
a5e32e |
+ unsigned char *format_ptr = formats;
|
|
|
a5e32e |
+ for (unsigned formati = 0; formati < format_count; ++formati)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ unsigned lnct = read_uleb128 (format_ptr);
|
|
|
a5e32e |
+ unsigned form = read_uleb128 (format_ptr);
|
|
|
a5e32e |
+ bool handled_form = false;
|
|
|
a5e32e |
+ bool handled_strp = false;
|
|
|
a5e32e |
+ bool line_strp = form == DW_FORM_line_strp;
|
|
|
a5e32e |
+ if (lnct == DW_LNCT_path)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ switch (form)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ case DW_FORM_strp:
|
|
|
a5e32e |
+ case DW_FORM_line_strp:
|
|
|
a5e32e |
+ if (dest_dir && phase == 0)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ size_t idx = do_read_32_relocated (*ptrp);
|
|
|
a5e32e |
+ if (record_file_string_entry_idx (line_strp, dso, idx))
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ if (line_strp)
|
|
|
a5e32e |
+ need_line_strp_update = true;
|
|
|
a5e32e |
+ else
|
|
|
a5e32e |
+ need_strp_update = true;
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+ handled_strp = true;
|
|
|
a5e32e |
+ if (collecting_dirs || writing_files)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ debug_section *sec = &debug_sections[line_strp
|
|
|
a5e32e |
+ ? DEBUG_LINE_STR : DEBUG_STR];
|
|
|
a5e32e |
+ if (collecting_dirs)
|
|
|
a5e32e |
+ dir = (char *)sec->data + idx;
|
|
|
a5e32e |
+ if (writing_files)
|
|
|
a5e32e |
+ file = (char *)sec->data + idx;
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+ break;
|
|
|
a5e32e |
+ default:
|
|
|
a5e32e |
+ error (0, 0, "%s: Unsupported "
|
|
|
a5e32e |
+ ".debug_line %s %u path DW_FORM_0x%x",
|
|
|
a5e32e |
+ dso->filename, entry_name, entryi, form);
|
|
|
a5e32e |
+ return false;
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+ if (writing_files && lnct == DW_LNCT_directory_index)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ int dirndx;
|
|
|
a5e32e |
+ switch (form)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ case DW_FORM_udata:
|
|
|
a5e32e |
+ handled_form = true;
|
|
|
a5e32e |
+ dirndx = read_uleb128 (*ptrp);
|
|
|
a5e32e |
+ break;
|
|
|
a5e32e |
+ case DW_FORM_data1:
|
|
|
a5e32e |
+ dirndx = **ptrp;
|
|
|
a5e32e |
+ break;
|
|
|
a5e32e |
+ case DW_FORM_data2:
|
|
|
a5e32e |
+ dirndx = do_read_16 (*ptrp);
|
|
|
a5e32e |
+ break;
|
|
|
a5e32e |
+ case DW_FORM_data4:
|
|
|
a5e32e |
+ dirndx = do_read_32 (*ptrp);
|
|
|
a5e32e |
+ break;
|
|
|
a5e32e |
+ default:
|
|
|
a5e32e |
+ error (0, 0, "%s: Unsupported "
|
|
|
a5e32e |
+ ".debug_line %s %u dirndx DW_FORM_0x%x",
|
|
|
a5e32e |
+ dso->filename, entry_name, entryi, form);
|
|
|
a5e32e |
+ return false;
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+
|
|
|
a5e32e |
+ if (dirndx > *ndir)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ error (0, 0, "%s: Bad dir number %u in .debug_line %s",
|
|
|
a5e32e |
+ dso->filename, entryi, entry_name);
|
|
|
a5e32e |
+ return false;
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+ dir = (*dirs)[dirndx];
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+
|
|
|
a5e32e |
+ switch (form)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ case DW_FORM_strp:
|
|
|
a5e32e |
+ case DW_FORM_line_strp:
|
|
|
a5e32e |
+ edit_strp (dso, line_strp, *ptrp, phase, handled_strp);
|
|
|
a5e32e |
+ break;
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+
|
|
|
a5e32e |
+ if (!handled_form)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ switch (skip_form (dso, &form, ptrp))
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ case FORM_OK:
|
|
|
a5e32e |
+ break;
|
|
|
a5e32e |
+ case FORM_ERROR:
|
|
|
a5e32e |
+ return false;
|
|
|
a5e32e |
+ case FORM_INDIRECT:
|
|
|
a5e32e |
+ error (0, 0, "%s: Unsupported "
|
|
|
a5e32e |
+ ".debug_line %s %u DW_FORM_indirect",
|
|
|
a5e32e |
+ dso->filename, entry_name, entryi);
|
|
|
a5e32e |
+ return false;
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+
|
|
|
a5e32e |
+ if (collecting_dirs)
|
|
|
a5e32e |
+ (*dirs)[entryi] = dir;
|
|
|
a5e32e |
+
|
|
|
a5e32e |
+ if (writing_files)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ char *comp_dir = (*dirs)[0];
|
|
|
a5e32e |
+ size_t comp_dir_len = strlen(comp_dir);
|
|
|
a5e32e |
+ size_t file_len = strlen (file);
|
|
|
a5e32e |
+ size_t dir_len = strlen (dir);
|
|
|
a5e32e |
+
|
|
|
a5e32e |
+ char *s = malloc (comp_dir_len + 1 + file_len + 1 + dir_len + 1);
|
|
|
a5e32e |
+ if (s == NULL)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ error (0, ENOMEM, "%s: Reading file table", dso->filename);
|
|
|
a5e32e |
+ return false;
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+ if (file[0] == '/')
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ memcpy (s, file, file_len + 1);
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+ else if (dir[0] == '/')
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ memcpy (s, dir, dir_len);
|
|
|
a5e32e |
+ s[dir_len] = '/';
|
|
|
a5e32e |
+ memcpy (s + dir_len + 1, file, file_len + 1);
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+ else
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ char *p = s;
|
|
|
a5e32e |
+ if (comp_dir_len != 0)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ memcpy (s, comp_dir, comp_dir_len);
|
|
|
a5e32e |
+ s[comp_dir_len] = '/';
|
|
|
a5e32e |
+ p += comp_dir_len + 1;
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+ memcpy (p, dir, dir_len);
|
|
|
a5e32e |
+ p[dir_len] = '/';
|
|
|
a5e32e |
+ memcpy (p + dir_len + 1, file, file_len + 1);
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+ canonicalize_path (s, s);
|
|
|
a5e32e |
+ if (list_file_fd != -1)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ const char *p = NULL;
|
|
|
a5e32e |
+ if (base_dir == NULL)
|
|
|
a5e32e |
+ p = s;
|
|
|
a5e32e |
+ else
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ p = skip_dir_prefix (s, base_dir);
|
|
|
a5e32e |
+ if (p == NULL && dest_dir != NULL)
|
|
|
a5e32e |
+ p = skip_dir_prefix (s, dest_dir);
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+
|
|
|
a5e32e |
+ if (p)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ size_t size = strlen (p) + 1;
|
|
|
a5e32e |
+ while (size > 0)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ ssize_t ret = write (list_file_fd, p, size);
|
|
|
a5e32e |
+ if (ret == -1)
|
|
|
a5e32e |
+ break;
|
|
|
a5e32e |
+ size -= ret;
|
|
|
a5e32e |
+ p += ret;
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+
|
|
|
a5e32e |
+ free (s);
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+
|
|
|
a5e32e |
+ return true;
|
|
|
a5e32e |
+}
|
|
|
a5e32e |
+
|
|
|
a5e32e |
+/* Part of read_dwarf2_line processing DWARF-5. */
|
|
|
a5e32e |
+static bool
|
|
|
a5e32e |
+read_dwarf5_line (DSO *dso, unsigned char *ptr, struct line_table *table,
|
|
|
a5e32e |
+ int phase)
|
|
|
a5e32e |
+{
|
|
|
a5e32e |
+ char **dirs = NULL;
|
|
|
a5e32e |
+ int ndir;
|
|
|
a5e32e |
+ /* Skip header. */
|
|
|
a5e32e |
+ ptr += (4 /* unit len */
|
|
|
a5e32e |
+ + 2 /* version */
|
|
|
a5e32e |
+ + (table->version < 5 ? 0 : 0
|
|
|
a5e32e |
+ + 1 /* address_size */
|
|
|
a5e32e |
+ + 1 /* segment_selector*/)
|
|
|
a5e32e |
+ + 4 /* header len */
|
|
|
a5e32e |
+ + 1 /* min instr len */
|
|
|
a5e32e |
+ + (table->version >= 4) /* max op per instr, if version >= 4 */
|
|
|
a5e32e |
+ + 1 /* default is stmt */
|
|
|
a5e32e |
+ + 1 /* line base */
|
|
|
a5e32e |
+ + 1 /* line range */
|
|
|
a5e32e |
+ + 1 /* opcode base */
|
|
|
a5e32e |
+ + table->opcode_base - 1); /* opcode len table */
|
|
|
a5e32e |
+
|
|
|
a5e32e |
+ bool retval = (read_dwarf5_line_entries (dso, &ptr, table, phase,
|
|
|
a5e32e |
+ &dirs, &ndir, "directory")
|
|
|
a5e32e |
+ && read_dwarf5_line_entries (dso, &ptr, table, phase,
|
|
|
a5e32e |
+ &dirs, &ndir, "file name"));
|
|
|
a5e32e |
+ free (dirs);
|
|
|
a5e32e |
+ return retval;
|
|
|
a5e32e |
+}
|
|
|
a5e32e |
+
|
|
|
a5e32e |
/* Called during phase zero for each debug_line table referenced from
|
|
|
a5e32e |
.debug_info. Outputs all source files seen and records any
|
|
|
a5e32e |
adjustments needed in the debug_list data structures. Returns true
|
|
|
a5e32e |
@@ -1778,6 +2057,9 @@ read_dwarf2_line (DSO *dso, uint32_t off, char *comp_dir)
|
|
|
a5e32e |
ptr = debug_sections[DEBUG_LINE].data + off;
|
|
|
a5e32e |
ptr += (4 /* unit len */
|
|
|
a5e32e |
+ 2 /* version */
|
|
|
a5e32e |
+ + (table->version < 5 ? 0 : 0
|
|
|
a5e32e |
+ + 1 /* address_size */
|
|
|
a5e32e |
+ + 1 /* segment_selector*/)
|
|
|
a5e32e |
+ 4 /* header len */
|
|
|
a5e32e |
+ 1 /* min instr len */
|
|
|
a5e32e |
+ (table->version >= 4) /* max op per instr, if version >= 4 */
|
|
|
a5e32e |
@@ -1787,8 +2069,13 @@ read_dwarf2_line (DSO *dso, uint32_t off, char *comp_dir)
|
|
|
a5e32e |
+ 1 /* opcode base */
|
|
|
a5e32e |
+ table->opcode_base - 1); /* opcode len table */
|
|
|
a5e32e |
|
|
|
a5e32e |
- if (! read_dwarf4_line (dso, ptr, comp_dir, table))
|
|
|
a5e32e |
- return false;
|
|
|
a5e32e |
+ /* DWARF version 5 line tables won't change size. But they might need
|
|
|
a5e32e |
+ [line]strp recording/updates. Handle that part later. */
|
|
|
a5e32e |
+ if (table->version < 5)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ if (! read_dwarf4_line (dso, ptr, comp_dir, table))
|
|
|
a5e32e |
+ return false;
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
|
|
|
a5e32e |
dso->lines.debug_lines_len += 4 + table->unit_length + table->size_diff;
|
|
|
a5e32e |
return table->replace_dirs || table->replace_files;
|
|
|
a5e32e |
@@ -1807,20 +2094,22 @@ find_new_list_offs (struct debug_lines *lines, size_t idx)
|
|
|
a5e32e |
return table->new_idx;
|
|
|
a5e32e |
}
|
|
|
a5e32e |
|
|
|
a5e32e |
-/* Read DW_FORM_strp collecting compilation directory. */
|
|
|
a5e32e |
+/* Read DW_FORM_strp or DW_FORM_line_strp collecting compilation directory. */
|
|
|
a5e32e |
static void
|
|
|
a5e32e |
-edit_attributes_str_comp_dir (DSO *dso, unsigned char **ptrp, int phase,
|
|
|
a5e32e |
- char **comp_dirp, bool *handled_strpp)
|
|
|
a5e32e |
+edit_attributes_str_comp_dir (bool line_strp, DSO *dso, unsigned char **ptrp,
|
|
|
a5e32e |
+ int phase, char **comp_dirp, bool *handled_strpp)
|
|
|
a5e32e |
{
|
|
|
a5e32e |
const char *dir;
|
|
|
a5e32e |
size_t idx = do_read_32_relocated (*ptrp);
|
|
|
a5e32e |
/* In phase zero we collect the comp_dir. */
|
|
|
a5e32e |
if (phase == 0)
|
|
|
a5e32e |
{
|
|
|
a5e32e |
- if (idx >= debug_sections[DEBUG_STR].size)
|
|
|
a5e32e |
- error (1, 0, "%s: Bad string pointer index %zd for comp_dir",
|
|
|
a5e32e |
- dso->filename, idx);
|
|
|
a5e32e |
- dir = (char *) debug_sections[DEBUG_STR].data + idx;
|
|
|
a5e32e |
+ debug_section *sec = &debug_sections[line_strp
|
|
|
a5e32e |
+ ? DEBUG_LINE_STR : DEBUG_STR];
|
|
|
a5e32e |
+ if (sec->data == NULL || idx >= sec->size)
|
|
|
a5e32e |
+ error (1, 0, "%s: Bad string pointer index %zd for comp_dir (%s)",
|
|
|
a5e32e |
+ dso->filename, idx, sec->name);
|
|
|
a5e32e |
+ dir = (char *) sec->data + idx;
|
|
|
a5e32e |
|
|
|
a5e32e |
free (*comp_dirp);
|
|
|
a5e32e |
*comp_dirp = strdup (dir);
|
|
|
a5e32e |
@@ -1828,8 +2117,13 @@ edit_attributes_str_comp_dir (DSO *dso, unsigned char **ptrp, int phase,
|
|
|
a5e32e |
|
|
|
a5e32e |
if (dest_dir != NULL && phase == 0)
|
|
|
a5e32e |
{
|
|
|
a5e32e |
- if (record_file_string_entry_idx (&dso->strings, idx))
|
|
|
a5e32e |
- need_strp_update = true;
|
|
|
a5e32e |
+ if (record_file_string_entry_idx (line_strp, dso, idx))
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ if (line_strp)
|
|
|
a5e32e |
+ need_line_strp_update = true;
|
|
|
a5e32e |
+ else
|
|
|
a5e32e |
+ need_strp_update = true;
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
*handled_strpp = true;
|
|
|
a5e32e |
}
|
|
|
a5e32e |
}
|
|
|
a5e32e |
@@ -1937,17 +2231,24 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase)
|
|
|
a5e32e |
}
|
|
|
a5e32e |
}
|
|
|
a5e32e |
}
|
|
|
a5e32e |
- else if (form == DW_FORM_strp &&
|
|
|
a5e32e |
- debug_sections[DEBUG_STR].data)
|
|
|
a5e32e |
- edit_attributes_str_comp_dir (dso, &ptr, phase, &comp_dir,
|
|
|
a5e32e |
+ else if (form == DW_FORM_strp)
|
|
|
a5e32e |
+ edit_attributes_str_comp_dir (false /* line_strp */, dso,
|
|
|
a5e32e |
+ &ptr, phase, &comp_dir,
|
|
|
a5e32e |
&handled_strp);
|
|
|
a5e32e |
+ else if (form == DW_FORM_line_strp)
|
|
|
a5e32e |
+ edit_attributes_str_comp_dir (true /* line_strp */, dso, &ptr,
|
|
|
a5e32e |
+ phase, &comp_dir, &handled_strp);
|
|
|
a5e32e |
}
|
|
|
a5e32e |
else if ((t->tag == DW_TAG_compile_unit
|
|
|
a5e32e |
|| t->tag == DW_TAG_partial_unit)
|
|
|
a5e32e |
- && t->attr[i].attr == DW_AT_name
|
|
|
a5e32e |
- && form == DW_FORM_strp
|
|
|
a5e32e |
- && debug_sections[DEBUG_STR].data)
|
|
|
a5e32e |
+ && ((form == DW_FORM_strp
|
|
|
a5e32e |
+ && debug_sections[DEBUG_STR].data)
|
|
|
a5e32e |
+ || (form == DW_FORM_line_strp
|
|
|
a5e32e |
+ && debug_sections[DEBUG_LINE_STR].data))
|
|
|
a5e32e |
+ && t->attr[i].attr == DW_AT_name)
|
|
|
a5e32e |
{
|
|
|
a5e32e |
+ bool line_strp = form == DW_FORM_line_strp;
|
|
|
a5e32e |
+
|
|
|
a5e32e |
/* DW_AT_name is the primary file for this compile
|
|
|
a5e32e |
unit. If starting with / it is a full path name.
|
|
|
a5e32e |
Note that we don't handle DW_FORM_string in this
|
|
|
a5e32e |
@@ -1957,11 +2258,14 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase)
|
|
|
a5e32e |
/* In phase zero we will look for a comp_dir to use. */
|
|
|
a5e32e |
if (phase == 0)
|
|
|
a5e32e |
{
|
|
|
a5e32e |
- if (idx >= debug_sections[DEBUG_STR].size)
|
|
|
a5e32e |
+ debug_section *sec = &debug_sections[line_strp
|
|
|
a5e32e |
+ ? DEBUG_LINE_STR
|
|
|
a5e32e |
+ : DEBUG_STR];
|
|
|
a5e32e |
+ if (idx >= sec->size)
|
|
|
a5e32e |
error (1, 0,
|
|
|
a5e32e |
- "%s: Bad string pointer index %zd for unit name",
|
|
|
a5e32e |
- dso->filename, idx);
|
|
|
a5e32e |
- char *name = (char *) debug_sections[DEBUG_STR].data + idx;
|
|
|
a5e32e |
+ "%s: Bad string pointer index %zd for unit name (%s)",
|
|
|
a5e32e |
+ dso->filename, idx, sec->name);
|
|
|
a5e32e |
+ char *name = (char *) sec->data + idx;
|
|
|
a5e32e |
if (*name == '/' && comp_dir == NULL)
|
|
|
a5e32e |
{
|
|
|
a5e32e |
char *enddir = strrchr (name, '/');
|
|
|
a5e32e |
@@ -1982,8 +2286,13 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase)
|
|
|
a5e32e |
pass (1) stores it (the new index). */
|
|
|
a5e32e |
if (dest_dir && phase == 0)
|
|
|
a5e32e |
{
|
|
|
a5e32e |
- if (record_file_string_entry_idx (&dso->strings, idx))
|
|
|
a5e32e |
- need_strp_update = true;
|
|
|
a5e32e |
+ if (record_file_string_entry_idx (line_strp, dso, idx))
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ if (line_strp)
|
|
|
a5e32e |
+ need_line_strp_update = true;
|
|
|
a5e32e |
+ else
|
|
|
a5e32e |
+ need_strp_update = true;
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
handled_strp = true;
|
|
|
a5e32e |
}
|
|
|
a5e32e |
}
|
|
|
a5e32e |
@@ -1991,7 +2300,10 @@ edit_attributes (DSO *dso, unsigned char *ptr, struct abbrev_tag *t, int phase)
|
|
|
a5e32e |
switch (form)
|
|
|
a5e32e |
{
|
|
|
a5e32e |
case DW_FORM_strp:
|
|
|
a5e32e |
- edit_strp (dso, ptr, phase, handled_strp);
|
|
|
a5e32e |
+ edit_strp (dso, false /* line_strp */, ptr, phase, handled_strp);
|
|
|
a5e32e |
+ break;
|
|
|
a5e32e |
+ case DW_FORM_line_strp:
|
|
|
a5e32e |
+ edit_strp (dso, true /* line_strp */, ptr, phase, handled_strp);
|
|
|
a5e32e |
break;
|
|
|
a5e32e |
}
|
|
|
a5e32e |
|
|
|
a5e32e |
@@ -2196,11 +2508,11 @@ edit_info (DSO *dso, int phase, struct debug_section *sec)
|
|
|
a5e32e |
|
|
|
a5e32e |
/* Rebuild .debug_str. */
|
|
|
a5e32e |
static void
|
|
|
a5e32e |
-edit_dwarf2_any_str (DSO *dso)
|
|
|
a5e32e |
+edit_dwarf2_any_str (DSO *dso, struct strings *strings, debug_section *secp)
|
|
|
a5e32e |
{
|
|
|
a5e32e |
- Strtab *strtab = dso->strings.str_tab;
|
|
|
a5e32e |
- Elf_Data *strdata = debug_sections[DEBUG_STR].elf_data;
|
|
|
a5e32e |
- int strndx = debug_sections[DEBUG_STR].sec;
|
|
|
a5e32e |
+ Strtab *strtab = strings->str_tab;
|
|
|
a5e32e |
+ Elf_Data *strdata = secp->elf_data;
|
|
|
a5e32e |
+ int strndx = secp->sec;
|
|
|
a5e32e |
Elf_Scn *strscn = dso->scn[strndx];
|
|
|
a5e32e |
|
|
|
a5e32e |
/* Out with the old. */
|
|
|
a5e32e |
@@ -2212,8 +2524,8 @@ edit_dwarf2_any_str (DSO *dso)
|
|
|
a5e32e |
but the old ebl version will just abort on out of
|
|
|
a5e32e |
memory... */
|
|
|
a5e32e |
strtab_finalize (strtab, strdata);
|
|
|
a5e32e |
- debug_sections[DEBUG_STR].size = strdata->d_size;
|
|
|
a5e32e |
- dso->strings.str_buf = strdata->d_buf;
|
|
|
a5e32e |
+ secp->size = strdata->d_size;
|
|
|
a5e32e |
+ strings->str_buf = strdata->d_buf;
|
|
|
a5e32e |
}
|
|
|
a5e32e |
|
|
|
a5e32e |
static int
|
|
|
a5e32e |
@@ -2359,12 +2671,14 @@ edit_dwarf2 (DSO *dso)
|
|
|
a5e32e |
bool info_rel_updated = false;
|
|
|
a5e32e |
bool types_rel_updated = false;
|
|
|
a5e32e |
bool macro_rel_updated = false;
|
|
|
a5e32e |
+ bool line_rel_updated = false;
|
|
|
a5e32e |
|
|
|
a5e32e |
for (phase = 0; phase < 2; phase++)
|
|
|
a5e32e |
{
|
|
|
a5e32e |
/* If we don't need to update anyhing, skip phase 1. */
|
|
|
a5e32e |
if (phase == 1
|
|
|
a5e32e |
&& !need_strp_update
|
|
|
a5e32e |
+ && !need_line_strp_update
|
|
|
a5e32e |
&& !need_string_replacement
|
|
|
a5e32e |
&& !need_stmt_update)
|
|
|
a5e32e |
break;
|
|
|
a5e32e |
@@ -2582,15 +2896,14 @@ edit_dwarf2 (DSO *dso)
|
|
|
a5e32e |
if (phase == 0)
|
|
|
a5e32e |
{
|
|
|
a5e32e |
size_t idx = read_32_relocated (ptr);
|
|
|
a5e32e |
- record_existing_string_entry_idx (&dso->strings,
|
|
|
a5e32e |
- idx);
|
|
|
a5e32e |
+ record_existing_string_entry_idx (false, dso, idx);
|
|
|
a5e32e |
}
|
|
|
a5e32e |
else
|
|
|
a5e32e |
{
|
|
|
a5e32e |
struct stridxentry *entry;
|
|
|
a5e32e |
size_t idx, new_idx;
|
|
|
a5e32e |
idx = do_read_32_relocated (ptr);
|
|
|
a5e32e |
- entry = string_find_entry (&dso->strings, idx);
|
|
|
a5e32e |
+ entry = string_find_entry (&dso->debug_str, idx);
|
|
|
a5e32e |
new_idx = strent_offset (entry->entry);
|
|
|
a5e32e |
write_32_relocated (ptr, new_idx);
|
|
|
a5e32e |
}
|
|
|
a5e32e |
@@ -2610,24 +2923,50 @@ edit_dwarf2 (DSO *dso)
|
|
|
a5e32e |
}
|
|
|
a5e32e |
}
|
|
|
a5e32e |
|
|
|
a5e32e |
- /* Same for the debug_str section. Make sure everything is
|
|
|
a5e32e |
- in place for phase 1 updating of debug_info
|
|
|
a5e32e |
+
|
|
|
a5e32e |
+ /* Now handle all the DWARF5 line tables, they contain strp
|
|
|
a5e32e |
+ and/or line_strp entries that need to be registered/rewritten. */
|
|
|
a5e32e |
+ setup_relbuf(dso, &debug_sections[DEBUG_LINE], &reltype);
|
|
|
a5e32e |
+ rel_updated = false;
|
|
|
a5e32e |
+
|
|
|
a5e32e |
+ /* edit_dwarf2_line will have set this up, unless there are no
|
|
|
a5e32e |
+ moved/resized (DWARF4) lines. In which case we can just use
|
|
|
a5e32e |
+ the original section data. new_idx will have been setup
|
|
|
a5e32e |
+ correctly, even if it is the same as old_idx. */
|
|
|
a5e32e |
+ unsigned char *line_buf = (unsigned char *)dso->lines.line_buf;
|
|
|
a5e32e |
+ if (line_buf == NULL)
|
|
|
a5e32e |
+ line_buf = debug_sections[DEBUG_LINE].data;
|
|
|
a5e32e |
+ for (int ldx = 0; ldx < dso->lines.used; ldx++)
|
|
|
a5e32e |
+ {
|
|
|
a5e32e |
+ struct line_table *t = &dso->lines.table[ldx];
|
|
|
a5e32e |
+ if (t->version >= 5)
|
|
|
a5e32e |
+ read_dwarf5_line (dso, line_buf + t->new_idx, t, phase);
|
|
|
a5e32e |
+ }
|
|
|
a5e32e |
+ if (rel_updated)
|
|
|
a5e32e |
+ line_rel_updated = true;
|
|
|
a5e32e |
+
|
|
|
a5e32e |
+ /* Same for the debug_str and debug_line_str sections.
|
|
|
a5e32e |
+ Make sure everything is in place for phase 1 updating of debug_info
|
|
|
a5e32e |
references. */
|
|
|
a5e32e |
if (phase == 0 && need_strp_update)
|
|
|
a5e32e |
- edit_dwarf2_any_str (dso);
|
|
|
a5e32e |
-
|
|
|
a5e32e |
+ edit_dwarf2_any_str (dso, &dso->debug_str,
|
|
|
a5e32e |
+ &debug_sections[DEBUG_STR]);
|
|
|
a5e32e |
+ if (phase == 0 && need_line_strp_update)
|
|
|
a5e32e |
+ edit_dwarf2_any_str (dso, &dso->debug_line_str,
|
|
|
a5e32e |
+ &debug_sections[DEBUG_LINE_STR]);
|
|
|
a5e32e |
}
|
|
|
a5e32e |
|
|
|
a5e32e |
/* After phase 1 we might have rewritten the debug_info with
|
|
|
a5e32e |
new strp, strings and/or linep offsets. */
|
|
|
a5e32e |
- if (need_strp_update || need_string_replacement || need_stmt_update) {
|
|
|
a5e32e |
+ if (need_strp_update || need_line_strp_update
|
|
|
a5e32e |
+ || need_string_replacement || need_stmt_update) {
|
|
|
a5e32e |
dirty_section (DEBUG_INFO);
|
|
|
a5e32e |
if (debug_sections[DEBUG_TYPES].data != NULL)
|
|
|
a5e32e |
dirty_section (DEBUG_TYPES);
|
|
|
a5e32e |
}
|
|
|
a5e32e |
if (need_strp_update || need_stmt_update)
|
|
|
a5e32e |
dirty_section (DEBUG_MACRO);
|
|
|
a5e32e |
- if (need_stmt_update)
|
|
|
a5e32e |
+ if (need_stmt_update || need_line_strp_update)
|
|
|
a5e32e |
dirty_section (DEBUG_LINE);
|
|
|
a5e32e |
|
|
|
a5e32e |
/* Update any relocations addends we might have touched. */
|
|
|
a5e32e |
@@ -2653,6 +2992,9 @@ edit_dwarf2 (DSO *dso)
|
|
|
a5e32e |
}
|
|
|
a5e32e |
}
|
|
|
a5e32e |
|
|
|
a5e32e |
+ if (line_rel_updated)
|
|
|
a5e32e |
+ update_rela_data (dso, &debug_sections[DEBUG_LINE]);
|
|
|
a5e32e |
+
|
|
|
a5e32e |
return 0;
|
|
|
a5e32e |
}
|
|
|
a5e32e |
|
|
|
a5e32e |
@@ -2745,7 +3087,8 @@ fdopen_dso (int fd, const char *name)
|
|
|
a5e32e |
}
|
|
|
a5e32e |
|
|
|
a5e32e |
dso->filename = (const char *) strdup (name);
|
|
|
a5e32e |
- setup_strings (&dso->strings);
|
|
|
a5e32e |
+ setup_strings (&dso->debug_str);
|
|
|
a5e32e |
+ setup_strings (&dso->debug_line_str);
|
|
|
a5e32e |
setup_lines (&dso->lines);
|
|
|
a5e32e |
return dso;
|
|
|
a5e32e |
|
|
|
a5e32e |
@@ -2753,7 +3096,8 @@ error_out:
|
|
|
a5e32e |
if (dso)
|
|
|
a5e32e |
{
|
|
|
a5e32e |
free ((char *) dso->filename);
|
|
|
a5e32e |
- destroy_strings (&dso->strings);
|
|
|
a5e32e |
+ destroy_strings (&dso->debug_str);
|
|
|
a5e32e |
+ destroy_strings (&dso->debug_line_str);
|
|
|
a5e32e |
destroy_lines (&dso->lines);
|
|
|
a5e32e |
free (dso);
|
|
|
a5e32e |
}
|
|
|
a5e32e |
@@ -3034,7 +3378,9 @@ main (int argc, char *argv[])
|
|
|
a5e32e |
in elfutils before 0.169 we will have to update and write out all
|
|
|
a5e32e |
section data if any data has changed (when ELF_F_LAYOUT was
|
|
|
a5e32e |
set). https://sourceware.org/bugzilla/show_bug.cgi?id=21199 */
|
|
|
a5e32e |
- bool need_update = need_strp_update || need_stmt_update;
|
|
|
a5e32e |
+ bool need_update = (need_strp_update
|
|
|
a5e32e |
+ || need_line_strp_update
|
|
|
a5e32e |
+ || need_stmt_update);
|
|
|
a5e32e |
|
|
|
a5e32e |
#if !_ELFUTILS_PREREQ (0, 169)
|
|
|
a5e32e |
/* string replacements or build_id updates don't change section size. */
|
|
|
a5e32e |
@@ -3106,10 +3452,12 @@ main (int argc, char *argv[])
|
|
|
a5e32e |
GElf_Xword sec_size = shdr->sh_size;
|
|
|
a5e32e |
|
|
|
a5e32e |
/* We might have changed the size (and content) of the
|
|
|
a5e32e |
- debug_str or debug_line section. */
|
|
|
a5e32e |
+ debug_str, debug_line_str or debug_line section. */
|
|
|
a5e32e |
size_t secnum = elf_ndxscn (scn);
|
|
|
a5e32e |
if (secnum == debug_sections[DEBUG_STR].sec)
|
|
|
a5e32e |
sec_size = debug_sections[DEBUG_STR].size;
|
|
|
a5e32e |
+ if (secnum == debug_sections[DEBUG_LINE_STR].sec)
|
|
|
a5e32e |
+ sec_size = debug_sections[DEBUG_LINE_STR].size;
|
|
|
a5e32e |
if (secnum == debug_sections[DEBUG_LINE].sec)
|
|
|
a5e32e |
sec_size = debug_sections[DEBUG_LINE].size;
|
|
|
a5e32e |
|
|
|
a5e32e |
@@ -3179,7 +3527,8 @@ main (int argc, char *argv[])
|
|
|
a5e32e |
chmod (file, stat_buf.st_mode);
|
|
|
a5e32e |
|
|
|
a5e32e |
free ((char *) dso->filename);
|
|
|
a5e32e |
- destroy_strings (&dso->strings);
|
|
|
a5e32e |
+ destroy_strings (&dso->debug_str);
|
|
|
a5e32e |
+ destroy_strings (&dso->debug_line_str);
|
|
|
a5e32e |
destroy_lines (&dso->lines);
|
|
|
a5e32e |
free (dso);
|
|
|
a5e32e |
|
|
|
a5e32e |
--
|
|
|
a5e32e |
2.18.4
|
|
|
a5e32e |
|