summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPetr Machata <pmachata@redhat.com>2010-04-06 14:16:58 +0200
committerPetr Machata <pmachata@redhat.com>2010-04-06 14:18:12 +0200
commit77961b517488065e852ac83a1a5cdf7d18fe954c (patch)
treed98a145652b5d783932ed69db1cfb5dea1b7f37d
parentf56a9882f709637fb2af1179d20ac41c7f4badc0 (diff)
downloadandroid_external_elfutils-77961b517488065e852ac83a1a5cdf7d18fe954c.tar.gz
android_external_elfutils-77961b517488065e852ac83a1a5cdf7d18fe954c.tar.bz2
android_external_elfutils-77961b517488065e852ac83a1a5cdf7d18fe954c.zip
Testcase for elf_getdata/elf_flagdata on NOBITS section
-rw-r--r--tests/ChangeLog7
-rw-r--r--tests/Makefile.am7
-rwxr-xr-xtests/run-test-flag-nobits.sh30
-rw-r--r--tests/test-flag-nobits.c43
4 files changed, 85 insertions, 2 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index c871baa1..c44e8186 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -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.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 1b9bc73b..048bb63b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -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
index 00000000..1fae6603
--- /dev/null
+++ b/tests/run-test-flag-nobits.sh
@@ -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
index 00000000..3a79da91
--- /dev/null
+++ b/tests/test-flag-nobits.c
@@ -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);
+}