summaryrefslogtreecommitdiffstats
path: root/libdwfl
diff options
context:
space:
mode:
authorRoland McGrath <[email protected]>2008-03-26 20:51:59 +0000
committerRoland McGrath <[email protected]>2008-03-26 20:51:59 +0000
commitd11f9cbecac4a5ac3848a68597028d1924f3ff6b (patch)
treebebe015f7e02d133fa3dec01f3d34c76fdb74756 /libdwfl
parent472b20d24ffbc2485f8a5e2be208a11d77e8e846 (diff)
libdwfl/
* dwfl_module_getdwarf.c (load_symtab): Don't return success for SHT_DYNSYM, just set *SYMSCN like the comment says.
Diffstat (limited to 'libdwfl')
-rw-r--r--libdwfl/ChangeLog19
-rw-r--r--libdwfl/argp-std.c6
-rw-r--r--libdwfl/dwfl_end.c11
-rw-r--r--libdwfl/dwfl_module_getdwarf.c8
-rw-r--r--libdwfl/dwfl_module_getsrc.c5
-rw-r--r--libdwfl/libdwflP.h6
6 files changed, 42 insertions, 13 deletions
diff --git a/libdwfl/ChangeLog b/libdwfl/ChangeLog
index 01a2537e..265720ae 100644
--- a/libdwfl/ChangeLog
+++ b/libdwfl/ChangeLog
@@ -1,3 +1,22 @@
+2008-03-26 Roland McGrath <[email protected]>
+
+ * dwfl_module_getdwarf.c (load_symtab): Don't return success for
+ SHT_DYNSYM, just set *SYMSCN like the comment says.
+
+ * dwfl_end.c (dwfl_end): Iterate on modulelist chain, not modules array.
+
+ * argp-std.c (parse_opt): On failure, call dwfl_end before argp_failure.
+
+2008-03-19 Roland McGrath <[email protected]>
+
+ * dwfl_module_getsrc.c: Adjust address for module bias before search.
+
+2008-03-01 Roland McGrath <[email protected]>
+
+ * libdwflP.h (__libdwfl_seterrno): Remove parameter name from
+ prototype to avoid older compiler's complaint about reuse of the name.
+ (__libdwfl_canon_error): Likewise.
+
2008-02-19 Roland McGrath <[email protected]>
* relocate.c (relocate_section): Check for an unhandled relocation
diff --git a/libdwfl/argp-std.c b/libdwfl/argp-std.c
index 11397889..1abb568f 100644
--- a/libdwfl/argp-std.c
+++ b/libdwfl/argp-std.c
@@ -1,5 +1,5 @@
/* Standard argp argument parsers for tools using libdwfl.
- Copyright (C) 2005, 2007 Red Hat, Inc.
+ Copyright (C) 2005, 2007, 2008 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -108,13 +108,13 @@ parse_opt (int key, char *arg, struct argp_state *state)
{
inline void failure (Dwfl *dwfl, int errnum, const char *msg)
{
+ if (dwfl != NULL)
+ dwfl_end (dwfl);
if (errnum == -1)
argp_failure (state, EXIT_FAILURE, 0, "%s: %s",
msg, INTUSE(dwfl_errmsg) (-1));
else
argp_failure (state, EXIT_FAILURE, errnum, "%s", msg);
- if (dwfl != NULL)
- dwfl_end (dwfl);
}
inline error_t fail (Dwfl *dwfl, int errnum, const char *msg)
{
diff --git a/libdwfl/dwfl_end.c b/libdwfl/dwfl_end.c
index e339b147..4bd40052 100644
--- a/libdwfl/dwfl_end.c
+++ b/libdwfl/dwfl_end.c
@@ -1,5 +1,5 @@
/* Finish a session using libdwfl.
- Copyright (C) 2005 Red Hat, Inc.
+ Copyright (C) 2005, 2008 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -54,9 +54,12 @@ dwfl_end (Dwfl *dwfl)
{
if (dwfl != NULL)
{
- for (size_t i = 0; i < dwfl->nmodules; ++i)
- if (dwfl->modules[i] != NULL)
- __libdwfl_module_free (dwfl->modules[i]);
+ while (dwfl->modulelist != NULL)
+ {
+ Dwfl_Module *mod = dwfl->modulelist;
+ dwfl->modulelist = mod->next;
+ __libdwfl_module_free (mod);
+ }
free (dwfl->modules);
free (dwfl);
}
diff --git a/libdwfl/dwfl_module_getdwarf.c b/libdwfl/dwfl_module_getdwarf.c
index 7dd9b53f..38bffe58 100644
--- a/libdwfl/dwfl_module_getdwarf.c
+++ b/libdwfl/dwfl_module_getdwarf.c
@@ -218,6 +218,7 @@ load_symtab (struct dwfl_file *file, struct dwfl_file **symfile,
Elf_Scn **symscn, Elf_Scn **xndxscn,
size_t *syments, GElf_Word *strshndx)
{
+ bool symtab = false;
Elf_Scn *scn = NULL;
while ((scn = elf_nextscn (file->elf, scn)) != NULL)
{
@@ -226,6 +227,7 @@ load_symtab (struct dwfl_file *file, struct dwfl_file **symfile,
switch (shdr->sh_type)
{
case SHT_SYMTAB:
+ symtab = true;
*symscn = scn;
*symfile = file;
*strshndx = shdr->sh_link;
@@ -235,6 +237,8 @@ load_symtab (struct dwfl_file *file, struct dwfl_file **symfile,
break;
case SHT_DYNSYM:
+ if (symtab)
+ break;
/* Use this if need be, but keep looking for SHT_SYMTAB. */
*symscn = scn;
*symfile = file;
@@ -244,7 +248,7 @@ load_symtab (struct dwfl_file *file, struct dwfl_file **symfile,
case SHT_SYMTAB_SHNDX:
*xndxscn = scn;
- if (*symscn != NULL)
+ if (symtab)
return DWFL_E_NOERROR;
break;
@@ -253,7 +257,7 @@ load_symtab (struct dwfl_file *file, struct dwfl_file **symfile,
}
}
- if (*symscn != NULL)
+ if (symtab)
/* We found one, though no SHT_SYMTAB_SHNDX to go with it. */
return DWFL_E_NOERROR;
diff --git a/libdwfl/dwfl_module_getsrc.c b/libdwfl/dwfl_module_getsrc.c
index 84c7eaaf..be03055e 100644
--- a/libdwfl/dwfl_module_getsrc.c
+++ b/libdwfl/dwfl_module_getsrc.c
@@ -1,5 +1,5 @@
/* Find source location for PC address in module.
- Copyright (C) 2005 Red Hat, Inc.
+ Copyright (C) 2005, 2008 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -63,6 +63,9 @@ dwfl_module_getsrc (Dwfl_Module *mod, Dwarf_Addr addr)
error = __libdwfl_cu_getsrclines (cu);
if (likely (error == DWFL_E_NOERROR))
{
+ /* Now we look at the module-relative address. */
+ addr -= bias;
+
/* The lines are sorted by address, so we can use binary search. */
size_t l = 0, u = cu->die.cu->lines->nlines;
while (l < u)
diff --git a/libdwfl/libdwflP.h b/libdwfl/libdwflP.h
index bbb56aac..50c6cd83 100644
--- a/libdwfl/libdwflP.h
+++ b/libdwfl/libdwflP.h
@@ -1,5 +1,5 @@
/* Internal definitions for libdwfl.
- Copyright (C) 2005, 2006, 2007 Red Hat, Inc.
+ Copyright (C) 2005, 2006, 2007, 2008 Red Hat, Inc.
This file is part of Red Hat elfutils.
Red Hat elfutils is free software; you can redistribute it and/or modify
@@ -99,8 +99,8 @@ typedef enum { DWFL_ERRORS DWFL_E_NUM } Dwfl_Error;
#define OTHER_ERROR(name) ((unsigned int) DWFL_E_##name << 16)
#define DWFL_E(name, errno) (OTHER_ERROR (name) | (errno))
-extern int __libdwfl_canon_error (Dwfl_Error error) internal_function;
-extern void __libdwfl_seterrno (Dwfl_Error error) internal_function;
+extern int __libdwfl_canon_error (Dwfl_Error) internal_function;
+extern void __libdwfl_seterrno (Dwfl_Error) internal_function;
struct Dwfl
{