1 /* elfcomm.h -- include file of common code for ELF format file.
2 Copyright (C) 2010-2015 Free Software Foundation, Inc.
4 Originally developed by Eric Youngdale <eric@andante.jic.com>
5 Modifications by Nick Clifton <nickc@redhat.com>
7 This file is part of GNU Binutils.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
29 void error (const char *, ...) ATTRIBUTE_PRINTF_1;
30 void warn (const char *, ...) ATTRIBUTE_PRINTF_1;
32 #if defined HAVE_LONG_LONG && SIZEOF_LONG_LONG > SIZEOF_LONG
33 /* We can't use any bfd types here since readelf may define BFD64 and
35 #define HOST_WIDEST_INT long long
37 #define HOST_WIDEST_INT long
39 typedef unsigned HOST_WIDEST_INT elf_vma;
41 extern void (*byte_put) (unsigned char *, elf_vma, int);
42 extern void byte_put_little_endian (unsigned char *, elf_vma, int);
43 extern void byte_put_big_endian (unsigned char *, elf_vma, int);
45 extern elf_vma (*byte_get) (unsigned char *, int);
46 extern elf_vma byte_get_signed (unsigned char *, int);
47 extern elf_vma byte_get_little_endian (unsigned char *, int);
48 extern elf_vma byte_get_big_endian (unsigned char *, int);
49 extern void byte_get_64 (unsigned char *, elf_vma *, elf_vma *);
51 #define BYTE_PUT(field, val) byte_put (field, val, sizeof (field))
52 #define BYTE_GET(field) byte_get (field, sizeof (field))
53 #define BYTE_GET_SIGNED(field) byte_get_signed (field, sizeof (field))
55 /* This is just a bit of syntatic sugar. */
56 #define streq(a,b) (strcmp ((a), (b)) == 0)
57 #define strneq(a,b,n) (strncmp ((a), (b), (n)) == 0)
58 #define const_strneq(a,b) (strncmp ((a), (b), sizeof (b) - 1) == 0)
60 /* Structure to hold information about an archive file. */
64 char * file_name; /* Archive file name. */
65 FILE * file; /* Open file descriptor. */
66 elf_vma index_num; /* Number of symbols in table. */
67 elf_vma * index_array; /* The array of member offsets. */
68 char * sym_table; /* The symbol table. */
69 unsigned long sym_size; /* Size of the symbol table. */
70 char * longnames; /* The long file names table. */
71 unsigned long longnames_size; /* Size of the long file names table. */
72 unsigned long nested_member_origin; /* Origin in the nested archive of the current member. */
73 unsigned long next_arhdr_offset; /* Offset of the next archive header. */
74 bfd_boolean is_thin_archive; /* TRUE if this is a thin archive. */
75 bfd_boolean uses_64bit_indicies; /* TRUE if the index table uses 64bit entries. */
76 struct ar_hdr arhdr; /* Current archive header. */
79 /* Return the path name for a proxy entry in a thin archive. */
80 extern char *adjust_relative_path (const char *, const char *, unsigned long);
82 /* Read the symbol table and long-name table from an archive. */
83 extern int setup_archive (struct archive_info *, const char *, FILE *,
84 bfd_boolean, bfd_boolean);
86 /* Open and setup a nested archive, if not already open. */
87 extern int setup_nested_archive (struct archive_info *, const char *);
89 /* Release the memory used for the archive information. */
90 extern void release_archive (struct archive_info *);
92 /* Get the name of an archive member from the current archive header. */
94 extern char *get_archive_member_name (struct archive_info *,
95 struct archive_info *);
97 /* Get the name of an archive member at a given offset within an
100 extern char *get_archive_member_name_at (struct archive_info *,
102 struct archive_info *);
104 /* Construct a string showing the name of the archive member, qualified
105 with the name of the containing archive file. */
107 extern char *make_qualified_name (struct archive_info *,
108 struct archive_info *,
111 #endif /* _ELFCOMM_H */