12159047fSniklas /* NLM (NetWare Loadable Module) support for BFD. 2*c074d1c9Sdrahn Copyright 1993, 2001 Free Software Foundation, Inc. 32159047fSniklas 42159047fSniklas Written by Fred Fish @ Cygnus Support 52159047fSniklas 62159047fSniklas This file is part of BFD, the Binary File Descriptor library. 72159047fSniklas 82159047fSniklas This program is free software; you can redistribute it and/or modify 92159047fSniklas it under the terms of the GNU General Public License as published by 102159047fSniklas the Free Software Foundation; either version 2 of the License, or 112159047fSniklas (at your option) any later version. 122159047fSniklas 132159047fSniklas This program is distributed in the hope that it will be useful, 142159047fSniklas but WITHOUT ANY WARRANTY; without even the implied warranty of 152159047fSniklas MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 162159047fSniklas GNU General Public License for more details. 172159047fSniklas 182159047fSniklas You should have received a copy of the GNU General Public License 192159047fSniklas along with this program; if not, write to the Free Software 202159047fSniklas Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ 212159047fSniklas 222159047fSniklas 232159047fSniklas /* This file is part of NLM support for BFD, and contains the portions 242159047fSniklas that are common to both the internal and external representations. */ 252159047fSniklas 262159047fSniklas /* If NLM_ARCH_SIZE is not defined, default to 32. NLM_ARCH_SIZE is 272159047fSniklas optionally defined by the application. */ 282159047fSniklas 292159047fSniklas #ifndef NLM_ARCH_SIZE 302159047fSniklas # define NLM_ARCH_SIZE 32 312159047fSniklas #endif 322159047fSniklas 33*c074d1c9Sdrahn /* Due to horrible details of ANSI macro expansion, we can't use CONCAT4 34*c074d1c9Sdrahn for NLM_NAME. CONCAT2 is used in BFD_JUMP_TABLE macros, and some of 35*c074d1c9Sdrahn them will expand to tokens that themselves are macros defined in terms 36*c074d1c9Sdrahn of NLM_NAME. If NLM_NAME were defined using CONCAT4 (which is itself 37*c074d1c9Sdrahn defined in bfd-in.h using CONCAT2), ANSI preprocessor rules say that 38*c074d1c9Sdrahn the CONCAT2 within NLM_NAME should not be expanded. 39*c074d1c9Sdrahn So use another name. */ 40*c074d1c9Sdrahn #if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE) 41*c074d1c9Sdrahn #ifdef SABER 42*c074d1c9Sdrahn #define NLM_CAT4(a,b,c,d) a##b##c##d 43*c074d1c9Sdrahn #else 44*c074d1c9Sdrahn /* This hack is to avoid a problem with some strict ANSI C preprocessors. 45*c074d1c9Sdrahn The problem is, "32_" is not a valid preprocessing token, and we don't 46*c074d1c9Sdrahn want extra underscores (e.g., "nlm_32_"). The NLM_XCAT2 macro will 47*c074d1c9Sdrahn cause the inner CAT2 macros to be evaluated first, producing 48*c074d1c9Sdrahn still-valid pp-tokens. Then the final concatenation can be done. */ 49*c074d1c9Sdrahn #define NLM_CAT2(a,b) a##b 50*c074d1c9Sdrahn #define NLM_XCAT2(a,b) NLM_CAT2(a,b) 51*c074d1c9Sdrahn #define NLM_CAT4(a,b,c,d) NLM_XCAT2(NLM_CAT2(a,b),NLM_CAT2(c,d)) 52*c074d1c9Sdrahn #endif 53*c074d1c9Sdrahn #else 54*c074d1c9Sdrahn #define NLM_CAT4(a,b,c,d) a/**/b/**/c/**/d 55*c074d1c9Sdrahn #endif 56*c074d1c9Sdrahn 572159047fSniklas #if NLM_ARCH_SIZE == 32 582159047fSniklas # define NLM_TARGET_LONG_SIZE 4 592159047fSniklas # define NLM_TARGET_ADDRESS_SIZE 4 602159047fSniklas # define NLM_NAME(x,y) NLM_CAT4(x,32,_,y) 612159047fSniklas # define NLM_HIBIT (((bfd_vma) 1) << 31) 622159047fSniklas #endif 632159047fSniklas #if NLM_ARCH_SIZE == 64 642159047fSniklas # define NLM_TARGET_LONG_SIZE 8 652159047fSniklas # define NLM_TARGET_ADDRESS_SIZE 8 662159047fSniklas # define NLM_NAME(x,y) NLM_CAT4(x,64,_,y) 672159047fSniklas # define NLM_HIBIT (((bfd_vma) 1) << 63) 682159047fSniklas #endif 692159047fSniklas 702159047fSniklas #define NlmNAME(X) NLM_NAME(Nlm,X) 712159047fSniklas #define nlmNAME(X) NLM_NAME(nlm,X) 722159047fSniklas 732159047fSniklas /* Give names to things that should not change. */ 742159047fSniklas 752159047fSniklas #define NLM_MAX_DESCRIPTION_LENGTH 127 762159047fSniklas #define NLM_MAX_SCREEN_NAME_LENGTH 71 772159047fSniklas #define NLM_MAX_THREAD_NAME_LENGTH 71 782159047fSniklas #define NLM_MAX_COPYRIGHT_MESSAGE_LENGTH 255 792159047fSniklas #define NLM_OTHER_DATA_LENGTH 400 /* FIXME */ 802159047fSniklas #define NLM_OLD_THREAD_NAME_LENGTH 5 812159047fSniklas #define NLM_SIGNATURE_SIZE 24 822159047fSniklas #define NLM_HEADER_VERSION 4 832159047fSniklas #define NLM_MODULE_NAME_SIZE 14 842159047fSniklas #define NLM_DEFAULT_STACKSIZE (8 * 1024) 852159047fSniklas 862159047fSniklas /* Alpha information. This should probably be in a separate Alpha 872159047fSniklas header file, but it can't go in alpha-ext.h because some of it is 882159047fSniklas needed by nlmconv.c. */ 892159047fSniklas 902159047fSniklas /* Magic number in Alpha prefix header. */ 912159047fSniklas #define NLM32_ALPHA_MAGIC (0x83561840) 922159047fSniklas 932159047fSniklas /* The r_type field in an Alpha reloc is one of the following values. */ 942159047fSniklas #define ALPHA_R_IGNORE 0 952159047fSniklas #define ALPHA_R_REFLONG 1 962159047fSniklas #define ALPHA_R_REFQUAD 2 972159047fSniklas #define ALPHA_R_GPREL32 3 982159047fSniklas #define ALPHA_R_LITERAL 4 992159047fSniklas #define ALPHA_R_LITUSE 5 1002159047fSniklas #define ALPHA_R_GPDISP 6 1012159047fSniklas #define ALPHA_R_BRADDR 7 1022159047fSniklas #define ALPHA_R_HINT 8 1032159047fSniklas #define ALPHA_R_SREL16 9 1042159047fSniklas #define ALPHA_R_SREL32 10 1052159047fSniklas #define ALPHA_R_SREL64 11 1062159047fSniklas #define ALPHA_R_OP_PUSH 12 1072159047fSniklas #define ALPHA_R_OP_STORE 13 1082159047fSniklas #define ALPHA_R_OP_PSUB 14 1092159047fSniklas #define ALPHA_R_OP_PRSHIFT 15 1102159047fSniklas #define ALPHA_R_GPVALUE 16 1112159047fSniklas #define ALPHA_R_NW_RELOC 250 1122159047fSniklas 1132159047fSniklas /* A local reloc, other than ALPHA_R_GPDISP or ALPHA_R_IGNORE, must be 1142159047fSniklas against one of these symbol indices. */ 1152159047fSniklas #define ALPHA_RELOC_SECTION_TEXT 1 1162159047fSniklas #define ALPHA_RELOC_SECTION_DATA 3 1172159047fSniklas 1182159047fSniklas /* An ALPHA_R_NW_RELOC has one of these values in the size field. If 1192159047fSniklas it is SETGP, the r_vaddr field holds the GP value to use. If it is 1202159047fSniklas LITA, the r_vaddr field holds the address of the .lita section and 1212159047fSniklas the r_symndx field holds the size of the .lita section. */ 1222159047fSniklas #define ALPHA_R_NW_RELOC_SETGP 1 1232159047fSniklas #define ALPHA_R_NW_RELOC_LITA 2 124