Home | History | Annotate | Download | only in nlm
      1 /* NLM (NetWare Loadable Module) support for BFD.
      2    Copyright (C) 1993-2016 Free Software Foundation, Inc.
      3 
      4    Written by Fred Fish @ Cygnus Support
      5 
      6    This file is part of BFD, the Binary File Descriptor library.
      7 
      8    This program is free software; you can redistribute it and/or modify
      9    it under the terms of the GNU General Public License as published by
     10    the Free Software Foundation; either version 3 of the License, or
     11    (at your option) any later version.
     12 
     13    This program is distributed in the hope that it will be useful,
     14    but WITHOUT ANY WARRANTY; without even the implied warranty of
     15    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     16    GNU General Public License for more details.
     17 
     18    You should have received a copy of the GNU General Public License
     19    along with this program; if not, write to the Free Software
     20    Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston,
     21    MA 02110-1301, USA.  */
     22 
     23 /* This file is part of NLM support for BFD, and contains the portions
     24    that are common to both the internal and external representations.  */
     25 
     26 /* If NLM_ARCH_SIZE is not defined, default to 32.  NLM_ARCH_SIZE is
     27    optionally defined by the application.  */
     28 
     29 #ifndef NLM_ARCH_SIZE
     30 #  define NLM_ARCH_SIZE			32
     31 #endif
     32 
     33 /* Due to horrible details of ANSI macro expansion, we can't use CONCAT4
     34    for NLM_NAME.  CONCAT2 is used in BFD_JUMP_TABLE macros, and some of
     35    them will expand to tokens that themselves are macros defined in terms
     36    of NLM_NAME.  If NLM_NAME were defined using CONCAT4 (which is itself
     37    defined in bfd-in.h using CONCAT2), ANSI preprocessor rules say that
     38    the CONCAT2 within NLM_NAME should not be expanded.
     39    So use another name.  */
     40 #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
     41 #ifdef SABER
     42 #define NLM_CAT4(a,b,c,d) a##b##c##d
     43 #else
     44 /* This hack is to avoid a problem with some strict ANSI C preprocessors.
     45    The problem is, "32_" is not a valid preprocessing token, and we don't
     46    want extra underscores (e.g., "nlm_32_").  The NLM_XCAT2 macro will
     47    cause the inner CAT2 macros to be evaluated first, producing
     48    still-valid pp-tokens.  Then the final concatenation can be done.  */
     49 #define NLM_CAT2(a,b)	  a##b
     50 #define NLM_XCAT2(a,b)	  NLM_CAT2(a,b)
     51 #define NLM_CAT4(a,b,c,d) NLM_XCAT2(NLM_CAT2(a,b),NLM_CAT2(c,d))
     52 #endif
     53 #else
     54 #define NLM_CAT4(a,b,c,d) a/**/b/**/c/**/d
     55 #endif
     56 
     57 #if NLM_ARCH_SIZE == 32
     58 #  define NLM_TARGET_LONG_SIZE		4
     59 #  define NLM_TARGET_ADDRESS_SIZE	4
     60 #  define NLM_NAME(x,y)			NLM_CAT4(x,32,_,y)
     61 #  define NLM_HIBIT			(((bfd_vma) 1) << 31)
     62 #endif
     63 #if NLM_ARCH_SIZE == 64
     64 #  define NLM_TARGET_LONG_SIZE		8
     65 #  define NLM_TARGET_ADDRESS_SIZE	8
     66 #  define NLM_NAME(x,y)			NLM_CAT4(x,64,_,y)
     67 #  define NLM_HIBIT			(((bfd_vma) 1) << 63)
     68 #endif
     69 
     70 #define NlmNAME(X)		NLM_NAME(Nlm,X)
     71 #define nlmNAME(X)		NLM_NAME(nlm,X)
     72 
     73 /* Give names to things that should not change. */
     74 
     75 #define NLM_MAX_DESCRIPTION_LENGTH		127
     76 #define NLM_MAX_SCREEN_NAME_LENGTH		71
     77 #define NLM_MAX_THREAD_NAME_LENGTH		71
     78 #define NLM_MAX_COPYRIGHT_MESSAGE_LENGTH	255
     79 #define NLM_OTHER_DATA_LENGTH 			400		/* FIXME */
     80 #define NLM_OLD_THREAD_NAME_LENGTH		5
     81 #define NLM_SIGNATURE_SIZE			24
     82 #define NLM_HEADER_VERSION			4
     83 #define NLM_MODULE_NAME_SIZE			14
     84 #define NLM_DEFAULT_STACKSIZE			(8 * 1024)
     85 
     86 /* Alpha information.  This should probably be in a separate Alpha
     88    header file, but it can't go in alpha-ext.h because some of it is
     89    needed by nlmconv.c.  */
     90 
     91 /* Magic number in Alpha prefix header.  */
     92 #define NLM32_ALPHA_MAGIC (0x83561840)
     93 
     94 /* The r_type field in an Alpha reloc is one of the following values.  */
     95 #define ALPHA_R_IGNORE		0
     96 #define ALPHA_R_REFLONG		1
     97 #define ALPHA_R_REFQUAD		2
     98 #define ALPHA_R_GPREL32		3
     99 #define ALPHA_R_LITERAL		4
    100 #define ALPHA_R_LITUSE		5
    101 #define ALPHA_R_GPDISP		6
    102 #define ALPHA_R_BRADDR		7
    103 #define ALPHA_R_HINT		8
    104 #define ALPHA_R_SREL16		9
    105 #define ALPHA_R_SREL32	       10
    106 #define ALPHA_R_SREL64	       11
    107 #define ALPHA_R_OP_PUSH	       12
    108 #define ALPHA_R_OP_STORE       13
    109 #define ALPHA_R_OP_PSUB	       14
    110 #define ALPHA_R_OP_PRSHIFT     15
    111 #define ALPHA_R_GPVALUE	       16
    112 #define ALPHA_R_NW_RELOC      250
    113 
    114 /* A local reloc, other than ALPHA_R_GPDISP or ALPHA_R_IGNORE, must be
    115    against one of these symbol indices.  */
    116 #define ALPHA_RELOC_SECTION_TEXT	1
    117 #define ALPHA_RELOC_SECTION_DATA	3
    118 
    119 /* An ALPHA_R_NW_RELOC has one of these values in the size field.  If
    120    it is SETGP, the r_vaddr field holds the GP value to use.  If it is
    121    LITA, the r_vaddr field holds the address of the .lita section and
    122    the r_symndx field holds the size of the .lita section.  */
    123 #define ALPHA_R_NW_RELOC_SETGP	1
    124 #define ALPHA_R_NW_RELOC_LITA	2
    125