2 dnl Copyright (C) 2006 Free Software Foundation, Inc.
3 dnl This file is free software; the Free Software Foundation
4 dnl gives unlimited permission to copy and/or distribute it,
5 dnl with or without modifications, as long as this notice is preserved.
7 # Sets LDDPROG to a command and LDDPOSTPROC to a filter command, such that
8 # $LDDPROG program $LDDPOSTPROC
9 # outputs a whitespace-separated list of the dynamically linked dependencies
10 # of the program, as library names (no full pathnames), or nothing if the
11 # program is statically linked or if the service is not supported on the given
14 dnl From Bruno Haible.
18 AC_REQUIRE([AC_CANONICAL_HOST])
19 AC_REQUIRE([AC_PROG_CC])
23 dnl First try objdump, since it works when cross-compiling.
24 AC_CHECK_TOOL([OBJDUMP], [objdump], [:])
25 if test "$OBJDUMP" != ":"; then
26 LDDPROG="LC_ALL=C $OBJDUMP -p"
27 dnl The output of "LC_ALL=C objdump -p program" of a program or library
30 dnl libnet.so: file format elf32-i386
33 dnl LOAD off 0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**12
34 dnl filesz 0x0001391d memsz 0x0001391d flags r-x
35 dnl LOAD off 0x00013920 vaddr 0x00014920 paddr 0x00014920 align 2**12
36 dnl filesz 0x00001874 memsz 0x0001b020 flags rw-
37 dnl DYNAMIC off 0x00015104 vaddr 0x00016104 paddr 0x00016104 align 2**2
38 dnl filesz 0x00000090 memsz 0x00000090 flags rw-
58 LDDPOSTPROC="2>/dev/null | sed -n -e 's,^ NEEDED *\\([^ ].*\\)\$,\\1,p'"
60 if test "$cross_compiling" = no; then
61 dnl Not cross-compiling. Try system dependent vendor tools.
64 LDDPROG="LC_ALL=C dump -H"
65 dnl The output of "LC_ALL=C dump -H program" looks like this:
69 dnl ***Loader Section***
70 dnl Loader Header Information
71 dnl VERSION# #SYMtableENT #RELOCent LENidSTR
72 dnl 0x00000001 0x00000005 0x0000000d 0x0000001e
74 dnl #IMPfilID OFFidSTR LENstrTBL OFFstrTBL
75 dnl 0x00000002 0x00000134 0x0000000d 0x00000152
78 dnl ***Import File Strings***
79 dnl INDEX PATH BASE MEMBER
83 LDDPOSTPROC="2>/dev/null | sed -e '/^[^0-9]/d' -e '/^0x/d' | sed -n -e 's,^[0-9]* *\\([^ ]*\\).*\$,\\1,p' | sed -e 's,^.*/,,'"
87 dnl The output of "otool -L program" looks like this:
89 dnl /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 71.1.4)
90 LDDPOSTPROC="2>/dev/null | sed -n -e 's,^ \\([^ ]*\\).*\$,\\1,p' | sed -e 's,^.*/,,'"
93 LDDPROG="LC_ALL=C chatr"
94 dnl The output of "LC_ALL=C chatr program" looks like this:
97 dnl shared library dynamic path search:
98 dnl SHLIB_PATH disabled second
99 dnl embedded path disabled first Not Defined
100 dnl shared library list:
101 dnl dynamic /usr/lib/libc.2
102 dnl shared library binding:
104 dnl global hash table disabled
105 dnl plabel caching disabled
106 dnl global hash array size:1103
107 dnl global hash array nbuckets:3
108 dnl shared vtable support disabled
109 dnl static branch prediction disabled
110 dnl executable from stack: D (default)
111 dnl kernel assisted branch prediction enabled
112 dnl lazy swap allocation disabled
113 dnl text segment locking disabled
114 dnl data segment locking disabled
115 dnl third quadrant private data space disabled
116 dnl fourth quadrant private data space disabled
117 dnl third quadrant global data space disabled
118 dnl data page size: D (default)
119 dnl instruction page size: D (default)
120 dnl nulptr references disabled
121 dnl shared library private mapping disabled
122 dnl shared library text merging disabled
126 dnl 32-bit ELF executable
127 dnl shared library dynamic path search:
128 dnl LD_LIBRARY_PATH enabled first
129 dnl SHLIB_PATH enabled second
130 dnl embedded path enabled third /usr/lib/hpux32:/opt/langtools/lib/hpux32
131 dnl shared library list:
133 dnl shared library binding:
135 dnl global hash table disabled
136 dnl global hash table size 1103
137 dnl shared library mapped private disabled
138 dnl shared library segment merging disabled
139 dnl shared vtable support disabled
140 dnl explicit unloading disabled
142 dnl index type address flags size
143 dnl 7 text 04000000 z---c- D (default)
144 dnl 8 data 40000000 ---m-- D (default)
145 dnl executable from stack: D (default)
146 dnl kernel assisted branch prediction enabled
147 dnl lazy swap allocation for dynamic segments disabled
148 dnl nulptr references disabled
149 dnl address space model: default
150 dnl caliper dynamic instrumentation disabled
152 LDDPOSTPROC="2>/dev/null | sed -e '1,/shared library list:/d' -e '/shared library binding:/,\$d' | sed -e 's,^.*[ ]\\([^ ][^ ]*\\)\$,\\1,' | sed -e 's,^.*/,,'"
155 LDDPROG="elfdump -Dl"
156 dnl The output of "elfdump -Dl program" looks like this:
160 dnl **** MIPS LIBLIST INFORMATION ****
162 dnl [INDEX] Timestamp Checksum Flags Name Version
163 dnl [1] Oct 2 05:19:12 1999 0x867bf7a8 ----- libc.so.1 sgi1.0
165 LDDPOSTPROC="2>/dev/null | sed -n -e 's,^[[][0-9]*[]].* 0x[^ ]* [^ ][^ ]* \\([^ ][^ ]*\\).*\$,\\1,p' | sed -e 's,^.*/,,'"
167 linux* | gnu* | kfreebsd*-gnu | knetbsd*-gnu) # glibc-based systems
168 LDDPROG="LC_ALL=C ldd"
169 dnl The output of "ldd program" looks like this:
170 dnl libc.so.6 => /lib/libc.so.6 (0x4002d000)
171 dnl /lib/ld-linux.so.2 (0x40000000)
172 LDDPOSTPROC="2>/dev/null | sed -n -e 's,^ \\([^ ][^ ]*\\).*\$,\\1,p' | sed -e 's,^.*/,,'"
175 LDDPROG="LC_ALL=C odump -Dl"
176 dnl The output of "odump -Dl program" looks like this:
178 dnl ***LIBRARY LIST SECTION***
179 dnl Name Time-Stamp CheckSum Flags Version
181 dnl libc.so Dec 30 00:09:30 1997 0x5e955f9b 0 osf.1
183 LDDPOSTPROC="2>/dev/null | sed -n -e 's,^ \\([^ ][^ ]*\\).*,\\1,p' | sed -e '/^Name\$/d' | sed -e 's,^.*/,,'"
186 LDDPROG="LC_ALL=C ldd"
187 dnl The output of "ldd program" looks like this:
188 dnl libc.so.1 => /usr/lib/libc.so.1
189 dnl libdl.so.1 => /usr/lib/libdl.so.1
190 dnl /usr/platform/SUNW,Ultra-5_10/lib/libc_psr.so.1
191 dnl The first sed collects the indented lines.
192 dnl The second sed extracts the left-hand part.
193 dnl The third sed removes directory specifications.
194 LDDPOSTPROC="2>/dev/null | sed -n -e 's,^ \\([^ ].*\\)\$,\\1,p' | sed -e 's, =>.*\$,,' | sed -e 's,^.*/,,'"
200 AC_SUBST([LDDPOSTPROC])