blob: 466f2f68d66292df6c8b71a86d840f85638c2bca [file] [log] [blame]
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00001/* Copyright (C) 1999, 2000, 2001, 2002, 2005 Red Hat, Inc.
Mark Wielaardde2ed972012-06-05 17:15:16 +02002 This file is part of elfutils.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00003
Mark Wielaardde2ed972012-06-05 17:15:16 +02004 This file is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
Ulrich Drepperb08d5a82005-07-26 05:00:05 +00008
Mark Wielaardde2ed972012-06-05 17:15:16 +02009 elfutils is distributed in the hope that it will be useful, but
Ulrich Drepper361df7d2006-04-04 21:38:57 +000010 WITHOUT ANY WARRANTY; without even the implied warranty of
Mark Wielaardde2ed972012-06-05 17:15:16 +020011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
Ulrich Drepper361df7d2006-04-04 21:38:57 +000013
Mark Wielaardde2ed972012-06-05 17:15:16 +020014 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000016
Roland McGrathd7f8d0c2005-11-17 02:32:03 +000017#ifdef HAVE_CONFIG_H
18# include <config.h>
19#endif
20
Ulrich Drepperb08d5a82005-07-26 05:00:05 +000021#include <assert.h>
22#include <fcntl.h>
23#include <libelf.h>
24#include <stdio.h>
25#include <stdlib.h>
26#include <unistd.h>
27
28
29int
30main (void)
31{
32 Elf *elf;
33 int fd;
34 Elf_Scn *section;
35
36 if (elf_version (EV_CURRENT) == EV_NONE)
37 {
38 fprintf (stderr, "library fd of date\n");
39 exit (1);
40 }
41
42 char name[] = "test.XXXXXX";
43 fd = mkstemp (name);
44 if (fd < 0)
45 {
46 fprintf (stderr, "Failed to open fdput file: %s\n", name);
47 exit (1);
48 }
49 unlink (name);
50
51 elf = elf_begin (fd, ELF_C_WRITE, NULL);
52 if (elf == NULL)
53 {
54 fprintf (stderr, "Failed to elf_begin fdput file: %s\n", name);
55 exit (1);
56 }
57
58 section = elf_newscn (elf);
59 section = elf_nextscn (elf, section);
60 assert (section == NULL);
61
62 elf_end (elf);
63 close (fd);
64
65 return 0;
66}