summaryrefslogtreecommitdiff
path: root/libdw
diff options
context:
space:
mode:
authorRoland McGrath <roland@redhat.com>2007-04-16 23:13:37 +0000
committerRoland McGrath <roland@redhat.com>2007-04-16 23:13:37 +0000
commit43da9895c6d828ceae65a47f2337e8ef24eb97c1 (patch)
tree4454878335a5a6f65083a04824b3968702bfcf6b /libdw
parentbf2ee480165faec726d678f189acd2bd54e07573 (diff)
downloadelfutils-43da9895c6d828ceae65a47f2337e8ef24eb97c1.tar.gz
libdw/
2007-04-16 Roland McGrath <roland@redhat.com> * libdw.map (ELFUTILS_0.127): Add dwfl_module_address_section. libdwfl/ 2007-04-16 Roland McGrath <roland@redhat.com> * derelocate.c (cache_sections): Apply bias to sh_addr. (compare_secrefs): Fix address comparison to avoid signed overflow. (find_section): New function, broken out of ... (dwfl_module_relocate_address): ... here, call it. (check_module): New function, broken out of ... (dwfl_module_relocate_address): ... here, call it. (dwfl_module_address_section): New function. * libdwfl.h: Declare it. tests/ 2007-04-16 Roland McGrath <roland@redhat.com> * dwfl-addr-sect.c: New file. * Makefile.am (noinst_PROGRAMS): Add it. (dwfl_addr_sect_LDADD): New variable.
Diffstat (limited to 'libdw')
-rw-r--r--libdw/ChangeLog14
-rw-r--r--libdw/Makefile.am4
-rw-r--r--libdw/dwarf_getsrcdirs.c69
-rw-r--r--libdw/dwarf_getsrclines.c24
-rw-r--r--libdw/libdw.h10
-rw-r--r--libdw/libdw.map3
-rw-r--r--libdw/libdwP.h4
7 files changed, 115 insertions, 13 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog
index 5d55dee2..50dc089e 100644
--- a/libdw/ChangeLog
+++ b/libdw/ChangeLog
@@ -1,5 +1,19 @@
+2007-04-16 Roland McGrath <roland@redhat.com>
+
+ * libdw.map (ELFUTILS_0.127): Add dwfl_module_address_section.
+
2007-04-05 Roland McGrath <roland@redhat.com>
+ * dwarf_getsrcdirs.c: New file.
+ * Makefile.am (libdw_a_SOURCES): Add it.
+ * libdw.h: Declare dwarf_getsrcdirs.
+ * libdw.map (ELFUTILS_0.127): Add it.
+
+ * libdwP.h (struct Dwarf_Files_s): New member ndirs.
+ * dwarf_getsrclines.c (dwarf_getsrclines): Don't clobber NDIRLIST to
+ zero before we use it to check for DWARF_E_INVALID_DIR_IDX.
+ Save DIRARRAY in the Dwarf_Files.
+
* dwarf_ranges.c (dwarf_ranges): Don't sign-extend 32-bit BEGIN
address to check for all-ones base address entry. Check directly.
Reported by Sébastien Dugué <sebastien.dugue@bull.net>.
diff --git a/libdw/Makefile.am b/libdw/Makefile.am
index 04d15bbf..62057dc9 100644
--- a/libdw/Makefile.am
+++ b/libdw/Makefile.am
@@ -1,6 +1,6 @@
## Process this file with automake to create Makefile.in
##
-## Copyright (C) 2002, 2003, 2004, 2005, 2006 Red Hat, Inc.
+## Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Red Hat, Inc.
## This file is part of Red Hat elfutils.
##
## Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -73,7 +73,7 @@ libdw_a_SOURCES = dwarf_begin.c dwarf_begin_elf.c dwarf_end.c dwarf_getelf.c \
dwarf_lineendsequence.c dwarf_lineblock.c \
dwarf_lineprologueend.c dwarf_lineepiloguebegin.c \
dwarf_onesrcline.c dwarf_formblock.c \
- dwarf_getsrcfiles.c dwarf_filesrc.c \
+ dwarf_getsrcfiles.c dwarf_filesrc.c dwarf_getsrcdirs.c \
dwarf_getlocation.c dwarf_getstring.c dwarf_offabbrev.c \
dwarf_getaranges.c dwarf_onearange.c dwarf_getarangeinfo.c \
dwarf_getarange_addr.c dwarf_getattrs.c dwarf_formflag.c \
diff --git a/libdw/dwarf_getsrcdirs.c b/libdw/dwarf_getsrcdirs.c
new file mode 100644
index 00000000..74786dd0
--- /dev/null
+++ b/libdw/dwarf_getsrcdirs.c
@@ -0,0 +1,69 @@
+/* Find include directories in source file information.
+ Copyright (C) 2007 Red Hat, Inc.
+ This file is part of Red Hat elfutils.
+
+ Red Hat elfutils is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by the
+ Free Software Foundation; version 2 of the License.
+
+ Red Hat elfutils is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ General Public License for more details.
+
+ You should have received a copy of the GNU General Public License along
+ with Red Hat elfutils; if not, write to the Free Software Foundation,
+ Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
+
+ In addition, as a special exception, Red Hat, Inc. gives You the
+ additional right to link the code of Red Hat elfutils with code licensed
+ under any Open Source Initiative certified open source license
+ (http://www.opensource.org/licenses/index.php) which requires the
+ distribution of source code with any binary distribution and to
+ distribute linked combinations of the two. Non-GPL Code permitted under
+ this exception must only link to the code of Red Hat elfutils through
+ those well defined interfaces identified in the file named EXCEPTION
+ found in the source code files (the "Approved Interfaces"). The files
+ of Non-GPL Code may instantiate templates or use macros or inline
+ functions from the Approved Interfaces without causing the resulting
+ work to be covered by the GNU General Public License. Only Red Hat,
+ Inc. may make changes or additions to the list of Approved Interfaces.
+ Red Hat's grant of this exception is conditioned upon your not adding
+ any new exceptions. If you wish to add a new Approved Interface or
+ exception, please contact Red Hat. You must obey the GNU General Public
+ License in all respects for all of the Red Hat elfutils code and other
+ code used in conjunction with Red Hat elfutils except the Non-GPL Code
+ covered by this exception. If you modify this file, you may extend this
+ exception to your version of the file, but you are not obligated to do
+ so. If you do not wish to provide this exception without modification,
+ you must delete this exception statement from your version and license
+ this file solely under the GPL without exception.
+
+ Red Hat elfutils is an included package of the Open Invention Network.
+ An included package of the Open Invention Network is a package for which
+ Open Invention Network licensees cross-license their patents. No patent
+ license is granted, either expressly or impliedly, by designation as an
+ included package. Should you wish to participate in the Open Invention
+ Network licensing program, please visit www.openinventionnetwork.com
+ <http://www.openinventionnetwork.com>. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "libdwP.h"
+
+
+int
+dwarf_getsrcdirs (files, result, ndirs)
+ Dwarf_Files *files;
+ const char *const **result;
+ size_t *ndirs;
+{
+ if (files == NULL)
+ return -1;
+
+ *result = (void *) &files->info[files->nfiles];
+ *ndirs = files->ndirs;
+ return 0;
+}
diff --git a/libdw/dwarf_getsrclines.c b/libdw/dwarf_getsrclines.c
index 2aed5d93..666cca22 100644
--- a/libdw/dwarf_getsrclines.c
+++ b/libdw/dwarf_getsrclines.c
@@ -1,5 +1,5 @@
/* Return line number information of CU.
- Copyright (C) 2004, 2005 Red Hat, Inc.
+ Copyright (C) 2004, 2005, 2007 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2004.
@@ -256,13 +256,10 @@ dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines, size_t *nlines)
/* Rearrange the list in array form. */
struct dirlist **dirarray
= (struct dirlist **) alloca (ndirlist * sizeof (*dirarray));
- while (ndirlist-- > 0)
- {
- dirarray[ndirlist] = dirlist;
- dirlist = dirlist->next;
- }
+ for (unsigned int n = ndirlist; n-- > 0; dirlist = dirlist->next)
+ dirarray[n] = dirlist;
- /* Now read the files. */
+ /* Now read the files. */
struct filelist null_file =
{
.info =
@@ -618,8 +615,11 @@ dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines, size_t *nlines)
/* Put all the files in an array. */
Dwarf_Files *files = libdw_alloc (dbg, Dwarf_Files,
sizeof (Dwarf_Files)
- + nfilelist * sizeof (Dwarf_Fileinfo),
- 1);
+ + nfilelist * sizeof (Dwarf_Fileinfo)
+ + (ndirlist + 1) * sizeof (char *),
+ 1);
+ const char **dirs = (void *) &files->info[nfilelist];
+
files->nfiles = nfilelist;
while (nfilelist-- > 0)
{
@@ -628,6 +628,12 @@ dwarf_getsrclines (Dwarf_Die *cudie, Dwarf_Lines **lines, size_t *nlines)
}
assert (filelist == NULL);
+ /* Put all the directory strings in an array. */
+ files->ndirs = ndirlist;
+ for (unsigned int i = 0; i < ndirlist; ++i)
+ dirs[i] = dirarray[i]->dir;
+ dirs[ndirlist] = NULL;
+
/* Remember the debugging descriptor. */
files->dbg = dbg;
diff --git a/libdw/libdw.h b/libdw/libdw.h
index d44f427d..968e73a2 100644
--- a/libdw/libdw.h
+++ b/libdw/libdw.h
@@ -1,5 +1,5 @@
/* Interfaces for libdw.
- Copyright (C) 2002, 2004, 2005, 2006 Red Hat, Inc.
+ Copyright (C) 2002, 2004, 2005, 2006, 2007 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -473,6 +473,14 @@ extern const char *dwarf_linesrc (Dwarf_Line *line,
extern const char *dwarf_filesrc (Dwarf_Files *file, size_t idx,
Dwarf_Word *mtime, Dwarf_Word *length);
+/* Return the directory list used in the file information extracted.
+ (*RESULT)[0] is the CU's DW_AT_comp_dir value, and may be null.
+ (*RESULT)[0..*NDIRS-1] are the compile-time include directory path
+ encoded by the compiler. */
+extern int dwarf_getsrcdirs (Dwarf_Files *files,
+ const char *const **result, size_t *ndirs)
+ __nonnull_attribute__ (2, 3);
+
/* Return location expression, decoded as a list of operations. */
extern int dwarf_getlocation (Dwarf_Attribute *attr, Dwarf_Op **expr,
diff --git a/libdw/libdw.map b/libdw/libdw.map
index e79b6e01..654bdfba 100644
--- a/libdw/libdw.map
+++ b/libdw/libdw.map
@@ -156,8 +156,11 @@ ELFUTILS_0.126 {
ELFUTILS_0.127 {
global:
+ dwarf_getsrcdirs;
+
dwfl_module_addrsym;
dwfl_report_begin_add;
+ dwfl_module_address_section;
local:
*;
diff --git a/libdw/libdwP.h b/libdw/libdwP.h
index 8baa3fa3..f069075b 100644
--- a/libdw/libdwP.h
+++ b/libdw/libdwP.h
@@ -1,5 +1,5 @@
/* Internal definitions for libdwarf.
- Copyright (C) 2002, 2003, 2004, 2005, 2006 Red Hat, Inc.
+ Copyright (C) 2002, 2003, 2004, 2005, 2006, 2007 Red Hat, Inc.
This file is part of Red Hat elfutils.
Written by Ulrich Drepper <drepper@redhat.com>, 2002.
@@ -209,6 +209,7 @@ struct Dwarf_Abbrev
struct Dwarf_Files_s
{
Dwarf *dbg;
+ unsigned int ndirs;
unsigned int nfiles;
struct Dwarf_Fileinfo_s
{
@@ -216,6 +217,7 @@ struct Dwarf_Files_s
Dwarf_Word mtime;
Dwarf_Word length;
} info[0];
+ /* nfiles of those, followed by char *[ndirs]. */
};
typedef struct Dwarf_Fileinfo_s Dwarf_Fileinfo;