home *** CD-ROM | disk | FTP | other *** search
/ Il CD di internet / CD.iso / SOURCE / D / LIBC / LIBC-4.6 / LIBC-4 / libc-linux / sysdeps / linux / fixups.h < prev    next >
Encoding:
C/C++ Source or Header  |  1993-10-14  |  5.7 KB  |  133 lines

  1. #ifndef _FIXUPS_H
  2. #define _FIXUPS_H
  3.  
  4. /*
  5.  * Copyright (c) 1993 Eric Youngdale, Peter MacDonald, David Engel
  6.  * and Hongjiu Lu.
  7.  *
  8.  * All rights reserved.
  9.  *
  10.  * Redistribution and use in source and binary forms, with or without
  11.  * modification, are permitted provided that the following conditions
  12.  * are met:
  13.  * 1. Redistributions of source code must retain the above copyright
  14.  *    notice, this list of conditions and the following disclaimer.
  15.  * 2. All advertising materials mentioning features or use of this software
  16.  *    must display the following acknowledgement:
  17.  *    This product includes software developed by Eric Youngdale,
  18.  *      Peter MacDonald, David Engel and Hongjiu Lu.
  19.  * 3. The name of the above contributors may not be
  20.  *    used to endorse or promote products derived from this software
  21.  *    without specific prior written permission.
  22.  *
  23.  * THIS SOFTWARE IS PROVIDED BY THE CONTRIBUTORS ``AS IS'' AND
  24.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  25.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  26.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE
  27.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  28.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  29.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  30.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  31.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  32.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  33.  * SUCH DAMAGE.
  34.  */
  35.  
  36. /* Notice of general intent:
  37.  *
  38.  * The linux operating system generally contains large amounts of code
  39.  * that fall under the GNU General Public License, or GPL for short.
  40.  * This file contains source code that by it's very nature would always
  41.  * be linked with an application program, and because of this a GPL type
  42.  * of copyright on this file would place restrictions upon the
  43.  * distribution of binary-only commercial software.  Since the goal of the
  44.  * Linux project as a whole is not to discourage the development and
  45.  * distribution of commercial software for Linux, this file has been placed
  46.  * under a more relaxed BSD-style of copyright.
  47.  *
  48.  * It is the general understanding of the above contributors that a
  49.  * program executable linked to a library containing code that falls
  50.  * under the GPL or GLPL style of license is not subject to the terms of
  51.  * the GPL or GLPL license if the program executable(s) that are supplied
  52.  * are linked to a shared library form of the GPL or GLPL library, and as long
  53.  * as the form of the shared library is such that it is possible for
  54.  * the end user to modify and rebuild the library and use it in
  55.  * conjunction with the program executable.
  56.  */
  57.  
  58. /* This list is generated by the linker - it corresponds to the SETD
  59.    list generated in conjunction with the variable __SHARABLE_CONFLICTS__.
  60.    The linker does not do anything special with this symbol - it simply
  61.    puts together the pieces that are needed.  The list of fixups to local
  62.    variables is generated internally by the linker, and ld fills in this
  63.    one field as a special case before writing the image.  The array size
  64.    is listed as 1, but it would actually be  ->size - 2.  __load.c will
  65.    pick up this pointer and pass it to __dynamic_resolve() and __do_fixups().
  66. */
  67.  
  68. struct fixuplist {  /* This list is generated by the linker */
  69.   int size;
  70.   int * magic;  /* Used for verification purposes */
  71.   struct image_fixuplist * list;  /* Fixups to local variables */
  72.   struct fixuplist *** shrlib_list[1];  /* One for each sharable
  73.             library this program is linked to.  The sharable libraries
  74.         are linked to other sharable libraries, so we have to walk
  75.         this tree and resolve all of the fixups. */
  76. };            
  77.  
  78. /* This is a linker-generated list of fixups.  The linker essentially
  79.    watches for    multiple definitions of symbols, and if there is a
  80.    __GOT__ symbol then it does not flag an error condition.  Instead, it
  81.    adds a fixup to the fixuplist which will correct the __GOT__ that 
  82.    appears later on the link command line.  The number of pointer pairs
  83.    is always specified by the size field, and after the last pointer pair
  84.    is the pointer to the builtin_fixups.
  85.    */
  86.  
  87. struct image_fixuplist {
  88.   int size;
  89.   struct elemental_fixup {
  90.     union {
  91.       int  newaddr;
  92.       struct builtin_fixup* bifu;
  93.     }un;
  94.     int * fixaddr;
  95.   } fix[1];
  96. };
  97.  
  98. /* Each link image (sharable libraries are each considered a sharable
  99.    link image) will have a list of builtin fixups as well, as many as one
  100.    for each source file that went into the link image.  These lists
  101.    are generated by jumpas as needed (perhaps one per source file), and a SETD
  102.    symbol __BUILTIN_FIXUPS__.  These will never appear in a user program -
  103.    only in a shared library.  This structure contains a series of pointers
  104.    to these different lists, and we need to walk through and apply all
  105.    of the fixups.  The array size is listed as 1, but it can be any number
  106.  */
  107.  
  108. struct builtin_fixup {
  109.     int len;
  110.     struct file_fixup * fixpnt[1];  /* Potentially one for every source
  111.                         file that was linked */
  112. };
  113.  
  114. /* Each source file can potentially have one of these beasts.  There
  115.    are a series of pointer pairs, terminated by a NULL.  The idea here is
  116.    that we are supposed to copy the number out of gotaddr  and store it at
  117.    fixaddr.  This is the list that is generated by the jumpas tool.
  118.    This is listed with an array size of 1, but it can be any number.
  119.  */
  120.  
  121. struct file_fixup {
  122.   struct builtin_elemental_fixup {
  123.     int * gotaddr;
  124.     int * fixaddr;
  125.   } fixup[1];
  126. };
  127.  
  128. int __reset_magic(struct fixuplist * xpnt);
  129. int __do_fixups(struct fixuplist * xpnt, int flag);
  130. int __dynamic_resolve(struct fixuplist * xpnt);
  131.  
  132. #endif /* _FIXUPS_H */
  133.