Hi Mark, jankratochvil/s390-core-readelf
On Tue, 29 Jan 2013 11:22:17 +0100, Mark Wielaard wrote: > On Wed, 2013-01-23 at 22:13 +0100, Jan Kratochvil wrote: > > Re: [patch] Implement reglocs for s390/s390x > > https://lists.fedorahosted.org/pipermail/elfutils-devel/2012-October/002715.html > > Message-ID: <[email protected]> > > I admit to be a little lost in the review thread. But it seems to me > this could be split up between formatting changes (like the \n, b, B > readelf.c one) and the actual s390_corenote.c change. Would it be > possible to post this as separate patches (and maybe even split off the > test addition if that depends on the formatting)? here is the readelf.c part. But it is not useful without [patch 2/2] as nothing in elfutils is using the format this patch fixes. If you use jankratochvil/s390-core with this patch undone one sees (reversed): LINUX 8 S390_LAST_BREAK - last_break: 0xfd75ccbe, last_break: 0x06000000 - last_break: 0x07030000 [...] - last_break: 0x10809f00 - la./test-subr.sh: line 73: 20195 Segmentation fault LD_LIBRARY_PATH="${built_library_path}${LD_LIBRARY_PATH:+:}$LD_LIBRARY_PATH" $VALGRIND_CMD "$@" + last_break: 0xfd75ccbe + LINUX 4 S390_SYSTEM_CALL This is because S390_LAST_BREAK has only single item and readelf.c expected single-item is repeating through the whole section data. But in this case the item has even offset 4 bytes (and size 4 bytes in a section of 8 bytes; initial 4 bytes are ignored). Repeating items with offset were not handled correctly, which led to the crash. So it is best not to errorneously consider S390_LAST_BREAK to have repeating content. Thanks, Jan commit 22881b36d6512394a20c67edfc31ae745e0e50b3 Author: Jan Kratochvil <[email protected]> Date: Wed Oct 10 19:32:05 2012 +0200 src/ * readelf.c (handle_core_items): Limit special repeated items handling to single-item formats '\n', 'b' and 'B', assert OFFSET 0 there. Signed-off-by: Jan Kratochvil <[email protected]> diff --git a/src/ChangeLog b/src/ChangeLog index 377c124..4d00013 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,8 @@ +2013-01-29 Jan Kratochvil <[email protected]> + + * readelf.c (handle_core_items): Limit special repeated items handling + to single-item formats '\n', 'b' and 'B', assert OFFSET 0 there. + 2012-12-18 Mark Wielaard <[email protected]> * readelf.c (ELF_INPUT_SECTION): New argp key value. diff --git a/src/readelf.c b/src/readelf.c index 0b46459..c256102 100644 --- a/src/readelf.c +++ b/src/readelf.c @@ -7851,6 +7851,24 @@ handle_core_items (Elf *core, const void *desc, size_t descsz, { if (nitems == 0) return 0; + unsigned int colno = 0; + + /* FORMAT '\n' makes sense to be present only as a single item as it + processes all the data of a note. FORMATs 'b' and 'B' have a special case + if present as a single item but they can be also processed with other + items below. */ + if (nitems == 1 && (items[0].format == '\n' || items[0].format == 'b' + || items[0].format == 'B')) + { + assert (items[0].offset == 0); + size_t size = descsz; + colno = handle_core_item (core, items, desc, colno, &size); + /* If SIZE is not zero here there is some remaining data. But we do not + know how to process it anyway. */ + return colno; + } + for (size_t i = 0; i < nitems; ++i) + assert (items[i].format != '\n'); /* Sort to collect the groups together. */ const Ebl_Core_Item *sorted_items[nitems]; @@ -7869,23 +7887,7 @@ handle_core_items (Elf *core, const void *desc, size_t descsz, qsort (groups, ngroups, sizeof groups[0], &compare_core_item_groups); /* Write out all the groups. */ - unsigned int colno = 0; - const void *last = desc; - if (nitems == 1) - { - size_t size = descsz; - /* If this note contains registers as well as items, don't pass - &size to express that we don't wish to repeat. */ - colno = handle_core_item (core, sorted_items[0], desc, colno, - size != 0 ? &size : NULL); - - if (size == 0) - return colno; - desc += descsz - size; - descsz = size; - } - do { for (size_t i = 0; i < ngroups; ++i) _______________________________________________ elfutils-devel mailing list [email protected] https://lists.fedorahosted.org/mailman/listinfo/elfutils-devel
