• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /* Copyright (C) 1999, 2000, 2001, 2002 Red Hat, Inc.
2 
3    This program is Open Source software; you can redistribute it and/or
4    modify it under the terms of the Open Software License version 1.0 as
5    published by the Open Source Initiative.
6 
7    You should have received a copy of the Open Software License along
8    with this program; if not, you may obtain a copy of the Open Software
9    License version 1.0 from http://www.opensource.org/licenses/osl.php or
10    by writing the Open Source Initiative c/o Lawrence Rosen, Esq.,
11    3001 King Ranch Road, Ukiah, CA 95482.   */
12 
13 #include <assert.h>
14 #include <fcntl.h>
15 #include <libelf.h>
16 #include <stdio.h>
17 #include <stdlib.h>
18 #include <unistd.h>
19 
20 
21 int
main(int argc,char * argv[])22 main (int argc, char *argv[])
23 {
24   Elf *elf;
25   int fd;
26   Elf_Scn *section;
27 
28   if (elf_version (EV_CURRENT) == EV_NONE)
29     {
30       fprintf (stderr, "library fd of date\n");
31       exit (1);
32     }
33 
34   char name[] = "test.XXXXXX";
35   fd = mkstemp (name);
36   if (fd < 0)
37     {
38       fprintf (stderr, "Failed to open fdput file: %s\n", name);
39       exit (1);
40     }
41   unlink (name);
42 
43   elf = elf_begin (fd, ELF_C_WRITE, NULL);
44   if (elf == NULL)
45     {
46       fprintf (stderr, "Failed to elf_begin fdput file: %s\n", name);
47       exit (1);
48     }
49 
50   section = elf_newscn (elf);
51   section = elf_nextscn (elf, section);
52   assert (section == NULL);
53 
54   elf_end (elf);
55   close (fd);
56 
57   return 0;
58 }
59