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