elfcomm.h 4.5 KB

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