From ba718b11356bdb0caea95a49a06ddb61a843cd3e Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Tue, 4 Apr 2006 21:31:16 +0000 Subject: [PATCH] Test case for problem in libelf with writing out existing ELF file with different location of the section headers. --- tests/ChangeLog | 8 ++++++++ tests/Makefile.am | 8 +++++--- tests/rdwrmmap.c | 29 +++++++++++++++++++++++++++++ tests/run-bug1-test.sh | 22 ++++++++++++++++++++++ tests/testfile28.bz2 | Bin 0 -> 171 bytes tests/testfile28.rdwr.bz2 | Bin 0 -> 172 bytes 6 files changed, 64 insertions(+), 3 deletions(-) create mode 100644 tests/rdwrmmap.c create mode 100755 tests/run-bug1-test.sh create mode 100644 tests/testfile28.bz2 create mode 100644 tests/testfile28.rdwr.bz2 diff --git a/tests/ChangeLog b/tests/ChangeLog index bccd736c3..16b1491c0 100644 --- a/tests/ChangeLog +++ b/tests/ChangeLog @@ -1,3 +1,11 @@ +2006-04-04 Ulrich Drepper + + * Makefile.am: Add rules to run run-bug1-test.sh. + * rdwrmmap.c: New file. + * run-bug1-test.sh: New file. + * testfile28.bz2: New file. + * testfile28.rdwr.bz2: New file. + 2006-03-09 Roland McGrath * Makefile.am (AM_LDFLAGS): Define to pass -rpath-link. diff --git a/tests/Makefile.am b/tests/Makefile.am index 92881094c..a88836bd8 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -45,7 +45,7 @@ noinst_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \ show-die-info get-files get-lines get-pubnames \ get-aranges allfcts line2addr addrscopes funcscopes \ show-abbrev hash newscn ecp dwflmodtest \ - find-prologues funcretval allregs + find-prologues funcretval allregs rdwrmmap # get-ciefde asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \ asm-tst6 asm-tst7 asm-tst8 asm-tst9 @@ -62,7 +62,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \ run-ranlib-test2.sh run-ranlib-test3.sh run-ranlib-test4.sh \ run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \ run-find-prologues.sh run-allregs.sh run-readelf-test1.sh \ - run-native-test.sh + run-native-test.sh run-bug1-test.sh # run-show-ciefde.sh if !STANDALONE @@ -99,7 +99,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \ testfile21.bz2 testfile21.index.bz2 \ testfile22.bz2 testfile23.bz2 testfile24.bz2 testfile25.bz2 \ testfile26.bz2 testfile27.bz2 \ - coverage.sh test-subr.sh test-wrapper.sh run-readelf-test1.sh + coverage.sh test-subr.sh test-wrapper.sh run-readelf-test1.sh \ + run-bug1-test.sh testfile28.bz2 testfile28.rdwr.bz2 installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir) \ bindir=$(DESTDIR)$(bindir) \ @@ -181,6 +182,7 @@ asm_tst7_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl asm_tst8_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl asm_tst9_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl dwflmodtest_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl +rdwrmmap_LDADD = $(libelf) CLEANFILES = xxx *.gcno *.gcda *gconv diff --git a/tests/rdwrmmap.c b/tests/rdwrmmap.c new file mode 100644 index 000000000..263be0fd3 --- /dev/null +++ b/tests/rdwrmmap.c @@ -0,0 +1,29 @@ +#include +#include +#include +#include +#include +#include + +int +main (int argc __attribute__ ((unused)), char *argv[]) +{ + int fd = open (argv[1], O_RDWR); + if (fd < 0) + error (2, errno, "open: %s", argv[1]); + + if (elf_version (EV_CURRENT) == EV_NONE) + error (1, 0, "libelf version mismatch"); + + Elf *elf = elf_begin (fd, ELF_C_RDWR_MMAP, NULL); + if (elf == NULL) + error (1, 0, "elf_begin: %s", elf_errmsg (-1)); + + if (elf_update (elf, ELF_C_WRITE) < 0) + error (1, 0, "elf_update: %s", elf_errmsg (-1)); + + elf_end (elf); + close (fd); + + return 0; +} diff --git a/tests/run-bug1-test.sh b/tests/run-bug1-test.sh new file mode 100755 index 000000000..4e12b77da --- /dev/null +++ b/tests/run-bug1-test.sh @@ -0,0 +1,22 @@ +#! /bin/sh +# Copyright (C) 2006 Red Hat, Inc. +# Written by Ulrich Drepper , 2006. +# +# This program is Open Source software; you can redistribute it and/or +# modify it under the terms of the Open Software License version 1.0 as +# published by the Open Source Initiative. +# +# You should have received a copy of the Open Software License along +# with this program; if not, you may obtain a copy of the Open Software +# License version 1.0 from http://www.opensource.org/licenses/osl.php or +# by writing the Open Source Initiative c/o Lawrence Rosen, Esq., +# 3001 King Ranch Road, Ukiah, CA 95482. +. $srcdir/test-subr.sh + +testfiles testfile28 testfile28.rdwr + +testrun ./rdwrmmap testfile28 + +cmp testfile28 testfile28.rdwr + +exit 0 diff --git a/tests/testfile28.bz2 b/tests/testfile28.bz2 new file mode 100644 index 0000000000000000000000000000000000000000..ca0dff3d007bdb2f22bb3ade2abc68bbc514b243 GIT binary patch literal 171 zc-jH0095}%T4*^jL0KkKS=Qebh5!JNeV~8os7N4%KmlU}c0ycWzyKfsi49Llsxo+> zXxb1O7$@op5=a^vX`pB^G|(DY@#CCVZ|R_ep&}qul%dIt=fOylS5kozrdA_@N*_uf z8wS$e${I+!-Q=9`>aIf>T%#LdUd2x00@T8m4T(mZg}j0gFdbcO+AV2@P%WSYQ{_NP++W literal 0 Hc-jL100001 diff --git a/tests/testfile28.rdwr.bz2 b/tests/testfile28.rdwr.bz2 new file mode 100644 index 0000000000000000000000000000000000000000..4c658484fe82fd51ab026810bad9c13367e8e75e GIT binary patch literal 172 zc-jH108{@$T4*^jL0KkKS=Zef+W-KL|AK$$s7fG(00Bb;0swYGTwuUJAOMLF)M}4J z*%JxsU=YC{stFQM+Km7Pni^?{1b<^o(^oC5C!6OD5DX?rd?mhnx&k&K9Ki$bVUe1L z(wGLpw79cNNf!IKlg$o_$qkk7g=