home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 4: GNU Archives / Linux Cubed Series 4 - GNU Archives.iso / gnu / binutils.7 / binutils / binutils-2.7 / include / elf / mips.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-07-04  |  13.6 KB  |  477 lines

  1. /* MIPS ELF support for BFD.
  2.    Copyright (C) 1993, 1994, 1995, 1996 Free Software Foundation, Inc.
  3.  
  4.    By Ian Lance Taylor, Cygnus Support, <ian@cygnus.com>, from
  5.    information in the System V Application Binary Interface, MIPS
  6.    Processor Supplement.
  7.  
  8. This file is part of BFD, the Binary File Descriptor library.
  9.  
  10. This program is free software; you can redistribute it and/or modify
  11. it under the terms of the GNU General Public License as published by
  12. the Free Software Foundation; either version 2 of the License, or
  13. (at your option) any later version.
  14.  
  15. This program is distributed in the hope that it will be useful,
  16. but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  18. GNU General Public License for more details.
  19.  
  20. You should have received a copy of the GNU General Public License
  21. along with this program; if not, write to the Free Software
  22. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
  23.  
  24. /* This file holds definitions specific to the MIPS ELF ABI.  Note
  25.    that most of this is not actually implemented by BFD.  */
  26.  
  27. #ifndef _ELF_MIPS_H
  28. #define _ELF_MIPS_H
  29.  
  30. /* Processor specific flags for the ELF header e_flags field.  */
  31.  
  32. /* At least one .noreorder directive appears in the source.  */
  33. #define EF_MIPS_NOREORDER    0x00000001
  34.  
  35. /* File contains position independent code.  */
  36. #define EF_MIPS_PIC        0x00000002
  37.  
  38. /* Code in file uses the standard calling sequence for calling
  39.    position independent code.  */
  40. #define EF_MIPS_CPIC        0x00000004
  41.  
  42. /* Four bit MIPS architecture field.  */
  43. #define EF_MIPS_ARCH        0xf0000000
  44.  
  45. /* -mips1 code.  */
  46. #define E_MIPS_ARCH_1        0x00000000
  47.  
  48. /* -mips2 code.  */
  49. #define E_MIPS_ARCH_2        0x10000000
  50.  
  51. /* -mips3 code.  */
  52. #define E_MIPS_ARCH_3        0x20000000
  53.  
  54. /* -mips4 code.  */
  55. #define E_MIPS_ARCH_4        0x30000000
  56.  
  57. /* Processor specific section indices.  These sections do not actually
  58.    exist.  Symbols with a st_shndx field corresponding to one of these
  59.    values have a special meaning.  */
  60.  
  61. /* Defined and allocated common symbol.  Value is virtual address.  If
  62.    relocated, alignment must be preserved.  */
  63. #define SHN_MIPS_ACOMMON    0xff00
  64.  
  65. /* Defined and allocated text symbol.  Value is virtual address.
  66.    Occur in the dynamic symbol table of Alpha OSF/1 and Irix 5 executables.  */
  67. #define SHN_MIPS_TEXT        0xff01
  68.  
  69. /* Defined and allocated data symbol.  Value is virtual address.
  70.    Occur in the dynamic symbol table of Alpha OSF/1 and Irix 5 executables.  */
  71. #define SHN_MIPS_DATA        0xff02
  72.  
  73. /* Small common symbol.  */
  74. #define SHN_MIPS_SCOMMON    0xff03
  75.  
  76. /* Small undefined symbol.  */
  77. #define SHN_MIPS_SUNDEFINED    0xff04
  78.  
  79. /* Processor specific section types.  */
  80.  
  81. /* Section contains the set of dynamic shared objects used when
  82.    statically linking.  */
  83. #define SHT_MIPS_LIBLIST    0x70000000
  84.  
  85. /* I'm not sure what this is, but it's used on Irix 5.  */
  86. #define SHT_MIPS_MSYM        0x70000001
  87.  
  88. /* Section contains list of symbols whose definitions conflict with
  89.    symbols defined in shared objects.  */
  90. #define SHT_MIPS_CONFLICT    0x70000002
  91.  
  92. /* Section contains the global pointer table.  */
  93. #define SHT_MIPS_GPTAB        0x70000003
  94.  
  95. /* Section contains microcode information.  The exact format is
  96.    unspecified.  */
  97. #define SHT_MIPS_UCODE        0x70000004
  98.  
  99. /* Section contains some sort of debugging information.  The exact
  100.    format is unspecified.  It's probably ECOFF symbols.  */
  101. #define SHT_MIPS_DEBUG        0x70000005
  102.  
  103. /* Section contains register usage information.  */
  104. #define SHT_MIPS_REGINFO    0x70000006
  105.  
  106. /* Section contains miscellaneous options.  */
  107. #define SHT_MIPS_OPTIONS    0x7000000d
  108.  
  109. /* DWARF debugging section.  */
  110. #define SHT_MIPS_DWARF        0x7000001e
  111.  
  112. /* Events section.  */
  113. #define SHT_MIPS_EVENTS        0x70000021
  114.  
  115. /* A section of type SHT_MIPS_LIBLIST contains an array of the
  116.    following structure.  The sh_link field is the section index of the
  117.    string table.  The sh_info field is the number of entries in the
  118.    section.  */
  119. typedef struct
  120. {
  121.   /* String table index for name of shared object.  */
  122.   unsigned long l_name;
  123.   /* Time stamp.  */
  124.   unsigned long l_time_stamp;
  125.   /* Checksum of symbol names and common sizes.  */
  126.   unsigned long l_checksum;
  127.   /* String table index for version.  */
  128.   unsigned long l_version;
  129.   /* Flags.  */
  130.   unsigned long l_flags;
  131. } Elf32_Lib;
  132.  
  133. /* The l_flags field of an Elf32_Lib structure may contain the
  134.    following flags.  */
  135.  
  136. /* Require an exact match at runtime.  */
  137. #define LL_EXACT_MATCH        0x00000001
  138.  
  139. /* Ignore version incompatibilities at runtime.  */
  140. #define LL_IGNORE_INT_VER    0x00000002
  141.  
  142. /* A section of type SHT_MIPS_CONFLICT is an array of indices into the
  143.    .dynsym section.  Each element has the following type.  */
  144. typedef unsigned long Elf32_Conflict;
  145.  
  146. /* A section of type SHT_MIPS_GPTAB contains information about how
  147.    much GP space would be required for different -G arguments.  This
  148.    information is only used so that the linker can provide informative
  149.    suggestions as to the best -G value to use.  The sh_info field is
  150.    the index of the section for which this information applies.  The
  151.    contents of the section are an array of the following union.  The
  152.    first element uses the gt_header field.  The remaining elements use
  153.    the gt_entry field.  */
  154. typedef union
  155. {
  156.   struct
  157.     {
  158.       /* -G value actually used for this object file.  */
  159.       unsigned long gt_current_g_value;
  160.       /* Unused.  */
  161.       unsigned long gt_unused;
  162.     } gt_header;
  163.   struct
  164.     {
  165.       /* If this -G argument has been used...  */
  166.       unsigned long gt_g_value;
  167.       /* ...this many GP section bytes would be required.  */
  168.       unsigned long gt_bytes;
  169.     } gt_entry;
  170. } Elf32_gptab;
  171.  
  172. /* The external version of Elf32_gptab.  */
  173.  
  174. typedef union
  175. {
  176.   struct
  177.     {
  178.       unsigned char gt_current_g_value[4];
  179.       unsigned char gt_unused[4];
  180.     } gt_header;
  181.   struct
  182.     {
  183.       unsigned char gt_g_value[4];
  184.       unsigned char gt_bytes[4];
  185.     } gt_entry;
  186. } Elf32_External_gptab;
  187.  
  188. /* A section of type SHT_MIPS_REGINFO contains the following
  189.    structure.  */
  190. typedef struct
  191. {
  192.   /* Mask of general purpose registers used.  */
  193.   unsigned long ri_gprmask;
  194.   /* Mask of co-processor registers used.  */
  195.   unsigned long ri_cprmask[4];
  196.   /* GP register value for this object file.  */
  197.   long ri_gp_value;
  198. } Elf32_RegInfo;
  199.  
  200. /* The external version of the Elf_RegInfo structure.  */
  201. typedef struct
  202. {
  203.   unsigned char ri_gprmask[4];
  204.   unsigned char ri_cprmask[4][4];
  205.   unsigned char ri_gp_value[4];
  206. } Elf32_External_RegInfo;
  207.  
  208. /* MIPS ELF .reginfo swapping routines.  */
  209. extern void bfd_mips_elf32_swap_reginfo_in
  210.   PARAMS ((bfd *, const Elf32_External_RegInfo *, Elf32_RegInfo *));
  211. extern void bfd_mips_elf32_swap_reginfo_out
  212.   PARAMS ((bfd *, const Elf32_RegInfo *, Elf32_External_RegInfo *));
  213.  
  214. /* Processor specific section flags.  */
  215.  
  216. /* This section must be in the global data area.  */
  217. #define SHF_MIPS_GPREL        0x10000000
  218.  
  219. /* Processor specific program header types.  */
  220.  
  221. /* Register usage information.  Identifies one .reginfo section.  */
  222. #define PT_MIPS_REGINFO        0x70000000
  223.  
  224. /* Runtime procedure table.  */
  225. #define PT_MIPS_RTPROC        0x70000001
  226.  
  227. /* Processor specific dynamic array tags.  */
  228.  
  229. /* 32 bit version number for runtime linker interface.  */
  230. #define DT_MIPS_RLD_VERSION    0x70000001
  231.  
  232. /* Time stamp.  */
  233. #define DT_MIPS_TIME_STAMP    0x70000002
  234.  
  235. /* Checksum of external strings and common sizes.  */
  236. #define DT_MIPS_ICHECKSUM    0x70000003
  237.  
  238. /* Index of version string in string table.  */
  239. #define DT_MIPS_IVERSION    0x70000004
  240.  
  241. /* 32 bits of flags.  */
  242. #define DT_MIPS_FLAGS        0x70000005
  243.  
  244. /* Base address of the segment.  */
  245. #define DT_MIPS_BASE_ADDRESS    0x70000006
  246.  
  247. /* Address of .conflict section.  */
  248. #define DT_MIPS_CONFLICT    0x70000008
  249.  
  250. /* Address of .liblist section.  */
  251. #define DT_MIPS_LIBLIST        0x70000009
  252.  
  253. /* Number of local global offset table entries.  */
  254. #define DT_MIPS_LOCAL_GOTNO    0x7000000a
  255.  
  256. /* Number of entries in the .conflict section.  */
  257. #define DT_MIPS_CONFLICTNO    0x7000000b
  258.  
  259. /* Number of entries in the .liblist section.  */
  260. #define DT_MIPS_LIBLISTNO    0x70000010
  261.  
  262. /* Number of entries in the .dynsym section.  */
  263. #define DT_MIPS_SYMTABNO    0x70000011
  264.  
  265. /* Index of first external dynamic symbol not referenced locally.  */
  266. #define DT_MIPS_UNREFEXTNO    0x70000012
  267.  
  268. /* Index of first dynamic symbol in global offset table.  */
  269. #define DT_MIPS_GOTSYM        0x70000013
  270.  
  271. /* Number of page table entries in global offset table.  */
  272. #define DT_MIPS_HIPAGENO    0x70000014
  273.  
  274. /* Address of run time loader map, used for debugging.  */
  275. #define DT_MIPS_RLD_MAP        0x70000016
  276.  
  277. /* Flags which may appear in a DT_MIPS_FLAGS entry.  */
  278.  
  279. /* No flags.  */
  280. #define RHF_NONE        0x00000000
  281.  
  282. /* Uses shortcut pointers.  */
  283. #define RHF_QUICKSTART        0x00000001
  284.  
  285. /* Hash size is not a power of two.  */
  286. #define RHF_NOTPOT        0x00000002
  287.  
  288. /* Ignore LD_LIBRARY_PATH.  */
  289. #define RHS_NO_LIBRARY_REPLACEMENT \
  290.                 0x00000004
  291.  
  292. /* Special values for the st_other field in the symbol table.  These
  293.    are used in an Irix 5 dynamic symbol table.  */
  294.  
  295. #define STO_DEFAULT        0x00
  296. #define STO_INTERNAL        0x01
  297. #define STO_HIDDEN        0x02
  298. #define STO_PROTECTED        0x03
  299.  
  300. /* The 64-bit MIPS ELF ABI uses an usual reloc format.  Each
  301.    relocation entry specifies up to three actual relocations, all at
  302.    the same address.  The first relocation which required a symbol
  303.    uses the symbol in the r_sym field.  The second relocation which
  304.    requires a symbol uses the symbol in the r_ssym field.  If all
  305.    three relocations require a symbol, the third one uses a zero
  306.    value.  */
  307.  
  308. /* An entry in a 64 bit SHT_REL section.  */
  309.  
  310. typedef struct
  311. {
  312.   /* Address of relocation.  */
  313.   unsigned char r_offset[8];
  314.   /* Symbol index.  */
  315.   unsigned char r_sym[4];
  316.   /* Special symbol.  */
  317.   unsigned char r_ssym[1];
  318.   /* Third relocation.  */
  319.   unsigned char r_type3[1];
  320.   /* Second relocation.  */
  321.   unsigned char r_type2[1];
  322.   /* First relocation.  */
  323.   unsigned char r_type[1];
  324. } Elf64_Mips_External_Rel;
  325.  
  326. typedef struct
  327. {
  328.   /* Address of relocation.  */
  329.   bfd_vma r_offset;
  330.   /* Symbol index.  */
  331.   unsigned long r_sym;
  332.   /* Special symbol.  */
  333.   unsigned char r_ssym;
  334.   /* Third relocation.  */
  335.   unsigned char r_type3;
  336.   /* Second relocation.  */
  337.   unsigned char r_type2;
  338.   /* First relocation.  */
  339.   unsigned char r_type;
  340. } Elf64_Mips_Internal_Rel;
  341.  
  342. /* An entry in a 64 bit SHT_RELA section.  */
  343.  
  344. typedef struct
  345. {
  346.   /* Address of relocation.  */
  347.   unsigned char r_offset[8];
  348.   /* Symbol index.  */
  349.   unsigned char r_sym[4];
  350.   /* Special symbol.  */
  351.   unsigned char r_ssym[1];
  352.   /* Third relocation.  */
  353.   unsigned char r_type3[1];
  354.   /* Second relocation.  */
  355.   unsigned char r_type2[1];
  356.   /* First relocation.  */
  357.   unsigned char r_type[1];
  358.   /* Addend.  */
  359.   unsigned char r_addend[8];
  360. } Elf64_Mips_External_Rela;
  361.  
  362. typedef struct
  363. {
  364.   /* Address of relocation.  */
  365.   bfd_vma r_offset;
  366.   /* Symbol index.  */
  367.   unsigned long r_sym;
  368.   /* Special symbol.  */
  369.   unsigned char r_ssym;
  370.   /* Third relocation.  */
  371.   unsigned char r_type3;
  372.   /* Second relocation.  */
  373.   unsigned char r_type2;
  374.   /* First relocation.  */
  375.   unsigned char r_type;
  376.   /* Addend.  */
  377.   bfd_signed_vma r_addend;
  378. } Elf64_Mips_Internal_Rela;
  379.  
  380. /* Values found in the r_ssym field of a relocation entry.  */
  381.  
  382. /* No relocation.  */
  383. #define RSS_UNDEF    0
  384.  
  385. /* Value of GP.  */
  386. #define RSS_GP        1
  387.  
  388. /* Value of GP in object being relocated.  */
  389. #define RSS_GP0        2
  390.  
  391. /* Address of location being relocated.  */
  392. #define RSS_LOC        3
  393.  
  394. /* A SHT_MIPS_OPTIONS section contains a series of options, each of
  395.    which starts with this header.  */
  396.  
  397. typedef struct
  398. {
  399.   /* Type of option.  */
  400.   unsigned char kind[1];
  401.   /* Size of option descriptor, including header.  */
  402.   unsigned char size[1];
  403.   /* Section index of affected section, or 0 for global option.  */
  404.   unsigned char section[2];
  405.   /* Information specific to this kind of option.  */
  406.   unsigned char info[4];
  407. } Elf_External_Options;
  408.  
  409. typedef struct
  410. {
  411.   /* Type of option.  */
  412.   unsigned char kind;
  413.   /* Size of option descriptor, including header.  */
  414.   unsigned char size;
  415.   /* Section index of affected section, or 0 for global option.  */
  416.   unsigned short section;
  417.   /* Information specific to this kind of option.  */
  418.   unsigned long info;
  419. } Elf_Internal_Options;
  420.  
  421. /* MIPS ELF option header swapping routines.  */
  422. extern void bfd_mips_elf_swap_options_in
  423.   PARAMS ((bfd *, const Elf_External_Options *, Elf_Internal_Options *));
  424. extern void bfd_mips_elf_swap_options_out
  425.   PARAMS ((bfd *, const Elf_Internal_Options *, Elf_External_Options *));
  426.  
  427. /* Values which may appear in the kind field of an Elf_Options
  428.    structure.  */
  429.  
  430. /* Undefined.  */
  431. #define ODK_NULL    0
  432.  
  433. /* Register usage and GP value.  */
  434. #define ODK_REGINFO    1
  435.  
  436. /* Exception processing information.  */
  437. #define ODK_EXCEPTIONS    2
  438.  
  439. /* Section padding information.  */
  440. #define ODK_PAD        3
  441.  
  442. /* In the 32 bit ABI, an ODK_REGINFO option is just a Elf32_Reginfo
  443.    structure.  In the 64 bit ABI, it is the following structure.  The
  444.    info field of the options header is not used.  */
  445.  
  446. typedef struct
  447. {
  448.   /* Mask of general purpose registers used.  */
  449.   unsigned char ri_gprmask[4];
  450.   /* Padding.  */
  451.   unsigned char ri_pad[4];
  452.   /* Mask of co-processor registers used.  */
  453.   unsigned char ri_cprmask[4][4];
  454.   /* GP register value for this object file.  */
  455.   unsigned char ri_gp_value[8];
  456. } Elf64_External_RegInfo;
  457.  
  458. typedef struct
  459. {
  460.   /* Mask of general purpose registers used.  */
  461.   unsigned long ri_gprmask;
  462.   /* Padding.  */
  463.   unsigned long ri_pad;
  464.   /* Mask of co-processor registers used.  */
  465.   unsigned long ri_cprmask[4];
  466.   /* GP register value for this object file.  */
  467.   bfd_vma ri_gp_value;
  468. } Elf64_Internal_RegInfo;
  469.  
  470. /* MIPS ELF reginfo swapping routines.  */
  471. extern void bfd_mips_elf64_swap_reginfo_in
  472.   PARAMS ((bfd *, const Elf64_External_RegInfo *, Elf64_Internal_RegInfo *));
  473. extern void bfd_mips_elf64_swap_reginfo_out
  474.   PARAMS ((bfd *, const Elf64_Internal_RegInfo *, Elf64_External_RegInfo *));
  475.  
  476. #endif /* _ELF_MIPS_H */
  477.