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