* libbacktrace patch committed: Don't strip underscore on 64-bit PE
@ 2020-09-09 2:22 Ian Lance Taylor
0 siblings, 0 replies; only message in thread
From: Ian Lance Taylor @ 2020-09-09 2:22 UTC (permalink / raw)
To: gcc-patches
[-- Attachment #1: Type: text/plain, Size: 284 bytes --]
This patch to libbacktrace avoids stripping a leading underscore from
symbol names on 64-bit PE COFF. Bootstrapped and ran Go tests on
x86_64-pc-linux-gnu. Committed to mainline.
Ian
* pecoff.c (coff_initialize_syminfo): Add is_64 parameter.
(coff_add): Determine and pass is_64.
[-- Attachment #2: patch.txt --]
[-- Type: text/plain, Size: 2080 bytes --]
diff --git a/libbacktrace/pecoff.c b/libbacktrace/pecoff.c
index 221571c862e..49e5c3d868c 100644
--- a/libbacktrace/pecoff.c
+++ b/libbacktrace/pecoff.c
@@ -330,7 +330,7 @@ coff_is_function_symbol (const b_coff_internal_symbol *isym)
static int
coff_initialize_syminfo (struct backtrace_state *state,
- uintptr_t base_address,
+ uintptr_t base_address, int is_64,
const b_coff_section_header *sects, size_t sects_num,
const b_coff_external_symbol *syms, size_t syms_size,
const unsigned char *strtab, size_t strtab_size,
@@ -426,9 +426,12 @@ coff_initialize_syminfo (struct backtrace_state *state,
else
name = isym.name;
- /* Strip leading '_'. */
- if (name[0] == '_')
- name++;
+ if (!is_64)
+ {
+ /* Strip leading '_'. */
+ if (name[0] == '_')
+ name++;
+ }
/* Symbol value is section relative, so we need to read the address
of its section. */
@@ -605,6 +608,7 @@ coff_add (struct backtrace_state *state, int descriptor,
off_t max_offset;
struct backtrace_view debug_view;
int debug_view_valid;
+ int is_64;
uintptr_t image_base;
struct dwarf_sections dwarf_sections;
@@ -680,12 +684,16 @@ coff_add (struct backtrace_state *state, int descriptor,
sects = (const b_coff_section_header *)
(sects_view.data + fhdr.size_of_optional_header);
+ is_64 = 0;
if (fhdr.size_of_optional_header > sizeof (*opt_hdr))
{
if (opt_hdr->magic == PE_MAGIC)
image_base = opt_hdr->u.pe.image_base;
else if (opt_hdr->magic == PEP_MAGIC)
- image_base = opt_hdr->u.pep.image_base;
+ {
+ image_base = opt_hdr->u.pep.image_base;
+ is_64 = 1;
+ }
else
{
error_callback (data, "bad magic in PE optional header", 0);
@@ -778,7 +786,7 @@ coff_add (struct backtrace_state *state, int descriptor,
if (sdata == NULL)
goto fail;
- if (!coff_initialize_syminfo (state, image_base,
+ if (!coff_initialize_syminfo (state, image_base, is_64,
sects, sects_num,
syms_view.data, syms_size,
str_view.data, str_size,
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2020-09-09 2:22 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-09 2:22 libbacktrace patch committed: Don't strip underscore on 64-bit PE Ian Lance Taylor
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).