Many recent fixes from Paul K, add support for chaining of shared lib deps.
[unix-history] / gnu / usr.bin / ld / ld.h
index 687b7a3..3336b80 100644 (file)
@@ -1,4 +1,4 @@
-/*     $Id: ld.h,v 1.4 1993/11/01 16:26:16 pk Exp $    */
+/*     $Id: ld.h,v 1.5 1993/11/10 21:53:42 pk Exp $    */
 /*-
  * This code is derived from software copyrighted by the Free Software
  * Foundation.
 /*-
  * This code is derived from software copyrighted by the Free Software
  * Foundation.
@@ -343,11 +343,11 @@ int oldmagic;
 
 typedef struct glosym {
        /* Pointer to next symbol in this symbol's hash bucket.  */
 
 typedef struct glosym {
        /* Pointer to next symbol in this symbol's hash bucket.  */
-       struct glosym  *link;
+       struct glosym   *link;
        /* Name of this symbol.  */
        /* Name of this symbol.  */
-       char           *name;
+       char            *name;
        /* Value of this symbol as a global symbol.  */
        /* Value of this symbol as a global symbol.  */
-       long            value;
+       long            value;
        /*
         * Chain of external 'nlist's in files for this symbol, both defs and
         * refs.
        /*
         * Chain of external 'nlist's in files for this symbol, both defs and
         * refs.
@@ -357,34 +357,34 @@ typedef struct glosym {
         * Any warning message that might be associated with this symbol from
         * an N_WARNING symbol encountered.
         */
         * Any warning message that might be associated with this symbol from
         * an N_WARNING symbol encountered.
         */
-       char           *warning;
+       char            *warning;
        /*
         * Nonzero means definitions of this symbol as common have been seen,
         * and the value here is the largest size specified by any of them.
         */
        /*
         * Nonzero means definitions of this symbol as common have been seen,
         * and the value here is the largest size specified by any of them.
         */
-       int             max_common_size;
+       int             max_common_size;
        /*
         * For relocatable_output, records the index of this global sym in
         * the symbol table to be written, with the first global sym given
         * index 0.
         */
        /*
         * For relocatable_output, records the index of this global sym in
         * the symbol table to be written, with the first global sym given
         * index 0.
         */
-       int             symbolnum;
+       int             symbolnum;
        /*
         * For dynamically linked output, records the index in the RRS
         * symbol table.
         */
        /*
         * For dynamically linked output, records the index in the RRS
         * symbol table.
         */
-       int             rrs_symbolnum;
+       int             rrs_symbolnum;
        /*
         * Nonzero means a definition of this global symbol is known to
         * exist. Library members should not be loaded on its account.
         */
        /*
         * Nonzero means a definition of this global symbol is known to
         * exist. Library members should not be loaded on its account.
         */
-       char            defined;
+       char            defined;
        /*
         * Nonzero means a reference to this global symbol has been seen in a
         * file that is surely being loaded. A value higher than 1 is the
         * n_type code for the symbol's definition.
         */
        /*
         * Nonzero means a reference to this global symbol has been seen in a
         * file that is surely being loaded. A value higher than 1 is the
         * n_type code for the symbol's definition.
         */
-       char            referenced;
+       char            referenced;
        /*
         * A count of the number of undefined references printed for a
         * specific symbol.  If a symbol is unresolved at the end of
        /*
         * A count of the number of undefined references printed for a
         * specific symbol.  If a symbol is unresolved at the end of
@@ -394,15 +394,15 @@ typedef struct glosym {
         * symbol here.  When the number hits MAX_UREFS_PRINTED, messages
         * stop.
         */
         * symbol here.  When the number hits MAX_UREFS_PRINTED, messages
         * stop.
         */
-       unsigned char   undef_refs;
+       unsigned char   undef_refs;
        /*
         * 1 means that this 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.
         */
        /*
         * 1 means that this 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;
+       unsigned char   multiply_defined;
        /* Nonzero means print a message at all refs or defs of this symbol */
        /* Nonzero means print a message at all refs or defs of this symbol */
-       char            trace;
+       char            trace;
 
        /*
         * For symbols of type N_INDR, this points at the real symbol.
 
        /*
         * For symbols of type N_INDR, this points at the real symbol.
@@ -422,10 +422,17 @@ typedef struct glosym {
         * section of the resulting a.out file. They *do* go into the
         * dynamic link information segment.
         */
         * section of the resulting a.out file. They *do* go into the
         * dynamic link information segment.
         */
-       char            so_defined;
+       char            so_defined;
 
 
-       /* Size of symbol as determined by N_SIZE 'nlist's in object files */
-       int             size;
+       /* Size of symbol as determined by N_SIZE symbols in object files */
+       int             size;
+
+       /* Auxialiary info to put in the `nz_other' field of the
+        * RRS symbol table. Used by the run-time linker to resolve
+        * references to function addresses from within shared objects.
+        */
+       int             aux;
+#define RRS_FUNC       2
 
        /*
         * Chain of external 'nlist's in shared objects for this symbol, both
 
        /*
         * Chain of external 'nlist's in shared objects for this symbol, both
@@ -463,6 +470,12 @@ symbol *symtab[TABSIZE];
 /* Number of symbols in symbol hash table. */
 int num_hash_tab_syms;
 
 /* Number of symbols in symbol hash table. */
 int num_hash_tab_syms;
 
+/* Count number of nlist entries for global symbols */
+int global_sym_count;
+
+/* Count number of N_SIZE nlist entries for output (relocatable_output only) */
+int size_sym_count;
+
 /* 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 symbol table.  */
 /* 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 symbol table.  */
@@ -576,8 +589,10 @@ struct file_entry {
 
        /* The file's a.out header.  */
        struct exec     header;
 
        /* The file's a.out header.  */
        struct exec     header;
+#if 0
        /* Offset in file of GDB symbol segment, or 0 if there is none.  */
        int             symseg_offset;
        /* Offset in file of GDB symbol segment, or 0 if there is none.  */
        int             symseg_offset;
+#endif
 
        /* Describe data from the file loaded into core */
 
 
        /* Describe data from the file loaded into core */
 
@@ -593,6 +608,10 @@ struct file_entry {
                struct localsymbol      *next;
                long                    gotslot_offset;
                char                    gotslot_claimed;
                struct localsymbol      *next;
                long                    gotslot_offset;
                char                    gotslot_claimed;
+               char                    write;
+               char                    is_L_symbol;
+               char                    rename;
+               int                     symbolnum;
        } *symbols;
 
        /* Number of symbols in above array. */
        } *symbols;
 
        /* Number of symbols in above array. */
@@ -631,11 +650,13 @@ struct file_entry {
 
        /* Start of this file's bss seg in the output file core image.  */
        int             bss_start_address;
 
        /* Start of this file's bss seg in the output file core image.  */
        int             bss_start_address;
+#if 0
        /*
         * Offset in bytes in the output file symbol table of the first local
         * symbol for this file. Set by `write_file_symbols'.
         */
        int             local_syms_offset;
        /*
         * Offset in bytes in the output file symbol table of the first local
         * symbol for this file. Set by `write_file_symbols'.
         */
        int             local_syms_offset;
+#endif
 
        /* For library members only */
 
 
        /* For library members only */
 
@@ -657,6 +678,11 @@ struct file_entry {
        /* For library member, points to next entry for next member.  */
        struct file_entry *chain;
 
        /* For library member, points to next entry for next member.  */
        struct file_entry *chain;
 
+#ifdef SUN_COMPAT
+       /* For shared libraries which have a .sa companion */
+       struct file_entry *silly_archive;
+#endif
+
        /* 1 if file is a library. */
        char            library_flag;
 
        /* 1 if file is a library. */
        char            library_flag;
 
@@ -681,6 +707,9 @@ struct file_entry {
 
        /* This entry is a shared object */
        char            is_dynamic;
 
        /* This entry is a shared object */
        char            is_dynamic;
+
+       /* 1 if this entry is not a major player anymore */
+       char            scrapped;
 };
 
 typedef struct localsymbol localsymbol_t;
 };
 
 typedef struct localsymbol localsymbol_t;
@@ -698,7 +727,8 @@ int number_of_files;
 #define FORCEARCHIVE   4               /* Force inclusion of all members
                                           of archives */
 #define SHAREABLE      8               /* Build a shared object */
 #define FORCEARCHIVE   4               /* Force inclusion of all members
                                           of archives */
 #define SHAREABLE      8               /* Build a shared object */
-int link_mode;
+#define SILLYARCHIVE   16              /* Process .sa companions, if any */
+int    link_mode;
 
 /*
  * Runtime Relocation Section (RRS).
 
 /*
  * Runtime Relocation Section (RRS).
@@ -845,18 +875,25 @@ void      read_shared_object __P((int, struct file_entry *));
 int    findlib __P((struct file_entry *));
 
 /* In shlib.c: */
 int    findlib __P((struct file_entry *));
 
 /* In shlib.c: */
-char   *findshlib __P((char *, int *, int *));
+char   *findshlib __P((char *, int *, int *, int));
 void   add_search_dir __P((char *));
 void   std_search_dirs __P((char *));
 
 /* In rrs.c: */
 void   init_rrs __P((void));
 void   add_search_dir __P((char *));
 void   std_search_dirs __P((char *));
 
 /* In rrs.c: */
 void   init_rrs __P((void));
-void   rrs_add_shobj __P((struct file_entry *));
-void   alloc_rrs_reloc __P((symbol *));
-void   alloc_rrs_segment_reloc __P((struct relocation_info  *));
-void   alloc_rrs_jmpslot __P((symbol *));
-void   alloc_rrs_gotslot __P((struct relocation_info  *, localsymbol_t *));
-void   alloc_rrs_copy_reloc __P((symbol *));
+int    rrs_add_shobj __P((struct file_entry *));
+void   alloc_rrs_reloc __P((struct file_entry *, symbol *));
+void   alloc_rrs_segment_reloc __P((struct file_entry *, struct relocation_info  *));
+void   alloc_rrs_jmpslot __P((struct file_entry *, symbol *));
+void   alloc_rrs_gotslot __P((struct file_entry *, struct relocation_info  *, localsymbol_t *));
+void   alloc_rrs_cpy_reloc __P((struct file_entry *, symbol *));
+
+int    claim_rrs_reloc __P((struct file_entry *, struct relocation_info *, symbol *, long *));
+long   claim_rrs_jmpslot __P((struct file_entry *, struct relocation_info *, symbol *, long));
+long   claim_rrs_gotslot __P((struct file_entry *, struct relocation_info *, struct localsymbol *, long));
+long   claim_rrs_internal_gotslot __P((struct file_entry *, struct relocation_info *, struct localsymbol *, long));
+void   claim_rrs_cpy_reloc __P((struct file_entry *, struct relocation_info *, symbol *));
+void   claim_rrs_segment_reloc __P((struct file_entry *, struct relocation_info *));
 
 /* In <md>.c */
 void   md_init_header __P((struct exec *, int, int));
 
 /* In <md>.c */
 void   md_init_header __P((struct exec *, int, int));