blob: 56eae97111c9efa4a6312158980fc987ad5231e2 [file] [log] [blame]
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00001/* Copyright (C) 1999, 2000, 2001, 2002, 2005 Red Hat, Inc.
Ulrich Drepper361df7d2006-04-04 21:38:57 +00002 This file is part of Red Hat elfutils.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00003
Ulrich Drepper361df7d2006-04-04 21:38:57 +00004 Red Hat elfutils is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by the
6 Free Software Foundation; version 2 of the License.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00007
Ulrich Drepper361df7d2006-04-04 21:38:57 +00008 Red Hat elfutils is distributed in the hope that it will be useful, but
9 WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 General Public License for more details.
12
13 You should have received a copy of the GNU General Public License along
14 with Red Hat elfutils; if not, write to the Free Software Foundation,
Ulrich Drepper1e9ef502006-04-04 22:29:06 +000015 Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA.
Ulrich Drepper361df7d2006-04-04 21:38:57 +000016
17 Red Hat elfutils is an included package of the Open Invention Network.
18 An included package of the Open Invention Network is a package for which
19 Open Invention Network licensees cross-license their patents. No patent
20 license is granted, either expressly or impliedly, by designation as an
21 included package. Should you wish to participate in the Open Invention
22 Network licensing program, please visit www.openinventionnetwork.com
23 <http://www.openinventionnetwork.com>. */
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000024
Roland McGrathd7f8d0c2005-11-17 02:32:03 +000025#ifdef HAVE_CONFIG_H
26# include <config.h>
27#endif
28
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000029#include <assert.h>
30#include <fcntl.h>
31#include <libelf.h>
32#include <stdio.h>
33#include <stdlib.h>
34#include <unistd.h>
35
36
37int
38main (void)
39{
40 Elf *elf;
41 int fd;
42 Elf_Scn *section;
43
44 if (elf_version (EV_CURRENT) == EV_NONE)
45 {
46 fprintf (stderr, "library fd of date\n");
47 exit (1);
48 }
49
50 char name[] = "test.XXXXXX";
51 fd = mkstemp (name);
52 if (fd < 0)
53 {
54 fprintf (stderr, "Failed to open fdput file: %s\n", name);
55 exit (1);
56 }
57 unlink (name);
58
59 elf = elf_begin (fd, ELF_C_WRITE, NULL);
60 if (elf == NULL)
61 {
62 fprintf (stderr, "Failed to elf_begin fdput file: %s\n", name);
63 exit (1);
64 }
65
66 section = elf_newscn (elf);
67 section = elf_nextscn (elf, section);
68 assert (section == NULL);
69
70 elf_end (elf);
71 close (fd);
72
73 return 0;
74}