From 77961b517488065e852ac83a1a5cdf7d18fe954c Mon Sep 17 00:00:00 2001 From: Petr Machata Date: Tue, 6 Apr 2010 14:16:58 +0200 Subject: [PATCH] Testcase for elf_getdata/elf_flagdata on NOBITS section --- tests/ChangeLog | 7 ++++++ tests/Makefile.am | 7 ++++-- tests/run-test-flag-nobits.sh | 30 ++++++++++++++++++++++++ tests/test-flag-nobits.c | 43 +++++++++++++++++++++++++++++++++++ 4 files changed, 85 insertions(+), 2 deletions(-) create mode 100755 tests/run-test-flag-nobits.sh create mode 100644 tests/test-flag-nobits.c diff --git a/tests/ChangeLog b/tests/ChangeLog index c871baa1f..c44e8186d 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,10 @@ +2010-04-01 Petr Machata + + * 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 * Makefile.am: Use config/eu.am for common stuff. diff --git a/tests/Makefile.am b/tests/Makefile.am index 1b9bc73b9..048bb63b7 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 000000000..1fae66036 --- /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 +# . + +. $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 000000000..3a79da918 --- /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 + . */ + +#include +#include +#include + +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); +} -- 2.47.2