OSDN Git Service

LDP: Update draft and release (from the previous commit)
[linuxjm/jm.git] / manual / LDP_man-pages / draft / man3 / dlopen.3
index 235bfb4..b6d3cdc 100644 (file)
@@ -1,9 +1,9 @@
-.\" -*- nroff -*-
 .\" Copyright 1995 Yggdrasil Computing, Incorporated.
 .\" written by Adam J. Richter (adam@yggdrasil.com),
 .\" with typesetting help from Daniel Quinlan (quinlan@yggdrasil.com).
 .\" and Copyright 2003 Michael Kerrisk (mtk.manpages@gmail.com).
 .\"
+.\" %%%LICENSE_START(GPLv2+_DOC_FULL)
 .\" This is free documentation; 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 2 of
@@ -20,9 +20,9 @@
 .\" GNU General Public License for more details.
 .\"
 .\" You should have received a copy of the GNU General Public
-.\" License along with this manual; if not, write to the Free
-.\" Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
-.\" USA.
+.\" License along with this manual; if not, see
+.\" <http://www.gnu.org/licenses/>.
+.\" %%%LICENSE_END
 .\"
 .\" Modified by David A. Wheeler <dwheeler@dwheeler.com> 2000-11-28.
 .\" Applied patch by Terran Melconian, aeb, 2001-12-14.
 .\" This file was generated with po4a. Translate the source file.
 .\"
 .\"*******************************************************************
-.TH DLOPEN 3 2008\-12\-06 Linux "Linux Programmer's Manual"
+.\"
+.\" Japanese Version Copyright (c) 1998 NAKANO Takeo all rights reserved.
+.\" Translated Sat May 23 1998 by NAKANO Takeo <nakano@apm.seikei.ac.jp>
+.\" Updated & Modified 1999-09-14, NAKANO Takeo
+.\" Modified 2000-03-19, HANATAKA Shinya <hanataka@abyss.rim.or.jp>
+.\" Updated 2001-02-16, Kentaro Shirakata <argrath@ub32.org>
+.\" Updated 2001-12-21, Kentaro Shirakata <argrath@ub32.org>
+.\" Updated 2002-10-21, Kentaro Shirakata <argrath@ub32.org>
+.\" Updated 2003-09-01, Kentaro Shirakata <argrath@ub32.org>
+.\" Updated 2005-03-15, Akihiro MOTOKI <amotoki@dd.iij4u.or.jp>
+.\" Updated 2006-01-20, Akihiro MOTOKI
+.\" Updated 2009-03-02, Akihiro MOTOKI, LDP v3.19
+.\"
+.TH DLOPEN 3 2014\-01\-08 Linux "Linux Programmer's Manual"
 .SH 名前
 dlclose, dlerror, dlopen, dlsym \- 動的リンクを行うローダへの プログラミングインターフェース
 .SH 書式
@@ -124,7 +137,7 @@ lazy binding (手抜きなシンボルの結び付け) が行う。 シンボル
 このライブラリ内のシンボルの参照領域をグローバル領域よりも前に配置する。 つまり、内蔵型のライブラリでは、すでにロードされたライブラリに含まれる
 同じ名前のグローバルなシンボルよりも自ライブラリ内のシンボルが優先して 使われる。 このフラグは POSIX.1\-2001 では規定されていない。
 .PP
-\fIfilename\fP ã\81\8c NULL ã\83\9dã\82¤ã\83³ã\82¿ã\81§ã\81\82ã\82\8bå ´å\90\88ã\81¯ã\80\81 è¿\94ã\81\95ã\82\8cã\82\8bã\83\8fã\83³ã\83\89ã\83«ã\81¯ã\83¡ã\82¤ã\83³ã\83»ã\83\97ã\83­ã\82°ã\83©ã\83 ã\81®ã\82\82ã\81®ã\81«ã\81ªã\82\8bã\80\82 ã\81\93ã\81®ã\83\8fã\83³ã\83\89ã\83«ã\81\8c \fBdlsym\fP()
+\fIfilename\fP が NULL である場合は、 返されるハンドルはメイン・プログラムのものになる。 このハンドルが \fBdlsym\fP()
 に渡されると、シンボルの検索は、メイン・プログラム内、 プログラムの起動時にロードされる全ての共有ライブラリ、 \fBdlopen\fP()  によって
 \fBRTLD_GLOBAL\fP フラグ付きでロードされた全ての共有ライブラリ、の順序で行われる。
 .PP
@@ -196,8 +209,8 @@ typedef struct {
                                contains address */
     void       *dli_fbase;  /* Address at which shared object
                                is loaded */
-    const char *dli_sname;  /* Name of nearest symbol with address
-                               lower than \fIaddr\fP */
+    const char *dli_sname;  /* Name of symbol whose definition
+                               overlaps \fIaddr\fP */
     void       *dli_saddr;  /* Exact address of symbol named
                                in \fIdli_sname\fP */
 } Dl_info;
@@ -265,17 +278,29 @@ main(int argc, char **argv)
 
     dlerror();    /* Clear any existing error */
 
-    /* Writing: cosine = (double (*)(double)) dlsym(handle, "cos");
-       would seem more natural, but the C99 standard leaves
-       casting from "void *" to a function pointer undefined.
-       The assignment used below is the POSIX.1\-2003 (Technical
-       Corrigendum 1) workaround; see the Rationale for the
-       POSIX specification of dlsym(). */
+    cosine = (double (*)(double)) dlsym(handle, "cos");
+
+    /* According to the ISO C standard, casting between function
+       pointers and 'void *', as done above, produces undefined results.
+       POSIX.1\-2003 and POSIX.1\-2008 accepted this state of affairs and
+       proposed the following workaround:
 
-.\" But in fact "gcc -O2 -Wall" will complain about the preceding cast.
-    *(void **) (&cosine) = dlsym(handle, "cos");
+           *(void **) (&cosine) = dlsym(handle, "cos");
 
-    if ((error = dlerror()) != NULL)  {
+       This (clumsy) cast conforms with the ISO C standard and will
+       avoid any compiler warnings.
+
+.\" http://pubs.opengroup.org/onlinepubs/009695399/functions/dlsym.html#tag_03_112_08
+.\" http://pubs.opengroup.org/onlinepubs/9699919799/functions/dlsym.html#tag_16_96_07
+.\" http://austingroupbugs.net/view.php?id=74
+       The 2013 Technical Corrigendum to POSIX.1\-2008 (a.k.a.
+       POSIX.1\-2013) improved matters by requiring that conforming
+       implementations support casting 'void *' to a function pointer.
+       Nevertheless, some compilers (e.g., gcc with the '\-pedantic'
+       option) may complain about the cast used in this program. */
+
+    error = dlerror();
+    if (error != NULL) {
         fprintf(stderr, "%s\en", error);
         exit(EXIT_FAILURE);
     }
@@ -300,4 +325,10 @@ main(int argc, char **argv)
 .in
 .SH 関連項目
 \fBld\fP(1), \fBldd\fP(1), \fBdl_iterate_phdr\fP(3), \fBrtld\-audit\fP(7), \fBld.so\fP(8),
-\fBldconfig\fP(8), ld.so info pages, gcc info pages, ld info pages
+\fBldconfig\fP(8)
+
+ld.so info pages, gcc info pages, ld info pages
+.SH この文書について
+この man ページは Linux \fIman\-pages\fP プロジェクトのリリース 3.63 の一部
+である。プロジェクトの説明とバグ報告に関する情報は
+http://www.kernel.org/doc/man\-pages/ に書かれている。