/docs/MyDocs

To get this branch, use:
bzr branch http://darksoft.org/webbzr/docs/MyDocs

« back to all changes in this revision

Viewing changes to SCM/packaging/general/linking/ld_assume_kernel.html

  • Committer: Suren A. Chilingaryan
  • Date: 2017-04-03 02:45:17 UTC
  • Revision ID: csa@suren.me-20170403024517-dwzj0z0k1cmhxm7u
Restructuring, OpenShift, Ansible, Git

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-transitional.dtd">
 
3
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
 
4
  <head>
 
5
      <title>Explaining LD_ASSUME_KERNEL</title>
 
6
  </head>
 
7
 
 
8
  <body>
 
9
    <h1>Explaining <tt>LD_ASSUME_KERNEL</tt></h1>
 
10
 
 
11
    <p>Ulrich Drepper, 2004-5-12</p>
 
12
 
 
13
    <p>It is frightening how something as simple as the mechanism
 
14
    behind <tt>LD_ASSUME_KERNEL</tt> can create that much confusion.  So
 
15
    here are a few details which should enable everybody to
 
16
    investigate the issue closer by her/himself.</p>
 
17
 
 
18
    <ol>
 
19
      <li>
 
20
        <p>First, <tt>LD_ASSUME_KERNEL</tt> is handled by the dynamic
 
21
        linker.</p>
 
22
       </li>
 
23
 
 
24
       <li>
 
25
         <p>The behavior of a specific value of <tt>LD_ASSUME_KERNEL</tt>
 
26
         is <b>not</b> hardcoded in the dynamic linker.</p>
 
27
       </li>
 
28
 
 
29
       <li>
 
30
         <p>Every DSO (Dynamic Shared Object, aka shared library) can
 
31
         tell the dynamic linker in glibc which minimum OS ABI version
 
32
         is needed.  NB: dynamic linkers other than glibc's do not
 
33
         have this feature.  The information about the minimum OS ABI
 
34
         version is encoded in a ELF note section usually named
 
35
         <tt>.note.ABI-tag</tt>.  This note section must be referenced
 
36
         by a <tt>PT_NOTE</tt> entry in the DSO's program header.</p>
 
37
 
 
38
         <p>To examine the content of a DSO's note section use the
 
39
         <tt>readelf</tt> program from <tt>elfutils</tt> (the version
 
40
         from <tt>binutils</tt> is not capable enough).  On Red Hat
 
41
         system the binary is called <tt>eu-readelf</tt>.  Using it on
 
42
         a Fedora Core 2 system shows the following:</p>
 
43
 
 
44
         <pre>$ eu-readelf -n /lib/tls/libc-2.3.3.so
 
45
 
 
46
Note segment of 32 bytes at offset 0x174:
 
47
  Owner          Data size  Type
 
48
  GNU                   16  VERSION
 
49
    OS: Linux, ABI: 2.4.20
 
50
</pre>
 
51
 
 
52
         <p>This means the <tt>/lib/tls/libc-2.3.3.so</tt> DSO
 
53
         requires at least OS ABI version 2.4.20.</p>
 
54
       </li>
 
55
 
 
56
       <li>
 
57
         <p>The specific ABI version requirements on a RHL9, and
 
58
         Fedora Core 1 and 2 system are as follows (NB: this implies
 
59
         IA-32 is the architecture):</p>
 
60
 
 
61
         <ul>
 
62
           <li><p>DSOs in <tt>/lib/tls</tt> need ABI version 2.4.20.</p></li>
 
63
           <li><p>DSOs in <tt>/lib/i686</tt> need ABI version 2.4.1.</p></li>
 
64
           <li><p>DSOs in <tt>/lib</tt> need ABI version 2.2.5.</p></li>
 
65
         </ul>
 
66
 
 
67
         <p>This means no <tt>LD_ASSUME_KERNEL</tt> setting requesting
 
68
         versions earlier than 2.2.5 will work at all.  Versions from
 
69
         2.2.5 to 2.4.0 will use the DSOs in <tt>/lib</tt>, versions
 
70
         from 2.4.1 to 2.4.19 will use the DSOs in <tt>/lib/i686</tt>,
 
71
         versions 2.4.20 and younger will use the DSOs in
 
72
         <tt>/lib/tls</tt>.</p>
 
73
 
 
74
         <p>For the Red Hat releases this layout was chosen to provide
 
75
         the maximum amount of backward compatibility for
 
76
         <b>broken</b> applications (correctly written applications
 
77
         have no problems anyway).  The code in <tt>/lib</tt> consists
 
78
         of the very early LinuxThreads code which had fixed size
 
79
         threads which could not be placed by the application.  The
 
80
         version in <tt>/lib/i686</tt> is the LinuxThreads code which
 
81
         does away with this limitation (aka floating stacks).  The
 
82
         code in <tt>/lib/tls</tt> is the new NPTL POSIX thread
 
83
         library.</p>
 
84
 
 
85
       </li>
 
86
 
 
87
       <li>
 
88
         <p>The fact that a DSO has a more stringent version
 
89
         requirement does not mean it is automatically chosen.  The
 
90
         dynamic only rejects loading DSOs based on the version
 
91
         information, it does not look for the best fit.  The above
 
92
         description is true because the dynamic linker always looks
 
93
         in the directories <tt>/lib/tls</tt>, <tt>/lib/i686</tt>, and
 
94
         <tt>/lib</tt> in this order.  Why this is the case is
 
95
         complicated and not explained here.  Read the dynamic linker
 
96
         source code.</p>
 
97
       </li>
 
98
 
 
99
       <li>
 
100
        <p>For architectures other than IA-32 the situation is
 
101
        similar, but less complicated.  In RHEL3 only two versions of
 
102
        glibc are needed, one using LinuxThreads and one using NPTL.
 
103
        The very old LinuxThreads code is not needed.</p>
 
104
       </li>
 
105
     </ol>
 
106
  </body>
 
107
</html>