summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2006-04-04 21:31:16 +0000
committerUlrich Drepper <drepper@redhat.com>2006-04-04 21:31:16 +0000
commitba718b11356bdb0caea95a49a06ddb61a843cd3e (patch)
treeb5688eb521f5d4b636940f407c6f2956e6f6c7c5
parentFix read/write of existing file using mmap and different layout of the ELF (diff)
downloadelfutils-ba718b11356bdb0caea95a49a06ddb61a843cd3e.tar.gz
elfutils-ba718b11356bdb0caea95a49a06ddb61a843cd3e.tar.bz2
elfutils-ba718b11356bdb0caea95a49a06ddb61a843cd3e.tar.xz
Test case for problem in libelf with writing out existing ELF file with
different location of the section headers.
-rw-r--r--tests/ChangeLog8
-rw-r--r--tests/Makefile.am8
-rw-r--r--tests/rdwrmmap.c29
-rwxr-xr-xtests/run-bug1-test.sh22
-rw-r--r--tests/testfile28.bz2bin0 -> 171 bytes
-rw-r--r--tests/testfile28.rdwr.bz2bin0 -> 172 bytes
6 files changed, 64 insertions, 3 deletions
diff --git a/tests/ChangeLog b/tests/ChangeLog
index bccd736c..16b1491c 100644
--- a/tests/ChangeLog
+++ b/tests/ChangeLog
@@ -1,3 +1,11 @@
12006-04-04 Ulrich Drepper <drepper@redhat.com>
2
3 * Makefile.am: Add rules to run run-bug1-test.sh.
4 * rdwrmmap.c: New file.
5 * run-bug1-test.sh: New file.
6 * testfile28.bz2: New file.
7 * testfile28.rdwr.bz2: New file.
8
12006-03-09 Roland McGrath <roland@redhat.com> 92006-03-09 Roland McGrath <roland@redhat.com>
2 10
3 * Makefile.am (AM_LDFLAGS): Define to pass -rpath-link. 11 * Makefile.am (AM_LDFLAGS): Define to pass -rpath-link.
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 92881094..a88836bd 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -45,7 +45,7 @@ noinst_PROGRAMS = arextract arsymtest newfile saridx scnnames sectiondump \
45 show-die-info get-files get-lines get-pubnames \ 45 show-die-info get-files get-lines get-pubnames \
46 get-aranges allfcts line2addr addrscopes funcscopes \ 46 get-aranges allfcts line2addr addrscopes funcscopes \
47 show-abbrev hash newscn ecp dwflmodtest \ 47 show-abbrev hash newscn ecp dwflmodtest \
48 find-prologues funcretval allregs 48 find-prologues funcretval allregs rdwrmmap
49# get-ciefde 49# get-ciefde
50asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \ 50asm_TESTS = asm-tst1 asm-tst2 asm-tst3 asm-tst4 asm-tst5 \
51 asm-tst6 asm-tst7 asm-tst8 asm-tst9 51 asm-tst6 asm-tst7 asm-tst8 asm-tst9
@@ -62,7 +62,7 @@ TESTS = run-arextract.sh run-arsymtest.sh newfile test-nlist \
62 run-ranlib-test2.sh run-ranlib-test3.sh run-ranlib-test4.sh \ 62 run-ranlib-test2.sh run-ranlib-test3.sh run-ranlib-test4.sh \
63 run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \ 63 run-addrscopes.sh run-strings-test.sh run-funcscopes.sh \
64 run-find-prologues.sh run-allregs.sh run-readelf-test1.sh \ 64 run-find-prologues.sh run-allregs.sh run-readelf-test1.sh \
65 run-native-test.sh 65 run-native-test.sh run-bug1-test.sh
66# run-show-ciefde.sh 66# run-show-ciefde.sh
67 67
68if !STANDALONE 68if !STANDALONE
@@ -99,7 +99,8 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh \
99 testfile21.bz2 testfile21.index.bz2 \ 99 testfile21.bz2 testfile21.index.bz2 \
100 testfile22.bz2 testfile23.bz2 testfile24.bz2 testfile25.bz2 \ 100 testfile22.bz2 testfile23.bz2 testfile24.bz2 testfile25.bz2 \
101 testfile26.bz2 testfile27.bz2 \ 101 testfile26.bz2 testfile27.bz2 \
102 coverage.sh test-subr.sh test-wrapper.sh run-readelf-test1.sh 102 coverage.sh test-subr.sh test-wrapper.sh run-readelf-test1.sh \
103 run-bug1-test.sh testfile28.bz2 testfile28.rdwr.bz2
103 104
104installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir) \ 105installed_TESTS_ENVIRONMENT = libdir=$(DESTDIR)$(libdir) \
105 bindir=$(DESTDIR)$(bindir) \ 106 bindir=$(DESTDIR)$(bindir) \
@@ -181,6 +182,7 @@ asm_tst7_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl
181asm_tst8_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl 182asm_tst8_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl
182asm_tst9_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl 183asm_tst9_LDADD = $(libasm) $(libebl) $(libelf) $(libmudflap) -ldl
183dwflmodtest_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl 184dwflmodtest_LDADD = $(libdw) $(libebl) $(libelf) $(libmudflap) -ldl
185rdwrmmap_LDADD = $(libelf)
184 186
185CLEANFILES = xxx *.gcno *.gcda *gconv 187CLEANFILES = xxx *.gcno *.gcda *gconv
186 188
diff --git a/tests/rdwrmmap.c b/tests/rdwrmmap.c
new file mode 100644
index 00000000..263be0fd
--- /dev/null
+++ b/tests/rdwrmmap.c
@@ -0,0 +1,29 @@
1#include <errno.h>
2#include <error.h>
3#include <stdio.h>
4#include <fcntl.h>
5#include <unistd.h>
6#include <libelf.h>
7
8int
9main (int argc __attribute__ ((unused)), char *argv[])
10{
11 int fd = open (argv[1], O_RDWR);
12 if (fd < 0)
13 error (2, errno, "open: %s", argv[1]);
14
15 if (elf_version (EV_CURRENT) == EV_NONE)
16 error (1, 0, "libelf version mismatch");
17
18 Elf *elf = elf_begin (fd, ELF_C_RDWR_MMAP, NULL);
19 if (elf == NULL)
20 error (1, 0, "elf_begin: %s", elf_errmsg (-1));
21
22 if (elf_update (elf, ELF_C_WRITE) < 0)
23 error (1, 0, "elf_update: %s", elf_errmsg (-1));
24
25 elf_end (elf);
26 close (fd);
27
28 return 0;
29}
diff --git a/tests/run-bug1-test.sh b/tests/run-bug1-test.sh
new file mode 100755
index 00000000..4e12b77d
--- /dev/null
+++ b/tests/run-bug1-test.sh
@@ -0,0 +1,22 @@
1#! /bin/sh
2# Copyright (C) 2006 Red Hat, Inc.
3# Written by Ulrich Drepper <drepper@redhat.com>, 2006.
4#
5# This program is Open Source software; you can redistribute it and/or
6# modify it under the terms of the Open Software License version 1.0 as
7# published by the Open Source Initiative.
8#
9# You should have received a copy of the Open Software License along
10# with this program; if not, you may obtain a copy of the Open Software
11# License version 1.0 from http://www.opensource.org/licenses/osl.php or
12# by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
13# 3001 King Ranch Road, Ukiah, CA 95482.
14. $srcdir/test-subr.sh
15
16testfiles testfile28 testfile28.rdwr
17
18testrun ./rdwrmmap testfile28
19
20cmp testfile28 testfile28.rdwr
21
22exit 0
diff --git a/tests/testfile28.bz2 b/tests/testfile28.bz2
new file mode 100644
index 00000000..ca0dff3d
--- /dev/null
+++ b/tests/testfile28.bz2
Binary files differ
diff --git a/tests/testfile28.rdwr.bz2 b/tests/testfile28.rdwr.bz2
new file mode 100644
index 00000000..4c658484
--- /dev/null
+++ b/tests/testfile28.rdwr.bz2
Binary files differ