]> git.ipfire.org Git - thirdparty/elfutils.git/commitdiff
Testcase for elf_getdata/elf_flagdata on NOBITS section
authorPetr Machata <pmachata@redhat.com>
Tue, 6 Apr 2010 12:16:58 +0000 (14:16 +0200)
committerPetr Machata <pmachata@redhat.com>
Tue, 6 Apr 2010 12:18:12 +0000 (14:18 +0200)
tests/ChangeLog
tests/Makefile.am
tests/run-test-flag-nobits.sh [new file with mode: 0755]
tests/test-flag-nobits.c [new file with mode: 0644]

index c871baa1f5bf6f527ea1a52a4fb996755c442e3f..c44e8186dd69ee5733bfb2f0cc3b073735e418dd 100644 (file)
@@ -1,3 +1,10 @@
+2010-04-01  Petr Machata  <pmachata@redhat.com>
+
+       * test-flag-nobits.c: New test.
+       * run-test-flag-nobits.sh: And its wrapper.
+       * Makefile.am (noinst_PROGRAMS, TESTS): Add them.
+       (test_flag_nobits_LDADD): New variable.
+
 2010-02-15  Roland McGrath  <roland@redhat.com>
 
        * Makefile.am: Use config/eu.am for common stuff.
index 1b9bc73b9aaae83db391d684549befe4db6479f2..048bb63b7ac48753848807a5cb2c5abeac049d03 100644 (file)
@@ -56,7 +56,8 @@ noinst_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \
                  find-prologues funcretval allregs rdwrmmap \
                  dwfl-bug-addr-overflow arls dwfl-bug-fd-leak \
                  dwfl-addr-sect dwfl-bug-report early-offscn \
-                 dwfl-bug-getmodules dwarf-getmacros addrcfi
+                 dwfl-bug-getmodules dwarf-getmacros addrcfi \
+                 test-flag-nobits
 asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \
            asm-tst6 asm-tst7 asm-tst8 asm-tst9
 
@@ -81,7 +82,8 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
        dwfl-bug-fd-leak dwfl-bug-report \
        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
+       run-early-offscn.sh run-dwarf-getmacros.sh \
+       run-test-flag-nobits.sh
 # run-show-ciefde.sh
 
 if !STANDALONE
@@ -230,6 +232,7 @@ dwfl_addr_sect_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
 sha1_tst_LDADD = $(libeu) $(libmudflap)
 dwarf_getmacros_LDADD = $(libdw) $(libmudflap)
 addrcfi_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
+test_flag_nobits_LDADD = $(libelf) $(libmudflap)
 
 if GCOV
 check: check-am coverage
diff --git a/tests/run-test-flag-nobits.sh b/tests/run-test-flag-nobits.sh
new file mode 100755 (executable)
index 0000000..1fae660
--- /dev/null
@@ -0,0 +1,30 @@
+#! /bin/sh
+# Copyright (C) 2010 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
+# <http://www.openinventionnetwork.com>.
+
+. $srcdir/test-subr.sh
+
+testfiles testfile
+
+testrun ./test-flag-nobits testfile
diff --git a/tests/test-flag-nobits.c b/tests/test-flag-nobits.c
new file mode 100644 (file)
index 0000000..3a79da9
--- /dev/null
@@ -0,0 +1,43 @@
+/* Copyright (C) 2010 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
+   <http://www.openinventionnetwork.com>.  */
+
+#include <fcntl.h>
+#include <stdlib.h>
+#include <gelf.h>
+
+int
+main (int argc, char **argv)
+{
+  if (argc != 2)
+    abort ();
+
+  elf_version (EV_CURRENT);
+
+  int fd = open64 (argv[1], O_RDONLY);
+  Elf *stripped = elf_begin (fd, ELF_C_READ, NULL);
+
+  Elf_Scn *scn = NULL;
+  while ((scn = elf_nextscn (stripped, scn)) != NULL)
+    elf_flagdata (elf_getdata (scn, NULL), ELF_C_SET, ELF_F_DIRTY);
+}