summaryrefslogtreecommitdiffstats
path: root/tests/test-flag-nobits.c
diff options
context:
space:
mode:
authorPetr Machata <[email protected]>2010-04-06 14:16:58 +0200
committerPetr Machata <[email protected]>2010-04-06 14:18:12 +0200
commit77961b517488065e852ac83a1a5cdf7d18fe954c (patch)
treed98a145652b5d783932ed69db1cfb5dea1b7f37d /tests/test-flag-nobits.c
parentf56a9882f709637fb2af1179d20ac41c7f4badc0 (diff)
Testcase for elf_getdata/elf_flagdata on NOBITS section
Diffstat (limited to 'tests/test-flag-nobits.c')
-rw-r--r--tests/test-flag-nobits.c43
1 files changed, 43 insertions, 0 deletions
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);
+}