diff options
author | Roland McGrath <roland@redhat.com> | 2008-03-26 20:51:59 +0000 |
---|---|---|
committer | Roland McGrath <roland@redhat.com> | 2008-03-26 20:51:59 +0000 |
commit | d11f9cbecac4a5ac3848a68597028d1924f3ff6b (patch) | |
tree | bebe015f7e02d133fa3dec01f3d34c76fdb74756 | |
parent | 472b20d24ffbc2485f8a5e2be208a11d77e8e846 (diff) | |
download | elfutils-d11f9cbecac4a5ac3848a68597028d1924f3ff6b.tar.gz |
libdwfl/
* dwfl_module_getdwarf.c (load_symtab): Don't return success for
SHT_DYNSYM, just set *SYMSCN like the comment says.
-rw-r--r-- | libdwfl/ChangeLog | 19 | ||||
-rw-r--r-- | libdwfl/argp-std.c | 6 | ||||
-rw-r--r-- | libdwfl/dwfl_end.c | 11 | ||||
-rw-r--r-- | libdwfl/dwfl_module_getdwarf.c | 8 | ||||
-rw-r--r-- | libdwfl/dwfl_module_getsrc.c | 5 | ||||
-rw-r--r-- | libdwfl/libdwflP.h | 6 | ||||
-rw-r--r-- | src/ChangeLog | 6 | ||||
-rw-r--r-- | src/elflint.c | 5 | ||||
-rw-r--r-- | tests/ChangeLog | 4 | ||||
-rwxr-xr-x | tests/run-addrname-test.sh | 24 |
10 files changed, 78 insertions, 16 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 <roland@redhat.com> + + * 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 <roland@redhat.com> + + * dwfl_module_getsrc.c: Adjust address for module bias before search. + +2008-03-01 Roland McGrath <roland@redhat.com> + + * 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 <roland@redhat.com> * 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 { diff --git a/src/ChangeLog b/src/ChangeLog index 0bba5ca5..37127f56 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +2008-03-26 Roland McGrath <roland@redhat.com> + + * elflint.c (check_program_header): Accept PT_GNU_RELRO p_flags + that matches its PT_LOAD's p_flags &~ PF_W. On sparc, PF_X really + is valid in RELRO. + 2008-02-29 Roland McGrath <roland@redhat.com> * readelf.c (print_attributes): Add a cast. diff --git a/src/elflint.c b/src/elflint.c index 54aa1114..4448eef1 100644 --- a/src/elflint.c +++ b/src/elflint.c @@ -4055,9 +4055,10 @@ more than one GNU_RELRO entry in program header\n")); if ((phdr2->p_flags & PF_W) == 0) ERROR (gettext ("\ loadable segment GNU_RELRO applies to is not writable\n")); - if ((phdr2->p_flags & PF_X) != 0) + if ((phdr2->p_flags &~ PF_W) != (phdr->p_flags &~ PF_W)) ERROR (gettext ("\ -loadable segment GNU_RELRO applies to is executable\n")); +loadable segment [%u] flags do not match GNU_RELRO [%u] flags\n"), + cnt, inner); break; } } diff --git a/tests/ChangeLog b/tests/ChangeLog index 82fcc12a..502d0ab3 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,7 @@ +2008-03-19 Roland McGrath <roland@redhat.com> + + * run-addrname-test.sh: Add a new case. + 2008-02-22 Roland McGrath <roland@redhat.com> * run-elflint-test.sh: Typo fix. diff --git a/tests/run-addrname-test.sh b/tests/run-addrname-test.sh index ce47fe10..ab37e286 100755 --- a/tests/run-addrname-test.sh +++ b/tests/run-addrname-test.sh @@ -1,5 +1,5 @@ #! /bin/sh -# Copyright (C) 2007 Red Hat, Inc. +# Copyright (C) 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 @@ -62,4 +62,26 @@ small_global_first_at_large_global+0x1 ??:0 EOF +testfiles testfile12 testfile14 +tempfiles testmaps + +cat > testmaps <<EOF +00400000-00401000 r-xp 00000000 fd:01 4006812 `pwd`/testfile14 +00500000-00501000 rw-p 00000000 fd:01 4006812 `pwd`/testfile14 +01000000-01001000 r-xp 00000000 fd:01 1234567 `pwd`/testfile12 +01100000-01011000 rw-p 00000000 fd:01 1234567 `pwd`/testfile12 +2aaaaaaab000-2aaaaaaad000 rw-p 2aaaaaaab000 00:00 0 +2aaaaaae2000-2aaaaaae3000 rw-p 2aaaaaae2000 00:00 0 +7fff61068000-7fff6107d000 rw-p 7ffffffea000 00:00 0 [stack] +7fff611fe000-7fff61200000 r-xp 7fff611fe000 00:00 0 [vdso] +ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall] +EOF + +testrun_compare ../src/addr2line -S -M testmaps 0x40047c 0x10009db <<\EOF +caller+0x14 +/home/drepper/local/elfutils-build/20050425/v.c:11 +foo+0xb +/home/drepper/local/elfutils-build/20030710/u.c:5 +EOF + exit 0 |