From 3dd657b1d099808f55beac3272b3d41d6048472c Mon Sep 17 00:00:00 2001 From: Tom Rix Date: Thu, 24 May 2001 20:32:58 +0000 Subject: [PATCH] Support for xcoff64 --- include/coff/ChangeLog | 8 + include/coff/internal.h | 16 +- include/coff/rs6000.h | 266 +++++++++++------ include/coff/rs6k64.h | 303 +++++++++++--------- include/coff/xcoff.h | 617 ++++++++++++++++++++++++++++++++++++++++ 5 files changed, 986 insertions(+), 224 deletions(-) create mode 100644 include/coff/xcoff.h diff --git a/include/coff/ChangeLog b/include/coff/ChangeLog index 2341019f7c1..712ecc11753 100644 --- a/include/coff/ChangeLog +++ b/include/coff/ChangeLog @@ -1,3 +1,11 @@ +2001-04-05 Tom Rix + + * rs6000.h : move xcoff32 external structures from xcofflink. + * rs6k64.h : move xcoff64 external structures from xcofflink. + * internal.h : promote 32 bit structure elements to 64 bit + for xcoff64 support + * xcoff.h : New file. + 2001-03-23 Nick Clifton * a29k.h: Fix compile time warning. diff --git a/include/coff/internal.h b/include/coff/internal.h index 9b62710cd25..bc62b06f95a 100644 --- a/include/coff/internal.h +++ b/include/coff/internal.h @@ -173,7 +173,7 @@ struct internal_aouthdr unsigned long tagentries; /* number of tag entries to follow */ /* RS/6000 stuff */ - unsigned long o_toc; /* address of TOC */ + bfd_vma o_toc; /* address of TOC */ short o_snentry; /* section number for entry point */ short o_sntext; /* section number for text */ short o_sndata; /* section number for data */ @@ -184,8 +184,8 @@ struct internal_aouthdr short o_algndata; /* max alignment for data */ short o_modtype; /* Module type field, 1R,RE,RO */ short o_cputype; /* Encoded CPU type */ - unsigned long o_maxstack; /* max stack size allowed. */ - unsigned long o_maxdata; /* max data size allowed. */ + bfd_vma o_maxstack; /* max stack size allowed. */ + bfd_vma o_maxdata; /* max data size allowed. */ /* ECOFF stuff */ bfd_vma bss_start; /* Base of bss section. */ @@ -357,8 +357,8 @@ struct internal_lineno { union { - long l_symndx; /* function name symbol index, iff l_lnno == 0*/ - long l_paddr; /* (physical) address of line number */ + bfd_signed_vma l_symndx; /* function name symbol index, iff l_lnno == 0*/ + bfd_signed_vma l_paddr; /* (physical) address of line number */ } l_addr; unsigned long l_lnno; /* line number */ }; @@ -381,7 +381,7 @@ struct internal_syment } _n_n; char *_n_nptr[2]; /* allows for overlaying */ } _n; - long n_value; /* value of symbol */ + bfd_vma n_value; /* value of symbol */ short n_scnum; /* section number */ unsigned short n_flags; /* copy of flags from filhdr */ unsigned short n_type; /* type and derived type */ @@ -468,7 +468,7 @@ union internal_auxent { struct { /* if ISFCN, tag, or .bb */ - long x_lnnoptr; /* ptr to fcn line # */ + bfd_signed_vma x_lnnoptr; /* ptr to fcn line # */ union { /* entry ndx past block end */ long l; @@ -519,7 +519,7 @@ union internal_auxent { union { /* csect length or enclosing csect */ - long l; + bfd_signed_vma l; struct coff_ptr_struct *p; } x_scnlen; long x_parmhash; /* parm type hash index */ diff --git a/include/coff/rs6000.h b/include/coff/rs6000.h index afddc765725..0c34861142a 100644 --- a/include/coff/rs6000.h +++ b/include/coff/rs6000.h @@ -1,5 +1,5 @@ /* IBM RS/6000 "XCOFF" file definitions for BFD. - Copyright 1990, 1991, 1993, 1994, 1995 Free Software Foundation, Inc. + Copyright (C) 1990, 1991 Free Software Foundation, Inc. FIXME: Can someone provide a transliteration of this name into ASCII? Using the following chars caused a compiler warning on HIUX (so I replaced them with octal escapes), and isn't useful without an understanding of what @@ -7,10 +7,17 @@ Written by Mimi Ph\373\364ng-Th\345o V\365 of IBM and John Gilmore of Cygnus Support. */ -#define DO_NOT_DEFINE_AOUTHDR -#define DO_NOT_DEFINE_AUXENT -#define L_LNNO_SIZE 2 -#include "coff/external.h" +/********************** FILE HEADER **********************/ + +struct external_filehdr { + char f_magic[2]; /* magic number */ + char f_nscns[2]; /* number of sections */ + char f_timdat[4]; /* time & date stamp */ + char f_symptr[4]; /* file pointer to symtab */ + char f_nsyms[4]; /* number of symtab entries */ + char f_opthdr[2]; /* sizeof(optional hdr) */ + char f_flags[2]; /* flags */ +}; /* IBM RS/6000 */ #define U802WRMAGIC 0730 /* writeable text segments **chh** */ @@ -21,8 +28,13 @@ ((x).f_magic != U802ROMAGIC && (x).f_magic != U802WRMAGIC && \ (x).f_magic != U802TOCMAGIC) +#define FILHDR struct external_filehdr +#define FILHSZ 20 + + /********************** AOUT "OPTIONAL HEADER" **********************/ + typedef struct { unsigned char magic[2]; /* type of file */ @@ -54,115 +66,149 @@ AOUTHDR; #define SMALL_AOUTSZ (28) #define AOUTHDRSZ 72 -#define RS6K_AOUTHDR_OMAGIC 0x0107 /* old: text & data writeable */ -#define RS6K_AOUTHDR_NMAGIC 0x0108 /* new: text r/o, data r/w */ -#define RS6K_AOUTHDR_ZMAGIC 0x010B /* paged: text r/o, both page-aligned */ +/********************** SECTION HEADER **********************/ -/* More names of "special" sections. */ -#define _PAD ".pad" -#define _LOADER ".loader" -/* XCOFF uses a special .loader section with type STYP_LOADER. */ -#define STYP_LOADER 0x1000 - -/* XCOFF uses a special .debug section with type STYP_DEBUG. */ -#define STYP_DEBUG 0x2000 - -/* XCOFF handles line number or relocation overflow by creating - another section header with STYP_OVRFLO set. */ -#define STYP_OVRFLO 0x8000 +struct external_scnhdr { + char s_name[8]; /* section name */ + char s_paddr[4]; /* physical address, aliased s_nlib */ + char s_vaddr[4]; /* virtual address */ + char s_size[4]; /* section size */ + char s_scnptr[4]; /* file ptr to raw data for section */ + char s_relptr[4]; /* file ptr to relocation */ + char s_lnnoptr[4]; /* file ptr to line numbers */ + char s_nreloc[2]; /* number of relocation entries */ + char s_nlnno[2]; /* number of line number entries*/ + char s_flags[4]; /* flags */ +}; -union external_auxent -{ - struct - { - char x_tagndx[4]; /* str, un, or enum tag indx */ +#define SCNHDR struct external_scnhdr +#define SCNHSZ 40 + +/********************** LINE NUMBERS **********************/ + +/* 1 line number entry for every "breakpointable" source line in a section. + * Line numbers are grouped on a per function basis; first entry in a function + * grouping will have l_lnno = 0 and in place of physical address will be the + * symbol table index of the function name. + */ +struct external_lineno { + union { + char l_symndx[4]; /* function name symbol index, iff l_lnno == 0*/ + char l_paddr[4]; /* (physical) address of line number */ + } l_addr; + char l_lnno[2]; /* line number */ +}; - union - { - struct - { - char x_lnno[2]; /* declaration line number */ - char x_size[2]; /* str/union/array size */ - } x_lnsz; - char x_fsize[4]; /* size of function */ +#define LINENO struct external_lineno +#define LINESZ 6 - } x_misc; - union - { - struct /* if ISFCN, tag, or .bb */ - { - char x_lnnoptr[4]; /* ptr to fcn line # */ - char x_endndx[4]; /* entry ndx past block end */ - } x_fcn; +/********************** SYMBOLS **********************/ - struct /* if ISARY, up to 4 dimen. */ - { - char x_dimen[E_DIMNUM][2]; - } x_ary; +#define E_SYMNMLEN 8 /* # characters in a symbol name */ +#define E_FILNMLEN 14 /* # characters in a file name */ +#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ - } x_fcnary; +struct external_syment +{ + union { + char e_name[E_SYMNMLEN]; + struct { + char e_zeroes[4]; + char e_offset[4]; + } e; + } e; + char e_value[4]; + char e_scnum[2]; + char e_type[2]; + char e_sclass[1]; + char e_numaux[1]; +}; - char x_tvndx[2]; /* tv index */ - } x_sym; - union - { - char x_fname[E_FILNMLEN]; +#define N_BTMASK (017) +#define N_TMASK (060) +#define N_BTSHFT (4) +#define N_TSHIFT (2) + + +union external_auxent { + struct { + char x_tagndx[4]; /* str, un, or enum tag indx */ + union { + struct { + char x_lnno[2]; /* declaration line number */ + char x_size[2]; /* str/union/array size */ + } x_lnsz; + char x_fsize[4]; /* size of function */ + } x_misc; + union { + struct { /* if ISFCN, tag, or .bb */ + char x_lnnoptr[4]; /* ptr to fcn line # */ + char x_endndx[4]; /* entry ndx past block end */ + } x_fcn; + struct { /* if ISARY, up to 4 dimen. */ + char x_dimen[E_DIMNUM][2]; + } x_ary; + } x_fcnary; + char x_tvndx[2]; /* tv index */ + } x_sym; + + union { + char x_fname[E_FILNMLEN]; + struct { + char x_zeroes[4]; + char x_offset[4]; + } x_n; + } x_file; + + struct { + char x_scnlen[4]; /* section length */ + char x_nreloc[2]; /* # relocation entries */ + char x_nlinno[2]; /* # line numbers */ + } x_scn; + + struct { + char x_tvfill[4]; /* tv fill value */ + char x_tvlen[2]; /* length of .tv */ + char x_tvran[2][2]; /* tv range */ + } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ + + struct { + unsigned char x_scnlen[4]; + unsigned char x_parmhash[4]; + unsigned char x_snhash[2]; + unsigned char x_smtyp[1]; + unsigned char x_smclas[1]; + unsigned char x_stab[4]; + unsigned char x_snstab[2]; + } x_csect; - struct - { - char x_zeroes[4]; - char x_offset[4]; - } x_n; - - } x_file; - - struct - { - char x_scnlen[4]; /* section length */ - char x_nreloc[2]; /* # relocation entries */ - char x_nlinno[2]; /* # line numbers */ - } x_scn; - - struct - { - char x_tvfill[4]; /* tv fill value */ - char x_tvlen[2]; /* length of .tv */ - char x_tvran[2][2]; /* tv range */ - } x_tv; /* info about .tv section (in auxent of symbol .tv)) */ - - struct - { - unsigned char x_scnlen[4]; - unsigned char x_parmhash[4]; - unsigned char x_snhash[2]; - unsigned char x_smtyp[1]; - unsigned char x_smclas[1]; - unsigned char x_stab[4]; - unsigned char x_snstab[2]; - } x_csect; }; +#define SYMENT struct external_syment +#define SYMESZ 18 #define AUXENT union external_auxent #define AUXESZ 18 - #define DBXMASK 0x80 /* for dbx storage mask */ #define SYMNAME_IN_DEBUG(symptr) ((symptr)->n_sclass & DBXMASK) + + /********************** RELOCATION DIRECTIVES **********************/ -struct external_reloc -{ + +struct external_reloc { char r_vaddr[4]; char r_symndx[4]; char r_size[1]; char r_type[1]; }; + #define RELOC struct external_reloc #define RELSZ 10 @@ -171,3 +217,51 @@ struct external_reloc #define DEFAULT_TEXT_SECTION_ALIGNMENT 4 /* For new sections we havn't heard of before */ #define DEFAULT_SECTION_ALIGNMENT 4 + +/* The ldhdr structure. This appears at the start of the .loader + section. */ + +struct external_ldhdr +{ + bfd_byte l_version[4]; + bfd_byte l_nsyms[4]; + bfd_byte l_nreloc[4]; + bfd_byte l_istlen[4]; + bfd_byte l_nimpid[4]; + bfd_byte l_impoff[4]; + bfd_byte l_stlen[4]; + bfd_byte l_stoff[4]; +}; + +#define LDHDRSZ (8 * 4) + +struct external_ldsym +{ + union + { + bfd_byte _l_name[SYMNMLEN]; + struct + { + bfd_byte _l_zeroes[4]; + bfd_byte _l_offset[4]; + } _l_l; + } _l; + bfd_byte l_value[4]; + bfd_byte l_scnum[2]; + bfd_byte l_smtype[1]; + bfd_byte l_smclas[1]; + bfd_byte l_ifile[4]; + bfd_byte l_parm[4]; +}; + +#define LDSYMSZ (8 + 3 * 4 + 2 + 2) + +struct external_ldrel +{ + bfd_byte l_vaddr[4]; + bfd_byte l_symndx[4]; + bfd_byte l_rtype[2]; + bfd_byte l_rsecnm[2]; +}; + +#define LDRELSZ (2 * 4 + 2 * 2) diff --git a/include/coff/rs6k64.h b/include/coff/rs6k64.h index a8675bd8602..c9dd29f5c1f 100644 --- a/include/coff/rs6k64.h +++ b/include/coff/rs6k64.h @@ -1,6 +1,5 @@ /* IBM RS/6000 "XCOFF64" file definitions for BFD. - - Copyright 2000 Free Software Foundation, Inc. + Copyright (C) 2000 Free Software Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -14,47 +13,58 @@ You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software - Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - -#define DO_NOT_DEFINE_AOUTHDR -#define DO_NOT_DEFINE_SCNHDR -#define DO_NOT_DEFINE_LINENO -#define DO_NOT_DEFINE_AUXENT -#include "coff/external.h" + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + +/********************** FILE HEADER **********************/ + +struct external_filehdr { + char f_magic[2]; /* magic number */ + char f_nscns[2]; /* number of sections */ + char f_timdat[4]; /* time & date stamp */ + char f_symptr[8];/* file pointer to symtab */ + char f_opthdr[2]; /* sizeof(optional hdr) */ + char f_flags[2]; /* flags */ + char f_nsyms[4]; /* number of symtab entries */ +}; /* IBM RS/6000 */ #define U803XTOCMAGIC 0757 /* readonly text segments and TOC, XCOFF64 */ #define BADMAG(x) ((x).f_magic != U803XTOCMAGIC) +#define FILHDR struct external_filehdr +#define FILHSZ 24 + /********************** AOUT "OPTIONAL HEADER" **********************/ + typedef struct { - unsigned char magic[2]; /* type of file */ - unsigned char vstamp[2]; /* version stamp */ - unsigned char o_debugger[4]; /* reserved */ + unsigned char magic[2]; /* type of file */ + unsigned char vstamp[2]; /* version stamp */ + unsigned char o_debugger[4]; /* reserved */ unsigned char text_start[8]; /* base of text used for this file */ unsigned char data_start[8]; /* base of data used for this file */ unsigned char o_toc[8]; /* address of TOC */ - unsigned char o_snentry[2]; /* section number of entry point */ - unsigned char o_sntext[2]; /* section number of .text section */ - unsigned char o_sndata[2]; /* section number of .data section */ - unsigned char o_sntoc[2]; /* section number of TOC */ - unsigned char o_snloader[2]; /* section number of .loader section */ - unsigned char o_snbss[2]; /* section number of .bss section */ - unsigned char o_algntext[2]; /* .text alignment */ - unsigned char o_algndata[2]; /* .data alignment */ - unsigned char o_modtype[2]; /* module type (??) */ - unsigned char o_cputype[2]; /* cpu type */ - unsigned char o_resv2[4]; /* reserved */ - unsigned char tsize[8]; /* text size bytes, padded to FW bdry */ - unsigned char dsize[8]; /* initialized data " " */ - unsigned char bsize[8]; /* uninitialized data " " */ - unsigned char entry[8]; /* entry pt. */ + unsigned char o_snentry[2]; /* section number of entry point */ + unsigned char o_sntext[2]; /* section number of .text section */ + unsigned char o_sndata[2]; /* section number of .data section */ + unsigned char o_sntoc[2]; /* section number of TOC */ + unsigned char o_snloader[2]; /* section number of .loader section */ + unsigned char o_snbss[2]; /* section number of .bss section */ + unsigned char o_algntext[2]; /* .text alignment */ + unsigned char o_algndata[2]; /* .data alignment */ + unsigned char o_modtype[2]; /* module type (??) */ + unsigned char o_cputype[2]; /* cpu type */ + unsigned char o_resv2[4]; /* reserved */ + unsigned char tsize[8]; /* text size bytes, padded to FW bdry */ + unsigned char dsize[8]; /* initialized data " " */ + unsigned char bsize[8]; /* uninitialized data " " */ + unsigned char entry[8]; /* entry pt. */ unsigned char o_maxstack[8]; /* max stack size (??) */ unsigned char o_maxdata[8]; /* max data size (??) */ - unsigned char o_resv3[16]; /* reserved */ + unsigned char o_resv3[16]; /* reserved */ } AOUTHDR; @@ -62,15 +72,11 @@ AOUTHDR; #define SMALL_AOUTSZ (0) #define AOUTHDRSZ 72 -#define RS6K_AOUTHDR_OMAGIC 0x0107 /* old: text & data writeable */ -#define RS6K_AOUTHDR_NMAGIC 0x0108 /* new: text r/o, data r/w */ -#define RS6K_AOUTHDR_ZMAGIC 0x010B /* paged: text r/o, both page-aligned */ +/********************** SECTION HEADER **********************/ -/********************** SECTION HEADER **********************/ -struct external_scnhdr -{ - char s_name[8]; /* section name */ +struct external_scnhdr { + char s_name[8]; /* section name */ char s_paddr[8]; /* physical address, aliased s_nlib */ char s_vaddr[8]; /* virtual address */ char s_size[8]; /* section size */ @@ -79,121 +85,114 @@ struct external_scnhdr char s_lnnoptr[8]; /* file ptr to line numbers */ char s_nreloc[4]; /* number of relocation entries */ char s_nlnno[4]; /* number of line number entries*/ - char s_flags[4]; /* flags */ - char s_pad[4]; /* padding */ + char s_flags[4]; /* flags */ + char s_pad[4]; /* padding */ }; -/* - * names of "special" sections - */ -#define _TEXT ".text" -#define _DATA ".data" -#define _BSS ".bss" -#define _PAD ".pad" -#define _LOADER ".loader" #define SCNHDR struct external_scnhdr #define SCNHSZ 72 -/* XCOFF uses a special .loader section with type STYP_LOADER. */ -#define STYP_LOADER 0x1000 - -/* XCOFF uses a special .debug section with type STYP_DEBUG. */ -#define STYP_DEBUG 0x2000 - -/* XCOFF handles line number or relocation overflow by creating - another section header with STYP_OVRFLO set. */ -#define STYP_OVRFLO 0x8000 - /********************** LINE NUMBERS **********************/ /* 1 line number entry for every "breakpointable" source line in a section. - Line numbers are grouped on a per function basis; first entry in a function - grouping will have l_lnno = 0 and in place of physical address will be the - symbol table index of the function name. */ -struct external_lineno -{ - union - { - char l_symndx[8];/* function name symbol index, iff l_lnno == 0*/ - char l_paddr[8]; /* (physical) address of line number */ - } l_addr; - - char l_lnno[4]; /* line number */ + * Line numbers are grouped on a per function basis; first entry in a function + * grouping will have l_lnno = 0 and in place of physical address will be the + * symbol table index of the function name. + */ +struct external_lineno { + union { + char l_symndx[4];/* function name symbol index, iff l_lnno == 0*/ + char l_paddr[8]; /* (physical) address of line number */ + } l_addr; + char l_lnno[4]; /* line number */ }; + #define LINENO struct external_lineno + #define LINESZ 12 -union external_auxent +/********************** SYMBOLS **********************/ + +#define E_SYMNMLEN 8 /* # characters in a symbol name */ +#define E_FILNMLEN 14 /* # characters in a file name */ +#define E_DIMNUM 4 /* # array dimensions in auxiliary entry */ + +struct external_syment { - struct - { - union - { - struct - { - char x_lnno[4]; /* declaration line number */ - char x_size[2]; /* str/union/array size */ - } x_lnsz; - - struct - { - char x_lnnoptr[8];/* ptr to fcn line */ - char x_fsize[4]; /* size of function */ - char x_endndx[4]; /* entry ndx past block end */ - } x_fcn; - - } x_fcnary; - - } x_sym; + char e_value[8]; + char e_offset[4]; + char e_scnum[2]; + char e_type[2]; + char e_sclass[1]; + char e_numaux[1]; +}; + + + +#define N_BTMASK (017) +#define N_TMASK (060) +#define N_BTSHFT (4) +#define N_TSHIFT (2) + + +union external_auxent { + + struct { + union { + struct { + char x_lnno[4]; /* declaration line number */ + char x_size[2]; /* str/union/array size */ + } x_lnsz; + struct { + char x_lnnoptr[8];/* ptr to fcn line */ + char x_fsize[4]; /* size of function */ + char x_endndx[4]; /* entry ndx past block end */ + } x_fcn; + } x_fcnary; + } x_sym; - union - { - char x_fname[E_FILNMLEN]; - - struct - { - char x_zeroes[4]; - char x_offset[4]; - char x_pad[6]; - unsigned char x_ftype[1]; - unsigned char x_resv[2]; - } x_n; - - } x_file; - - struct - { - char x_exptr[8]; - char x_fsize[4]; - char x_endndx[4]; - char x_pad[1]; - } x_except; - - struct - { - unsigned char x_scnlen_lo[4]; - unsigned char x_parmhash[4]; - unsigned char x_snhash[2]; - unsigned char x_smtyp[1]; - unsigned char x_smclas[1]; - unsigned char x_scnlen_hi[4]; - unsigned char x_pad[1]; - } x_csect; - - struct - { - char x_pad[17]; - char x_auxtype[1]; - } x_auxtype; + union { + char x_fname[E_FILNMLEN]; + struct { + char x_zeroes[4]; + char x_offset[4]; + char x_pad[6]; + unsigned char x_ftype[1]; + unsigned char x_resv[2]; + } x_n; + } x_file; + + struct { + char x_exptr[8]; + char x_fsize[4]; + char x_endndx[4]; + char x_pad[1]; + } x_except; + + struct { + unsigned char x_scnlen_lo[4]; + unsigned char x_parmhash[4]; + unsigned char x_snhash[2]; + unsigned char x_smtyp[1]; + unsigned char x_smclas[1]; + unsigned char x_scnlen_hi[4]; + unsigned char x_pad[1]; + } x_csect; + + struct { + char x_pad[17]; + char x_auxtype[1]; + } x_auxtype; }; +#define SYMENT struct external_syment +#define SYMESZ 18 #define AUXENT union external_auxent #define AUXESZ 18 - #define DBXMASK 0x80 /* for dbx storage mask */ #define SYMNAME_IN_DEBUG(symptr) ((symptr)->n_sclass & DBXMASK) @@ -204,16 +203,19 @@ union external_auxent #define _AUX_FILE 252 #define _AUX_CSECT 251 + + /********************** RELOCATION DIRECTIVES **********************/ -struct external_reloc -{ + +struct external_reloc { char r_vaddr[8]; char r_symndx[4]; char r_size[1]; char r_type[1]; }; + #define RELOC struct external_reloc #define RELSZ 14 @@ -222,3 +224,44 @@ struct external_reloc #define DEFAULT_TEXT_SECTION_ALIGNMENT 4 /* For new sections we havn't heard of before */ #define DEFAULT_SECTION_ALIGNMENT 4 + +/* The ldhdr structure. This appears at the start of the .loader + section. */ + +struct external_ldhdr +{ + bfd_byte l_version[4]; + bfd_byte l_nsyms[4]; + bfd_byte l_nreloc[4]; + bfd_byte l_istlen[4]; + bfd_byte l_nimpid[4]; + bfd_byte l_stlen[4]; + bfd_byte l_impoff[8]; + bfd_byte l_stoff[8]; + bfd_byte l_symoff[8]; + bfd_byte l_rldoff[8]; +}; +#define LDHDRSZ (56) + +struct external_ldsym +{ + bfd_byte l_value[8]; + bfd_byte l_offset[4]; + bfd_byte l_scnum[2]; + bfd_byte l_smtype[1]; + bfd_byte l_smclas[1]; + bfd_byte l_ifile[4]; + bfd_byte l_parm[4]; +}; + +#define LDSYMSZ (24) + +struct external_ldrel +{ + bfd_byte l_vaddr[8]; + bfd_byte l_rtype[2]; + bfd_byte l_rsecnm[2]; + bfd_byte l_symndx[4]; +}; + +#define LDRELSZ (16) diff --git a/include/coff/xcoff.h b/include/coff/xcoff.h new file mode 100644 index 00000000000..bc1ee5cb28d --- /dev/null +++ b/include/coff/xcoff.h @@ -0,0 +1,617 @@ +/* Internal format of XCOFF object file data structures for BFD. + + Copyright 1995, 1996, 1997, 1998, 1999, 2000 Free Software Foundation, Inc. + Written by Ian Lance Taylor , Cygnus Support. + + This file is part of BFD, the Binary File Descriptor library. + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ + +#ifndef _INTERNAL_XCOFF_H +#define _INTERNAL_XCOFF_H + +/* + * LINKER + */ + +/* + * names of "special" sections + */ +#define _TEXT ".text" +#define _DATA ".data" +#define _BSS ".bss" +#define _PAD ".pad" +#define _LOADER ".loader" + +/* XCOFF uses a special .loader section with type STYP_LOADER. */ +#define STYP_LOADER 0x1000 + +/* XCOFF uses a special .debug section with type STYP_DEBUG. */ +#define STYP_DEBUG 0x2000 + +/* XCOFF handles line number or relocation overflow by creating + another section header with STYP_OVRFLO set. */ +#define STYP_OVRFLO 0x8000 + +#define RS6K_AOUTHDR_OMAGIC 0x0107 /* old: text & data writeable */ +#define RS6K_AOUTHDR_NMAGIC 0x0108 /* new: text r/o, data r/w */ +#define RS6K_AOUTHDR_ZMAGIC 0x010B /* paged: text r/o, both page-aligned */ + + +/* XCOFF relocation types. + The relocations are described in the function + xcoff[64]_ppc_relocate_section in coff64-rs6000.c and coff-rs6000.c */ + +#define R_POS (0x00) +#define R_NEG (0x01) +#define R_REL (0x02) +#define R_TOC (0x03) +#define R_RTB (0x04) +#define R_GL (0x05) +#define R_TCL (0x06) +#define R_BA (0x08) +#define R_BR (0x0a) +#define R_RL (0x0c) +#define R_RLA (0x0d) +#define R_REF (0x0f) +#define R_TRL (0x12) +#define R_TRLA (0x13) +#define R_RRTBI (0x14) +#define R_RRTBA (0x15) +#define R_CAI (0x16) +#define R_CREL (0x17) +#define R_RBA (0x18) +#define R_RBAC (0x19) +#define R_RBR (0x1a) +#define R_RBRC (0x1b) + + +/* + * Storage class #defines, from /usr/include/storclass.h + * That are not already defined in internal.h + */ +#define C_INFO 110 /* Comment string in .info section */ + + +/* + * AUXILLARY SYMBOL ENTRIES + * + * auxemt + */ + +/* x_smtyp values: */ + +#define SMTYP_ALIGN(x) ((x) >> 3) /* log2 of alignment */ +#define SMTYP_SMTYP(x) ((x) & 0x7) /* symbol type */ +/* Symbol type values: */ +#define XTY_ER 0 /* External reference */ +#define XTY_SD 1 /* Csect definition */ +#define XTY_LD 2 /* Label definition */ +#define XTY_CM 3 /* .BSS */ +#define XTY_EM 4 /* Error message */ +#define XTY_US 5 /* "Reserved for internal use" */ + +/* x_smclas values: */ + +#define XMC_PR 0 /* Read-only program code */ +#define XMC_RO 1 /* Read-only constant */ +#define XMC_DB 2 /* Read-only debug dictionary table */ +#define XMC_TC 3 /* Read-write general TOC entry */ +#define XMC_UA 4 /* Read-write unclassified */ +#define XMC_RW 5 /* Read-write data */ +#define XMC_GL 6 /* Read-only global linkage */ +#define XMC_XO 7 /* Read-only extended operation */ +#define XMC_SV 8 /* Read-only supervisor call */ +#define XMC_BS 9 /* Read-write BSS */ +#define XMC_DS 10 /* Read-write descriptor csect */ +#define XMC_UC 11 /* Read-write unnamed Fortran common */ +#define XMC_TI 12 /* Read-only traceback index csect */ +#define XMC_TB 13 /* Read-only traceback table csect */ +/* 14 ??? */ +#define XMC_TC0 15 /* Read-write TOC anchor */ +#define XMC_TD 16 /* Read-write data in TOC */ + +/* The ldhdr structure. This appears at the start of the .loader + section. */ + +struct internal_ldhdr +{ + /* + * The version number: + * 1 : 32 bit + * 2 : 64 bit + */ + unsigned long l_version; + /* The number of symbol table entries. */ + bfd_size_type l_nsyms; + /* The number of relocation table entries. */ + bfd_size_type l_nreloc; + /* The length of the import file string table. */ + bfd_size_type l_istlen; + /* The number of import files. */ + bfd_size_type l_nimpid; + /* The offset from the start of the .loader section to the first + entry in the import file table. */ + bfd_size_type l_impoff; + /* The length of the string table. */ + bfd_size_type l_stlen; + /* The offset from the start of the .loader section to the first + entry in the string table. */ + bfd_size_type l_stoff; + /* The offset to start of the symbol table, only in XCOFF64 */ + bfd_vma l_symoff; + /* The offset to the start of the relocation table, only in XCOFF64 */ + bfd_vma l_rldoff; +}; + +/* The ldsym structure. This is used to represent a symbol in the + .loader section. */ + +struct internal_ldsym +{ + union + { + /* The symbol name if <= SYMNMLEN characters. */ + char _l_name[SYMNMLEN]; + struct + { + /* Zero if the symbol name is more than SYMNMLEN characters. */ + long _l_zeroes; + /* The offset in the string table if the symbol name is more + than SYMNMLEN characters. */ + long _l_offset; + } _l_l; + } _l; + /* The symbol value. */ + bfd_vma l_value; + /* The symbol section number. */ + short l_scnum; + /* The symbol type and flags. */ + char l_smtype; + /* The symbol storage class. */ + char l_smclas; + /* The import file ID. */ + bfd_size_type l_ifile; + /* Offset to the parameter type check string. */ + bfd_size_type l_parm; +}; + +/* These flags are for the l_smtype field (the lower three bits are an + XTY_* value). */ + +/* Imported symbol. */ +#define L_IMPORT (0x40) +/* Entry point. */ +#define L_ENTRY (0x20) +/* Exported symbol. */ +#define L_EXPORT (0x10) + +/* The ldrel structure. This is used to represent a reloc in the + .loader section. */ + +struct internal_ldrel +{ + /* The reloc address. */ + bfd_vma l_vaddr; + /* The symbol table index in the .loader section symbol table. */ + bfd_size_type l_symndx; + /* The relocation type and size. */ + short l_rtype; + /* The section number this relocation applies to. */ + short l_rsecnm; +}; + +/* An entry in the XCOFF linker hash table. */ +struct xcoff_link_hash_entry +{ + struct bfd_link_hash_entry root; + + /* Symbol index in output file. Set to -1 initially. Set to -2 if + there is a reloc against this symbol. */ + long indx; + + /* If we have created a TOC entry for this symbol, this is the .tc + section which holds it. */ + asection *toc_section; + + union + { + /* If we have created a TOC entry (the XCOFF_SET_TOC flag is + set), this is the offset in toc_section. */ + bfd_vma toc_offset; + /* If the TOC entry comes from an input file, this is set to the + symbol index of the C_HIDEXT XMC_TC or XMC_TD symbol. */ + long toc_indx; + } u; + + /* If this symbol is a function entry point which is called, this + field holds a pointer to the function descriptor. If this symbol + is a function descriptor, this field holds a pointer to the + function entry point. */ + struct xcoff_link_hash_entry *descriptor; + + /* The .loader symbol table entry, if there is one. */ + struct internal_ldsym *ldsym; + + /* If XCOFF_BUILT_LDSYM is set, this is the .loader symbol table + index. If XCOFF_BUILD_LDSYM is clear, and XCOFF_IMPORT is set, + this is the l_ifile value. */ + long ldindx; + + /* Some linker flags. */ + unsigned long flags; + + /* The storage mapping class. */ + unsigned char smclas; +}; + +/* + * #define for xcoff_link_hash_entry.flags + * + * XCOFF_REF_REGULAR + * Symbol is referenced by a regular object. + * + * XCOFF_DEF_REGULAR + * Symbol is defined by a regular object. + * + * XCOFF_DEF_DYNAMIC + * Symbol is defined by a dynamic object. + * + * XCOFF_LDREL + * Symbol is used in a reloc being copied into the .loader section. + * + * XCOFF_ENTRY + * Symbol is the entry point. + * + * XCOFF_CALLED + * Symbol is called; this is, it appears in a R_BR reloc. + * + * XCOFF_SET_TOC + * Symbol needs the TOC entry filled in. + * + * XCOFF_IMPORT + * Symbol is explicitly imported. + * + * XCOFF_EXPORT + * Symbol is explicitly exported. + * + * XCOFF_BUILT_LDSYM + * Symbol has been processed by xcoff_build_ldsyms. + * + * XCOFF_MARK + * Symbol is mentioned by a section which was not garbage collected. + * + * XCOFF_HAS_SIZE + * Symbol size is recorded in size_list list from hash table. + * + * XCOFF_DESCRIPTOR + * Symbol is a function descriptor. + * + * XCOFF_MULTIPLY_DEFINED + * Multiple definitions have been for the symbol. + * + * XCOFF_RTINIT + * Symbol is the __rtinit symbol + * + */ + +#define XCOFF_REF_REGULAR 0x00000001 +#define XCOFF_DEF_REGULAR 0x00000002 +#define XCOFF_DEF_DYNAMIC 0x00000004 +#define XCOFF_LDREL 0x00000008 +#define XCOFF_ENTRY 0x00000010 +#define XCOFF_CALLED 0x00000020 +#define XCOFF_SET_TOC 0x00000040 +#define XCOFF_IMPORT 0x00000080 +#define XCOFF_EXPORT 0x00000100 +#define XCOFF_BUILT_LDSYM 0x00000200 +#define XCOFF_MARK 0x00000400 +#define XCOFF_HAS_SIZE 0x00000800 +#define XCOFF_DESCRIPTOR 0x00001000 +#define XCOFF_MULTIPLY_DEFINED 0x00002000 +#define XCOFF_RTINIT 0x00004000 + + +/* The XCOFF linker hash table. */ + +#define XCOFF_NUMBER_OF_SPECIAL_SECTIONS 6 +#define XCOFF_SPECIAL_SECTION_TEXT 0 +#define XCOFF_SPECIAL_SECTION_ETEXT 1 +#define XCOFF_SPECIAL_SECTION_DATA 2 +#define XCOFF_SPECIAL_SECTION_EDATA 3 +#define XCOFF_SPECIAL_SECTION_END 4 +#define XCOFF_SPECIAL_SECTION_END2 5 + +struct xcoff_link_hash_table +{ + struct bfd_link_hash_table root; + + /* The .debug string hash table. We need to compute this while + reading the input files, so that we know how large the .debug + section will be before we assign section positions. */ + struct bfd_strtab_hash *debug_strtab; + + /* The .debug section we will use for the final output. */ + asection *debug_section; + + /* The .loader section we will use for the final output. */ + asection *loader_section; + + /* A count of non TOC relative relocs which will need to be + allocated in the .loader section. */ + size_t ldrel_count; + + /* The .loader section header. */ + struct internal_ldhdr ldhdr; + + /* The .gl section we use to hold global linkage code. */ + asection *linkage_section; + + /* The .tc section we use to hold toc entries we build for global + linkage code. */ + asection *toc_section; + + /* The .ds section we use to hold function descriptors which we + create for exported symbols. */ + asection *descriptor_section; + + /* The list of import files. */ + struct xcoff_import_file *imports; + + /* Required alignment of sections within the output file. */ + unsigned long file_align; + + /* Whether the .text section must be read-only. */ + boolean textro; + + /* Whether garbage collection was done. */ + boolean gc; + + /* A linked list of symbols for which we have size information. */ + struct xcoff_link_size_list + { + struct xcoff_link_size_list *next; + struct xcoff_link_hash_entry *h; + bfd_size_type size; + } *size_list; + + /* Magic sections: _text, _etext, _data, _edata, _end, end. */ + asection *special_sections[XCOFF_NUMBER_OF_SPECIAL_SECTIONS]; +}; + + +/* This structure is used to pass information through + xcoff_link_hash_traverse. */ + +struct xcoff_loader_info +{ + /* Set if a problem occurred. */ + boolean failed; + /* Output BFD. */ + bfd *output_bfd; + /* Link information structure. */ + struct bfd_link_info *info; + /* Whether all defined symbols should be exported. */ + boolean export_defineds; + /* Number of ldsym structures. */ + size_t ldsym_count; + /* Size of string table. */ + size_t string_size; + /* String table. */ + bfd_byte *strings; + /* Allocated size of string table. */ + size_t string_alc; +}; + +/* In case we're on a 32-bit machine, construct a 64-bit "-1" value + from smaller values. Start with zero, widen, *then* decrement. */ +#define MINUS_ONE (((bfd_vma)0) - 1) + + +/* + * __rtinit + * from /usr/include/rtinit.h + */ +struct __rtinit { + int (*rtl)(); /* Pointer to runtime linker */ + int init_offset; /* Offset to array of init functions + (0 if none). */ + int fini_offset; /* Offset to array of fini functions + (0 if none). */ + int __rtinit_descriptor_size; /* Size of __RTINIT_DESCRIPTOR. + This value should be used instead + of sizeof(__RTINIT_DESCRIPTOR). */ +}; + +#define RTINIT_DESCRIPTOR_SIZE (12) + +struct __rtinit_descriptor { + int f; /* Init/fini function. */ + int name_offset; /* Offset (within __rtinit symbol) + to name of function. */ + unsigned char flags; /* Flags */ +}; + + + +/* + * ARCHIVE + */ + +#define XCOFFARMAG "\012" +#define XCOFFARMAGBIG "\012" +#define SXCOFFARMAG 8 + +/* This terminates an XCOFF archive member name. */ + +#define XCOFFARFMAG "`\012" +#define SXCOFFARFMAG 2 + +/* XCOFF archives start with this (printable) structure. */ + +struct xcoff_ar_file_hdr +{ + /* Magic string. */ + char magic[SXCOFFARMAG]; + + /* Offset of the member table (decimal ASCII string). */ + char memoff[12]; + + /* Offset of the global symbol table (decimal ASCII string). */ + char symoff[12]; + + /* Offset of the first member in the archive (decimal ASCII string). */ + char firstmemoff[12]; + + /* Offset of the last member in the archive (decimal ASCII string). */ + char lastmemoff[12]; + + /* Offset of the first member on the free list (decimal ASCII + string). */ + char freeoff[12]; +}; + +#define SIZEOF_AR_FILE_HDR (5 * 12 + SXCOFFARMAG) + +/* This is the equivalent data structure for the big archive format. */ + +struct xcoff_ar_file_hdr_big +{ + /* Magic string. */ + char magic[SXCOFFARMAG]; + + /* Offset of the member table (decimal ASCII string). */ + char memoff[20]; + + /* Offset of the global symbol table for 32-bit objects (decimal ASCII + string). */ + char symoff[20]; + + /* Offset of the global symbol table for 64-bit objects (decimal ASCII + string). */ + char symoff64[20]; + + /* Offset of the first member in the archive (decimal ASCII string). */ + char firstmemoff[20]; + + /* Offset of the last member in the archive (decimal ASCII string). */ + char lastmemoff[20]; + + /* Offset of the first member on the free list (decimal ASCII + string). */ + char freeoff[20]; +}; + +#define SIZEOF_AR_FILE_HDR_BIG (6 * 20 + SXCOFFARMAG) + + +/* Each XCOFF archive member starts with this (printable) structure. */ + +struct xcoff_ar_hdr +{ + /* File size not including the header (decimal ASCII string). */ + char size[12]; + + /* File offset of next archive member (decimal ASCII string). */ + char nextoff[12]; + + /* File offset of previous archive member (decimal ASCII string). */ + char prevoff[12]; + + /* File mtime (decimal ASCII string). */ + char date[12]; + + /* File UID (decimal ASCII string). */ + char uid[12]; + + /* File GID (decimal ASCII string). */ + char gid[12]; + + /* File mode (octal ASCII string). */ + char mode[12]; + + /* Length of file name (decimal ASCII string). */ + char namlen[4]; + + /* This structure is followed by the file name. The length of the + name is given in the namlen field. If the length of the name is + odd, the name is followed by a null byte. The name and optional + null byte are followed by XCOFFARFMAG, which is not included in + namlen. The contents of the archive member follow; the number of + bytes is given in the size field. */ +}; + +#define SIZEOF_AR_HDR (7 * 12 + 4) + +/* The equivalent for the big archive format. */ + +struct xcoff_ar_hdr_big +{ + /* File size not including the header (decimal ASCII string). */ + char size[20]; + + /* File offset of next archive member (decimal ASCII string). */ + char nextoff[20]; + + /* File offset of previous archive member (decimal ASCII string). */ + char prevoff[20]; + + /* File mtime (decimal ASCII string). */ + char date[12]; + + /* File UID (decimal ASCII string). */ + char uid[12]; + + /* File GID (decimal ASCII string). */ + char gid[12]; + + /* File mode (octal ASCII string). */ + char mode[12]; + + /* Length of file name (decimal ASCII string). */ + char namlen[4]; + + /* This structure is followed by the file name. The length of the + name is given in the namlen field. If the length of the name is + odd, the name is followed by a null byte. The name and optional + null byte are followed by XCOFFARFMAG, which is not included in + namlen. The contents of the archive member follow; the number of + bytes is given in the size field. */ +}; + +#define SIZEOF_AR_HDR_BIG (3 * 20 + 4 * 12 + 4) + +/* We often have to distinguish between the old and big file format. + Make it a bit cleaner. We can use `xcoff_ardata' here because the + `hdr' member has the same size and position in both formats. */ +#define xcoff_big_format_p(abfd) \ + (xcoff_ardata (abfd)->magic[1] == 'b') + +/* We store a copy of the xcoff_ar_file_hdr in the tdata field of the + artdata structure. Similar for the big archive. */ +#define xcoff_ardata(abfd) \ + ((struct xcoff_ar_file_hdr *) bfd_ardata (abfd)->tdata) +#define xcoff_ardata_big(abfd) \ + ((struct xcoff_ar_file_hdr_big *) bfd_ardata (abfd)->tdata) + +/* We store a copy of the xcoff_ar_hdr in the arelt_data field of an + archive element. Similar for the big archive. */ +#define arch_eltdata(bfd) ((struct areltdata *) ((bfd)->arelt_data)) +#define arch_xhdr(bfd) \ + ((struct xcoff_ar_hdr *) arch_eltdata (bfd)->arch_header) +#define arch_xhdr_big(bfd) \ + ((struct xcoff_ar_hdr_big *) arch_eltdata (bfd)->arch_header) + +#endif /* _INTERNAL_XCOFF_H */ -- 2.30.2