home *** CD-ROM | disk | FTP | other *** search
Text File | 1993-10-07 | 71.7 KB | 2,381 lines | [TEXT/CPED] |
- #define SystemSixOrLater 1
- #include <Types.h>
- #include <Errors.h>
- #include <Memory.h>
- #include <OSUtils.h>
- #include <SegLoad.h>
- #include <Quickdraw.h>
- #include <Files.h>
- #include <Menus.h>
- #include <Fonts.h>
- #include <Resources.h>
- #include <GestaltEqu.h>
- #include <Traps.h>
-
- #define TrapMask 0x0800
-
- short NumToolboxTraps( void )
- {
- if (NGetTrapAddress(_InitGraf, ToolTrap) ==
- NGetTrapAddress(0xAA6E, ToolTrap))
- return(0x0200);
- else
- return(0x0400);
- }
-
- TrapType GetTrapType(short theTrap)
- {
-
- if ((theTrap & TrapMask) > 0)
- return(ToolTrap);
- else
- return(OSTrap);
-
- }
-
- Boolean TrapAvailable(short theTrap)
- {
-
- TrapType tType;
-
- tType = GetTrapType(theTrap);
- if (tType == ToolTrap)
- theTrap = theTrap & 0x07FF;
- if (theTrap >= NumToolboxTraps())
- theTrap = _Unimplemented;
-
- return (NGetTrapAddress(theTrap, tType) !=
- NGetTrapAddress(_Unimplemented, ToolTrap));
- }
-
- // FlushCache
- // Flush the CPU cache(s). This is required on the 68040 after modifying
- // code.
-
- #define _CacheFlushTrap 0xA0BD
-
- void FlushCache(void)
- {
- if (TrapAvailable( _CacheFlushTrap))
- asm
- {
- dc.w _CacheFlushTrap
- }
- }
-
- /* Linker `ld' for GNU
- Copyright (C) 1988 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
- the Free Software Foundation; either version 1, 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., 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- /* Written by Richard Stallman with some help from Eric Albert.
- Set, indirect, and warning ld_symbol features added by Randy Smith. */
-
- /* Define how to initialize system-dependent header fields. */
- #ifdef sun
- /* Use Sun's TARGET convention. */
- #ifndef TARGET
- #define SUN2 2
- #define SUN3 3
- #define SUN4 4
- #if defined(sparc)
- #define TARGET SUN4
- #else
- #if defined(mc68020) || defined(m68020)
- #define TARGET SUN3
- #else
- #define TARGET SUN2
- #endif
- #endif
- #else
- #define _CROSS_TARGET_ARCH TARGET /* locate the correct a.out.h file */
- #endif
- #endif
-
- #include <sys/types.h>
- #include <sys/stat.h>
- #include <sys/file.h>
- #ifndef sony_news
- #include <sys/fcntl.h>
- #endif
-
- #ifdef COFF_ENCAPSULATE
- #include "a.out.encap.h"
- #else
- #include <a.out.h>
- #endif
-
- #ifndef N_SET_MAGIC
- #define N_SET_MAGIC(exec, val) ((exec).a_magic = val)
- #endif
-
- /* Always use the GNU version of debugging ld_symbol type codes, if possible. */
-
- #include "stab.h"
- #define CORE_ADDR unsigned long /* For symseg.h */
- /* GDB symbol table format definitions.
- Copyright (C) 1986, 1989 Free Software Foundation, Inc.
- Hacked by Michael Tiemann (tiemann@mcc.com)
-
- This file is part of GDB.
-
- GDB 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 1, or (at your option)
- any later version.
-
- GDB 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 GDB; see the file COPYING. If not, write to
- the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */
-
- /* Format of GDB symbol table data.
- There is one symbol segment for each source file or
- independant compilation. These segments are simply concatenated
- to form the GDB symbol table. A zero word where the beginning
- of a segment is expected indicates there are no more segments.
-
- Format of a symbol segment:
-
- The symbol segment begins with a word containing 1
- if it is in the format described here. Other formats may
- be designed, with other code numbers.
-
- The segment contains many objects which point at each other.
- The pointers are offsets in bytes from the beginning of the segment.
- Thus, each segment can be loaded into core and its pointers relocated
- to make valid in-core pointers.
-
- All the data objects in the segment can be found indirectly from
- one of them, the root object, of type `struct symbol_root'.
- It appears at the beginning of the segment.
-
- The total size of the segment, in bytes, appears as the `length'
- field of this object. This size includes the size of the
- root object.
-
- All the object data types are defined here to contain pointer types
- appropriate for in-core use on a relocated symbol segment.
- Casts to and from type int are required for working with
- unrelocated symbol segments such as are found in the file.
-
- The ldsymaddr word is filled in by the loader to contain
- the offset (in bytes) within the ld symbol table
- of the first nonglobal symbol from this compilation.
- This makes it possible to match those symbols
- (which contain line number information) reliably with
- the segment they go with.
-
- Core addresses within the program that appear in the symbol segment
- are not relocated by the loader. They are inserted by the assembler
- and apply to addresses as output by the assembler, so GDB must
- relocate them when it loads the symbol segment. It gets the information
- on how to relocate from the textrel, datarel, bssrel, databeg and bssbeg
- words of the root object.
-
- The words textrel, datarel and bssrel
- are filled in by ld with the amounts to relocate within-the-file
- text, data and bss addresses by; databeg and bssbeg can be
- used to tell which kind of relocation an address needs. */
-
- enum language {language_c};
-
- struct symbol_root
- {
- int format; /* Data format version */
- int length; /* # bytes in this symbol segment */
- int ldsymoff; /* Offset in ld symtab of this file's syms */
- int textrel; /* Relocation for text addresses */
- int datarel; /* Relocation for data addresses */
- int bssrel; /* Relocation for bss addresses */
- char *filename; /* Name of main source file compiled */
- char *filedir; /* Name of directory it was reached from */
- struct blockvector *blockvector; /* Vector of all symbol-naming blocks */
- struct typevector *typevector; /* Vector of all data types */
- enum language language; /* Code identifying the language used */
- char *version; /* Version info. Not fully specified */
- char *compilation; /* Compilation info. Not fully specified */
- int databeg; /* Address within the file of data start */
- int bssbeg; /* Address within the file of bss start */
- struct sourcevector *sourcevector; /* Vector of line-number info */
- };
-
- /* All data types of symbols in the compiled program
- are represented by `struct type' objects.
- All of these objects are pointed to by the typevector.
- The type vector may have empty slots that contain zero. */
-
- struct typevector
- {
- int length; /* Number of types described */
- struct type *type[1];
- };
-
- /* Different kinds of data types are distinguished by the `code' field. */
-
- enum type_code
- {
- TYPE_CODE_UNDEF, /* Not used; catches errors */
- TYPE_CODE_PTR, /* Pointer type */
- TYPE_CODE_ARRAY, /* Array type, lower bound zero */
- TYPE_CODE_STRUCT, /* C struct or Pascal record */
- TYPE_CODE_UNION, /* C union or Pascal variant part */
- TYPE_CODE_ENUM, /* Enumeration type */
- TYPE_CODE_FUNC, /* Function type */
- TYPE_CODE_INT, /* Integer type */
- TYPE_CODE_FLT, /* Floating type */
- TYPE_CODE_VOID, /* Void type (values zero length) */
- TYPE_CODE_SET, /* Pascal sets */
- TYPE_CODE_RANGE, /* Range (integers within spec'd bounds) */
- TYPE_CODE_PASCAL_ARRAY, /* Array with explicit type of index */
-
- /* C++ */
- TYPE_CODE_MEMBER, /* Member type */
- TYPE_CODE_METHOD, /* Method type */
- TYPE_CODE_REF /* C++ Reference types */
- };
-
- /* This appears in a type's flags word for an unsigned integer type. */
- #define TYPE_FLAG_UNSIGNED 1
- /* This appears in a type's flags word
- if it is a (pointer to a|function returning a)* built in scalar type.
- These types are never freed. */
- #define TYPE_FLAG_PERM 4
- /* This appears in a type's flags word if it is a stub type (eg. if
- someone referenced a type that wasn't definined in a source file
- via (struct sir_not_appearing_in_this_film *)). */
- #define TYPE_FLAG_STUB 8
- /* Set when a classic has a constructor defined */
- #define TYPE_FLAG_HAS_CONSTRUCTOR 256
- /* Set when a classic has a destructor defined */
- #define TYPE_FLAG_HAS_DESTRUCTOR 512
- /* Indicates that this type is a public baseclass of another classic,
- i.e. that all its public methods are available in the derived
- classic. */
- #define TYPE_FLAG_VIA_PUBLIC 1024
- /* Indicates that this type is a virtual baseclass of another classic,
- i.e. that if this classic is inherited more than once by another
- classic, only one set of member variables will be included. */
- #define TYPE_FLAG_VIA_VIRTUAL 2048
-
- struct type
- {
- /* Code for kind of type */
- enum type_code code;
- /* Name of this type, or zero if none.
- This is used for printing only.
- Type names specified as input are defined by symbols. */
- char *name;
- /* Length in bytes of storage for a value of this type */
- int length;
- /* For a pointer type, describes the type of object pointed to.
- For an array type, describes the type of the elements.
- For a function or method type, describes the type of the value.
- For a range type, describes the type of the full range.
- Unused otherwise. */
- struct type *target_type;
- /* Type that is a pointer to this type.
- Zero if no such pointer-to type is known yet.
- The debugger may add the address of such a type
- if it has to construct one later. */
- struct type *pointer_type;
- /* C++: also need a reference type. */
- struct type *reference_type;
- struct type **arg_types;
-
- /* Type that is a function returning this type.
- Zero if no such function type is known here.
- The debugger may add the address of such a type
- if it has to construct one later. */
- struct type *function_type;
-
- /* Handling of pointers to members:
- TYPE_MAIN_VARIANT is used for pointer and pointer
- to member types. Normally it the value of the address of its
- containing type. However, for pointers to members, we must be
- able to allocate pointer to member types and look them up
- from some place of reference.
- NEXT_VARIANT is the next element in the chain. */
- struct type *main_variant, *next_variant;
-
- /* Flags about this type. */
- short flags;
- /* Number of fields described for this type */
- short nfields;
- /* For structure and union types, a description of each field.
- For set and pascal array types, there is one "field",
- whose type is the domain type of the set or array.
- For range types, there are two "fields",
- the minimum and maximum values (both inclusive).
- For enum types, each possible value is described by one "field".
-
- Using a pointer to a separate array of fields
- allows all types to have the same size, which is useful
- because we can allocate the space for a type before
- we know what to put in it. */
- struct field
- {
- /* Position of this field, counting in bits from start of
- containing structure. For a function type, this is the
- position in the argument list of this argument.
- For a range bound or enum value, this is the value itself. */
- int bitpos;
- /* Size of this field, in bits, or zero if not packed.
- For an unpacked field, the field's type's length
- says how many bytes the field occupies. */
- int bitsize;
- /* In a struct or enum type, type of this field.
- In a function type, type of this argument.
- In an array type, the domain-type of the array. */
- struct type *type;
- /* Name of field, value or argument.
- Zero for range bounds and array domains. */
- char *name;
- } *fields;
-
- /* C++ */
- int *private_field_bits;
- int *protected_field_bits;
-
- /* Number of methods described for this type */
- short nfn_fields;
- /* Number of base classes this type derives from. */
- short n_baseclasses;
-
- /* Number of methods described for this type plus all the
- methods that it derives from. */
- int nfn_fields_total;
-
- /* For classes, structures, and unions, a description of each field,
- which consists of an overloaded name, followed by the types of
- arguments that the method expects, and then the name after it
- has been renamed to make it distinct. */
- struct fn_fieldlist
- {
- /* The overloaded name. */
- char *name;
- /* The number of methods with this name. */
- int length;
- /* The list of methods. */
- struct fn_field
- {
- #if 0
- /* The overloaded name */
- char *name;
- #endif
- /* The return value of the method */
- struct type *type;
- /* The argument list */
- struct type **args;
- /* The name after it has been processed */
- char *physname;
- /* If this is a virtual function, the offset into the vtbl-1,
- else 0. */
- int voffset;
- } *fn_fields;
-
- int *private_fn_field_bits;
- int *protected_fn_field_bits;
-
- } *fn_fieldlists;
-
- unsigned char via_protected;
- unsigned char via_public;
-
- /* For types with virtual functions, VPTR_BASETYPE is the base classic which
- defined the virtual function table pointer. VPTR_FIELDNO is
- the field number of that pointer in the structure.
-
- For types that are pointer to member types, VPTR_BASETYPE
- ifs the type that this pointer is a member of.
-
- Unused otherwise. */
- struct type *vptr_basetype;
-
- int vptr_fieldno;
-
- /* If this type has a base classic, put it here.
- If this type is a pointer type, the chain of member pointer
- types goes here.
- Unused otherwise.
-
- Contrary to all maxims of C style and common sense, the baseclasses
- are indexed from 1 to N_BASECLASSES rather than 0 to N_BASECLASSES-1
- (i.e. BASECLASSES points to one *before* the first element of
- the array). */
- struct type **baseclasses;
- };
-
- /* All of the name-scope contours of the program
- are represented by `struct block' objects.
- All of these objects are pointed to by the blockvector.
-
- Each block represents one name scope.
- Each lexical context has its own block.
-
- The first two blocks in the blockvector are special.
- The first one contains all the symbols defined in this compilation
- whose scope is the entire program linked together.
- The second one contains all the symbols whose scope is the
- entire compilation excluding other separate compilations.
- In C, these correspond to global symbols and static symbols.
-
- Each block records a range of core addresses for the code that
- is in the scope of the block. The first two special blocks
- give, for the range of code, the entire range of code produced
- by the compilation that the symbol segment belongs to.
-
- The blocks appear in the blockvector
- in order of increasing starting-address,
- and, within that, in order of decreasing ending-address.
-
- This implies that within the body of one function
- the blocks appear in the order of a depth-first tree walk. */
-
- struct blockvector
- {
- /* Number of blocks in the list. */
- int nblocks;
- /* The blocks themselves. */
- struct block *block[1];
- };
-
- struct block
- {
- /* Addresses in the executable code that are in this block.
- Note: in an unrelocated symbol segment in a file,
- these are always zero. They can be filled in from the
- N_LBRAC and N_RBRAC symbols in the loader symbol table. */
- int startaddr, endaddr;
- /* The symbol that names this block,
- if the block is the body of a function;
- otherwise, zero.
- Note: In an unrelocated symbol segment in an object file,
- this field may be zero even when the block has a name.
- That is because the block is output before the name
- (since the name resides in a higher block).
- Since the symbol does point to the block (as its value),
- it is possible to find the block and set its name properly. */
- struct symbol *function;
- /* The `struct block' for the containing block, or 0 if none. */
- /* Note that in an unrelocated symbol segment in an object file
- this pointer may be zero when the correct value should be
- the second special block (for symbols whose scope is one compilation).
- This is because the compiler ouptuts the special blocks at the
- very end, after the other blocks. */
- struct block *superblock;
- /* A flag indicating whether or not the fucntion corresponding
- to this block was compiled with gcc or not. If there is no
- function corresponding to this block, this meaning of this flag
- is undefined. (In practice it will be 1 if the block was created
- while processing a file compiled with gcc and 0 when not). */
- unsigned char gcc_compile_flag;
- /* Number of local symbols. */
- int nsyms;
- /* The symbols. */
- struct symbol *sym[1];
- };
-
- /* Represent one symbol name; a variable, constant, function or typedef. */
-
- /* Different name spaces for symbols. Looking up a symbol specifies
- a namespace and ignores symbol definitions in other name spaces.
-
- VAR_NAMESPACE is the usual namespace.
- In C, this contains variables, function names, typedef names
- and enum type values.
-
- STRUCT_NAMESPACE is used in C to hold struct, union and enum type names.
- Thus, if `struct foo' is used in a C program,
- it produces a symbol named `foo' in the STRUCT_NAMESPACE.
-
- LABEL_NAMESPACE may be used for names of labels (for gotos);
- currently it is not used and labels are not recorded at all. */
-
- /* For a non-global symbol allocated statically,
- the correct core address cannot be determined by the compiler.
- The compiler puts an index number into the symbol's value field.
- This index number can be matched with the "desc" field of
- an entry in the loader symbol table. */
-
- enum namespace
- {
- UNDEF_NAMESPACE, VAR_NAMESPACE, STRUCT_NAMESPACE, LABEL_NAMESPACE
- };
-
- /* An address-classic says where to find the value of the symbol in core. */
-
- enum address_class
- {
- LOC_UNDEF, /* Not used; catches errors */
- LOC_CONST, /* Value is constant int */
- LOC_STATIC, /* Value is at fixed address */
- LOC_REGISTER, /* Value is in register */
- LOC_ARG, /* Value is at spec'd position in arglist */
- LOC_REF_ARG, /* Value address is at spec'd position in */
- /* arglist. */
- LOC_REGPARM, /* Value is at spec'd position in register window */
- LOC_LOCAL, /* Value is at spec'd pos in stack frame */
- LOC_TYPEDEF, /* Value not used; definition in SYMBOL_TYPE
- Symbols in the namespace STRUCT_NAMESPACE
- all have this classic. */
- LOC_LABEL, /* Value is address in the code */
- LOC_BLOCK, /* Value is address of a `struct block'.
- Function names have this classic. */
- LOC_EXTERNAL, /* Value is at address not in this compilation.
- This is used for .comm symbols
- and for extern symbols within functions.
- Inside GDB, this is changed to LOC_STATIC once the
- real address is obtained from a loader symbol. */
- LOC_CONST_BYTES /* Value is a constant byte-sequence. */
- };
-
- struct symbol
- {
- /* Symbol name */
- char *name;
- /* Name space code. */
- enum namespace namespace;
- /* Address classic */
- enum address_class classic;
- /* Data type of value */
- struct type *type;
- /* constant value, or address if static, or register number,
- or offset in arguments, or offset in stack frame. */
- union
- {
- long value;
- struct block *block; /* for LOC_BLOCK */
- char *bytes; /* for LOC_CONST_BYTES */
- }
- value;
- };
-
- struct partial_symbol
- {
- /* Symbol name */
- char *name;
- /* Name space code. */
- enum namespace namespace;
- /* Address classic (for info_symbols) */
- enum address_class classic;
- /* Value (only used for static functions currently). Done this
- way so that we can use the struct symbol macros.
- Note that the address of a function is SYMBOL_VALUE (pst)
- in a partial symbol table, but BLOCK_START (SYMBOL_BLOCK_VALUE (st))
- in a symbol table. */
- union
- {
- long value;
- }
- value;
- };
-
- /*
- * Vectors of all partial symbols read in from file; actually declared
- * and used in dbxread.c.
- */
- extern struct psymbol_allocation_list {
- struct partial_symbol *list, *next;
- int size;
- } global_psymbols, static_psymbols;
-
-
- /* Source-file information.
- This describes the relation between source files and line numbers
- and addresses in the program text. */
-
- struct sourcevector
- {
- int length; /* Number of source files described */
- struct source *source[1]; /* Descriptions of the files */
- };
-
- /* Each item represents a line-->pc (or the reverse) mapping. This is
- somewhat more wasteful of space than one might wish, but since only
- the files which are actually debugged are read in to core, we don't
- waste much space.
-
- Each item used to be an int; either minus a line number, or a
- program counter. If it represents a line number, that is the line
- described by the next program counter value. If it is positive, it
- is the program counter at which the code for the next line starts. */
-
- struct linetable_entry
- {
- int line;
- CORE_ADDR pc;
- };
-
- struct linetable
- {
- int nitems;
- struct linetable_entry item[1];
- };
-
- /* All the information on one source file. */
-
- struct source
- {
- char *name; /* Name of file */
- struct linetable contents;
- };
-
- /*
- #ifdef USG
- #include <string.h>
- #else
- #include <strings.h>
- #endif
- */
-
- #define min(a,b) ((a) < (b) ? (a) : (b))
-
- /* Macro to control the number of undefined references printed */
- #define MAX_UREFS_PRINTED 10
-
- /*
- * Ok. Following are the relocation information macros. If your
- * system should not be able to use the default set (below), you must
- * define the following:
-
- * relocation_info: This must be typedef'd (or #define'd) to the type
- * of structure that is stored in the relocation info section of your
- * a.out files. Often this is defined in the a.out.h for your system.
- *
- * RELOC_ADDRESS (rval): Offset into the current section of the
- * <whatever> to be relocated. *Must be an lvalue*.
- *
- * RELOC_EXTERN_P (rval): Is this relocation entry based on an
- * external ld_symbol (1), or was it fully resolved upon entering the
- * loader (0) in which case some combination of the value in memory
- * (if RELOC_MEMORY_ADD_P) and the extra (if RELOC_ADD_EXTRA) contains
- * what the value of the relocation actually was. *Must be an lvalue*.
- *
- * RELOC_TYPE (rval): If this entry was fully resolved upon
- * entering the loader, what type should it be relocated as?
- *
- * RELOC_SYMBOL (rval): If this entry was not fully resolved upon
- * entering the loader, what is the index of it's ld_symbol in the ld_symbol
- * table? *Must be a lvalue*.
- *
- * RELOC_MEMORY_ADD_P (rval): This should return true if the final
- * relocation value output here should be added to memory, or if the
- * section of memory described should simply be set to the relocation
- * value.
- *
- * RELOC_ADD_EXTRA (rval): (Optional) This macro, if defined, gives
- * an extra value to be added to the relocation value based on the
- * individual relocation entry. *Must be an lvalue if defined*.
- *
- * RELOC_PCREL_P (rval): True if the relocation value described is
- * pc relative.
- *
- * RELOC_VALUE_RIGHTSHIFT (rval): Number of bits right to shift the
- * final relocation value before putting it where it belongs.
- *
- * RELOC_TARGET_SIZE (rval): log to the base 2 of the number of
- * bytes of size this relocation entry describes; 1 byte == 0; 2 bytes
- * == 1; 4 bytes == 2, and etc. This is somewhat redundant (we could
- * do everything in terms of the bit operators below), but having this
- * macro could end up producing better code on machines without fancy
- * bit twiddling. Also, it's easier to understand/code big/little
- * endian distinctions with this macro.
- *
- * RELOC_TARGET_BITPOS (rval): The starting bit position within the
- * object described in RELOC_TARGET_SIZE in which the relocation value
- * will go.
- *
- * RELOC_TARGET_BITSIZE (rval): How many bits are to be replaced
- * with the bits of the relocation value. It may be assumed by the
- * code that the relocation value will fit into this many bits. This
- * may be larger than RELOC_TARGET_SIZE if such be useful.
- *
- *
- * Things I haven't implemented
- * ----------------------------
- *
- * Values for RELOC_TARGET_SIZE other than 0, 1, or 2.
- *
- * Pc relative relocation for External references.
- *
- *
- */
-
- /* The following #if has been modifed for cross compilation */
- /* It originally ld_read: #if defined(sun) && defined(sparc) */
- /* Marc Ullman, Stanford University Nov. 1 1989 */
- #if defined(sun) && (TARGET == SUN4)
- /* Sparc (Sun 4) macros */
- #undef relocation_info
- #define relocation_info reloc_info_sparc
- #define RELOC_ADDRESS(r) ((r)->r_address)
- #define RELOC_EXTERN_P(r) ((r)->r_extern)
- #define RELOC_TYPE(r) ((r)->r_index)
- #define RELOC_SYMBOL(r) ((r)->r_index)
- #define RELOC_MEMORY_SUB_P(r) 0
- #define RELOC_MEMORY_ADD_P(r) 0
- #define RELOC_ADD_EXTRA(r) ((r)->r_addend)
- #define RELOC_PCREL_P(r) \
- ((r)->r_type >= RELOC_DISP8 && (r)->r_type <= RELOC_WDISP22)
- #define RELOC_VALUE_RIGHTSHIFT(r) (reloc_target_rightshift[(r)->r_type])
- #define RELOC_TARGET_SIZE(r) (reloc_target_size[(r)->r_type])
- #define RELOC_TARGET_BITPOS(r) 0
- #define RELOC_TARGET_BITSIZE(r) (reloc_target_bitsize[(r)->r_type])
-
- /* Note that these are very dependent on the order of the enums in
- enum reloc_type (in a.out.h); if they change the following must be
- changed */
- /* Also note that the last few may be incorrect; I have no information */
- static int reloc_target_rightshift[] = {
- 0, 0, 0, 0, 0, 0, 2, 2, 10, 0, 0, 0, 0, 0, 0,
- };
- static int reloc_target_size[] = {
- 0, 1, 2, 0, 1, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
- };
- static int reloc_target_bitsize[] = {
- 8, 16, 32, 8, 16, 32, 30, 22, 22, 22, 13, 10, 32, 32, 16,
- };
-
- #define MAX_ALIGNMENT (sizeof (double))
- #endif
- #ifdef sequent
- #define RELOC_ADDRESS(r) ((r)->r_address)
- #define RELOC_EXTERN_P(r) ((r)->r_extern)
- #define RELOC_TYPE(r) ((r)->r_symbolnum)
- #define RELOC_SYMBOL(r) ((r)->r_symbolnum)
- #define RELOC_MEMORY_SUB_P(r) ((r)->r_bsr)
- #define RELOC_MEMORY_ADD_P(r) 1
- #undef RELOC_ADD_EXTRA
- #define RELOC_PCREL_P(r) ((r)->r_pcrel || (r)->r_bsr)
- #define RELOC_VALUE_RIGHTSHIFT(r) 0
- #define RELOC_TARGET_SIZE(r) ((r)->r_length)
- #define RELOC_TARGET_BITPOS(r) 0
- #define RELOC_TARGET_BITSIZE(r) 32
- #endif
-
- /* Default macros */
- #ifndef RELOC_ADDRESS
- #define RELOC_ADDRESS(r) ((r)->r_address)
- #define RELOC_EXTERN_P(r) ((r)->r_extern)
- #define RELOC_TYPE(r) ((r)->r_symbolnum)
- #define RELOC_SYMBOL(r) ((r)->r_symbolnum)
- #define RELOC_MEMORY_SUB_P(r) 0
- #define RELOC_MEMORY_ADD_P(r) 1
- #undef RELOC_ADD_EXTRA
- #define RELOC_PCREL_P(r) ((r)->r_pcrel)
- #define RELOC_VALUE_RIGHTSHIFT(r) 0
- #define RELOC_TARGET_SIZE(r) ((r)->r_length)
- #define RELOC_TARGET_BITPOS(r) 0
- #define RELOC_TARGET_BITSIZE(r) 32
- #endif
-
- #ifndef MAX_ALIGNMENT
- #define MAX_ALIGNMENT (sizeof (int))
- #endif
-
- #ifdef nounderscore
- #define LPREFIX '.'
- #else
- #define LPREFIX 'L'
- #endif
-
- #ifndef TEXT_START
- #define TEXT_START(x) N_TXTADDR(x)
- #endif
-
- /* Special global ld_symbol types understood by GNU LD. */
-
- /* The following type indicates the definition of a ld_symbol as being
- an indirect reference to another ld_symbol. The other ld_symbol
- appears as an undefined reference, immediately following this ld_symbol.
-
- Indirection is asymmetrical. The other ld_symbol's value will be used
- to satisfy requests for the indirect ld_symbol, but not vice versa.
- If the other ld_symbol does not have a definition, libraries will
- be searched to find a definition.
-
- So, for example, the following two lines placed in an assembler
- input file would result in an object file which would direct gnu ld
- to resolve all references to ld_symbol "foo" as references to ld_symbol
- "bar".
-
- .stabs "_foo",11,0,0,0
- .stabs "_bar",1,0,0,0
-
- Note that (11 == (N_INDR | N_EXT)) and (1 == (N_UNDF | N_EXT)). */
-
- #ifndef N_INDR
- #define N_INDR 0xa
- #endif
-
- /* The following symbols refer to set elements. These are expected
- only in input to the loader; they should not appear in loader
- output (unless relocatable output is requested). To be recognized
- by the loader, the input symbols must have their N_EXT bit set.
- All the N_SET[ATDB] symbols with the same name form one set. The
- loader collects all of these elements at load time and outputs a
- vector for each name.
- Space (an array of 32 bit words) is allocated for the set in the
- data section, and the n_value field of each set element value is
- stored into one word of the array.
- The first word of the array is the length of the set (number of
- elements). The last word of the vector is set to zero for possible
- use by incremental loaders. The array is ordered by the linkage
- order; the first symbols which the linker encounters will be first
- in the array.
-
- In C syntax this looks like:
-
- struct set_vector {
- unsigned int length;
- unsigned int vector[length];
- unsigned int always_zero;
- };
-
- Before being placed into the array, each element is relocated
- according to its type. This allows the loader to create an array
- of pointers to objects automatically. N_SETA type symbols will not
- be relocated.
-
- The address of the set is made into an N_SETV ld_symbol
- whose name is the same as the name of the set.
- This ld_symbol acts like a N_DATA global ld_symbol
- in that it can satisfy undefined external references.
-
- For the purposes of determining whether or not to load in a library
- file, set element definitions are not considered "real
- definitions"; they will not cause the loading of a library
- member.
-
- If relocatable output is requested, none of this processing is
- done. The symbols are simply relocated and passed through to the
- output file.
-
- So, for example, the following three lines of assembler code
- (whether in one file or scattered between several different ones)
- will produce a three element vector (total length is five words;
- see above), referenced by the ld_symbol "_xyzzy", which will have the
- addresses of the routines _init1, _init2, and _init3.
-
- *NOTE*: If symbolic addresses are used in the n_value field of the
- defining .stabs, those symbols must be defined in the same file as
- that containing the .stabs.
-
- .stabs "_xyzzy",23,0,0,_init1
- .stabs "_xyzzy",23,0,0,_init2
- .stabs "_xyzzy",23,0,0,_init3
-
- Note that (23 == (N_SETT | N_EXT)). */
-
- #ifndef N_SETA
- #define N_SETA 0x14 /* Absolute set element ld_symbol */
- #endif /* This is input to LD, in a .o file. */
-
- #ifndef N_SETT
- #define N_SETT 0x16 /* Text set element ld_symbol */
- #endif /* This is input to LD, in a .o file. */
-
- #ifndef N_SETD
- #define N_SETD 0x18 /* Data set element ld_symbol */
- #endif /* This is input to LD, in a .o file. */
-
- #ifndef N_SETB
- #define N_SETB 0x1A /* Bss set element ld_symbol */
- #endif /* This is input to LD, in a .o file. */
-
- /* Macros dealing with the set element symbols defined in a.out.h */
- #define SET_ELEMENT_P(x) ((x)>=N_SETA&&(x)<=(N_SETB|N_EXT))
- #define TYPE_OF_SET_ELEMENT(x) ((x)-N_SETA+N_ABS)
-
- #ifndef N_SETV
- #define N_SETV 0x1C /* Pointer to set vector in data area. */
- #endif /* This is output from LD. */
-
- /* If a this type of ld_symbol is encountered, its name is a warning
- message to print each time the ld_symbol referenced by the next ld_symbol
- table entry is referenced.
-
- This feature may be used to allow backwards compatibility with
- certain functions (eg. gets) but to discourage programmers from
- their use.
-
- So if, for example, you wanted to have ld print a warning whenever
- the function "gets" was used in their C program, you would add the
- following to the assembler file in which gets is defined:
-
- .stabs "Obsolete function \"gets\" referenced",30,0,0,0
- .stabs "_gets",1,0,0,0
-
- These .stabs do not necessarily have to be in the same file as the
- gets function, they simply must exist somewhere in the compilation. */
-
- #ifndef N_WARNING
- #define N_WARNING 0x1E /* Warning message to print if ld_symbol
- included */
- #endif /* This is input to ld */
-
- #ifndef __GNU_STAB__
-
- /* Line number for the data section. This is to be used to describe
- the source location of a variable declaration. */
- #ifndef N_DSLINE
- #define N_DSLINE (N_SLINE+N_DATA-N_TEXT)
- #endif
-
- /* Line number for the bss section. This is to be used to describe
- the source location of a variable declaration. */
- #ifndef N_BSLINE
- #define N_BSLINE (N_SLINE+N_BSS-N_TEXT)
- #endif
-
- #endif /* not __GNU_STAB__ */
-
- /* Symbol table */
-
- /* Global ld_symbol data is recorded in these structures,
- one for each global ld_symbol.
- They are found via hashing in 'symtab', which points to a vector of buckets.
- Each bucket is a chain of these structures through the link field. */
-
- typedef
- struct glosym
- {
- /* Pointer to next ld_symbol in this ld_symbol's hash bucket. */
- struct glosym *link;
- /* Name of this ld_symbol. */
- char *name;
- /* Value of this ld_symbol as a global ld_symbol. */
- long value;
- /* Chain of external 'nlist's in files for this ld_symbol, both defs
- and refs. */
- struct nlist *refs;
- /* Any warning message that might be associated with this ld_symbol
- from an N_WARNING ld_symbol encountered. */
- char *warning;
- /* Nonzero means definitions of this ld_symbol as common have been seen,
- and the value here is the largest size specified by any of them. */
- int max_common_size;
- /* For relocatable_output, records the index of this global sym in the
- ld_symbol table to be written, with the first global sym given index 0.*/
- int def_count;
- /* Nonzero means a definition of this global ld_symbol is known to exist.
- Library members should not be loaded on its account. */
- char defined;
- /* Nonzero means a reference to this global ld_symbol has been seen
- in a file that is surely being loaded.
- A value higher than 1 is the n_type code for the ld_symbol's
- definition. */
- char referenced;
- /* A count of the number of undefined references printed for a
- specific ld_symbol. If a ld_symbol is unresolved at the end of
- digest_symbols (and the loading run is supposed to produce
- relocatable output) do_file_warnings keeps track of how many
- unresolved reference error messages have been printed for
- each ld_symbol here. When the number hits MAX_UREFS_PRINTED,
- messages stop. */
- unsigned char undef_refs;
- /* 1 means that this ld_symbol has multiple definitions. 2 means
- that it has multiple definitions, and some of them are set
- elements, one of which has been printed out already. */
- unsigned char multiply_defined;
- /* Nonzero means print a message at all refs or defs of this ld_symbol */
- char trace;
- }
- ld_symbol;
-
- /* Demangler for C++. */
- extern char *cplus_demangle ();
-
- /* Demangler function to use. */
- char *(*demangler)() = NULL;
-
- /* Number of buckets in ld_symbol hash table */
- #define TABSIZE 1009
-
- /* The ld_symbol hash table: a vector of TABSIZE pointers to struct glosym. */
- ld_symbol *symtab[TABSIZE];
-
- /* Number of symbols in ld_symbol hash table. */
- int num_hash_tab_syms = 0;
-
- /* Count the number of nlist entries that are for local symbols.
- This count and the three following counts
- are incremented as as symbols are entered in the ld_symbol table. */
- int local_sym_count;
-
- /* Count number of nlist entries that are for local symbols
- whose names don't start with L. */
- int non_L_local_sym_count;
-
- /* Count the number of nlist entries for debugger info. */
- int debugger_sym_count;
-
- /* Count the number of global symbols referenced and not defined. */
- int undefined_global_sym_count;
-
- /* Count the number of global symbols multiply defined. */
- int multiple_def_count;
-
- /* Count the number of defined global symbols.
- Each ld_symbol is counted only once
- regardless of how many different nlist entries refer to it,
- since the output file will need only one nlist entry for it.
- This count is computed by `digest_symbols';
- it is undefined while symbols are being loaded. */
- int defined_global_sym_count;
-
- /* Count the number of symbols defined through common declarations.
- This count is kept in symdef_library, linear_library, and
- enter_global_ref. It is incremented when the defined flag is set
- in a ld_symbol because of a common definition, and decremented when
- the ld_symbol is defined "for real" (ie. by something besides a common
- definition). */
- int common_defined_global_count;
-
- /* Count the number of set element type symbols and the number of
- separate vectors which these symbols will fit into. See the
- GNU a.out.h for more info.
- This count is computed by 'enter_file_symbols' */
- int set_symbol_count;
- int set_vector_count;
-
- /* Define a linked list of strings which define symbols which should
- be treated as set elements even though they aren't. Any ld_symbol
- with a prefix matching one of these should be treated as a set
- element.
-
- This is to make up for deficiencies in many assemblers which aren't
- willing to pass any stabs through to the loader which they don't
- understand. */
- struct string_list_element {
- char *str;
- struct string_list_element *next;
- };
-
- struct string_list_element *set_element_prefixes;
-
- /* Count the number of definitions done indirectly (ie. done relative
- to the value of some other ld_symbol. */
- int global_indirect_count;
-
- /* Count the number of warning symbols encountered. */
- int warning_count;
-
- /* Total number of symbols to be written in the output file.
- Computed by digest_symbols from the variables above. */
- int nsyms;
-
-
- /* Nonzero means ptr to ld_symbol entry for ld_symbol to use as start addr.
- -e sets this. */
- ld_symbol *entry_symbol;
- ld_symbol *edata_symbol; /* the ld_symbol _edata */
- ld_symbol *etext_symbol; /* the ld_symbol _etext */
- ld_symbol *end_symbol; /* the ld_symbol _end */
- ld_symbol *qd_symbol;
-
- /* Each input file, and each library member ("subfile") being loaded,
- has a `file_entry' structure for it.
-
- For files specified by command args, these are contained in the vector
- which `file_table' points to.
-
- For library members, they are dynamically allocated,
- and chained through the `chain' field.
- The chain is found in the `subfiles' field of the `file_entry'.
- The `file_entry' objects for the members have `superfile' fields pointing
- to the one for the library. */
-
- struct file_entry {
- /* Name of this file. */
- char *filename;
- /* Name to use for the ld_symbol giving address of text start */
- /* Usually the same as filename, but for a file spec'd with -l
- this is the -l switch itself rather than the filename. */
- char *local_sym_name;
-
- /* Describe the layout of the contents of the file */
-
- /* The file's a.out header. */
- struct exec header;
- /* Offset in file of GDB ld_symbol segment, or 0 if there is none. */
- int symseg_offset;
-
- /* Describe data from the file loaded into core */
-
- /* Symbol table of the file. */
- struct nlist *symbols;
- /* Size in bytes of string table. */
- int string_size;
- /* Pointer to the string table.
- The string table is not kept in core all the time,
- but when it is in core, its address is here. */
- char *strings;
-
- /* Next two used only if `relocatable_output' or if needed for */
- /* output of undefined reference line numbers. */
-
- /* Text reloc info saved by `write_text' for `coptxtrel'. */
- struct relocation_info *textrel;
- /* Data reloc info saved by `write_data' for `copdatrel'. */
- struct relocation_info *datarel;
-
- /* Relation of this file's segments to the output file */
-
- /* Start of this file's text seg in the output file core image. */
- int text_start_address;
- /* Start of this file's data seg in the output file core image. */
- int data_start_address;
- /* Start of this file's bss seg in the output file core image. */
- int bss_start_address;
- /* Offset in bytes in the output file ld_symbol table
- of the first local ld_symbol for this file. Set by `write_file_symbols'. */
- int local_syms_offset;
-
- /* For library members only */
-
- /* For a library, points to chain of entries for the library members. */
- struct file_entry *subfiles;
- /* For a library member, offset of the member within the archive.
- Zero for files that are not library members. */
- int starting_offset;
- /* Size of contents of this file, if library member. */
- int total_size;
- /* For library member, points to the library's own entry. */
- struct file_entry *superfile;
- /* For library member, points to next entry for next member. */
- struct file_entry *chain;
-
- /* 1 if file is a library. */
- char library_flag;
-
- /* 1 if file's header has been ld_read into this structure. */
- char header_read_flag;
-
- /* 1 means search a set of directories for this file. */
- char search_dirs_flag;
-
- /* 1 means this is base file of incremental load.
- Do not load this file's text or data.
- Also default text_start to after this file's bss. */
- char just_syms_flag;
- };
-
- /* Vector of entries for input files specified by arguments.
- These are all the input files except for members of specified libraries. */
- struct file_entry *file_table;
-
- /* When loading the text and data, we can avoid doing a close
- and another open between members of the same library.
-
- These two variables remember the file that is currently open.
- Both are zero if no file is open.
-
- See `each_file' and `file_close'. */
-
- struct file_entry *input_file;
- int input_desc;
-
- /* The following are computed by `digest_symbols'. */
-
- int text_size; /* total size of text of all input files. */
- int data_size; /* total size of data of all input files. */
- int bss_size; /* total size of bss of all input files. */
- int text_reloc_size; /* total size of text relocation of all input files. */
- int data_reloc_size; /* total size of data relocation of all input */
- /* files. */
-
- /* Specifications of start and length of the area reserved at the end
- of the text segment for the set vectors. Computed in 'digest_symbols' */
- int set_sect_start;
- int set_sect_size;
-
- /* Amount of cleared space to leave between the text and data segments. */
-
- int text_pad;
-
- /* Amount of bss segment to include as part of the data segment. */
-
- int data_pad;
-
- /* Format of __.SYMDEF:
- First, a longword containing the size of the 'symdef' data that follows.
- Second, zero or more 'symdef' structures.
- Third, a longword containing the length of ld_symbol name strings.
- Fourth, zero or more ld_symbol name strings (each followed by a null). */
-
- struct symdef {
- int symbol_name_string_index;
- int library_member_offset;
- };
-
- /* Record most of the command options. */
-
- /* Address we assume the text section will be loaded at.
- We relocate symbols and text and data for this, but we do not
- write any padding in the output file for it. */
- int text_start;
-
- /* Offset of default entry-pc within the text section. */
- int entry_offset;
-
- /* Address we decide the data section will be loaded at. */
- int data_start;
-
- /* Size to pad data section up to.
- We simply increase the size of the data section, padding with zeros,
- and reduce the size of the bss section to match. */
- int specified_data_size;
-
- /* Magic number to use for the output file, set by switch. */
- int magic;
-
- /* Which symbols should be stripped (omitted from the output):
- none, all, or debugger symbols. */
- enum { STRIP_NONE, STRIP_ALL, STRIP_DEBUGGER } strip_symbols;
-
- /* Which local symbols should be omitted:
- none, all, or those starting with L.
- This is irrelevant if STRIP_NONE. */
- enum { DISCARD_NONE, DISCARD_ALL, DISCARD_L } discard_locals;
-
- /* Non zero means to create the output executable. */
- /* Cleared by nonfatal errors. */
- int make_executable;
-
- /* Force the executable to be output, even if there are non-fatal
- errors */
- int force_executable;
-
- void bcopy (), bzero ();
-
- int xmalloc ();
- void fatal ();
- void fatal_with_file ();
- void error ();
-
- void digest_symbols ();
- void print_symbols ();
- void load_symbols ();
- void decode_command ();
- void list_undefined_symbols ();
- void list_unresolved_references ();
- void write_output ();
- void write_header ();
- void write_text ();
- void write_data ();
- void write_rel ();
- void write_syms ();
- void write_symsegs ();
- void mywrite ();
- void symtab_init ();
- void padfile ();
- char *get_file_name ();
- ld_symbol *getsym (), *getsym_soft ();
-
- Handle resource_text;
-
- void read_file_symbols (), read_entry_symbols (), read_entry_strings ();
- void enter_file_symbols (), enter_global_ref (), search_library ();
- void modify_location (), perform_relocation (), copy_text (), copy_data ();
-
- int main (void)
- {
- register char *bytes;
- register int desc;
- struct file_entry fe;
- register int len,coresize,resource_size;
- struct exec hdr;
- register int i;
-
- /* Clear the cumulative info on the output file. */
-
- text_size = 0;
- data_size = 0;
- bss_size = 0;
- text_reloc_size = 0;
- data_reloc_size = 0;
-
- data_pad = 0;
- text_pad = 0;
-
- /* Initialize the data about options. */
-
- specified_data_size = 0;
- strip_symbols = STRIP_NONE;
- discard_locals = DISCARD_NONE;
- entry_symbol = 0;
- magic = OMAGIC;
- make_executable = 1;
- force_executable = 0;
- set_element_prefixes = 0;
-
- /* Initialize the cumulative counts of symbols. */
-
- local_sym_count = 0;
- non_L_local_sym_count = 0;
- debugger_sym_count = 0;
- undefined_global_sym_count = 0;
- set_symbol_count = 0;
- set_vector_count = 0;
- global_indirect_count = 0;
- warning_count = 0;
- multiple_def_count = 0;
- common_defined_global_count = 0;
-
- file_table = &fe;
- bzero (file_table, sizeof (struct file_entry));
-
- file_table->filename = "a.out";
- file_table->local_sym_name = "a.out";
-
-
- resource_text = GetResource('UNIX', 128);
- resource_size = SizeResource(resource_text);
-
- if (!resource_text) ExitToShell();
-
- bcopy( *resource_text, &file_table->header, sizeof (struct exec));
- if (N_BADMAG(file_table->header))
- fatal_with_file ("bad magic number in ", file_table);
-
- coresize = N_DATOFF(file_table->header) +
- (file_table->header).a_data +
- (file_table->header).a_bss;
-
- if (coresize > resource_size) resource_size = coresize;
-
- HPurge(resource_text);
- PurgeMem((Size) (1<<23));
-
- ResrvMem(resource_size);
- LoadResource(resource_text);
- HNoPurge(resource_text);
-
- DetachResource(resource_text);
-
- SetHandleSize(resource_text, resource_size);
-
- if (MemError()) ExitToShell();
-
- HLock(resource_text);
-
- /* Create the symbols `etext', `edata' and `end'. */
-
- symtab_init ();
-
- text_start = sizeof(struct exec) + ((long) StripAddress(*resource_text));
- data_start = text_start + file_table->header.a_text;
-
- file_table->header_read_flag = 1;
- file_table->symbols = N_SYMOFF (file_table->header) + (char *)*resource_text;
- file_table->string_size = *(int *)( N_STROFF (file_table->header) + (char *)*resource_text);
- file_table->strings = N_STROFF (file_table->header) + (char *)*resource_text;
- file_table->textrel = text_offset (file_table) + file_table->header.a_text + file_table->header.a_data + (char *)*resource_text;
- file_table->datarel = text_offset (file_table) + file_table->header.a_text + file_table->header.a_data + file_table->header.a_trsize + (char *)*resource_text;
- enter_file_symbols (file_table);
- file_table->text_start_address = text_size;
- text_size += file_table->header.a_text;
- file_table->data_start_address = data_size;
- data_size += file_table->header.a_data;
- file_table->bss_start_address = bss_size;
- bss_size += file_table->header.a_bss;
- text_reloc_size += file_table->header.a_trsize;
- data_reloc_size += file_table->header.a_drsize;
-
- digest_symbols ();
-
- /* Print error messages for any missing symbols, for any warning
- symbols, and possibly multiple definitions */
-
- bytes = text_offset (file_table) + (char *)*resource_text;
-
- perform_relocation (bytes, file_table->text_start_address, file_table->header.a_text,
- file_table->textrel, file_table->header.a_trsize, file_table);
-
- bytes = text_offset (file_table) + file_table->header.a_text + (char *)*resource_text;
-
- perform_relocation (bytes, file_table->data_start_address - file_table->header.a_text,
- file_table->header.a_data, file_table->datarel, file_table->header.a_drsize, file_table);
-
- bzero((void *)file_table->bss_start_address, (file_table->header).a_bss);
- SetHandleSize(resource_text, coresize);
-
- if (make_executable && entry_symbol->value)
- {
- long type;
- Size FreeBytes,growBytes;
- int addr = entry_symbol->value;
- malloc_free_all();
- FreeBytes = MaxMem(&growBytes);
-
- FlushCache();
-
- ((void (*)(void))((addr)))();
- }
-
- ExitToShell ();
- }
-
- void decode_option ();
-
- /* Analyze a command line argument.
- Return 0 if the argument is a filename.
- Return 1 if the argument is a option complete in itself.
- Return 2 if the argument is a option which uses an argument.
-
- Thus, the value is the number of consecutive arguments
- that are part of options. */
-
- int
- classify_arg (arg)
- register char *arg;
- {
- if (*arg != '-') return 0;
- switch (arg[1])
- {
- case 'A':
- case 'D':
- case 'e':
- case 'L':
- case 'l':
- case 'o':
- case 'u':
- case 'V':
- case 'y':
- if (arg[2])
- return 1;
- return 2;
-
- case 'B':
- if (! strcmp (&arg[2], "static"))
- return 1;
-
- case 'T':
- if (arg[2] == 0)
- return 2;
- if (! strcmp (&arg[2], "text"))
- return 2;
- if (! strcmp (&arg[2], "data"))
- return 2;
- return 1;
- }
-
- return 1;
- }
-
-
-
- int
- set_element_prefixed_p (name)
- char *name;
- {
- struct string_list_element *p;
- int i;
-
- for (p = set_element_prefixes; p; p = p->next)
- {
- for (i = 0; p->str[i] != '\0' && (p->str[i] == name[i]); i++)
- ;
-
- if (p->str[i] == '\0')
- return 1;
- }
- return 0;
- }
-
- /* Record an option and arrange to act on it later.
- ARG should be the following command argument,
- which may or may not be used by this option.
-
- The `l' and `A' options are ignored here since they actually
- specify input files. */
-
-
- /** Convenient functions for operating on one or all files being */
- /** loaded. */
- void print_file_name ();
-
-
- /* Close the input file that is now open. */
-
- void
- file_close ()
- {
- input_file = 0;
- }
-
- /* Open the input file specified by 'entry', and return a descriptor.
- The open file is remembered; if the same file is opened twice in a row,
- a new open is not actually done. */
-
- int
- file_open (entry)
- register struct file_entry *entry;
- {
- return input_desc;
- }
-
-
- /* Medium-level input routines for rel files. */
-
- /* Read a file's header into the proper place in the file_entry.
- DESC is the descriptor on which the file is open.
- ENTRY is the file's entry. */
- /* Read the string table of file ENTRY into core.
- Assume it is already open, on descriptor DESC.
- Also record whether a GDB ld_symbol segment follows the string table. */
-
-
- /* Enter the external ld_symbol defs and refs of ENTRY in the hash table. */
-
- void
- enter_file_symbols (entry)
- struct file_entry *entry;
- {
- register struct nlist
- *p,
- *end = entry->symbols + entry->header.a_syms / sizeof (struct nlist);
-
- for (p = entry->symbols; p < end; p++)
- {
- if (p->n_type == (N_SETV | N_EXT)) continue;
- if (set_element_prefixes
- && set_element_prefixed_p (p->n_un.n_strx + entry->strings))
- p->n_type += (N_SETA - N_ABS);
-
- if (SET_ELEMENT_P (p->n_type))
- {
- set_symbol_count++;
- enter_global_ref (p, p->n_un.n_strx + entry->strings, entry);
- }
- else if (p->n_type == N_WARNING)
- {
- char *name = p->n_un.n_strx + entry->strings;
-
- /* Grab the next entry. */
- p++;
- if (p->n_type != (N_UNDF | N_EXT))
- {
- make_executable = 0;
- p--; /* Process normally. */
- }
- else
- {
- ld_symbol *sp;
- char *sname = p->n_un.n_strx + entry->strings;
- /* Deal with the warning ld_symbol. */
- enter_global_ref (p, p->n_un.n_strx + entry->strings, entry);
- sp = getsym (sname);
- sp->warning = name;
- warning_count++;
- }
- }
- else if (p->n_type & N_EXT)
- enter_global_ref (p, p->n_un.n_strx + entry->strings, entry);
- else if (p->n_un.n_strx && !(p->n_type & (N_STAB | N_EXT)))
- {
- if ((p->n_un.n_strx + entry->strings)[0] != LPREFIX)
- non_L_local_sym_count++;
- local_sym_count++;
- }
- else debugger_sym_count++;
- }
-
- /* Count one for the local ld_symbol that we generate,
- whose name is the file's name (usually) and whose address
- is the start of the file's text. */
-
- local_sym_count++;
- non_L_local_sym_count++;
- }
-
- /* Enter one global ld_symbol in the hash table.
- NLIST_P points to the `struct nlist' ld_read from the file
- that describes the global ld_symbol. NAME is the ld_symbol's name.
- ENTRY is the file entry for the file the ld_symbol comes from.
-
- The `struct nlist' is modified by placing it on a chain of
- all such structs that refer to the same global ld_symbol.
- This chain starts in the `refs' field of the ld_symbol table entry
- and is chained through the `n_name'. */
-
- void
- enter_global_ref (nlist_p, name, entry)
- register struct nlist *nlist_p;
- char *name;
- struct file_entry *entry;
- {
- register ld_symbol *sp = getsym (name);
- register int type = nlist_p->n_type;
- int oldref = sp->referenced;
- int olddef = sp->defined;
-
- nlist_p->n_un.n_name = (char *) sp->refs;
- sp->refs = nlist_p;
-
- sp->referenced = 1;
- if (type != (N_UNDF | N_EXT) || nlist_p->n_value)
- {
- if (!sp->defined || sp->defined == (N_UNDF | N_EXT))
- sp->defined = type;
-
- if (oldref && !olddef)
- /* It used to be undefined and we're defining it. */
- undefined_global_sym_count--;
-
- if (!olddef && type == (N_UNDF | N_EXT) && nlist_p->n_value)
- {
- /* First definition and it's common. */
- common_defined_global_count++;
- sp->max_common_size = nlist_p->n_value;
- }
- else if (olddef && sp->max_common_size && type != (N_UNDF | N_EXT))
- {
- /* It used to be common and we're defining it as
- something else. */
- common_defined_global_count--;
- sp->max_common_size = 0;
- }
- else if (olddef && sp->max_common_size && type == (N_UNDF | N_EXT)
- && sp->max_common_size < nlist_p->n_value)
- /* It used to be common and this is a new common entry to
- which we need to pay attention. */
- sp->max_common_size = nlist_p->n_value;
-
- /* Are we defining it as a set element? */
- if (SET_ELEMENT_P (type)
- && (!olddef || (olddef && sp->max_common_size)))
- set_vector_count++;
- /* As an indirection? */
- else if (type == (N_INDR | N_EXT))
- {
- /* Indirect symbols value should be modified to point
- a ld_symbol being equivalenced to. */
- nlist_p->n_value
- = (unsigned int) getsym ((nlist_p + 1)->n_un.n_strx
- + entry->strings);
- if ((ld_symbol *) nlist_p->n_value == sp)
- {
- /* Rewrite this ld_symbol as being a global text ld_symbol
- with value 0. */
- nlist_p->n_type = sp->defined = N_TEXT | N_EXT;
- nlist_p->n_value = 0;
- /* Don't make the output executable. */
- make_executable = 0;
- }
- else
- global_indirect_count++;
- }
- }
- else
- if (!oldref)
- undefined_global_sym_count++;
-
- if (sp->trace)
- {
- register char *reftype;
- switch (type & N_TYPE)
- {
- case N_UNDF:
- if (nlist_p->n_value)
- reftype = "defined as common";
- else reftype = "referenced";
- break;
-
- case N_ABS:
- reftype = "defined as absolute";
- break;
-
- case N_TEXT:
- reftype = "defined in text section";
- break;
-
- case N_DATA:
- reftype = "defined in data section";
- break;
-
- case N_BSS:
- reftype = "defined in BSS section";
- break;
-
- case N_SETT:
- reftype = "is a text set element";
- break;
-
- case N_SETD:
- reftype = "is a data set element";
- break;
-
- case N_SETB:
- reftype = "is a BSS set element";
- break;
-
- case N_SETA:
- reftype = "is an absolute set element";
- break;
-
- case N_SETV:
- reftype = "defined in data section as vector";
- break;
-
- case N_INDR:
- reftype = "defined equivalent";
- break;
-
- }
-
- }
- }
-
- /* This return 0 if the given file entry's ld_symbol table does *not*
- contain the nlist point entry, and it returns the files entry
- pointer (cast to unsigned long) if it does. */
-
- unsigned long
- contains_symbol (entry, n_ptr)
- struct file_entry *entry;
- register struct nlist *n_ptr;
- {
- if (n_ptr >= entry->symbols &&
- n_ptr < (entry->symbols
- + (entry->header.a_syms / sizeof (struct nlist))))
- return (unsigned long) entry;
- return 0;
- }
-
-
-
-
- void consider_file_section_lengths (), relocate_file_addresses ();
-
- /* Having entered all the global symbols and found the sizes of sections
- of all files to be linked, make all appropriate deductions from this data.
-
- We propagate global ld_symbol values from definitions to references.
- We compute the layout of the output file and where each input file's
- contents fit into it. */
-
- void
- digest_symbols ()
- {
- register int i;
- int setv_fill_count;
-
- /* Set up the set element vector */
-
- {
- /* The set sector size is the number of set elements + a word
- for each ld_symbol for the length word at the beginning of the
- vector, plus a word for each ld_symbol for a zero at the end of
- the vector (for incremental linking). */
- set_sect_size
- = (2 * set_symbol_count + set_vector_count) * sizeof (unsigned long);
- set_sect_start = data_start + data_size;
- data_size += set_sect_size;
- setv_fill_count = 0;
- }
-
- /* Compute start addresses of each file's sections and symbols. */
-
- relocate_file_addresses ( file_table, 0);
-
- /* Now, for each ld_symbol, verify that it is defined globally at most once.
- Put the global value into the ld_symbol entry.
- Common symbols are allocated here, in the BSS section.
- Each defined ld_symbol is given a '->defined' field
- which is the correct N_ code for its definition,
- except in the case of common symbols with -r.
- Then make all the references point at the ld_symbol entry
- instead of being chained together. */
-
- defined_global_sym_count = 0;
-
- for (i = 0; i < TABSIZE; i++)
- {
- register ld_symbol *sp;
- for (sp = symtab[i]; sp; sp = sp->link)
- {
- /* For each ld_symbol */
- register struct nlist *p, *next;
- int defs = 0, com = sp->max_common_size;
- struct nlist *first_definition;
- for (p = sp->refs; p; p = next)
- {
- register int type = p->n_type;
-
- if (SET_ELEMENT_P (type))
- {
- if (!defs++)
- {
- sp->value = set_sect_start
- + setv_fill_count++ * sizeof (unsigned long);
- sp->defined = N_SETV | N_EXT;
- first_definition = p;
- }
- else if ((sp->defined & ~N_EXT) != N_SETV)
- {
- sp->multiply_defined = 1;
- multiple_def_count++;
- }
- setv_fill_count++;
- }
- else if ((type & N_EXT) && type != (N_UNDF | N_EXT))
- {
- /* non-common definition */
- if (defs++ && sp->value != p->n_value)
- {
- sp->multiply_defined = 1;
- multiple_def_count++;
- }
- sp->value = p->n_value;
- sp->defined = type;
- first_definition = p;
- }
- next = (struct nlist *) p->n_un.n_name;
- p->n_un.n_name = (char *) sp;
- }
- /* Allocate as common if defined as common and not defined for real */
- if (com && !defs)
- {
- {
- int align = sizeof (int);
-
- /* Round up to nearest sizeof (int). I don't know
- whether this is necessary or not (given that
- alignment is taken care of later), but it's
- traditional, so I'll leave it in. Note that if
- this size alignment is ever removed, ALIGN above
- will have to be initialized to 1 instead of
- sizeof (int). */
-
- com = (com + sizeof (int) - 1) & (- sizeof (int));
-
- while (!(com & align))
- align <<= 1;
-
- align = align > MAX_ALIGNMENT ? MAX_ALIGNMENT : align;
-
- bss_size = ((((bss_size + data_size + data_start)
- + (align - 1)) & (- align))
- - data_size - data_start);
-
- sp->value = data_start + data_size + bss_size;
- sp->defined = N_BSS | N_EXT;
- bss_size += com;
- }
- }
- /* Set length word at front of vector and zero byte at end.
- Reverse the vector itself to put it in file order. */
- if ((sp->defined & ~N_EXT) == N_SETV)
- {
- unsigned long length_word_index
- = (sp->value - set_sect_start) / sizeof (unsigned long);
- unsigned long i, tmp;
-
- setv_fill_count++;
- }
- if (sp->defined)
- defined_global_sym_count++;
- }
- }
-
- if (end_symbol) /* These are null if -r. */
- {
- etext_symbol->value = text_size + text_start;
- edata_symbol->value = data_start + data_size;
- end_symbol->value = data_start + data_size + bss_size;
- }
- }
-
- /* Determine where the sections of ENTRY go into the output file,
- whose total section sizes are already known.
- Also relocate the addresses of the file's local and debugger symbols. */
-
- void
- relocate_file_addresses (entry)
- register struct file_entry *entry;
- {
- entry->text_start_address += text_start;
- /* Note that `data_start' and `data_size' have not yet been
- adjusted for `data_pad'. If they had been, we would get the wrong
- results here. */
- entry->data_start_address += data_start;
- entry->bss_start_address += data_start + data_size;
-
- {
- register struct nlist *p;
- register struct nlist *end
- = entry->symbols + entry->header.a_syms / sizeof (struct nlist);
-
- for (p = entry->symbols; p < end; p++)
- {
- /* If this belongs to a section, update it by the section's start address */
- register int type = p->n_type & N_TYPE;
-
- switch (type)
- {
- case N_TEXT:
- case N_SETT:
- p->n_value += entry->text_start_address;
- break;
- case N_DATA:
- case N_SETV:
- case N_SETD:
- /* A ld_symbol whose value is in the data section
- is present in the input file as if the data section
- started at an address equal to the length of the file's text. */
- p->n_value += entry->data_start_address - entry->header.a_text;
- break;
- case N_BSS:
- case N_SETB:
- /* likewise for symbols with value in BSS. */
- p->n_value += entry->bss_start_address
- - entry->header.a_text - entry->header.a_data;
- break;
- }
- }
- }
- }
-
-
-
-
- int
- text_offset (entry)
- struct file_entry *entry;
- {
- return entry->starting_offset + N_TXTOFF (entry->header);
- }
-
- /* Relocate ENTRY's text or data section contents.
- DATA is the address of the contents, in core.
- DATA_SIZE is the length of the contents.
- PC_RELOCATION is the difference between the address of the contents
- in the output file and its address in the input file.
- RELOC_INFO is the address of the relocation info, in core.
- RELOC_SIZE is its length in bytes. */
- /* This version is about to be severly hacked by Randy. Hope it
- works afterwards. */
- void
- perform_relocation (data, pc_relocation, data_size, reloc_info, reloc_size, entry)
- char *data;
- struct relocation_info *reloc_info;
- struct file_entry *entry;
- int pc_relocation;
- int data_size;
- int reloc_size;
- {
- register struct relocation_info *p = reloc_info;
- struct relocation_info *end
- = reloc_info + reloc_size / sizeof (struct relocation_info);
- int text_relocation = entry->text_start_address;
- int data_relocation = entry->data_start_address - entry->header.a_text;
- int bss_relocation
- = entry->bss_start_address - entry->header.a_text - entry->header.a_data;
-
- for (; p < end; p++)
- {
- register int relocation = 0;
- register int addr = RELOC_ADDRESS(p);
- register unsigned int mask = 0;
-
- if (addr >= data_size)
- fatal_with_file ("relocation address out of range in ", entry);
-
- if (RELOC_EXTERN_P(p))
- {
- int symindex = RELOC_SYMBOL (p) * sizeof (struct nlist);
- ld_symbol *sp = ((ld_symbol *)
- (((struct nlist *)
- (((char *)entry->symbols) + symindex))
- ->n_un.n_name));
-
- #ifdef N_INDR
- /* Resolve indirection */
- if ((sp->defined & ~N_EXT) == N_INDR)
- sp = (ld_symbol *) sp->value;
- #endif
-
- if (symindex >= entry->header.a_syms)
- fatal_with_file ("relocation symbolnum out of range in ", entry);
-
- /* If the ld_symbol is undefined, leave it at zero. */
- if (! sp->defined)
- relocation = 0;
- else
- relocation = sp->value;
- }
- else switch (RELOC_TYPE(p))
- {
- case N_TEXT:
- case N_TEXT | N_EXT:
- relocation = text_relocation;
- break;
-
- case N_DATA:
- case N_DATA | N_EXT:
- /* A word that points to beginning of the the data section
- initially contains not 0 but rather the "address" of that section
- in the input file, which is the length of the file's text. */
- relocation = data_relocation;
- break;
-
- case N_BSS:
- case N_BSS | N_EXT:
- /* Similarly, an input word pointing to the beginning of the bss
- initially contains the length of text plus data of the file. */
- relocation = bss_relocation;
- break;
-
- case N_ABS:
- case N_ABS | N_EXT:
- /* Don't know why this code would occur, but apparently it does. */
- break;
-
- case 0:
- /* bodge */
- break;
-
- default:
- fatal_with_file ("nonexternal relocation code invalid in ", entry);
- }
-
- #ifdef RELOC_ADD_EXTRA
- relocation += RELOC_ADD_EXTRA(p);
- if (relocatable_output)
- {
- /* Non-PC relative relocations which are absolute
- or which have become non-external now have fixed
- relocations. Set the ADD_EXTRA of this relocation
- to be the relocation we have now determined. */
- if (! RELOC_PCREL_P (p))
- {
- if ((int)p->r_type <= RELOC_32
- || RELOC_EXTERN_P (p) == 0)
- RELOC_ADD_EXTRA (p) = relocation;
- }
- /* External PC-relative relocations continue to move around;
- update their relocations by the amount they have moved
- so far. */
- else if (RELOC_EXTERN_P (p))
- RELOC_ADD_EXTRA (p) -= pc_relocation;
- continue;
- }
- #endif
-
- if (RELOC_PCREL_P(p))
- relocation -= pc_relocation;
-
- relocation >>= RELOC_VALUE_RIGHTSHIFT(p);
-
- /* Unshifted mask for relocation */
- mask = 1 << RELOC_TARGET_BITSIZE(p) - 1;
- mask |= mask - 1;
- relocation &= mask;
-
- /* Shift everything up to where it's going to be used */
- relocation <<= RELOC_TARGET_BITPOS(p);
- mask <<= RELOC_TARGET_BITPOS(p);
-
- switch (RELOC_TARGET_SIZE(p))
- {
- case 0:
- if (RELOC_MEMORY_SUB_P(p))
- relocation -= mask & *(char *) (data + addr);
- else if (RELOC_MEMORY_ADD_P(p))
- relocation += mask & *(char *) (data + addr);
- *(char *) (data + addr) &= ~mask;
- *(char *) (data + addr) |= relocation;
- break;
-
- case 1:
- if (RELOC_MEMORY_SUB_P(p))
- relocation -= mask & *(short *) (data + addr);
- else if (RELOC_MEMORY_ADD_P(p))
- relocation += mask & *(short *) (data + addr);
- *(short *) (data + addr) &= ~mask;
- *(short *) (data + addr) |= relocation;
- break;
-
- case 2:
- #ifndef _CROSS_TARGET_ARCH
- if (RELOC_MEMORY_SUB_P(p))
- relocation -= mask & *(long *) (data + addr);
- else if (RELOC_MEMORY_ADD_P(p))
- relocation += mask & *(long *) (data + addr);
- *(long *) (data + addr) &= ~mask;
- *(long *) (data + addr) |= relocation;
- #else
- /* Handle long word alignment requirements of SPARC architecture */
- /* WARNING: This fix makes an assumption on byte ordering */
- /* Marc Ullman, Stanford University Nov. 1 1989 */
- if (RELOC_MEMORY_SUB_P(p)) {
- relocation -= mask &
- ((*(unsigned short *) (data + addr) << 16) |
- *(unsigned short *) (data + addr + 2));
- } else if (RELOC_MEMORY_ADD_P(p)) {
- relocation += mask &
- ((*(unsigned short *) (data + addr) << 16) |
- *(unsigned short *) (data + addr + 2));
- }
- *(unsigned short *) (data + addr) &= (~mask >> 16);
- *(unsigned short *) (data + addr + 2) &= (~mask & 0xffff);
- *(unsigned short *) (data + addr) |= (relocation >> 16);
- *(unsigned short *) (data + addr + 2) |= (relocation & 0xffff);
- #endif
- break;
-
- default:
- fatal_with_file ("Unimplemented relocation field length in ", entry);
- }
- }
- }
-
-
- void write_file_syms ();
- void write_string_table ();
-
- /* Offsets and current lengths of ld_symbol and string tables in output file. */
-
- int symbol_table_offset;
- int symbol_table_len;
-
- /* Address in output file where string table starts. */
- int string_table_offset;
-
- /* Offset within string table
- where the strings in `strtab_vector' should be written. */
- int string_table_len;
-
- /* Total size of string table strings allocated so far,
- including strings in `strtab_vector'. */
- int strtab_size;
-
- /* Vector whose elements are strings to be added to the string table. */
- char **strtab_vector;
-
- /* Vector whose elements are the lengths of those strings. */
- int *strtab_lens;
-
- /* Index in `strtab_vector' at which the next string will be stored. */
- int strtab_index;
-
- /* Add the string NAME to the output file string table.
- Record it in `strtab_vector' to be output later.
- Return the index within the string table that this string will have. */
-
- int
- assign_string_table_index (name)
- char *name;
- {
- register int index = strtab_size;
- register int len = strlen (name) + 1;
-
- strtab_size += len;
- strtab_vector[strtab_index] = name;
- strtab_lens[strtab_index++] = len;
-
- return index;
- }
-
- /* Create the ld_symbol table entries for `etext', `edata' and `end'. */
-
- void
- symtab_init ()
- {
- entry_symbol = getsym ("ENTRY_SYMBOL");
- if (!entry_symbol->defined && !entry_symbol->referenced)
- undefined_global_sym_count++;
- entry_symbol->referenced = 1;
- #ifndef nounderscore
- edata_symbol = getsym ("_edata");
- etext_symbol = getsym ("_etext");
- end_symbol = getsym ("_end");
- #else
- edata_symbol = getsym ("edata");
- etext_symbol = getsym ("etext");
- end_symbol = getsym ("end");
- #endif
-
- edata_symbol->defined = N_DATA | N_EXT;
- etext_symbol->defined = N_TEXT | N_EXT;
- end_symbol->defined = N_BSS | N_EXT;
-
- edata_symbol->referenced = 1;
- etext_symbol->referenced = 1;
- end_symbol->referenced = 1;
- }
-
- /* Compute the hash code for ld_symbol name KEY. */
-
- int
- hash_string (key)
- char *key;
- {
- register char *cp;
- register int k;
-
- cp = key;
- k = 0;
- while (*cp)
- k = (((k << 1) + (k >> 14)) ^ (*cp++)) & 0x3fff;
-
- return k;
- }
-
- /* Get the ld_symbol table entry for the global ld_symbol named KEY.
- Create one if there is none. */
-
- ld_symbol *
- getsym (key)
- char *key;
- {
- register int hashval;
- register ld_symbol *bp;
-
- /* Determine the proper bucket. */
-
- hashval = hash_string (key) % TABSIZE;
-
- /* Search the bucket. */
-
- for (bp = symtab[hashval]; bp; bp = bp->link)
- if (! strcmp (key, bp->name))
- return bp;
-
- /* Nothing was found; create a new ld_symbol table entry. */
-
- bp = (ld_symbol *) xmalloc (sizeof (ld_symbol));
- bp->refs = 0;
- bp->name = (char *) xmalloc (strlen (key) + 1);
- strcpy (bp->name, key);
- bp->defined = 0;
- bp->referenced = 0;
- bp->trace = 0;
- bp->value = 0;
- bp->max_common_size = 0;
- bp->warning = 0;
- bp->undef_refs = 0;
- bp->multiply_defined = 0;
-
- /* Add the entry to the bucket. */
-
- bp->link = symtab[hashval];
- symtab[hashval] = bp;
-
- ++num_hash_tab_syms;
-
- return bp;
- }
-
- /* Like `getsym' but return 0 if the ld_symbol is not already known. */
-
- ld_symbol *
- getsym_soft (key)
- char *key;
- {
- register int hashval;
- register ld_symbol *bp;
-
- /* Determine which bucket. */
-
- hashval = hash_string (key) % TABSIZE;
-
- /* Search the bucket. */
-
- for (bp = symtab[hashval]; bp; bp = bp->link)
- if (! strcmp (key, bp->name))
- return bp;
-
- return 0;
- }
-
- /* Report a fatal error.
- STRING is a printf format string and ARG is one arg for it. */
-
- void
- fatal (string, arg)
- char *string, *arg;
- {
- error(string);
- ExitToShell();
- }
-
- /* Report a fatal error. The error message is STRING
- followed by the filename of ENTRY. */
-
- void
- fatal_with_file (string, entry)
- char *string;
- struct file_entry *entry;
- {
- error(string);
- ExitToShell();
- }
-
- /* Report a nonfatal error.
- STRING is a format for printf, and ARG1 ... ARG3 are args for it. */
-
- void
- error (string, arg1, arg2, arg3)
- char *string, *arg1, *arg2, *arg3;
- {
- Str255 err;
- for (*err = 0; *string; string++)
- {
- *err += 1;
- err[*err] = *string;
- }
-
- DebugStr(err);
- }
-
- /* Like malloc but get fatal error if memory is exhausted. */
-
- int
- xmalloc (size)
- {
- register int result = (int)malloc (size);
- if (!result)
- fatal ("virtual memory exhausted", 0);
- return result;
- }
-
- int
- xrealloc (ptr, size)
- {
- register int result = (int)realloc (ptr, size);
- if (!result)
- fatal ("virtual memory exhausted", 0);
- return result;
- }
-
- void *emptyblock(size_t sz)
- {
- void *ptr = NewPtrClear(sz);
- return ptr;
- }
-
- int getpagesize(void)
- {
- return 8192;
- }
-