<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: shl_load() error in Operating System - HP-UX</title>
    <link>https://community.hpe.com/t5/operating-system-hp-ux/shl-load-error/m-p/2451848#M729067</link>
    <description>Hi Susan, &lt;BR /&gt;&lt;BR /&gt;I am not a programmer, but i have found the following in our documentation which might solve your problem:&lt;BR /&gt;&lt;BR /&gt;Thread local storage (TLS) is a section of contiguous memory that is created&lt;BR /&gt;for each thread running in a program, this memory is only addressable by a&lt;BR /&gt;specific thread.&lt;BR /&gt;&lt;BR /&gt;TLS is created for the first thread in a process differently between a 32 and&lt;BR /&gt;a 64 bit process. For a 32 bit process the dynamic loader initialises TLS, and&lt;BR /&gt;for a 64 bit process it is initialised by libc. Because TLS in a 32 and a 64&lt;BR /&gt;bit process is initialised before the user code in the program starts to&lt;BR /&gt;execute its size has to be known.&lt;BR /&gt;&lt;BR /&gt;TLS is fixed in size because of this, its size is the sum of the sizes of all&lt;BR /&gt;the variables defined in TLS. The man page for dld.sl(5) contains more&lt;BR /&gt;information on how TLS is calculated.&lt;BR /&gt;&lt;BR /&gt;The C/C++ __thread storage modifier is used to define a variable as being in&lt;BR /&gt;TLS. For example:&lt;BR /&gt;&lt;BR /&gt;__thread int my_errno;&lt;BR /&gt;&lt;BR /&gt;Would define the variable my_errno as being kept in TLS, this means that&lt;BR /&gt;each thread in the program (if it is multi-threaded) will see a different&lt;BR /&gt;my_errno in each thread. The main reason TLS is used in programs is that it&lt;BR /&gt;has very little impact on the structure of existing source code, and it is&lt;BR /&gt;much easier to code for than thread specific data keys created via&lt;BR /&gt;pthread_key_create(3T).&lt;BR /&gt;&lt;BR /&gt;The main restriction with TLS is that if you place TLS inside a shared&lt;BR /&gt;library you cannot use shl_load or dlopen to load the library dynamically.&lt;BR /&gt;From the diagnostics section of the shl_load(3) man page:&lt;BR /&gt;&lt;BR /&gt;      If a library cannot be loaded, shl_load() returns NULL and sets errno&lt;BR /&gt;      to indicate the error.  This includes trying to shl_load() a library&lt;BR /&gt;      containing thread local storage.  All other functions return -1 on&lt;BR /&gt;      error and set errno.&lt;BR /&gt;&lt;BR /&gt;The other restriction is that if a library containing TLS is listed as a&lt;BR /&gt;dependancy of library that a program tries to shl_load it will fail to load&lt;BR /&gt;unless the library with TLS has been linked against the program. The man page&lt;BR /&gt;for shl_load(3) in the warnings section says:&lt;BR /&gt;&lt;BR /&gt;      Use caution when building shared libraries with external library&lt;BR /&gt;      dependencies.  Any library that contains Thread Local Storage (TLS)&lt;BR /&gt;      should not be used as a dependency.  If a dependent library contains&lt;BR /&gt;      TLS, and it is not loaded during program startup (that is, not linked&lt;BR /&gt;      against the executable), the dynamic loader fails to perform the&lt;BR /&gt;      operation.&lt;BR /&gt;&lt;BR /&gt;The workaround to not being able to shl_load a shared library containing TLS&lt;BR /&gt;can be seen in the following example:&lt;BR /&gt;&lt;BR /&gt;#include &lt;BR /&gt;#include &lt;BR /&gt;#include &lt;BR /&gt;&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;        shl_load("/usr/lib/libcl.2", BIND_DEFERRED, NULL);&lt;BR /&gt;        printf("errno is %in", errno);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;$ cc testing.c -o testing&lt;BR /&gt;$ ./testing&lt;BR /&gt;/usr/lib/dld.sl: Can't shl_load() a library containing Thread Local&lt;BR /&gt;Storage: /usr/lib/libcl.2&lt;BR /&gt;/usr/lib/dld.sl: Exec format error&lt;BR /&gt;errno is 8&lt;BR /&gt;$ cc testing.c -o testing -lcl&lt;BR /&gt;$ ./testing&lt;BR /&gt;errno is 0&lt;BR /&gt;&lt;BR /&gt;The program does not produce an error when libcl.sl (-lcl) has been linked&lt;BR /&gt;directly against the program. This method does not require any changes to&lt;BR /&gt;the code only to the compilation flags (or makefile) as shl_load will ignore&lt;BR /&gt;any request to load a library that is already loaded.&lt;BR /&gt;&lt;BR /&gt;</description>
    <pubDate>Tue, 10 Oct 2000 05:35:15 GMT</pubDate>
    <dc:creator>Marcel Eken_2</dc:creator>
    <dc:date>2000-10-10T05:35:15Z</dc:date>
    <item>
      <title>shl_load() error</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shl-load-error/m-p/2451847#M729066</link>
      <description>Hi,&lt;BR /&gt;I posted this message a couple hours ago and it never showed up on the forum so I might have made an error.  If you are seeing this for the second time, my apologies.&lt;BR /&gt;&lt;BR /&gt;I built a module for perl using HP's f77.  It builds fine but gives this error when I try to access it:&lt;BR /&gt;/usr/lib/dld.sl: Can't shl_load() a library containing Thread Local Storage: /usr/lib/libcl.2&lt;BR /&gt;I spoke to the developers of the module and they have never tried it with HP.  I would really like to get this built but I am unclear as to where the error is.  Does anyone have any suggestions?&lt;BR /&gt;&lt;BR /&gt;Thank you for your help,&lt;BR /&gt;Susan&lt;BR /&gt;</description>
      <pubDate>Mon, 09 Oct 2000 23:22:42 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shl-load-error/m-p/2451847#M729066</guid>
      <dc:creator>Susan Markley</dc:creator>
      <dc:date>2000-10-09T23:22:42Z</dc:date>
    </item>
    <item>
      <title>Re: shl_load() error</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shl-load-error/m-p/2451848#M729067</link>
      <description>Hi Susan, &lt;BR /&gt;&lt;BR /&gt;I am not a programmer, but i have found the following in our documentation which might solve your problem:&lt;BR /&gt;&lt;BR /&gt;Thread local storage (TLS) is a section of contiguous memory that is created&lt;BR /&gt;for each thread running in a program, this memory is only addressable by a&lt;BR /&gt;specific thread.&lt;BR /&gt;&lt;BR /&gt;TLS is created for the first thread in a process differently between a 32 and&lt;BR /&gt;a 64 bit process. For a 32 bit process the dynamic loader initialises TLS, and&lt;BR /&gt;for a 64 bit process it is initialised by libc. Because TLS in a 32 and a 64&lt;BR /&gt;bit process is initialised before the user code in the program starts to&lt;BR /&gt;execute its size has to be known.&lt;BR /&gt;&lt;BR /&gt;TLS is fixed in size because of this, its size is the sum of the sizes of all&lt;BR /&gt;the variables defined in TLS. The man page for dld.sl(5) contains more&lt;BR /&gt;information on how TLS is calculated.&lt;BR /&gt;&lt;BR /&gt;The C/C++ __thread storage modifier is used to define a variable as being in&lt;BR /&gt;TLS. For example:&lt;BR /&gt;&lt;BR /&gt;__thread int my_errno;&lt;BR /&gt;&lt;BR /&gt;Would define the variable my_errno as being kept in TLS, this means that&lt;BR /&gt;each thread in the program (if it is multi-threaded) will see a different&lt;BR /&gt;my_errno in each thread. The main reason TLS is used in programs is that it&lt;BR /&gt;has very little impact on the structure of existing source code, and it is&lt;BR /&gt;much easier to code for than thread specific data keys created via&lt;BR /&gt;pthread_key_create(3T).&lt;BR /&gt;&lt;BR /&gt;The main restriction with TLS is that if you place TLS inside a shared&lt;BR /&gt;library you cannot use shl_load or dlopen to load the library dynamically.&lt;BR /&gt;From the diagnostics section of the shl_load(3) man page:&lt;BR /&gt;&lt;BR /&gt;      If a library cannot be loaded, shl_load() returns NULL and sets errno&lt;BR /&gt;      to indicate the error.  This includes trying to shl_load() a library&lt;BR /&gt;      containing thread local storage.  All other functions return -1 on&lt;BR /&gt;      error and set errno.&lt;BR /&gt;&lt;BR /&gt;The other restriction is that if a library containing TLS is listed as a&lt;BR /&gt;dependancy of library that a program tries to shl_load it will fail to load&lt;BR /&gt;unless the library with TLS has been linked against the program. The man page&lt;BR /&gt;for shl_load(3) in the warnings section says:&lt;BR /&gt;&lt;BR /&gt;      Use caution when building shared libraries with external library&lt;BR /&gt;      dependencies.  Any library that contains Thread Local Storage (TLS)&lt;BR /&gt;      should not be used as a dependency.  If a dependent library contains&lt;BR /&gt;      TLS, and it is not loaded during program startup (that is, not linked&lt;BR /&gt;      against the executable), the dynamic loader fails to perform the&lt;BR /&gt;      operation.&lt;BR /&gt;&lt;BR /&gt;The workaround to not being able to shl_load a shared library containing TLS&lt;BR /&gt;can be seen in the following example:&lt;BR /&gt;&lt;BR /&gt;#include &lt;BR /&gt;#include &lt;BR /&gt;#include &lt;BR /&gt;&lt;BR /&gt;main()&lt;BR /&gt;{&lt;BR /&gt;        shl_load("/usr/lib/libcl.2", BIND_DEFERRED, NULL);&lt;BR /&gt;        printf("errno is %in", errno);&lt;BR /&gt;}&lt;BR /&gt;&lt;BR /&gt;$ cc testing.c -o testing&lt;BR /&gt;$ ./testing&lt;BR /&gt;/usr/lib/dld.sl: Can't shl_load() a library containing Thread Local&lt;BR /&gt;Storage: /usr/lib/libcl.2&lt;BR /&gt;/usr/lib/dld.sl: Exec format error&lt;BR /&gt;errno is 8&lt;BR /&gt;$ cc testing.c -o testing -lcl&lt;BR /&gt;$ ./testing&lt;BR /&gt;errno is 0&lt;BR /&gt;&lt;BR /&gt;The program does not produce an error when libcl.sl (-lcl) has been linked&lt;BR /&gt;directly against the program. This method does not require any changes to&lt;BR /&gt;the code only to the compilation flags (or makefile) as shl_load will ignore&lt;BR /&gt;any request to load a library that is already loaded.&lt;BR /&gt;&lt;BR /&gt;</description>
      <pubDate>Tue, 10 Oct 2000 05:35:15 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shl-load-error/m-p/2451848#M729067</guid>
      <dc:creator>Marcel Eken_2</dc:creator>
      <dc:date>2000-10-10T05:35:15Z</dc:date>
    </item>
    <item>
      <title>Re: shl_load() error</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shl-load-error/m-p/2451849#M729068</link>
      <description>I have had the same exact problem using the Oracle DBI drivers for perl.&lt;BR /&gt;Simply add the pthread and cl libraries when building perl.  Note:&lt;BR /&gt;You MUST rebuild perl to get rid of this issue, if you are using a binary&lt;BR /&gt;then you must get the sources and recompile adding the libraries &lt;BR /&gt;-lpthread -lcl  when asked for the library information. Note2:  This is NOT building&lt;BR /&gt;a "threaded" perl either, unless you need threads you should be answering "no" to&lt;BR /&gt;building a threaded perl.&lt;BR /&gt;&lt;BR /&gt;Hope this helps&lt;BR /&gt;Guy</description>
      <pubDate>Thu, 12 Oct 2000 08:34:38 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shl-load-error/m-p/2451849#M729068</guid>
      <dc:creator>Guy Mengel</dc:creator>
      <dc:date>2000-10-12T08:34:38Z</dc:date>
    </item>
    <item>
      <title>Re: shl_load() error</title>
      <link>https://community.hpe.com/t5/operating-system-hp-ux/shl-load-error/m-p/2451850#M729069</link>
      <description>I just rebuild perl w/ -lcl and -lthread then PDL and it passed all the tests.  &lt;BR /&gt;&lt;BR /&gt;Whahoo!&lt;BR /&gt;&lt;BR /&gt;Thanks,&lt;BR /&gt;Susan&lt;BR /&gt;&lt;BR /&gt;PS - do you know why -lthread is necessary, not just -lcl?</description>
      <pubDate>Thu, 12 Oct 2000 22:34:55 GMT</pubDate>
      <guid>https://community.hpe.com/t5/operating-system-hp-ux/shl-load-error/m-p/2451850#M729069</guid>
      <dc:creator>Susan Markley</dc:creator>
      <dc:date>2000-10-12T22:34:55Z</dc:date>
    </item>
  </channel>
</rss>

