aboutsummaryrefslogtreecommitdiff
path: root/libdw
diff options
context:
space:
mode:
authorMark Wielaard <mark@klomp.org>2018-05-13 00:05:10 +0200
committerMark Wielaard <mark@klomp.org>2018-05-19 12:37:24 +0200
commita7bcf4322f5e23a638c3b5b6f3cf62855865cc4a (patch)
treebce3f42915f51b67d1021af2d8e19a9738083d40 /libdw
parent5e1a9f18aadf4804323ad470e33ddcd17650bc38 (diff)
downloadelfutils-a7bcf4322f5e23a638c3b5b6f3cf62855865cc4a.tar.gz
libdw, readelf: Handle .debug_*.dwo section name variants.
The .debug_*.dwo section names are handled just like their none .dwo variants. The section contents is the same as sections without the .dwo name, but they are only found in split-dwarf files. This patch allows opening and inspecting split-dwarf files. It doesn't yet connect the split-dwarf with their skeleton (or the other way around). It also doesn't yet handle any special split-dwarf attributes or tags. Signed-off-by: Mark Wielaard <mark@klomp.org>
Diffstat (limited to 'libdw')
-rw-r--r--libdw/ChangeLog5
-rw-r--r--libdw/dwarf_begin_elf.c31
2 files changed, 26 insertions, 10 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index e66a1ec4..42777b55 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,3 +1,8 @@
+2018-05-12 Mark Wielaard <mark@klomp.org>
+
+ * dwarf_begin_elf.c (check_section): Also recognize .dwo section
+ name variants.
+
2018-05-11 Mark Wielaard <mark@klomp.org>
* dwarf_formudata.c (dwarf_formudata): Handle DW_AT_macros as macptr.
diff --git a/libdw/dwarf_begin_elf.c b/libdw/dwarf_begin_elf.c
index 8bdcea2f..61de7526 100644
--- a/libdw/dwarf_begin_elf.c
+++ b/libdw/dwarf_begin_elf.c
@@ -1,7 +1,6 @@
/* Create descriptor from ELF descriptor for processing file.
- Copyright (C) 2002-2011, 2014, 2015, 2018 Red Hat, Inc.
+ Copyright (C) 2002-2011, 2014, 2015, 2017, 2018 Red Hat, Inc.
This file is part of elfutils.
- Written by Ulrich Drepper <drepper@redhat.com>, 2002.
This file is free software; you can redistribute it and/or modify
it under the terms of either
@@ -116,14 +115,26 @@ check_section (Dwarf *result, GElf_Ehdr *ehdr, Elf_Scn *scn, bool inscngrp)
size_t cnt;
bool gnu_compressed = false;
for (cnt = 0; cnt < ndwarf_scnnames; ++cnt)
- if (strcmp (scnname, dwarf_scnnames[cnt]) == 0)
- break;
- else if (scnname[0] == '.' && scnname[1] == 'z'
- && strcmp (&scnname[2], &dwarf_scnnames[cnt][1]) == 0)
- {
- gnu_compressed = true;
- break;
- }
+ {
+ size_t dbglen = strlen (dwarf_scnnames[cnt]);
+ size_t scnlen = strlen (scnname);
+ if (strncmp (scnname, dwarf_scnnames[cnt], dbglen) == 0
+ && (dbglen == scnlen
+ || (scnlen == dbglen + 4
+ && strstr (scnname, ".dwo") == scnname + dbglen)))
+ break;
+ else if (scnname[0] == '.' && scnname[1] == 'z'
+ && (strncmp (&scnname[2], &dwarf_scnnames[cnt][1],
+ dbglen - 1) == 0
+ && (scnlen == dbglen + 1
+ || (scnlen == dbglen + 5
+ && strstr (scnname,
+ ".dwo") == scnname + dbglen + 1))))
+ {
+ gnu_compressed = true;
+ break;
+ }
+ }
if (cnt >= ndwarf_scnnames)
/* Not a debug section; ignore it. */