summaryrefslogtreecommitdiffstats
path: root/tests/rdwrmmap.c
diff options
context:
space:
mode:
authorUlrich Drepper <[email protected]>2006-04-04 21:31:16 +0000
committerUlrich Drepper <[email protected]>2006-04-04 21:31:16 +0000
commitba718b11356bdb0caea95a49a06ddb61a843cd3e (patch)
treeb5688eb521f5d4b636940f407c6f2956e6f6c7c5 /tests/rdwrmmap.c
parent697d8d283e5fda32c1930135ff884dd276499e4a (diff)
Test case for problem in libelf with writing out existing ELF file with
different location of the section headers.
Diffstat (limited to 'tests/rdwrmmap.c')
-rw-r--r--tests/rdwrmmap.c29
1 files changed, 29 insertions, 0 deletions
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 @@
+#include <errno.h>
+#include <error.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <libelf.h>
+
+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;
+}