1/* NLM (NetWare Loadable Module) support for BFD. 2 Copyright 1993, 2001 Free Software Foundation, Inc. 3 4 Written by Fred Fish @ Cygnus Support 5 6This file is part of BFD, the Binary File Descriptor library. 7 8This program is free software; you can redistribute it and/or modify 9it under the terms of the GNU General Public License as published by 10the Free Software Foundation; either version 2 of the License, or 11(at your option) any later version. 12 13This program is distributed in the hope that it will be useful, 14but WITHOUT ANY WARRANTY; without even the implied warranty of 15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 16GNU General Public License for more details. 17 18You should have received a copy of the GNU General Public License 19along with this program; if not, write to the Free Software 20Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 21 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 87 header file, but it can't go in alpha-ext.h because some of it is 88 needed by nlmconv.c. */ 89 90/* Magic number in Alpha prefix header. */ 91#define NLM32_ALPHA_MAGIC (0x83561840) 92 93/* The r_type field in an Alpha reloc is one of the following values. */ 94#define ALPHA_R_IGNORE 0 95#define ALPHA_R_REFLONG 1 96#define ALPHA_R_REFQUAD 2 97#define ALPHA_R_GPREL32 3 98#define ALPHA_R_LITERAL 4 99#define ALPHA_R_LITUSE 5 100#define ALPHA_R_GPDISP 6 101#define ALPHA_R_BRADDR 7 102#define ALPHA_R_HINT 8 103#define ALPHA_R_SREL16 9 104#define ALPHA_R_SREL32 10 105#define ALPHA_R_SREL64 11 106#define ALPHA_R_OP_PUSH 12 107#define ALPHA_R_OP_STORE 13 108#define ALPHA_R_OP_PSUB 14 109#define ALPHA_R_OP_PRSHIFT 15 110#define ALPHA_R_GPVALUE 16 111#define ALPHA_R_NW_RELOC 250 112 113/* A local reloc, other than ALPHA_R_GPDISP or ALPHA_R_IGNORE, must be 114 against one of these symbol indices. */ 115#define ALPHA_RELOC_SECTION_TEXT 1 116#define ALPHA_RELOC_SECTION_DATA 3 117 118/* An ALPHA_R_NW_RELOC has one of these values in the size field. If 119 it is SETGP, the r_vaddr field holds the GP value to use. If it is 120 LITA, the r_vaddr field holds the address of the .lita section and 121 the r_symndx field holds the size of the .lita section. */ 122#define ALPHA_R_NW_RELOC_SETGP 1 123#define ALPHA_R_NW_RELOC_LITA 2 124