I came across a strange combination of new attribute with old form for
gcc. When gcc isn't using -gstrict-dwarf, it allows attributes from
newer versions, but doesn't use new forms, even if such an attribute
would need that. So this patch allows that (in particular for
DW_AT_ranges for dwarf2), but only in gnu mode. Does this look like a
I was seeing lots of warnings from dwarflint saying a location attribute
was outside containing scope. This was for things like the
DW_AT_location of a DW_TAG_formal_parameter. I think these shouldn't be
checked. In fact the first check in recursively_validate () already only
looked at code describing dies. So I made the second check for the
location address ranges use the same logic. Does this look OK, or is it
more subtle than that?
diff -w attached, full patch on mjw/location-range branch (since it is
I pushed some slightly higher level support for DW_TAG_GNU_call_site and
friends to the dwarf branch. Should have posted here. dwarflint doesn't
really check the requirements, but at least should not complain too
loudly when it encounters these new tags and attributes now.
-----BEGIN PGP SIGNED MESSAGE-----
Here's an attempt to cover elf_clone. I've tried to memcmp elf and cloned
elf, but this way it didn't work so I've used just manual comparison of
values. Tested on x86_64. Ok?
Signed-off-by: Marek Polacek <mpolacek(a)redhat.com>
tests/ChangeLog | 7 ++++
tests/Makefile.am | 7 ++--
tests/elf-clone.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++
tests/run-elf-clone.sh | 30 +++++++++++++++++++
4 files changed, 115 insertions(+), 3 deletions(-)
create mode 100644 tests/elf-clone.c
create mode 100755 tests/run-elf-clone.sh
diff --git a/tests/ChangeLog b/tests/ChangeLog
index 674fe96..3c51b13 100644
- --- a/tests/ChangeLog
@@ -1,3 +1,10 @@
+2011-03-31 Marek Polacek <mpolacek(a)redhat.com>
+ * elf-clone.c: New file.
+ * run-elf-clone.sh: Use it.
+ * Makefile.am (TESTS, EXTRA_DIST, noinst_PROGRAMS): Add files.
+ (elf_clone_LDADD): New variable.
2011-03-28 Marek Polacek <mpolacek(a)redhat.com>
* alldts.c: New file.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 35f55e3..83d6b25 100644
- --- a/tests/Makefile.am
@@ -58,7 +58,7 @@ noinst_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \
dwfl-addr-sect dwfl-bug-report early-offscn \
dwfl-bug-getmodules dwarf-getmacros addrcfi \
test-flag-nobits dwarf-getstring rerequest_tag \
- - alldts
+ alldts elf-clone
asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \
asm-tst6 asm-tst7 asm-tst8 asm-tst9
@@ -80,7 +80,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
run-readelf-test4.sh run-readelf-twofiles.sh \
run-native-test.sh run-bug1-test.sh \
dwfl-bug-addr-overflow run-addrname-test.sh \
- - dwfl-bug-fd-leak dwfl-bug-report \
+ dwfl-bug-fd-leak dwfl-bug-report run-elf-clone.sh \
run-dwfl-bug-offline-rel.sh run-dwfl-addr-sect.sh \
run-disasm-x86.sh run-disasm-x86-64.sh \
run-early-offscn.sh run-dwarf-getmacros.sh \
@@ -119,7 +119,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
run-addrname-test.sh run-dwfl-bug-offline-rel.sh \
run-dwfl-addr-sect.sh run-early-offscn.sh \
run-dwarf-getmacros.sh run-test-flag-nobits.sh \
- - run-dwarf-getstring.sh run-alldts.sh \
+ run-dwarf-getstring.sh run-alldts.sh run-elf-clone.sh \
testfile15.bz2 testfile15.debug.bz2 \
testfile16.bz2 testfile16.debug.bz2 \
testfile17.bz2 testfile17.debug.bz2 \
@@ -255,6 +255,7 @@ addrcfi_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
test_flag_nobits_LDADD = $(libelf) $(libmudflap)
rerequest_tag_LDADD = $(libdw) $(libmudflap)
alldts_LDADD = $(libebl) $(libelf) $(libmudflap)
+elf_clone_LDADD = $(libelf) $(libmudflap)
check: check-am coverage
diff --git a/tests/elf-clone.c b/tests/elf-clone.c
new file mode 100644
- --- /dev/null
@@ -0,0 +1,74 @@
+/* Test for elf_clone.
+ Copyright (C) 2011 Red Hat, Inc.
+ This file is part of Red Hat elfutils.
+ Written by Marek Polacek <mpolacek(a)redhat.com>, 2011.
+ 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.
+ 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>. */
+main (int argc __attribute__ ((unused)), char *argv)
+ /* Open ourselves for reading. */
+ int fd = open64 (argv, O_RDONLY);
+ if (fd == -1)
+ printf ("cannot open `%s': %m\n", argv);
+ return 1;
+ /* Tell the library which version are we expecting. */
+ elf_version (EV_CURRENT);
+ /* Get an ELF descriptor. */
+ struct Elf *elf = elf_begin (fd, ELF_C_RDWR, NULL);
+ if (elf == NULL)
+ printf ("cannot create ELF descriptor: %s\n", elf_errmsg (-1));
+ return 1;
+ /* This should return NULL. */
+ Elf *newelf = elf_clone (NULL, ELF_C_EMPTY);
+ if (newelf != NULL)
+ return 1;
+ /* Clone our descriptor. */
+ newelf = elf_clone (elf, ELF_C_EMPTY);
+ return !(elf->fildes == newelf->fildes
+ && elf->map_address == newelf->map_address
+ && elf->kind == newelf->kind
+ && elf->parent == newelf->parent
+ && elf->class == newelf->class
+ && elf->cmd == newelf->cmd
+ && elf->start_offset == newelf->start_offset
+ && elf->maximum_size == newelf->maximum_size
+ && newelf->ref_count == 1
+ && newelf->flags == ELF_F_DIRTY);
diff --git a/tests/run-elf-clone.sh b/tests/run-elf-clone.sh
new file mode 100755
- --- /dev/null
@@ -0,0 +1,30 @@
+# Copyright (C) 2011 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.
+# 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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (GNU/Linux)
-----END PGP SIGNATURE-----
I've just pushed another test for function ebl_dynamic_tag_name. This
function is used mainly in elflint, but also in readelf. Test is quite
simple--just print all the possible strings the function can return. Now
the ebl_dynamic_tag_name is fully covered.
I've also fixed last ChangeLog entry which contained wrong month number.
All is available in branch mpolacek/ebl_dynamic_tag_name.
Please review. Thanks,
I'd like to make -wline output more regular and useful. Currently lines
describing opcodes are formatted inconsistently either with or without
initial space. That's probably an aesthetic nit, I don't think that
there is a pattern to it.
Second, more important change is that I'd like to prefix opcode lines
with their offset. This should aid debugging and reviewing dwarflint
Both changes are on the branch pmachata/readelf.
All Fedora elfutils bugs are still getting assigned to me by default, I
presume just because I am the Fedora package owner. But I think you (or
Mark, I suppose) should be doing the initial triage for all such bugs.
You are auto-CC'd, so I'd just like your confirmation that you plan to
look at these and change their Assigned-to state in bugzilla on a
This patch adds support to the low-level dwarflint checks for the new
GNU extensions for call_site and entry_value support. Also on
OK to merge to dwarf branch and push?