diff options
author | Roland McGrath <roland@redhat.com> | 2009-05-07 18:55:17 -0700 |
---|---|---|
committer | Roland McGrath <roland@redhat.com> | 2009-05-07 18:55:17 -0700 |
commit | 4e5e29e7722e9b6881a685002487f4ca3001c480 (patch) | |
tree | 4bbfbf6849a9b4a23920cdb71802ccb24c494171 | |
parent | 88edbb0872595e306751c71b912c6f65c61b87c9 (diff) | |
parent | e2eabd88c9a95e640fee4afc64d7445d323b0716 (diff) | |
download | elfutils-4e5e29e7722e9b6881a685002487f4ca3001c480.tar.gz |
Merge commit 'origin/master' into dwarf
Conflicts:
libdw/ChangeLog
-rw-r--r-- | libdw/ChangeLog | 6 | ||||
-rw-r--r-- | libdw/dwarf_getmacros.c | 34 |
2 files changed, 26 insertions, 14 deletions
diff --git a/libdw/ChangeLog b/libdw/ChangeLog index d5928858..bd694639 100644 --- a/libdw/ChangeLog +++ b/libdw/ChangeLog @@ -55,6 +55,12 @@ * c++/dwarf: New file. * Makefile.am (pkginclude_HEADERS): Add it. +2009-05-07 Roland McGrath <roland@redhat.com> + + * dwarf_getmacros.c (dwarf_getmacros): Use absolute section offset in + return value and OFFSET argument, not CU-relative. Only fetch the + attribute data when called with OFFSET of 0. + 2009-05-07 Petr Machata <pmachata@redhat.com> * dwarf_getmacros.c (dwarf_getmacros): Take into account offset in diff --git a/libdw/dwarf_getmacros.c b/libdw/dwarf_getmacros.c index 5f24d37b..22afbc3f 100644 --- a/libdw/dwarf_getmacros.c +++ b/libdw/dwarf_getmacros.c @@ -1,5 +1,5 @@ /* Get macro information. - Copyright (C) 2002, 2003, 2004, 2005 Red Hat, Inc. + Copyright (C) 2002-2009 Red Hat, Inc. This file is part of Red Hat elfutils. Written by Ulrich Drepper <drepper@redhat.com>, 2002. @@ -65,16 +65,6 @@ dwarf_getmacros (die, callback, arg, offset) void *arg; ptrdiff_t offset; { - /* Get the appropriate attribute. */ - Dwarf_Attribute attr; - if (INTUSE(dwarf_attr) (die, DW_AT_macro_info, &attr) == NULL) - return -1; - - /* Offset into the .debug_macinfo section. */ - Dwarf_Word macoff; - if (INTUSE(dwarf_formudata) (&attr, &macoff) != 0) - return -1; - Elf_Data *d = die->cu->dbg->sectiondata[IDX_debug_macinfo]; if (unlikely (d == NULL) || unlikely (d->d_buf == NULL)) { @@ -82,8 +72,24 @@ dwarf_getmacros (die, callback, arg, offset) return -1; } - const unsigned char *macdata = d->d_buf + macoff; - const unsigned char *readp = macdata + offset; + if (offset == 0) + { + /* Get the appropriate attribute. */ + Dwarf_Attribute attr; + if (INTUSE(dwarf_attr) (die, DW_AT_macro_info, &attr) == NULL) + return -1; + + /* Offset into the .debug_macinfo section. */ + Dwarf_Word macoff; + if (INTUSE(dwarf_formudata) (&attr, &macoff) != 0) + return -1; + + offset = macoff; + } + if (unlikely (offset > (ptrdiff_t) d->d_size)) + goto invalid; + + const unsigned char *readp = d->d_buf + offset; const unsigned char *readendp = d->d_buf + d->d_size; if (readp == readendp) @@ -145,7 +151,7 @@ dwarf_getmacros (die, callback, arg, offset) mac.param2.s = str; if (callback (&mac, arg) != DWARF_CB_OK) - return readp - macdata; + return readp - (const unsigned char *) d->d_buf; } /* If we come here the termination of the data for the CU is not |