Merge lp:~aviksil/ubuntu/natty/ltrace/merge-with-upstream into lp:ubuntu/natty/ltrace

Proposed by Avik Sil
Status: Needs review
Proposed branch: lp:~aviksil/ubuntu/natty/ltrace/merge-with-upstream
Merge into: lp:ubuntu/natty/ltrace
Diff against target: 8638 lines (+4047/-2787)
122 files modified
.gitignore (+53/-0)
ChangeLog (+263/-0)
Makefile.am (+106/-0)
Makefile.in (+0/-74)
README (+1/-0)
VERSION (+0/-1)
aclocal.m4 (+0/-833)
autogen.sh (+25/-0)
breakpoints.c (+9/-3)
common.h (+27/-4)
configure (+0/-157)
configure.ac (+272/-0)
debian/changelog (+15/-0)
debian/control (+3/-4)
debian/control.in (+0/-25)
debian/rules (+1/-0)
debug.h (+4/-0)
defs.h (+1/-1)
display_args.c (+7/-7)
elf.c (+0/-619)
elf.h (+0/-49)
etc/ltrace.conf (+1/-0)
execute_program.c (+8/-0)
handle_event.c (+58/-35)
ltrace-elf.c (+827/-0)
ltrace-elf.h (+63/-0)
ltrace.1 (+18/-5)
mkdist (+0/-19)
options.c (+36/-2)
options.h (+19/-12)
output.c (+22/-1)
proc.c (+17/-0)
sysdeps/Makefile.am (+11/-0)
sysdeps/README (+1/-0)
sysdeps/linux-gnu/Makefile (+0/-60)
sysdeps/linux-gnu/Makefile.am (+40/-0)
sysdeps/linux-gnu/alpha/Makefile (+0/-10)
sysdeps/linux-gnu/alpha/Makefile.am (+16/-0)
sysdeps/linux-gnu/arch_syscallent.h (+1/-0)
sysdeps/linux-gnu/arm/Makefile (+0/-10)
sysdeps/linux-gnu/arm/Makefile.am (+18/-0)
sysdeps/linux-gnu/arm/plt.c (+13/-1)
sysdeps/linux-gnu/arm/regs.c (+2/-1)
sysdeps/linux-gnu/arm/trace.c (+2/-2)
sysdeps/linux-gnu/cris/Makefile (+10/-0)
sysdeps/linux-gnu/cris/arch.h (+6/-0)
sysdeps/linux-gnu/cris/plt.c (+12/-0)
sysdeps/linux-gnu/cris/ptrace.h (+1/-0)
sysdeps/linux-gnu/cris/regs.c (+37/-0)
sysdeps/linux-gnu/cris/signalent.h (+32/-0)
sysdeps/linux-gnu/cris/syscallent.h (+325/-0)
sysdeps/linux-gnu/cris/trace.c (+75/-0)
sysdeps/linux-gnu/events.c (+8/-2)
sysdeps/linux-gnu/i386/Makefile (+0/-10)
sysdeps/linux-gnu/i386/Makefile.am (+16/-0)
sysdeps/linux-gnu/ia64/Makefile (+0/-10)
sysdeps/linux-gnu/ia64/Makefile.am (+17/-0)
sysdeps/linux-gnu/m68k/Makefile (+0/-10)
sysdeps/linux-gnu/m68k/Makefile.am (+16/-0)
sysdeps/linux-gnu/mips (+1/-0)
sysdeps/linux-gnu/mipsel/Makefile (+0/-22)
sysdeps/linux-gnu/mipsel/Makefile.am (+20/-0)
sysdeps/linux-gnu/mipsel/mipsel.h (+2/-1)
sysdeps/linux-gnu/mipsel/plt.c (+1/-1)
sysdeps/linux-gnu/mipsel/regs.c (+0/-1)
sysdeps/linux-gnu/mipsel/signalent.h (+32/-32)
sysdeps/linux-gnu/mipsel/syscallent.h (+330/-241)
sysdeps/linux-gnu/mipsel/trace.c (+43/-19)
sysdeps/linux-gnu/mksyscallent_mips (+43/-0)
sysdeps/linux-gnu/ppc/Makefile (+0/-10)
sysdeps/linux-gnu/ppc/Makefile.am (+16/-0)
sysdeps/linux-gnu/ppc/ptrace.h (+15/-0)
sysdeps/linux-gnu/ppc/trace.c (+88/-54)
sysdeps/linux-gnu/proc.c (+248/-0)
sysdeps/linux-gnu/s390/Makefile (+0/-13)
sysdeps/linux-gnu/s390/Makefile.am (+20/-0)
sysdeps/linux-gnu/s390/arch.h (+5/-0)
sysdeps/linux-gnu/s390/trace.c (+9/-2)
sysdeps/linux-gnu/signalent1.h (+1/-0)
sysdeps/linux-gnu/sparc/Makefile (+0/-9)
sysdeps/linux-gnu/sparc/Makefile.am (+16/-0)
sysdeps/linux-gnu/syscallent1.h (+1/-0)
sysdeps/linux-gnu/trace.c (+45/-3)
sysdeps/linux-gnu/x86_64/Makefile (+0/-9)
sysdeps/linux-gnu/x86_64/Makefile.am (+18/-0)
sysdeps/linux-gnu/x86_64/ptrace.h (+13/-0)
sysdeps/linux-gnu/x86_64/trace.c (+101/-61)
sysdeps/sysdep.h (+1/-0)
testsuite/Makefile (+0/-71)
testsuite/Makefile.am (+41/-0)
testsuite/lib/ltrace.exp (+40/-5)
testsuite/ltrace.main/Makefile (+0/-33)
testsuite/ltrace.main/Makefile.am (+37/-0)
testsuite/ltrace.main/main-internal.exp (+3/-3)
testsuite/ltrace.main/main.exp (+5/-5)
testsuite/ltrace.main/parameters-lib.c (+21/-3)
testsuite/ltrace.main/parameters.c (+13/-2)
testsuite/ltrace.main/parameters.conf (+4/-1)
testsuite/ltrace.main/parameters.exp (+34/-22)
testsuite/ltrace.main/signals.exp (+3/-3)
testsuite/ltrace.main/system_calls.exp (+22/-22)
testsuite/ltrace.minor/Makefile (+0/-36)
testsuite/ltrace.minor/Makefile.am (+49/-0)
testsuite/ltrace.minor/attach-process.exp (+4/-4)
testsuite/ltrace.minor/count-record.exp (+15/-18)
testsuite/ltrace.minor/demangle-lib.cpp (+1/-1)
testsuite/ltrace.minor/demangle.exp (+6/-6)
testsuite/ltrace.minor/libdl-simple-lib.c (+4/-0)
testsuite/ltrace.minor/libdl-simple.c (+24/-0)
testsuite/ltrace.minor/libdl-simple.exp (+52/-0)
testsuite/ltrace.minor/print-instruction-pointer.exp (+5/-5)
testsuite/ltrace.minor/time-record-T.exp (+4/-4)
testsuite/ltrace.minor/time-record-tt.exp (+4/-4)
testsuite/ltrace.minor/time-record-ttt.exp (+4/-4)
testsuite/ltrace.minor/trace-clone.exp (+5/-15)
testsuite/ltrace.minor/trace-exec.exp (+10/-19)
testsuite/ltrace.minor/trace-fork.c (+1/-1)
testsuite/ltrace.minor/trace-fork.exp (+23/-18)
testsuite/ltrace.torture/Makefile (+0/-33)
testsuite/ltrace.torture/Makefile.am (+25/-0)
testsuite/ltrace.torture/signals.c (+1/-1)
testsuite/ltrace.torture/signals.exp (+3/-3)
To merge this branch: bzr merge lp:~aviksil/ubuntu/natty/ltrace/merge-with-upstream
Reviewer Review Type Date Requested Status
Steve Langasek Pending
Review via email: mp+53491@code.launchpad.net

Description of the change

Merged the latest upstream available today

To post a comment you must log in.

Unmerged revisions

18. By Avik Sil

* Add memmove prototype to etc/ltrace.conf
* New upstream release
* Support for cris added
* Numerous bugfixes for MIPS, ARM, and PPC
* Support for libunwind and libdl

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== added file '.gitignore'
--- .gitignore 1970-01-01 00:00:00 +0000
+++ .gitignore 2011-03-15 17:56:13 +0000
@@ -0,0 +1,53 @@
1*.la
2*.so
3*.lo
4*.o
5*.ltrace
6*~
7
8Makefile
9Makefile.in
10
11.deps
12.dirstamp
13.libs
14
15/aclocal.m4
16/autom4te.cache
17/config
18/config.h
19/config.h.in
20/config.log
21/config.status
22/configure
23/libtool
24/ltrace
25/ltrace-*.tar.*
26/stamp-h1
27
28site.exp
29site.bak
30ltrace.log
31ltrace.sum
32testrun.log
33testrun.sum
34
35testsuite/ltrace.main/main
36testsuite/ltrace.main/main-internal
37testsuite/ltrace.main/parameters
38testsuite/ltrace.main/signals
39testsuite/ltrace.main/system_calls
40testsuite/ltrace.minor/attach-process
41testsuite/ltrace.minor/count-record
42testsuite/ltrace.minor/demangle
43testsuite/ltrace.minor/libdl-simple
44testsuite/ltrace.minor/print-instruction-pointer
45testsuite/ltrace.minor/time-record-T
46testsuite/ltrace.minor/time-record-tt
47testsuite/ltrace.minor/time-record-ttt
48testsuite/ltrace.minor/trace-clone
49testsuite/ltrace.minor/trace-exec
50testsuite/ltrace.minor/trace-exec1
51testsuite/ltrace.minor/trace-fork
52testsuite/ltrace.torture/signals
53
054
=== modified file 'ChangeLog'
--- ChangeLog 2010-10-01 16:06:14 +0000
+++ ChangeLog 2011-03-15 17:56:13 +0000
@@ -1,7 +1,270 @@
12011-02-16 Petr Machata <pmachata@redhat.com>
2
3 * etc/ltrace.conf: Add memmove.
4
52011-01-06 Joe Damato <ice799@gmail.com>
6
7 * New release 0.6.0
8
92010-12-08 Zachary T Welch <zwelch@codesourcery.com>
10
11 * configure.ac: Make warning output independent of debug option.
12 Add option to allow -Werror to be disabled. Switch CFLAGS,
13 CPPFLAGS, and LDFLAGS to their AM_ variants to allow users to
14 provide alternate settings during 'make'. Remove -g/-O1/-O2
15 options from configure script; autoconf sets them appropriately
16 and the user should be in control of the desired optimizations.
17 Check elf_hash parameter to see if it is signed/unsigned char,
18 setting ELF_HASH_TAKES_SIGNED_CHAR as appropriate.
19 * handle_event.c (handle_breakpoint): Fix regression in
20 system_calls.exp test on ARMv7a. Also fixes libdl-simple.exp
21 test on same platform.
22 * display_args.c, ltrace-elf.[ch], options.[ch],
23 sysdeps/linux-gnu/{arm/trace,proc,trace}.c: Eliminate warnings
24 that will cause build to fail with -Werror; these mostly were
25 changes to avoid signed/unsigned comparisions.
26 * ltrace-elf.c (in_load_libraries): Use ELF_HASH_TAKES_SIGNED_CHAR
27
282010-12-06 Zachary T Welch <zwelch@codesourcery.com>
29
30 * configure.ac: Fix e-mail address.
31 * testsuite/lib/ltrace.exp: Fix failure reporting string
32 * ltrace-elf.c, sysdeps/linux-gnu/proc.c: Use portable
33 format specifiers from inttypes.h
34 * sysdeps/linux-gnu/trace.c (umovebytes): Remove unused variable
35 * Makefile.am: Fix distribution of renamed debian/control file.
36 * testsuite/ltrace.minor/Makefile.am: Include libdl-simple test
37 in the distribution tarballs.
38
392010-12-04 Joe Damato <ice799@gmail.com>
40
41 * debian/control.in: Renamed to debian/control.
42 * debian/control: Added new build dependencies.
43 * debian/rules: Added support for autotools.
44
452010-11-19 Petr Machata <pmachata@redhat.com>
46
47 * testsuite/ltrace.main/system_calls.exp: On s390x, names of mmap,
48 fstat and stat system calls are different.
49
502010-11-19 Petr Machata <pmachata@redhat.com>
51
52 * testsuite/lib/ltrace.exp (ltrace_verify_output): Add function
53 argument with grep flavor to use.
54
552010-11-19 Petr Machata <pmachata@redhat.com>
56
57 * testsuite/lib/ltrace.exp (ltrace_verify_output): Add function
58 argument with grep flavor to use.
59
602010-11-18 Petr Machata <pmachata@redhat.com>
61
62 * sysdeps/linux-gnu/ppc/ptrace.h (GET_FPREG): New macro.
63 (proc_archdep): Drop func_args, sysc_args.
64 * sysdeps/linux-gnu/ppc/trace.c: Use GET_FPREG.
65
662010-11-05 Zachary T Welch <zwelch@codesourcery,com>
67
68 * testsuite/: Convert to autotools and add to distribution.
69 Update test files to allow out-of-tree builds.
70 * configure.ac: Add maintainer mode, create Makefiles in
71 testsuite/ tree, improve --with-libunwind configuration
72 to accept non-standard install path.
73 * Makefile.am: Don't distribute autogen.sh and .gitignore.
74 Remove config.h.in during 'make maintainer-clean'
75 * .gitignore: Exclude test suite build/run artifacts.
76
772010-11-03 Petr Machata <pmachata@redhat.com>
78
79 * common.h: Add arch_ptr to callstack_element
80 * handle_event.c: Move callstack manipulation so that it's around
81 the output calls--push before output_left, pop after output_right.
82 (callstack_pop): Free the arch_ptr if it was set.
83 * sysdeps/linux-gnu/x86_64/ptrace.h: Split the archdep struct to
84 the proc part and the callstack_element part.
85 * sysdeps/linux-gnu/x86_64/trace.c (save_register_args): Init
86 callstack_element.arch_ptr.
87 (gimme_arg): Use it.
88
892010-11-03 Petr Machata <pmachata@redhat.com>
90
91 * testsuite/ltrace.main/parameters.* (func_work, func_call): new
92 functions for testing nested library calls
93
942010-11-03 Petr Machata <pmachata@redhat.com>
95
96 * sysdeps/linux-gnu/x86_64/trace.c: Fix passing and returning
97 float and double values.
98 * sysdeps/linux-gnu/x86_64/ptrace.h: Likewise.
99
1002010-11-03 Petr Machata <pmachata@redhat.com>
101
102 * testsuite/ltrace.main/parameters.* (func_float): now returns
103 float to test proper decoding of float return values.
104 (func_double): new function similar to func_float.
105
1062010-11-03 Petr Machata <pmachata@redhat.com>
107
108 * configure.ac: Don't assume that libelf comes with a .pc file.
109
1102010-11-01 Petr Machata <pmachata@redhat.com>
111
112 * configure.ac: ${host_cpu} for PPC64 is "powerpc64".
113
1142010-11-01 Petr Machata <pmachata@redhat.com>
115
116 * configure.ac: ${host_cpu} for PPC64 is "powerpc64".
117
1182010-10-31 Joe Damato <ice799@gmail.com>
119
120 * Makefile.am: Add autotool support for libunwind.
121 * configure.ac: Ditto.
122 * common.h: New structure fields for libunwind.
123 * execute_program.c: Initialize libunwind.
124 * proc.c: Ditto.
125 * options.c: New command line option (-w).
126 * options.h: New options parameter for libunwind.
127 * output.c: Use libunwind to do backtraces.
128
1292010-10-27 Petr Machata <pmachata@redhat.com>
130
131 * ltrace-elf.c (loaddata): Refactored code for loading Elf_Data.
132 (inside, maybe_pick_section, get_section_covering, read32be): New
133 functions.
134 (get_glink_vma): New function, computes .plt glink_vma address on
135 PPCs.
136 (do_init_elf): Load DT_PPC_GOT, .plt on PPC.
137 Use loaddata to load section data.
138
1392010-10-25 Petr Machata <pmachata@redhat.com>
140
141 * handle_event.c (handle_breakpoint): Do not assume that we can
142 find the breakpoint by address.
143
1442010-10-25 Petr Machata <pmachata@redhat.com>
145
146 * sysdeps/linux-gnu/ppc/ptrace.h (proc_archdep): New structure.
147 * sysdeps/linux-gnu/ppc/trace.c
148 (get_arch_dep): Initialize proc->arch_ptr.
149 (gimme_arg_regset, gimme_retval): New functions.
150 (gimme_arg): Dispatch to gimme_retval or gimme_arg_regset.
151 (save_register_args): Fill in the stub.
152
1532010-10-18 Petr Machata <pmachata@redhat.com>
154
155 * sysdeps/linux-gnu/s390/trace.c: Support 5th argument fetching on s390.
156 Contributed by Supriya Kannery.
157 * sysdeps/linux-gnu/s390/arch.h: Add support for fork/exec on 390.
158 * output.c: Cleanup.
159
1602010-10-14 Petr Machata <pmachata@redhat.com>
161
162 * ltrace.1: Remove claim that only 32-bit binaries are supported.
163 * testsuite/ltrace.minor/trace-fork.exp: Make fork test suite more accurate
164
1652010-10-08 Edgar E. Iglesias <edgar@axis.com>
166
167 * sysdeps/linux-gnu/cris/Makefile: New.
168 * sysdeps/linux-gnu/cris/arch.h: Ditto.
169 * sysdeps/linux-gnu/cris/plt.c: Ditto.
170 * sysdeps/linux-gnu/cris/ptrace.h: Ditto.
171 * sysdeps/linux-gnu/cris/regs.c: Ditto.
172 * sysdeps/linux-gnu/cris/signalent.h: Ditto.
173 * sysdeps/linux-gnu/cris/syscallent.h: Ditto.
174 * sysdeps/linux-gnu/cris/trace.c: Ditto.
175
1762010-10-08 Zach Welch <zwelch@codesourcery.com>
177
178 * Ensure Thumb mode gets set correct when updating ARM PC.
179
1802010-10-08 Zach Welch <zwelch@codesourcery.com>
181
182 * Allow ARM PLT lookups to work when containing Thumb stubs.
183
1842010-10-07 Zach Welch <zwelch@codesourcery.com>
185
186 * Improve breakpoint insertion to work with Thumb procedures.
187
12010-09-30 Zach Welch <zwelch@codesourcery.com>1882010-09-30 Zach Welch <zwelch@codesourcery.com>
2189
3 * Improve ARM syscall_p to handle Thumb-2 syscalls.190 * Improve ARM syscall_p to handle Thumb-2 syscalls.
4191
1922010-02-03 Marc Kleine-Budde <mkl@pengutronix.de>
193
194 * .gitignore: added git ignore
195
196 * Makefile.in, VERSION, aclocal.m4, configure, mkdist,
197 sysdeps/linux-gnu/Makefile, sysdeps/linux-gnu/alpha/Makefile,
198 sysdeps/linux-gnu/arm/Makefile, sysdeps/linux-gnu/i386/Makefile,
199 sysdeps/linux-gnu/ia64/Makefile, sysdeps/linux-gnu/m68k/Makefile,
200 sysdeps/linux-gnu/mipsel/Makefile, sysdeps/linux-gnu/ppc/Makefile,
201 sysdeps/linux-gnu/s390/Makefile, sysdeps/linux-gnu/sparc/Makefile,
202 sysdeps/linux-gnu/x86_64/Makefile: autotoolization: remove to-be
203 generated file This patch remove all files that will be
204 autogenerated by the autoools from the tree.
205
206 * Makefile.am, autogen.sh, configure.ac, sysdeps/Makefile.am,
207 sysdeps/linux-gnu/Makefile.am,
208 sysdeps/linux-gnu/alpha/Makefile.am,
209 sysdeps/linux-gnu/arch_syscallent.h,
210 sysdeps/linux-gnu/arm/Makefile.am,
211 sysdeps/linux-gnu/i386/Makefile.am,
212 sysdeps/linux-gnu/ia64/Makefile.am,
213 sysdeps/linux-gnu/m68k/Makefile.am,
214 sysdeps/linux-gnu/mipsel/Makefile.am,
215 sysdeps/linux-gnu/ppc/Makefile.am,
216 sysdeps/linux-gnu/s390/Makefile.am,
217 sysdeps/linux-gnu/signalent1.h,
218 sysdeps/linux-gnu/sparc/Makefile.am,
219 sysdeps/linux-gnu/syscallent1.h,
220 sysdeps/linux-gnu/x86_64/Makefile.am, sysdeps/sysdep.h:
221 autotoolization: add basic autotools infrastructure This patch add
222 a basic autotools infrastructure to ltrace. Native compilation on
223 i386, x86_64 and ppc. Cross compilation has been tested against
224 arm.
225
226 * common.h, elf.c, elf.h, ltrace-elf.c, ltrace-elf.h: rename
227 elf.{c,h} into ltrace-elf.{c,h} This patch renames these files to
228 avoid a conflict with the header files of the "libelfg0-dev"
229 package. This avoids the "-iquote" magic.
230
2312010-01-08 Arnaud Patard <apatard@mandriva.com>
232
233 * sysdeps/linux-gnu/mipsel/mipsel.h: Add floating point register offset.
234 * sysdeps/linux-gnu/x86_64/{ptrace.h, trace.c}: Save a copy of register vlaues and handle floats.
235 * sysdeps/linux-gnu/mips: Symlink created.
236 * sysdeps/linux-gnu/mipsel/trace.c: Handle more argument types.
237 * sysdeps/linux-gnu/trace.c: Don't use PTRACE_SINGLESTEP for MIPS.
238 * sysdeps/linux-gnu/arm/trace.c: Fix return value.
239 * handle_event.c: Fix for MIPS.
240 * sysdeps/linux-gnu/mipsel/{plt.c, regs.c}: Fix includes.
241 * sysdeps/linux-gnu/mipsetl/syscallent.h: Cleanup.
242 * sysdeps/linux-gnu/mipsel/signalent.h: Cleanup.
243 * sysdeps/linux-gnu/trace.c: Fix umovelong.
244 * .gitignore: New file.
245 * handle_event.c: abort() when call nesting too deep.
246 * testsuite/ltrace.minor/count-record.exp: Fix tests.
247 * handle_event.c: Handle functions which do not increase stack depth.
248 * testsuite/ltrace.torture/signals.c: Don't use magic numbers.
249 * testsuite/ltrace.minor/demangle-lib.cpp: Fix build failure.
250 * sysdeps/linux-gnu/mksyscallent_mips: New file.
251 * elf.c: Fix '-l' on MIPS.
252 * debug.h: Add macro guard.
253 * breakpoints.c: Fix MIPS breakpoints.
254
2552009-10-06 Joe Damato <ice799@gmail.com>
256
257 * handle_event.c: Do not print signals when -b is used.
258 * options.h, options.c: A new option (-b) was added.
259 * ltrace.1: Documentation for -b was added.
260
2612009-09-07 Joe Damato <ice799@gmail.com>
262
263 * options.c, options.h: A new option (-g) was added.
264 * ltrace.1: Documentation for -g was added.
265 * handle_event.c: Do not print when -g is used.
266 * elf.c: Ditto.
267
52009-07-25 Juan Cespedes <cespedes@debian.org>2682009-07-25 Juan Cespedes <cespedes@debian.org>
6269
7 * New release 0.5.3270 * New release 0.5.3
8271
=== added file 'Makefile.am'
--- Makefile.am 1970-01-01 00:00:00 +0000
+++ Makefile.am 2011-03-15 17:56:13 +0000
@@ -0,0 +1,106 @@
1SUBDIRS = \
2 sysdeps \
3 . \
4 testsuite
5
6AM_CPPFLAGS += \
7 $(libelf_CFLAGS) \
8 -DSYSCONFDIR=\"$(sysconfdir)\"
9
10noinst_LTLIBRARIES = \
11 libltrace.la
12
13libltrace_la_SOURCES = \
14 breakpoints.c \
15 debug.c \
16 demangle.c \
17 dict.c \
18 display_args.c \
19 ltrace-elf.c \
20 execute_program.c \
21 handle_event.c \
22 libltrace.c \
23 options.c \
24 output.c \
25 proc.c \
26 read_config_file.c \
27 summary.c
28
29libltrace_la_LIBADD = \
30 $(libelf_LIBS) \
31 $(liberty_LIBS) \
32 $(libsupcxx_LIBS) \
33 $(libunwind_LIBS) \
34 $(libunwind_ptrace_LIBS) \
35 $(libunwind_arch_LIBS) \
36 sysdeps/libos.la
37
38
39bin_PROGRAMS = \
40 ltrace
41
42ltrace_SOURCES = \
43 main.c
44
45ltrace_LDADD = \
46 libltrace.la
47
48
49noinst_HEADERS = \
50 common.h \
51 debug.h \
52 defs.h \
53 demangle.h \
54 dict.h \
55 ltrace-elf.h \
56 ltrace.h \
57 options.h \
58 output.h \
59 read_config_file.h
60
61dist_man1_MANS = \
62 ltrace.1
63
64dist_doc_DATA = \
65 COPYING \
66 README \
67 TODO \
68 BUGS \
69 ChangeLog
70
71dist_sysconf_DATA = \
72 etc/ltrace.conf
73
74EXTRA_DIST = \
75 ltrace.spec \
76 debian/changelog \
77 debian/compat \
78 debian/control \
79 debian/copyright \
80 debian/rules
81
82MAINTAINERCLEANFILES = \
83 configure \
84 Makefile.in \
85 aclocal.m4 \
86 config.h.in \
87 config.h.in~ \
88 config/autoconf/compile \
89 config/autoconf/config.guess \
90 config/autoconf/config.sub \
91 config/autoconf/depcomp \
92 config/autoconf/install-sh \
93 config/autoconf/ltmain.sh \
94 config/autoconf/mdate-sh \
95 config/autoconf/missing \
96 config/autoconf/texinfo.tex \
97 libtool.m4 \
98 ltoptions.m4 \
99 ltsugar.m4 \
100 ltversion.m4 \
101 lt~obsolete.m4 \
102 $(DIST_ARCHIVES)
103
104maintainer-clean-local:
105 -chmod -R a+rw $(distdir)
106 -rm -fr $(distdir)
0107
=== removed file 'Makefile.in'
--- Makefile.in 2009-07-28 16:44:35 +0000
+++ Makefile.in 1970-01-01 00:00:00 +0000
@@ -1,74 +0,0 @@
1#
2# ltrace's Makefile.in
3#
4
5#OS := $(shell uname -s)
6OS := @HOST_OS@
7
8TOPDIR = $(shell pwd)
9
10prefix = @prefix@
11sysconfdir = @sysconfdir@
12bindir = $(prefix)/bin
13mandir = @mandir@
14docdir = $(prefix)/share/doc/ltrace
15
16CC = @CC@
17CFLAGS = -Wall @CFLAGS@
18CPPFLAGS = -iquote $(TOPDIR) -iquote $(TOPDIR)/sysdeps/$(OS) -DSYSCONFDIR=\"$(sysconfdir)\" @CPPFLAGS@
19LDFLAGS = @LDFLAGS@
20LIBS = @LIBS@
21
22INSTALL = @INSTALL@
23INSTALL_FILE = $(INSTALL) -p -m 644
24INSTALL_PROGRAM = $(INSTALL) -p -m 755
25INSTALL_SCRIPT = $(INSTALL) -p -m 755
26INSTALL_DIR = $(INSTALL) -p -d -m 755
27
28OBJ = libltrace.o options.o elf.o output.o read_config_file.o \
29 execute_program.o handle_event.o display_args.o \
30 breakpoints.o proc.o demangle.o dict.o debug.o summary.o
31
32VERSION = @PACKAGE_VERSION@
33
34all: ltrace
35
36ltrace: main.o libltrace.a
37 $(CC) $(LDFLAGS) $^ $(LIBS) -o $@
38
39libltrace.a: sysdeps/sysdep.o $(OBJ)
40 $(AR) rcv $@ $^
41
42sysdeps/sysdep.o: dummy
43 $(MAKE) -C sysdeps/$(OS)
44
45clean-deja:
46 $(RM) testrun.log testrun.sum
47 cd testsuite; make clean
48
49clean: clean-deja
50 $(MAKE) -C sysdeps/$(OS) clean
51 rm -f ltrace main.o libltrace.a $(OBJ)
52 rm -f *~ *.bak a.out core
53
54distclean: clean
55 rm -f config.h Makefile
56
57realclean: distclean
58
59install: ltrace
60 $(INSTALL_DIR) $(DESTDIR)$(bindir) $(DESTDIR)$(docdir) $(DESTDIR)$(mandir)/man1
61 $(INSTALL_DIR) $(DESTDIR)$(sysconfdir)
62 $(INSTALL_PROGRAM) ltrace $(DESTDIR)$(bindir)
63 $(INSTALL_FILE) etc/ltrace.conf $(DESTDIR)$(sysconfdir)
64 $(INSTALL_FILE) COPYING README TODO BUGS ChangeLog $(DESTDIR)$(docdir)
65 $(INSTALL_FILE) ltrace.1 $(DESTDIR)$(mandir)/man1
66
67check:
68 cd testsuite;cat /proc/version;uptime;free -m;$(MAKE) check
69
70dummy:
71
72.PHONY: all clean distclean dist install dummy
73
74.EXPORT_ALL_VARIABLES:
750
=== modified file 'README'
--- README 2009-07-28 16:44:35 +0000
+++ README 2011-03-15 17:56:13 +0000
@@ -37,6 +37,7 @@
37* Ian Wienand <ianw@gelato.unsw.edu.au> (IA64 port)37* Ian Wienand <ianw@gelato.unsw.edu.au> (IA64 port)
38* Eric Vaitl <evaitl@cisco.com> (mipsel port)38* Eric Vaitl <evaitl@cisco.com> (mipsel port)
39* Petr Machata <pmachata@redhat.com> (misc fixes)39* Petr Machata <pmachata@redhat.com> (misc fixes)
40* Joe Damato <ice799@gmail.com> (libdl support, libunwind support)
4041
411. Introduction421. Introduction
42---------------43---------------
4344
=== removed file 'VERSION'
--- VERSION 2009-07-25 16:24:38 +0000
+++ VERSION 1970-01-01 00:00:00 +0000
@@ -1,1 +0,0 @@
10.5.3
20
=== removed file 'aclocal.m4'
--- aclocal.m4 2008-05-27 10:51:22 +0000
+++ aclocal.m4 1970-01-01 00:00:00 +0000
@@ -1,833 +0,0 @@
1dnl aclocal.m4t generated automatically by aclocal 1.4-p6
2
3dnl Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
4dnl This file is free software; the Free Software Foundation
5dnl gives unlimited permission to copy and/or distribute it,
6dnl with or without modifications, as long as this notice is preserved.
7
8dnl This program is distributed in the hope that it will be useful,
9dnl but WITHOUT ANY WARRANTY, to the extent permitted by law; without
10dnl even the implied warranty of MERCHANTABILITY or FITNESS FOR A
11dnl PARTICULAR PURPOSE.
12
13# lib-prefix.m4 serial 3 (gettext-0.13)
14dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
15dnl This file is free software, distributed under the terms of the GNU
16dnl General Public License. As a special exception to the GNU General
17dnl Public License, this file may be distributed as part of a program
18dnl that contains a configuration script generated by Autoconf, under
19dnl the same distribution terms as the rest of that program.
20
21dnl From Bruno Haible.
22
23dnl AC_LIB_ARG_WITH is synonymous to AC_ARG_WITH in autoconf-2.13, and
24dnl similar to AC_ARG_WITH in autoconf 2.52...2.57 except that is doesn't
25dnl require excessive bracketing.
26ifdef([AC_HELP_STRING],
27[AC_DEFUN([AC_LIB_ARG_WITH], [AC_ARG_WITH([$1],[[$2]],[$3],[$4])])],
28[AC_DEFUN([AC_][LIB_ARG_WITH], [AC_ARG_WITH([$1],[$2],[$3],[$4])])])
29
30dnl AC_LIB_PREFIX adds to the CPPFLAGS and LDFLAGS the flags that are needed
31dnl to access previously installed libraries. The basic assumption is that
32dnl a user will want packages to use other packages he previously installed
33dnl with the same --prefix option.
34dnl This macro is not needed if only AC_LIB_LINKFLAGS is used to locate
35dnl libraries, but is otherwise very convenient.
36AC_DEFUN([AC_LIB_PREFIX],
37[
38 AC_BEFORE([$0], [AC_LIB_LINKFLAGS])
39 AC_REQUIRE([AC_PROG_CC])
40 AC_REQUIRE([AC_CANONICAL_HOST])
41 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
42 dnl By default, look in $includedir and $libdir.
43 use_additional=yes
44 AC_LIB_WITH_FINAL_PREFIX([
45 eval additional_includedir=\"$includedir\"
46 eval additional_libdir=\"$libdir\"
47 ])
48 AC_LIB_ARG_WITH([lib-prefix],
49[ --with-lib-prefix[=DIR] search for libraries in DIR/include and DIR/lib
50 --without-lib-prefix don't search for libraries in includedir and libdir],
51[
52 if test "X$withval" = "Xno"; then
53 use_additional=no
54 else
55 if test "X$withval" = "X"; then
56 AC_LIB_WITH_FINAL_PREFIX([
57 eval additional_includedir=\"$includedir\"
58 eval additional_libdir=\"$libdir\"
59 ])
60 else
61 additional_includedir="$withval/include"
62 additional_libdir="$withval/lib"
63 fi
64 fi
65])
66 if test $use_additional = yes; then
67 dnl Potentially add $additional_includedir to $CPPFLAGS.
68 dnl But don't add it
69 dnl 1. if it's the standard /usr/include,
70 dnl 2. if it's already present in $CPPFLAGS,
71 dnl 3. if it's /usr/local/include and we are using GCC on Linux,
72 dnl 4. if it doesn't exist as a directory.
73 if test "X$additional_includedir" != "X/usr/include"; then
74 haveit=
75 for x in $CPPFLAGS; do
76 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
77 if test "X$x" = "X-I$additional_includedir"; then
78 haveit=yes
79 break
80 fi
81 done
82 if test -z "$haveit"; then
83 if test "X$additional_includedir" = "X/usr/local/include"; then
84 if test -n "$GCC"; then
85 case $host_os in
86 linux*) haveit=yes;;
87 esac
88 fi
89 fi
90 if test -z "$haveit"; then
91 if test -d "$additional_includedir"; then
92 dnl Really add $additional_includedir to $CPPFLAGS.
93 CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }-I$additional_includedir"
94 fi
95 fi
96 fi
97 fi
98 dnl Potentially add $additional_libdir to $LDFLAGS.
99 dnl But don't add it
100 dnl 1. if it's the standard /usr/lib,
101 dnl 2. if it's already present in $LDFLAGS,
102 dnl 3. if it's /usr/local/lib and we are using GCC on Linux,
103 dnl 4. if it doesn't exist as a directory.
104 if test "X$additional_libdir" != "X/usr/lib"; then
105 haveit=
106 for x in $LDFLAGS; do
107 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
108 if test "X$x" = "X-L$additional_libdir"; then
109 haveit=yes
110 break
111 fi
112 done
113 if test -z "$haveit"; then
114 if test "X$additional_libdir" = "X/usr/local/lib"; then
115 if test -n "$GCC"; then
116 case $host_os in
117 linux*) haveit=yes;;
118 esac
119 fi
120 fi
121 if test -z "$haveit"; then
122 if test -d "$additional_libdir"; then
123 dnl Really add $additional_libdir to $LDFLAGS.
124 LDFLAGS="${LDFLAGS}${LDFLAGS:+ }-L$additional_libdir"
125 fi
126 fi
127 fi
128 fi
129 fi
130])
131
132dnl AC_LIB_PREPARE_PREFIX creates variables acl_final_prefix,
133dnl acl_final_exec_prefix, containing the values to which $prefix and
134dnl $exec_prefix will expand at the end of the configure script.
135AC_DEFUN([AC_LIB_PREPARE_PREFIX],
136[
137 dnl Unfortunately, prefix and exec_prefix get only finally determined
138 dnl at the end of configure.
139 if test "X$prefix" = "XNONE"; then
140 acl_final_prefix="$ac_default_prefix"
141 else
142 acl_final_prefix="$prefix"
143 fi
144 if test "X$exec_prefix" = "XNONE"; then
145 acl_final_exec_prefix='${prefix}'
146 else
147 acl_final_exec_prefix="$exec_prefix"
148 fi
149 acl_save_prefix="$prefix"
150 prefix="$acl_final_prefix"
151 eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"
152 prefix="$acl_save_prefix"
153])
154
155dnl AC_LIB_WITH_FINAL_PREFIX([statement]) evaluates statement, with the
156dnl variables prefix and exec_prefix bound to the values they will have
157dnl at the end of the configure script.
158AC_DEFUN([AC_LIB_WITH_FINAL_PREFIX],
159[
160 acl_save_prefix="$prefix"
161 prefix="$acl_final_prefix"
162 acl_save_exec_prefix="$exec_prefix"
163 exec_prefix="$acl_final_exec_prefix"
164 $1
165 exec_prefix="$acl_save_exec_prefix"
166 prefix="$acl_save_prefix"
167])
168
169# lib-link.m4 serial 4 (gettext-0.12)
170dnl Copyright (C) 2001-2003 Free Software Foundation, Inc.
171dnl This file is free software, distributed under the terms of the GNU
172dnl General Public License. As a special exception to the GNU General
173dnl Public License, this file may be distributed as part of a program
174dnl that contains a configuration script generated by Autoconf, under
175dnl the same distribution terms as the rest of that program.
176
177dnl From Bruno Haible.
178
179dnl AC_LIB_LINKFLAGS(name [, dependencies]) searches for libname and
180dnl the libraries corresponding to explicit and implicit dependencies.
181dnl Sets and AC_SUBSTs the LIB${NAME} and LTLIB${NAME} variables and
182dnl augments the CPPFLAGS variable.
183AC_DEFUN([AC_LIB_LINKFLAGS],
184[
185 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
186 AC_REQUIRE([AC_LIB_RPATH])
187 define([Name],[translit([$1],[./-], [___])])
188 define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
189 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
190 AC_CACHE_CHECK([how to link with lib[]$1], [ac_cv_lib[]Name[]_libs], [
191 AC_LIB_LINKFLAGS_BODY([$1], [$2])
192 ac_cv_lib[]Name[]_libs="$LIB[]NAME"
193 ac_cv_lib[]Name[]_ltlibs="$LTLIB[]NAME"
194 ac_cv_lib[]Name[]_cppflags="$INC[]NAME"
195 ])
196 LIB[]NAME="$ac_cv_lib[]Name[]_libs"
197 LTLIB[]NAME="$ac_cv_lib[]Name[]_ltlibs"
198 INC[]NAME="$ac_cv_lib[]Name[]_cppflags"
199 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
200 AC_SUBST([LIB]NAME)
201 AC_SUBST([LTLIB]NAME)
202 dnl Also set HAVE_LIB[]NAME so that AC_LIB_HAVE_LINKFLAGS can reuse the
203 dnl results of this search when this library appears as a dependency.
204 HAVE_LIB[]NAME=yes
205 undefine([Name])
206 undefine([NAME])
207])
208
209dnl AC_LIB_HAVE_LINKFLAGS(name, dependencies, includes, testcode)
210dnl searches for libname and the libraries corresponding to explicit and
211dnl implicit dependencies, together with the specified include files and
212dnl the ability to compile and link the specified testcode. If found, it
213dnl sets and AC_SUBSTs HAVE_LIB${NAME}=yes and the LIB${NAME} and
214dnl LTLIB${NAME} variables and augments the CPPFLAGS variable, and
215dnl #defines HAVE_LIB${NAME} to 1. Otherwise, it sets and AC_SUBSTs
216dnl HAVE_LIB${NAME}=no and LIB${NAME} and LTLIB${NAME} to empty.
217AC_DEFUN([AC_LIB_HAVE_LINKFLAGS],
218[
219 AC_REQUIRE([AC_LIB_PREPARE_PREFIX])
220 AC_REQUIRE([AC_LIB_RPATH])
221 define([Name],[translit([$1],[./-], [___])])
222 define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
223 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
224
225 dnl Search for lib[]Name and define LIB[]NAME, LTLIB[]NAME and INC[]NAME
226 dnl accordingly.
227 AC_LIB_LINKFLAGS_BODY([$1], [$2])
228
229 dnl Add $INC[]NAME to CPPFLAGS before performing the following checks,
230 dnl because if the user has installed lib[]Name and not disabled its use
231 dnl via --without-lib[]Name-prefix, he wants to use it.
232 ac_save_CPPFLAGS="$CPPFLAGS"
233 AC_LIB_APPENDTOVAR([CPPFLAGS], [$INC]NAME)
234
235 AC_CACHE_CHECK([for lib[]$1], [ac_cv_lib[]Name], [
236 ac_save_LIBS="$LIBS"
237 LIBS="$LIBS $LIB[]NAME"
238 AC_TRY_LINK([$3], [$4], [ac_cv_lib[]Name=yes], [ac_cv_lib[]Name=no])
239 LIBS="$ac_save_LIBS"
240 ])
241 if test "$ac_cv_lib[]Name" = yes; then
242 HAVE_LIB[]NAME=yes
243 AC_DEFINE([HAVE_LIB]NAME, 1, [Define if you have the $1 library.])
244 AC_MSG_CHECKING([how to link with lib[]$1])
245 AC_MSG_RESULT([$LIB[]NAME])
246 else
247 HAVE_LIB[]NAME=no
248 dnl If $LIB[]NAME didn't lead to a usable library, we don't need
249 dnl $INC[]NAME either.
250 CPPFLAGS="$ac_save_CPPFLAGS"
251 LIB[]NAME=
252 LTLIB[]NAME=
253 fi
254 AC_SUBST([HAVE_LIB]NAME)
255 AC_SUBST([LIB]NAME)
256 AC_SUBST([LTLIB]NAME)
257 undefine([Name])
258 undefine([NAME])
259])
260
261dnl Determine the platform dependent parameters needed to use rpath:
262dnl libext, shlibext, hardcode_libdir_flag_spec, hardcode_libdir_separator,
263dnl hardcode_direct, hardcode_minus_L.
264AC_DEFUN([AC_LIB_RPATH],
265[
266 AC_REQUIRE([AC_PROG_CC]) dnl we use $CC, $GCC, $LDFLAGS
267 AC_REQUIRE([AC_LIB_PROG_LD]) dnl we use $LD, $with_gnu_ld
268 AC_REQUIRE([AC_CANONICAL_HOST]) dnl we use $host
269 AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT]) dnl we use $ac_aux_dir
270 AC_CACHE_CHECK([for shared library run path origin], acl_cv_rpath, [
271 CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \
272 ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh
273 . ./conftest.sh
274 rm -f ./conftest.sh
275 acl_cv_rpath=done
276 ])
277 wl="$acl_cv_wl"
278 libext="$acl_cv_libext"
279 shlibext="$acl_cv_shlibext"
280 hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"
281 hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"
282 hardcode_direct="$acl_cv_hardcode_direct"
283 hardcode_minus_L="$acl_cv_hardcode_minus_L"
284 dnl Determine whether the user wants rpath handling at all.
285 AC_ARG_ENABLE(rpath,
286 [ --disable-rpath do not hardcode runtime library paths],
287 :, enable_rpath=yes)
288])
289
290dnl AC_LIB_LINKFLAGS_BODY(name [, dependencies]) searches for libname and
291dnl the libraries corresponding to explicit and implicit dependencies.
292dnl Sets the LIB${NAME}, LTLIB${NAME} and INC${NAME} variables.
293AC_DEFUN([AC_LIB_LINKFLAGS_BODY],
294[
295 define([NAME],[translit([$1],[abcdefghijklmnopqrstuvwxyz./-],
296 [ABCDEFGHIJKLMNOPQRSTUVWXYZ___])])
297 dnl By default, look in $includedir and $libdir.
298 use_additional=yes
299 AC_LIB_WITH_FINAL_PREFIX([
300 eval additional_includedir=\"$includedir\"
301 eval additional_libdir=\"$libdir\"
302 ])
303 AC_LIB_ARG_WITH([lib$1-prefix],
304[ --with-lib$1-prefix[=DIR] search for lib$1 in DIR/include and DIR/lib
305 --without-lib$1-prefix don't search for lib$1 in includedir and libdir],
306[
307 if test "X$withval" = "Xno"; then
308 use_additional=no
309 else
310 if test "X$withval" = "X"; then
311 AC_LIB_WITH_FINAL_PREFIX([
312 eval additional_includedir=\"$includedir\"
313 eval additional_libdir=\"$libdir\"
314 ])
315 else
316 additional_includedir="$withval/include"
317 additional_libdir="$withval/lib"
318 fi
319 fi
320])
321 dnl Search the library and its dependencies in $additional_libdir and
322 dnl $LDFLAGS. Using breadth-first-seach.
323 LIB[]NAME=
324 LTLIB[]NAME=
325 INC[]NAME=
326 rpathdirs=
327 ltrpathdirs=
328 names_already_handled=
329 names_next_round='$1 $2'
330 while test -n "$names_next_round"; do
331 names_this_round="$names_next_round"
332 names_next_round=
333 for name in $names_this_round; do
334 already_handled=
335 for n in $names_already_handled; do
336 if test "$n" = "$name"; then
337 already_handled=yes
338 break
339 fi
340 done
341 if test -z "$already_handled"; then
342 names_already_handled="$names_already_handled $name"
343 dnl See if it was already located by an earlier AC_LIB_LINKFLAGS
344 dnl or AC_LIB_HAVE_LINKFLAGS call.
345 uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./-|ABCDEFGHIJKLMNOPQRSTUVWXYZ___|'`
346 eval value=\"\$HAVE_LIB$uppername\"
347 if test -n "$value"; then
348 if test "$value" = yes; then
349 eval value=\"\$LIB$uppername\"
350 test -z "$value" || LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$value"
351 eval value=\"\$LTLIB$uppername\"
352 test -z "$value" || LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$value"
353 else
354 dnl An earlier call to AC_LIB_HAVE_LINKFLAGS has determined
355 dnl that this library doesn't exist. So just drop it.
356 :
357 fi
358 else
359 dnl Search the library lib$name in $additional_libdir and $LDFLAGS
360 dnl and the already constructed $LIBNAME/$LTLIBNAME.
361 found_dir=
362 found_la=
363 found_so=
364 found_a=
365 if test $use_additional = yes; then
366 if test -n "$shlibext" && test -f "$additional_libdir/lib$name.$shlibext"; then
367 found_dir="$additional_libdir"
368 found_so="$additional_libdir/lib$name.$shlibext"
369 if test -f "$additional_libdir/lib$name.la"; then
370 found_la="$additional_libdir/lib$name.la"
371 fi
372 else
373 if test -f "$additional_libdir/lib$name.$libext"; then
374 found_dir="$additional_libdir"
375 found_a="$additional_libdir/lib$name.$libext"
376 if test -f "$additional_libdir/lib$name.la"; then
377 found_la="$additional_libdir/lib$name.la"
378 fi
379 fi
380 fi
381 fi
382 if test "X$found_dir" = "X"; then
383 for x in $LDFLAGS $LTLIB[]NAME; do
384 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
385 case "$x" in
386 -L*)
387 dir=`echo "X$x" | sed -e 's/^X-L//'`
388 if test -n "$shlibext" && test -f "$dir/lib$name.$shlibext"; then
389 found_dir="$dir"
390 found_so="$dir/lib$name.$shlibext"
391 if test -f "$dir/lib$name.la"; then
392 found_la="$dir/lib$name.la"
393 fi
394 else
395 if test -f "$dir/lib$name.$libext"; then
396 found_dir="$dir"
397 found_a="$dir/lib$name.$libext"
398 if test -f "$dir/lib$name.la"; then
399 found_la="$dir/lib$name.la"
400 fi
401 fi
402 fi
403 ;;
404 esac
405 if test "X$found_dir" != "X"; then
406 break
407 fi
408 done
409 fi
410 if test "X$found_dir" != "X"; then
411 dnl Found the library.
412 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$found_dir -l$name"
413 if test "X$found_so" != "X"; then
414 dnl Linking with a shared library. We attempt to hardcode its
415 dnl directory into the executable's runpath, unless it's the
416 dnl standard /usr/lib.
417 if test "$enable_rpath" = no || test "X$found_dir" = "X/usr/lib"; then
418 dnl No hardcoding is needed.
419 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
420 else
421 dnl Use an explicit option to hardcode DIR into the resulting
422 dnl binary.
423 dnl Potentially add DIR to ltrpathdirs.
424 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
425 haveit=
426 for x in $ltrpathdirs; do
427 if test "X$x" = "X$found_dir"; then
428 haveit=yes
429 break
430 fi
431 done
432 if test -z "$haveit"; then
433 ltrpathdirs="$ltrpathdirs $found_dir"
434 fi
435 dnl The hardcoding into $LIBNAME is system dependent.
436 if test "$hardcode_direct" = yes; then
437 dnl Using DIR/libNAME.so during linking hardcodes DIR into the
438 dnl resulting binary.
439 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
440 else
441 if test -n "$hardcode_libdir_flag_spec" && test "$hardcode_minus_L" = no; then
442 dnl Use an explicit option to hardcode DIR into the resulting
443 dnl binary.
444 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
445 dnl Potentially add DIR to rpathdirs.
446 dnl The rpathdirs will be appended to $LIBNAME at the end.
447 haveit=
448 for x in $rpathdirs; do
449 if test "X$x" = "X$found_dir"; then
450 haveit=yes
451 break
452 fi
453 done
454 if test -z "$haveit"; then
455 rpathdirs="$rpathdirs $found_dir"
456 fi
457 else
458 dnl Rely on "-L$found_dir".
459 dnl But don't add it if it's already contained in the LDFLAGS
460 dnl or the already constructed $LIBNAME
461 haveit=
462 for x in $LDFLAGS $LIB[]NAME; do
463 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
464 if test "X$x" = "X-L$found_dir"; then
465 haveit=yes
466 break
467 fi
468 done
469 if test -z "$haveit"; then
470 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir"
471 fi
472 if test "$hardcode_minus_L" != no; then
473 dnl FIXME: Not sure whether we should use
474 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
475 dnl here.
476 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_so"
477 else
478 dnl We cannot use $hardcode_runpath_var and LD_RUN_PATH
479 dnl here, because this doesn't fit in flags passed to the
480 dnl compiler. So give up. No hardcoding. This affects only
481 dnl very old systems.
482 dnl FIXME: Not sure whether we should use
483 dnl "-L$found_dir -l$name" or "-L$found_dir $found_so"
484 dnl here.
485 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
486 fi
487 fi
488 fi
489 fi
490 else
491 if test "X$found_a" != "X"; then
492 dnl Linking with a static library.
493 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$found_a"
494 else
495 dnl We shouldn't come here, but anyway it's good to have a
496 dnl fallback.
497 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$found_dir -l$name"
498 fi
499 fi
500 dnl Assume the include files are nearby.
501 additional_includedir=
502 case "$found_dir" in
503 */lib | */lib/)
504 basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e 's,/lib/*$,,'`
505 additional_includedir="$basedir/include"
506 ;;
507 esac
508 if test "X$additional_includedir" != "X"; then
509 dnl Potentially add $additional_includedir to $INCNAME.
510 dnl But don't add it
511 dnl 1. if it's the standard /usr/include,
512 dnl 2. if it's /usr/local/include and we are using GCC on Linux,
513 dnl 3. if it's already present in $CPPFLAGS or the already
514 dnl constructed $INCNAME,
515 dnl 4. if it doesn't exist as a directory.
516 if test "X$additional_includedir" != "X/usr/include"; then
517 haveit=
518 if test "X$additional_includedir" = "X/usr/local/include"; then
519 if test -n "$GCC"; then
520 case $host_os in
521 linux*) haveit=yes;;
522 esac
523 fi
524 fi
525 if test -z "$haveit"; then
526 for x in $CPPFLAGS $INC[]NAME; do
527 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
528 if test "X$x" = "X-I$additional_includedir"; then
529 haveit=yes
530 break
531 fi
532 done
533 if test -z "$haveit"; then
534 if test -d "$additional_includedir"; then
535 dnl Really add $additional_includedir to $INCNAME.
536 INC[]NAME="${INC[]NAME}${INC[]NAME:+ }-I$additional_includedir"
537 fi
538 fi
539 fi
540 fi
541 fi
542 dnl Look for dependencies.
543 if test -n "$found_la"; then
544 dnl Read the .la file. It defines the variables
545 dnl dlname, library_names, old_library, dependency_libs, current,
546 dnl age, revision, installed, dlopen, dlpreopen, libdir.
547 save_libdir="$libdir"
548 case "$found_la" in
549 */* | *\\*) . "$found_la" ;;
550 *) . "./$found_la" ;;
551 esac
552 libdir="$save_libdir"
553 dnl We use only dependency_libs.
554 for dep in $dependency_libs; do
555 case "$dep" in
556 -L*)
557 additional_libdir=`echo "X$dep" | sed -e 's/^X-L//'`
558 dnl Potentially add $additional_libdir to $LIBNAME and $LTLIBNAME.
559 dnl But don't add it
560 dnl 1. if it's the standard /usr/lib,
561 dnl 2. if it's /usr/local/lib and we are using GCC on Linux,
562 dnl 3. if it's already present in $LDFLAGS or the already
563 dnl constructed $LIBNAME,
564 dnl 4. if it doesn't exist as a directory.
565 if test "X$additional_libdir" != "X/usr/lib"; then
566 haveit=
567 if test "X$additional_libdir" = "X/usr/local/lib"; then
568 if test -n "$GCC"; then
569 case $host_os in
570 linux*) haveit=yes;;
571 esac
572 fi
573 fi
574 if test -z "$haveit"; then
575 haveit=
576 for x in $LDFLAGS $LIB[]NAME; do
577 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
578 if test "X$x" = "X-L$additional_libdir"; then
579 haveit=yes
580 break
581 fi
582 done
583 if test -z "$haveit"; then
584 if test -d "$additional_libdir"; then
585 dnl Really add $additional_libdir to $LIBNAME.
586 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-L$additional_libdir"
587 fi
588 fi
589 haveit=
590 for x in $LDFLAGS $LTLIB[]NAME; do
591 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
592 if test "X$x" = "X-L$additional_libdir"; then
593 haveit=yes
594 break
595 fi
596 done
597 if test -z "$haveit"; then
598 if test -d "$additional_libdir"; then
599 dnl Really add $additional_libdir to $LTLIBNAME.
600 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-L$additional_libdir"
601 fi
602 fi
603 fi
604 fi
605 ;;
606 -R*)
607 dir=`echo "X$dep" | sed -e 's/^X-R//'`
608 if test "$enable_rpath" != no; then
609 dnl Potentially add DIR to rpathdirs.
610 dnl The rpathdirs will be appended to $LIBNAME at the end.
611 haveit=
612 for x in $rpathdirs; do
613 if test "X$x" = "X$dir"; then
614 haveit=yes
615 break
616 fi
617 done
618 if test -z "$haveit"; then
619 rpathdirs="$rpathdirs $dir"
620 fi
621 dnl Potentially add DIR to ltrpathdirs.
622 dnl The ltrpathdirs will be appended to $LTLIBNAME at the end.
623 haveit=
624 for x in $ltrpathdirs; do
625 if test "X$x" = "X$dir"; then
626 haveit=yes
627 break
628 fi
629 done
630 if test -z "$haveit"; then
631 ltrpathdirs="$ltrpathdirs $dir"
632 fi
633 fi
634 ;;
635 -l*)
636 dnl Handle this in the next round.
637 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's/^X-l//'`
638 ;;
639 *.la)
640 dnl Handle this in the next round. Throw away the .la's
641 dnl directory; it is already contained in a preceding -L
642 dnl option.
643 names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`
644 ;;
645 *)
646 dnl Most likely an immediate library name.
647 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$dep"
648 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }$dep"
649 ;;
650 esac
651 done
652 fi
653 else
654 dnl Didn't find the library; assume it is in the system directories
655 dnl known to the linker and runtime loader. (All the system
656 dnl directories known to the linker should also be known to the
657 dnl runtime loader, otherwise the system is severely misconfigured.)
658 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }-l$name"
659 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-l$name"
660 fi
661 fi
662 fi
663 done
664 done
665 if test "X$rpathdirs" != "X"; then
666 if test -n "$hardcode_libdir_separator"; then
667 dnl Weird platform: only the last -rpath option counts, the user must
668 dnl pass all path elements in one option. We can arrange that for a
669 dnl single library, but not when more than one $LIBNAMEs are used.
670 alldirs=
671 for found_dir in $rpathdirs; do
672 alldirs="${alldirs}${alldirs:+$hardcode_libdir_separator}$found_dir"
673 done
674 dnl Note: hardcode_libdir_flag_spec uses $libdir and $wl.
675 acl_save_libdir="$libdir"
676 libdir="$alldirs"
677 eval flag=\"$hardcode_libdir_flag_spec\"
678 libdir="$acl_save_libdir"
679 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
680 else
681 dnl The -rpath options are cumulative.
682 for found_dir in $rpathdirs; do
683 acl_save_libdir="$libdir"
684 libdir="$found_dir"
685 eval flag=\"$hardcode_libdir_flag_spec\"
686 libdir="$acl_save_libdir"
687 LIB[]NAME="${LIB[]NAME}${LIB[]NAME:+ }$flag"
688 done
689 fi
690 fi
691 if test "X$ltrpathdirs" != "X"; then
692 dnl When using libtool, the option that works for both libraries and
693 dnl executables is -R. The -R options are cumulative.
694 for found_dir in $ltrpathdirs; do
695 LTLIB[]NAME="${LTLIB[]NAME}${LTLIB[]NAME:+ }-R$found_dir"
696 done
697 fi
698])
699
700dnl AC_LIB_APPENDTOVAR(VAR, CONTENTS) appends the elements of CONTENTS to VAR,
701dnl unless already present in VAR.
702dnl Works only for CPPFLAGS, not for LIB* variables because that sometimes
703dnl contains two or three consecutive elements that belong together.
704AC_DEFUN([AC_LIB_APPENDTOVAR],
705[
706 for element in [$2]; do
707 haveit=
708 for x in $[$1]; do
709 AC_LIB_WITH_FINAL_PREFIX([eval x=\"$x\"])
710 if test "X$x" = "X$element"; then
711 haveit=yes
712 break
713 fi
714 done
715 if test -z "$haveit"; then
716 [$1]="${[$1]}${[$1]:+ }$element"
717 fi
718 done
719])
720
721# lib-ld.m4 serial 3 (gettext-0.13)
722dnl Copyright (C) 1996-2003 Free Software Foundation, Inc.
723dnl This file is free software, distributed under the terms of the GNU
724dnl General Public License. As a special exception to the GNU General
725dnl Public License, this file may be distributed as part of a program
726dnl that contains a configuration script generated by Autoconf, under
727dnl the same distribution terms as the rest of that program.
728
729dnl Subroutines of libtool.m4,
730dnl with replacements s/AC_/AC_LIB/ and s/lt_cv/acl_cv/ to avoid collision
731dnl with libtool.m4.
732
733dnl From libtool-1.4. Sets the variable with_gnu_ld to yes or no.
734AC_DEFUN([AC_LIB_PROG_LD_GNU],
735[AC_CACHE_CHECK([if the linker ($LD) is GNU ld], acl_cv_prog_gnu_ld,
736[# I'd rather use --version here, but apparently some GNU ld's only accept -v.
737case `$LD -v 2>&1 </dev/null` in
738*GNU* | *'with BFD'*)
739 acl_cv_prog_gnu_ld=yes ;;
740*)
741 acl_cv_prog_gnu_ld=no ;;
742esac])
743with_gnu_ld=$acl_cv_prog_gnu_ld
744])
745
746dnl From libtool-1.4. Sets the variable LD.
747AC_DEFUN([AC_LIB_PROG_LD],
748[AC_ARG_WITH(gnu-ld,
749[ --with-gnu-ld assume the C compiler uses GNU ld [default=no]],
750test "$withval" = no || with_gnu_ld=yes, with_gnu_ld=no)
751AC_REQUIRE([AC_PROG_CC])dnl
752AC_REQUIRE([AC_CANONICAL_HOST])dnl
753# Prepare PATH_SEPARATOR.
754# The user is always right.
755if test "${PATH_SEPARATOR+set}" != set; then
756 echo "#! /bin/sh" >conf$$.sh
757 echo "exit 0" >>conf$$.sh
758 chmod +x conf$$.sh
759 if (PATH="/nonexistent;."; conf$$.sh) >/dev/null 2>&1; then
760 PATH_SEPARATOR=';'
761 else
762 PATH_SEPARATOR=:
763 fi
764 rm -f conf$$.sh
765fi
766ac_prog=ld
767if test "$GCC" = yes; then
768 # Check if gcc -print-prog-name=ld gives a path.
769 AC_MSG_CHECKING([for ld used by GCC])
770 case $host in
771 *-*-mingw*)
772 # gcc leaves a trailing carriage return which upsets mingw
773 ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
774 *)
775 ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
776 esac
777 case $ac_prog in
778 # Accept absolute paths.
779 [[\\/]* | [A-Za-z]:[\\/]*)]
780 [re_direlt='/[^/][^/]*/\.\./']
781 # Canonicalize the path of ld
782 ac_prog=`echo $ac_prog| sed 's%\\\\%/%g'`
783 while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
784 ac_prog=`echo $ac_prog| sed "s%$re_direlt%/%"`
785 done
786 test -z "$LD" && LD="$ac_prog"
787 ;;
788 "")
789 # If it fails, then pretend we aren't using GCC.
790 ac_prog=ld
791 ;;
792 *)
793 # If it is relative, then search for the first ld in PATH.
794 with_gnu_ld=unknown
795 ;;
796 esac
797elif test "$with_gnu_ld" = yes; then
798 AC_MSG_CHECKING([for GNU ld])
799else
800 AC_MSG_CHECKING([for non-GNU ld])
801fi
802AC_CACHE_VAL(acl_cv_path_LD,
803[if test -z "$LD"; then
804 IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}${PATH_SEPARATOR-:}"
805 for ac_dir in $PATH; do
806 test -z "$ac_dir" && ac_dir=.
807 if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
808 acl_cv_path_LD="$ac_dir/$ac_prog"
809 # Check to see if the program is GNU ld. I'd rather use --version,
810 # but apparently some GNU ld's only accept -v.
811 # Break only if it was the GNU/non-GNU ld that we prefer.
812 case `"$acl_cv_path_LD" -v 2>&1 < /dev/null` in
813 *GNU* | *'with BFD'*)
814 test "$with_gnu_ld" != no && break ;;
815 *)
816 test "$with_gnu_ld" != yes && break ;;
817 esac
818 fi
819 done
820 IFS="$ac_save_ifs"
821else
822 acl_cv_path_LD="$LD" # Let the user override the test with a path.
823fi])
824LD="$acl_cv_path_LD"
825if test -n "$LD"; then
826 AC_MSG_RESULT($LD)
827else
828 AC_MSG_RESULT(no)
829fi
830test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
831AC_LIB_PROG_LD_GNU
832])
833
8340
=== added file 'autogen.sh'
--- autogen.sh 1970-01-01 00:00:00 +0000
+++ autogen.sh 2011-03-15 17:56:13 +0000
@@ -0,0 +1,25 @@
1#!/bin/bash
2
3set -e
4
5#
6# usage:
7#
8# banner <target name>
9#
10banner() {
11 echo
12 TG=`echo $1 | sed -e "s,/.*/,,g"`
13 LINE=`echo $TG |sed -e "s/./-/g"`
14 echo $LINE
15 echo $TG
16 echo $LINE
17 echo
18}
19
20banner "autoreconf"
21
22mkdir -p config/autoconf config/m4
23autoreconf --force --install --symlink -Wall || exit $?
24
25banner "Finished"
026
=== modified file 'breakpoints.c'
--- breakpoints.c 2009-07-28 16:44:35 +0000
+++ breakpoints.c 2011-03-15 17:56:13 +0000
@@ -23,6 +23,12 @@
23 struct library_symbol *libsym) {23 struct library_symbol *libsym) {
24 Breakpoint *sbp;24 Breakpoint *sbp;
2525
26#ifdef __arm__
27 int thumb_mode = (int)addr & 1;
28 if (thumb_mode)
29 addr = (void *)((int)addr & ~1);
30#endif
31
26 debug(DEBUG_FUNCTION, "insert_breakpoint(pid=%d, addr=%p, symbol=%s)", proc->pid, addr, libsym ? libsym->name : "NULL");32 debug(DEBUG_FUNCTION, "insert_breakpoint(pid=%d, addr=%p, symbol=%s)", proc->pid, addr, libsym ? libsym->name : "NULL");
27 debug(1, "symbol=%s, addr=%p", libsym?libsym->name:"(nil)", addr);33 debug(1, "symbol=%s, addr=%p", libsym?libsym->name:"(nil)", addr);
2834
@@ -43,7 +49,7 @@
43 sbp->libsym = libsym;49 sbp->libsym = libsym;
44 }50 }
45#ifdef __arm__51#ifdef __arm__
46 sbp->thumb_mode = proc->thumb_mode;52 sbp->thumb_mode = thumb_mode | proc->thumb_mode;
47 proc->thumb_mode = 0;53 proc->thumb_mode = 0;
48#endif54#endif
49 sbp->enabled++;55 sbp->enabled++;
@@ -123,8 +129,8 @@
123 continue;129 continue;
124 }130 }
125 debug(2,"inserting bp %p %s",addr,sym->name);131 debug(2,"inserting bp %p %s",addr,sym->name);
126 new_sym=malloc(sizeof(*new_sym));132 new_sym=malloc(sizeof(*new_sym) + strlen(sym->name) + 1);
127 memcpy(new_sym,sym,sizeof(*new_sym));133 memcpy(new_sym,sym,sizeof(*new_sym) + strlen(sym->name) + 1);
128 new_sym->next=proc->list_of_symbols;134 new_sym->next=proc->list_of_symbols;
129 proc->list_of_symbols=new_sym;135 proc->list_of_symbols=new_sym;
130 insert_breakpoint(proc, addr, new_sym);136 insert_breakpoint(proc, addr, new_sym);
131137
=== modified file 'common.h'
--- common.h 2009-07-25 16:24:38 +0000
+++ common.h 2011-03-15 17:56:13 +0000
@@ -1,3 +1,7 @@
1#if defined(HAVE_LIBUNWIND)
2#include <libunwind.h>
3#endif /* defined(HAVE_LIBUNWIND) */
4
1#include <sys/types.h>5#include <sys/types.h>
2#include <sys/time.h>6#include <sys/time.h>
3#include <stdio.h>7#include <stdio.h>
@@ -7,7 +11,7 @@
7#include "dict.h"11#include "dict.h"
8#include "sysdep.h"12#include "sysdep.h"
9#include "debug.h"13#include "debug.h"
10#include "elf.h"14#include "ltrace-elf.h"
11#include "read_config_file.h"15#include "read_config_file.h"
1216
13#if defined HAVE_LIBIBERTY || defined HAVE_LIBSUPC__17#if defined HAVE_LIBIBERTY || defined HAVE_LIBSUPC__
@@ -145,6 +149,7 @@
145 int is_syscall;149 int is_syscall;
146 void * return_addr;150 void * return_addr;
147 struct timeval time_spent;151 struct timeval time_spent;
152 void * arch_ptr;
148};153};
149154
150#define MAX_CALLDEPTH 64155#define MAX_CALLDEPTH 64
@@ -171,7 +176,10 @@
171 struct callstack_element callstack[MAX_CALLDEPTH];176 struct callstack_element callstack[MAX_CALLDEPTH];
172 struct library_symbol * list_of_symbols;177 struct library_symbol * list_of_symbols;
173178
179 int libdl_hooked;
174 /* Arch-dependent: */180 /* Arch-dependent: */
181 void * debug; /* arch-dep process debug struct */
182 long debug_state; /* arch-dep debug state */
175 void * instruction_pointer;183 void * instruction_pointer;
176 void * stack_pointer; /* To get return addr, args... */184 void * stack_pointer; /* To get return addr, args... */
177 void * return_addr;185 void * return_addr;
@@ -186,6 +194,12 @@
186 /* output: */194 /* output: */
187 enum tof type_being_displayed;195 enum tof type_being_displayed;
188196
197#if defined(HAVE_LIBUNWIND)
198 /* libunwind address space */
199 unw_addr_space_t unwind_as;
200 void *unwind_priv;
201#endif /* defined(HAVE_LIBUNWIND) */
202
189 Process * next;203 Process * next;
190};204};
191205
@@ -222,6 +236,14 @@
222extern void show_summary(void);236extern void show_summary(void);
223extern arg_type_info * lookup_prototype(enum arg_type at);237extern arg_type_info * lookup_prototype(enum arg_type at);
224238
239extern void do_init_elf(struct ltelf *lte, const char *filename);
240extern void do_close_elf(struct ltelf *lte);
241extern int in_load_libraries(const char *name, struct ltelf *lte, size_t count, GElf_Sym *sym);
242extern struct library_symbol *library_symbols;
243extern void add_library_symbol(GElf_Addr addr, const char *name,
244 struct library_symbol **library_symbolspp,
245 enum toplt type_of_plt, int is_weak);
246
225/* Arch-dependent stuff: */247/* Arch-dependent stuff: */
226extern char * pid2name(pid_t pid);248extern char * pid2name(pid_t pid);
227extern void trace_set_options(Process * proc, pid_t pid);249extern void trace_set_options(Process * proc, pid_t pid);
@@ -245,9 +267,10 @@
245extern void save_register_args(enum tof type, Process * proc);267extern void save_register_args(enum tof type, Process * proc);
246extern int umovestr(Process * proc, void * addr, int len, void * laddr);268extern int umovestr(Process * proc, void * addr, int len, void * laddr);
247extern int umovelong (Process * proc, void * addr, long * result, arg_type_info * info);269extern int umovelong (Process * proc, void * addr, long * result, arg_type_info * info);
270extern size_t umovebytes (Process *proc, void * addr, void * laddr, size_t count);
248extern int ffcheck(void * maddr);271extern int ffcheck(void * maddr);
249extern void * sym2addr(Process *, struct library_symbol *);272extern void * sym2addr(Process *, struct library_symbol *);
273extern int linkmap_init(Process *, struct ltelf *);
274extern void arch_check_dbg(Process *proc);
250275
251#if 0 /* not yet */276extern struct ltelf main_lte;
252extern int umoven(Process * proc, void * addr, int len, void * laddr);
253#endif
254277
=== removed file 'configure'
--- configure 2009-07-28 16:44:35 +0000
+++ configure 1970-01-01 00:00:00 +0000
@@ -1,157 +0,0 @@
1#!/bin/sh
2
3if [ ! -f libltrace.c ]
4then
5 echo "configure: error: cannot find sources (libltrace.c)" 1>&2
6 exit 1
7fi
8
9echo -n "checking package name... "
10PACKAGE_NAME='ltrace'
11echo $PACKAGE_NAME
12
13echo -n "checking $PACKAGE_NAME version... "
14PACKAGE_VERSION=$( cat VERSION )
15echo $PACKAGE_VERSION
16
17echo -n "checking HOST_OS... "
18HOST_OS=$( uname -s )
19if [ "$HOST_OS" = "Linux" ]
20then
21 HOST_OS="linux-gnu"
22fi
23echo $HOST_OS
24
25# HAVE_LIBIBERTY
26echo -n "checking for cplus_demangle in -liberty... "
27cat > conftest.c << EOF
28char cplus_demangle();
29int main () {
30 return cplus_demangle();
31}
32EOF
33if gcc conftest.c -liberty 2>/dev/null
34then
35 HAVE_LIBIBERTY=1
36 echo "yes"
37else
38 unset HAVE_LIBIBERTY
39 echo "no"
40fi
41rm -f conftest.c a.out
42
43# HAVE_LIBSUPC__
44echo -n "checking for __cxa_demangle in -lsupc++... "
45cat > conftest.c << EOF
46char __cxa_demangle();
47int main () {
48 return __cxa_demangle();
49}
50EOF
51if gcc conftest.c -lsupc++ 2>/dev/null
52then
53 HAVE_LIBSUPC__=1
54 echo "yes"
55else
56 unset HAVE_LIBSUPC__
57 echo "no"
58fi
59rm -f conftest.c a.out
60
61# HAVE_ELF_C_READ_MMAP
62echo -n "checking whether elf_begin accepts ELF_C_READ_MMAP... "
63cat > conftest.c << EOF
64#include <gelf.h>
65int main () {
66 Elf *elf = elf_begin (4, ELF_C_READ_MMAP, 0);
67 return 0;
68}
69EOF
70if gcc conftest.c 2>/dev/null
71then
72 HAVE_ELF_C_READ_MMAP=1
73 echo "yes"
74else
75 unset HAVE_ELF_C_READ_MMAP
76 echo "no"
77fi
78rm -f conftest.c a.out
79
80CC=gcc
81CPPFLAGS=' -I /usr/include/libelf'
82CFLAGS='-g -O2'
83LIBS='-lelf -lsupc++ -liberty '
84INSTALL='/usr/bin/install -c'
85iquote='-iquote '
86iquoteend=''
87
88prefix=/usr/local
89sysconfdir='${prefix}/etc'
90bindir='${prefix}/bin'
91mandir='${prefix}/share/man'
92docdir='${prefix}/share/doc/ltrace'
93for x_option
94do
95 if test -n "$x_prev"; then
96 eval $x_prev=\$x_option
97 x_prev=
98 continue
99 fi
100 case $x_option in
101 --*=* | *=*)
102 x_var=`echo $x_option | sed 's/^--//' | sed 's/=.*//'`
103 x_val=`echo $x_option | sed 's/^.*=//'`
104 eval $x_var=$x_val
105 ;;
106 --*)
107 x_prev=`echo $x_option | sed 's/^--//'`
108 ;;
109 esac
110done
111
112echo "configure: creating Makefile"
113#
114# Makefile.in -> Makefile
115#
116x_subst_vars='PACKAGE_VERSION HOST_OS INSTALL CC CPPFLAGS CFLAGS LDFLAGS LIBS iquote iquoteend prefix sysconfdir mandir docdir'
117
118for i in $x_subst_vars
119do
120 x_val=`eval echo \\"\\$$i\\"`
121 x_sed="$x_sed
122s&@$i@&$x_val&g"
123done
124
125sed "$x_sed" Makefile.in > Makefile
126
127echo "configure: creating config.h"
128#
129# config.h
130#
131exec > config.h
132
133echo '#define PACKAGE_NAME "ltrace"'
134echo '#define PACKAGE_VERSION "'$PACKAGE_VERSION'"'
135
136if [ "$HAVE_LIBIBERTY" ]
137then
138 echo '#define HAVE_LIBIBERTY 1'
139else
140 echo '#undef HAVE_LIBIBERTY'
141fi
142
143if [ "$HAVE_LIBSUPC__" ]
144then
145 echo '#define HAVE_LIBSUPC__ 1'
146else
147 echo '#undef HAVE_LIBSUPC__'
148fi
149
150if [ "$HAVE_ELF_C_READ_MMAP" ]
151then
152 echo '#define HAVE_ELF_C_READ_MMAP 1'
153else
154 echo '#undef HAVE_ELF_C_READ_MMAP'
155fi
156
157exit 0
1580
=== added file 'configure.ac'
--- configure.ac 1970-01-01 00:00:00 +0000
+++ configure.ac 2011-03-15 17:56:13 +0000
@@ -0,0 +1,272 @@
1# -*- Autoconf -*-
2# Process this file with autoconf to produce a configure script.
3AC_PREREQ(2.59)
4
5AC_INIT([ltrace],[0.6.0],[ltrace-devel@lists.alioth.debian.org])
6AC_CONFIG_HEADERS([config.h])
7AC_CONFIG_SRCDIR(libltrace.c)
8#AC_CONFIG_MACRO_DIR([config/m4])
9AC_CONFIG_AUX_DIR([config/autoconf])
10AC_CANONICAL_BUILD
11AC_CANONICAL_HOST
12
13case "${host_os}" in
14 linux-gnu*) HOST_OS="linux-gnu" ;;
15 *) AC_MSG_ERROR([unkown host-os ${host_osx}]) ;;
16esac
17AC_SUBST(HOST_OS)
18
19case "${host_cpu}" in
20 arm*|sa110) HOST_CPU="arm" ;;
21 i?86) HOST_CPU="i386" ;;
22 powerpc|powerpc64) HOST_CPU="ppc" ;;
23 sun4u|sparc64) HOST_CPU="sparc" ;;
24 s390x) HOST_CPU="s390" ;;
25 *) HOST_CPU="${host_cpu}" ;;
26esac
27AC_SUBST(HOST_CPU)
28
29# Checks for programs.
30AC_PROG_CC
31AC_PROG_LIBTOOL
32# libtool-2: LT_INIT()
33AM_INIT_AUTOMAKE([foreign no-exeext dist-bzip2])
34AM_MAINTAINER_MODE
35
36AC_ARG_WITH([libelf],
37 AS_HELP_STRING([--with-libelf], [Prefix of libelf headers/library]),
38 [case "${withval}" in
39 (no)
40 AC_MSG_ERROR([*** libelf is a required dependency])
41 ;;
42 (yes)
43 AC_MSG_ERROR([*** --with-libelf requires you to specify a path])
44 ;;
45 (*)
46 AM_CPPFLAGS="${AM_CPPFLAGS} -I${withval}/include"
47 AM_LDFLAGS="${AM_LDFLAGS} -L${withval}/lib"
48 libelf_LD_LIBRARY_PATH="${withval}/lib"
49 ;;
50esac],[])
51
52# Checks for libraries.
53
54saved_CPPFLAGS="${CPPFLAGS}"
55saved_LDFLAGS="${LDFLAGS}"
56CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}"
57LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}"
58# libelf
59AC_CHECK_HEADERS([elf.h gelf.h],,
60 [AC_MSG_ERROR([*** libelf.h or gelf.h not found on your system])]
61)
62AC_CHECK_LIB([elf], [elf_begin],,
63 [AC_MSG_ERROR([*** libelf not found on your system])]
64)
65CPPFLAGS="${saved_CPPFLAGS}"
66LDFLAGS="${saved_LDFLAGS}"
67
68
69# HAVE_LIBIBERTY
70AC_CHECK_LIB([iberty], [cplus_demangle], [
71 AC_DEFINE([HAVE_LIBIBERTY], [1], [we have libiberty])
72 liberty_LIBS="-liberty"], [
73 liberty_LIBS=""])
74AC_SUBST(liberty_LIBS)
75
76
77# HAVE_LIBSUPC__
78AC_CHECK_LIB([supc++], [__cxa_demangle], [
79 AC_DEFINE([HAVE_LIBSUPC__], [1], [we have libsupc++])
80 libsupcxx_LIBS="-lsupc++"], [
81 libsupcxx_LIBS=""])
82AC_SUBST(libsupcxx_LIBS)
83
84
85# HAVE_LIBUNWIND
86AC_ARG_WITH(libunwind,
87 AS_HELP_STRING([--with-libunwind], [Use libunwind frame unwinding support]),
88 [case "${withval}" in
89 (yes|no) enable_libunwind=$withval;;
90 (*) enable_libunwind=yes
91 AM_CPPFLAGS="${AM_CPPFLAGS} -I${withval}/include"
92 AM_LDFLAGS="${AM_LDFLAGS} -L${withval}/lib"
93 libunwind_LD_LIBRARY_PATH="${withval}/lib"
94 ;;
95esac],[enable_libunwind=maybe])
96
97saved_CPPFLAGS="${CPPFLAGS}"
98CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}"
99AC_CHECK_HEADERS([libunwind.h], [have_libunwind_h=yes])
100AC_CHECK_HEADERS([libunwind-ptrace.h], [have_libunwind_ptrace_h=yes])
101CPPFLAGS="${saved_CPPFLAGS}"
102
103AC_MSG_CHECKING([whether to use libunwind support])
104case "${enable_libunwind}" in
105(yes|maybe)
106 if test x$have_libunwind_h = xyes -o x$have_libunwind_ptrace_h = xyes; then
107 enable_libunwind=yes
108 elif test $enable_libunwind = maybe; then
109 enable_libunwind=no
110 else
111 AC_MSG_RESULT([$enable_libunwind])
112 AC_MSG_ERROR([libunwind.h or libunwind-ptrace.h cannot be found])
113 fi
114 ;;
115(*) ;;
116esac
117AC_MSG_RESULT([$enable_libunwind])
118
119if test x"$enable_libunwind" = xyes; then
120 saved_LDFLAGS="${LDFLAGS}"
121 LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}"
122 AC_CHECK_LIB(unwind, backtrace, libunwind_LIBS=-lunwind, libunwind_LIBS=)
123 AC_SUBST(libunwind_LIBS)
124 AC_CHECK_LIB(unwind-ptrace, _UPT_create, libunwind_ptrace_LIBS=-lunwind-ptrace, libunwind_ptrace_LIBS=)
125 AC_SUBST(libunwind_ptrace_LIBS)
126
127 case "${host_cpu}" in
128 arm*|sa110) UNWIND_ARCH="arm" ;;
129 i?86) UNWIND_ARCH="x86" ;;
130 powerpc) UNWIND_ARCH="ppc32" ;;
131 ppc64) UNWIND_ARCH="ppc64" ;;
132 mips*) UNWIND_ARCH="mips" ;;
133 *) UNWIND_ARCH="${host_cpu}" ;;
134 esac
135
136 AC_CHECK_LIB(unwind-${UNWIND_ARCH}, _U${UNWIND_ARCH}_init_remote, libunwind_arch_LIBS=-lunwind-${UNWIND_ARCH}, libunwind_arch_LIBS=)
137 AC_SUBST(libunwind_arch_LIBS)
138 AC_DEFINE([HAVE_LIBUNWIND], [1], [we have libunwind])
139 LDFLAGS="${saved_LDFLAGS}"
140fi
141
142
143saved_CPPFLAGS="${CPPFLAGS}"
144saved_LDFLAGS="${LDFLAGS}"
145CPPFLAGS="${CPPFLAGS} ${AM_CPPFLAGS}"
146LDFLAGS="${LDFLAGS} ${AM_LDFLAGS}"
147# HAVE_ELF_C_READ_MMAP
148AC_MSG_CHECKING([whether elf_begin accepts ELF_C_READ_MMAP])
149AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <gelf.h>]], [[
150int main () {
151 Elf *elf = elf_begin(4, ELF_C_READ_MMAP, 0);
152 return 0;
153}
154 ]])],[
155 AC_DEFINE([HAVE_ELF_C_READ_MMAP], [1], [we have read mmap support])
156 AC_MSG_RESULT([yes])],[
157 AC_MSG_RESULT([no])])
158
159saved_CFLAGS="${CFLAGS}"
160CFLAGS="${CFLAGS} -Wall -Werror"
161AC_MSG_CHECKING([whether elf_hash takes a signed char string])
162AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <libelf.h>]], [[
163 (void) elf_hash("name");
164 ]])],
165 [AC_DEFINE([ELF_HASH_TAKES_SIGNED_CHAR], [1],
166 [elf_hash() takes signed char])
167 AC_MSG_RESULT([yes])],
168 [AC_MSG_RESULT([no])])
169CFLAGS="${saved_CFLAGS}"
170CPPFLAGS="${saved_CPPFLAGS}"
171LDFLAGS="${saved_LDFLAGS}"
172
173AM_CPPFLAGS=" \
174 ${AM_CPPFLAGS} \
175 -I\$(top_srcdir)/sysdeps/${HOST_OS}/${HOST_CPU} \
176 -I\$(top_srcdir)/sysdeps/${HOST_OS} \
177 -I\$(top_srcdir)/sysdeps \
178 -I\$(top_srcdir) \
179"
180
181# Checks for header files.
182AC_CHECK_HEADERS([ \
183 fcntl.h \
184 limits.h \
185 stddef.h \
186 stdint.h \
187 stdlib.h \
188 string.h \
189 sys/ioctl.h \
190 sys/param.h \
191 sys/time.h \
192 unistd.h \
193])
194
195# Checks for typedefs, structures, and compiler characteristics.
196AC_TYPE_UID_T
197AC_C_INLINE
198AC_TYPE_PID_T
199AC_TYPE_SIZE_T
200AC_CHECK_SIZEOF([long])
201
202
203# Checks for library functions.
204AC_FUNC_ERROR_AT_LINE
205AC_FUNC_FORK
206AC_CHECK_FUNCS([ \
207 alarm \
208 atexit \
209 getcwd \
210 gettimeofday \
211 memset \
212 mkdir \
213 rmdir \
214 strchr \
215 strdup \
216 strerror \
217 strtol \
218 strtoul \
219])
220
221
222#
223# Debugging
224#
225AC_MSG_CHECKING([whether to enable debugging])
226AC_ARG_ENABLE(debug,
227 AS_HELP_STRING([--enable-debug], [enable debugging @<:@default=no@:>@]),
228 [case "$enableval" in
229 y | yes) CONFIG_DEBUG=yes ;;
230 *) CONFIG_DEBUG=no ;;
231 esac],
232 [CONFIG_DEBUG=no])
233AC_MSG_RESULT([${CONFIG_DEBUG}])
234if test "${CONFIG_DEBUG}" = "yes"; then
235 AC_DEFINE(DEBUG, 1, [debugging])
236fi
237
238# Ignore the compiler's warnings at your own risk.
239AM_CFLAGS="${AM_CFLAGS} -Wall -Wsign-compare -Wfloat-equal -Wformat-security"
240AC_ARG_ENABLE([werror],
241 AS_HELP_STRING([--disable-werror], [disable use of -Werror]),
242 [enable_werror=$enableval], [enable_werror=yes])
243if test x$enable_werror = xyes; then
244 AM_CFLAGS="${AM_CFLAGS} -Werror"
245fi
246
247AC_SUBST(AM_CPPFLAGS)
248AC_SUBST(AM_CFLAGS)
249AC_SUBST(AM_LDFLAGS)
250AC_SUBST(libelf_LD_LIBRARY_PATH)
251AC_SUBST(libunwind_LD_LIBRARY_PATH)
252
253AC_CONFIG_FILES([
254 Makefile
255 sysdeps/Makefile
256 sysdeps/linux-gnu/Makefile
257 sysdeps/linux-gnu/alpha/Makefile
258 sysdeps/linux-gnu/arm/Makefile
259 sysdeps/linux-gnu/i386/Makefile
260 sysdeps/linux-gnu/ia64/Makefile
261 sysdeps/linux-gnu/m68k/Makefile
262 sysdeps/linux-gnu/mipsel/Makefile
263 sysdeps/linux-gnu/ppc/Makefile
264 sysdeps/linux-gnu/s390/Makefile
265 sysdeps/linux-gnu/sparc/Makefile
266 sysdeps/linux-gnu/x86_64/Makefile
267 testsuite/Makefile
268 testsuite/ltrace.main/Makefile
269 testsuite/ltrace.minor/Makefile
270 testsuite/ltrace.torture/Makefile
271])
272AC_OUTPUT
0273
=== modified file 'debian/changelog'
--- debian/changelog 2010-11-24 17:58:11 +0000
+++ debian/changelog 2011-03-15 17:56:13 +0000
@@ -1,3 +1,18 @@
1ltrace (0.6-1ubuntu1) natty; urgency=low
2
3 * Add memmove prototype to etc/ltrace.con
4
5 -- Avik Sil <avik.sil@linaro.org> Tue, 15 Mar 2011 17:48:04 +0530
6
7ltrace (0.6-1) unstable; urgency=low
8
9 * New upstream release
10 * Support for cris added
11 * Numerous bugfixes for MIPS, ARM, and PPC
12 * Support for libunwind and libdl
13
14 -- Joe Damato <ice799@gmail.com> Fri, 10 Dec 2010 00:41:20 -0800
15
1ltrace (0.5.3-2.1ubuntu1) natty; urgency=low16ltrace (0.5.3-2.1ubuntu1) natty; urgency=low
217
3 * Merge with Debian; remaining changes:18 * Merge with Debian; remaining changes:
419
=== modified file 'debian/control'
--- debian/control 2010-11-24 17:58:11 +0000
+++ debian/control 2011-03-15 17:56:13 +0000
@@ -1,13 +1,12 @@
1Source: ltrace1Source: ltrace
2Section: utils2Section: utils
3Priority: optional3Priority: optional
4Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>4Maintainer: Juan Cespedes <cespedes@debian.org>
5XSBC-Original-Maintainer: Juan Cespedes <cespedes@debian.org>
6Standards-Version: 3.8.25Standards-Version: 3.8.2
7Build-Depends: cdbs (>= 0.4.23-1.1), debhelper (>= 5), binutils-dev, libelf-dev6Build-Depends: cdbs, debhelper (>= 7), dh-autoreconf, binutils-dev, libelfg0-dev, libunwind7-dev [i386 amd64 ia64]
87
9Package: ltrace8Package: ltrace
10Architecture: i386 arm armeb armel m68k s390 powerpc sparc alpha amd64 ia64 ppc649Architecture: i386 arm armeb armel s390 powerpc sparc alpha amd64 ia64 ppc64
11Depends: ${shlibs:Depends}, ${misc:Depends}10Depends: ${shlibs:Depends}, ${misc:Depends}
12Description: Tracks runtime library calls in dynamically linked programs11Description: Tracks runtime library calls in dynamically linked programs
13 ltrace is a debugging program which runs a specified command until it12 ltrace is a debugging program which runs a specified command until it
1413
=== removed file 'debian/control.in'
--- debian/control.in 2010-11-24 17:58:11 +0000
+++ debian/control.in 1970-01-01 00:00:00 +0000
@@ -1,25 +0,0 @@
1Source: ltrace
2Section: utils
3Priority: optional
4Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
5XSBC-Original-Maintainer: Juan Cespedes <cespedes@debian.org>
6Maintainer: Juan Cespedes <cespedes@debian.org>
7Standards-Version: 3.8.2
8Build-Depends: @cdbs@, binutils-dev, libelf-dev
9
10Package: ltrace
11Architecture: i386 arm armeb armel m68k s390 powerpc sparc alpha amd64 ia64 ppc64
12Depends: ${shlibs:Depends}, ${misc:Depends}
13Description: Tracks runtime library calls in dynamically linked programs
14 ltrace is a debugging program which runs a specified command until it
15 exits. While the command is executing, ltrace intercepts and records
16 the dynamic library calls which are called by
17 the executed process and the signals received by that process.
18 It can also intercept and print the system calls executed by the program.
19 .
20 The program to be traced need not be recompiled for this, so you can
21 use it on binaries for which you don't have the source handy.
22 .
23 You should install ltrace if you need a sysadmin tool for tracking the
24 execution of processes.
25
260
=== modified file 'debian/rules'
--- debian/rules 2009-01-06 17:46:28 +0000
+++ debian/rules 2011-03-15 17:56:13 +0000
@@ -6,6 +6,7 @@
66
7include /usr/share/cdbs/1/rules/debhelper.mk7include /usr/share/cdbs/1/rules/debhelper.mk
8include /usr/share/cdbs/1/class/autotools.mk8include /usr/share/cdbs/1/class/autotools.mk
9include /usr/share/cdbs/1/rules/autoreconf.mk
910
10install/ltrace::11install/ltrace::
11 rm -f debian/ltrace/usr/share/doc/ltrace/*12 rm -f debian/ltrace/usr/share/doc/ltrace/*
1213
=== modified file 'debug.h'
--- debug.h 2009-07-28 16:44:35 +0000
+++ debug.h 2011-03-15 17:56:13 +0000
@@ -1,3 +1,6 @@
1#ifndef _DEBUG_H
2#define _DEBUG_H
3
1#include <features.h>4#include <features.h>
25
3/* debug levels:6/* debug levels:
@@ -15,3 +18,4 @@
1518
16# define debug(level, expr...) debug_(level, __FILE__, __LINE__, expr)19# define debug(level, expr...) debug_(level, __FILE__, __LINE__, expr)
1720
21#endif
1822
=== modified file 'defs.h'
--- defs.h 2009-07-28 16:44:35 +0000
+++ defs.h 2011-03-15 17:56:13 +0000
@@ -15,4 +15,4 @@
15#define DEFAULT_ARRAYLEN 4 /* default maximum # array elements */15#define DEFAULT_ARRAYLEN 4 /* default maximum # array elements */
16#endif /* (-A switch) */16#endif /* (-A switch) */
1717
18#define MAX_LIBRARIES 3018#define MAX_LIBRARIES 200
1919
=== modified file 'display_args.c'
--- display_args.c 2009-07-28 16:44:35 +0000
+++ display_args.c 2011-03-15 17:56:13 +0000
@@ -15,8 +15,8 @@
15static int display_unknown(enum tof type, Process *proc, long value);15static int display_unknown(enum tof type, Process *proc, long value);
16static int display_format(enum tof type, Process *proc, int arg_num);16static int display_format(enum tof type, Process *proc, int arg_num);
1717
18static int string_maxlength = INT_MAX;18static size_t string_maxlength = INT_MAX;
19static int array_maxlength = INT_MAX;19static size_t array_maxlength = INT_MAX;
2020
21static long21static long
22get_length(enum tof type, Process *proc, int len_spec,22get_length(enum tof type, Process *proc, int len_spec,
@@ -59,8 +59,8 @@
59 void *addr, arg_type_info * info,59 void *addr, arg_type_info * info,
60 void *st, arg_type_info* st_info) {60 void *st, arg_type_info* st_info) {
61 int len = 0;61 int len = 0;
62 int i;62 size_t i;
63 int array_len;63 size_t array_len;
6464
65 if (addr == NULL)65 if (addr == NULL)
66 return fprintf(options.output, "NULL");66 return fprintf(options.output, "NULL");
@@ -143,7 +143,7 @@
143static int143static int
144display_enum(enum tof type, Process *proc,144display_enum(enum tof type, Process *proc,
145 arg_type_info* info, long value) {145 arg_type_info* info, long value) {
146 int ii;146 size_t ii;
147 for (ii = 0; ii < info->u.enum_info.entries; ++ii) {147 for (ii = 0; ii < info->u.enum_info.entries; ++ii) {
148 if (info->u.enum_info.values[ii] == value)148 if (info->u.enum_info.values[ii] == value)
149 return fprintf(options.output, "%s", info->u.enum_info.keys[ii]);149 return fprintf(options.output, "%s", info->u.enum_info.keys[ii]);
@@ -281,7 +281,7 @@
281display_string(enum tof type, Process *proc, void *addr,281display_string(enum tof type, Process *proc, void *addr,
282 size_t maxlength) {282 size_t maxlength) {
283 unsigned char *str1;283 unsigned char *str1;
284 int i;284 size_t i;
285 int len = 0;285 int len = 0;
286286
287 if (!addr) {287 if (!addr) {
@@ -328,7 +328,7 @@
328 void *addr;328 void *addr;
329 unsigned char *str1;329 unsigned char *str1;
330 int i;330 int i;
331 int len = 0;331 size_t len = 0;
332 arg_type_info info;332 arg_type_info info;
333333
334 info.type = ARGTYPE_POINTER;334 info.type = ARGTYPE_POINTER;
335335
=== removed file 'elf.c'
--- elf.c 2009-07-28 16:44:35 +0000
+++ elf.c 1970-01-01 00:00:00 +0000
@@ -1,619 +0,0 @@
1# include "config.h"
2
3#include <endian.h>
4#include <errno.h>
5#include <error.h>
6#include <fcntl.h>
7#include <gelf.h>
8#include <stdint.h>
9#include <stdlib.h>
10#include <string.h>
11#include <unistd.h>
12
13#include "common.h"
14
15static void do_init_elf(struct ltelf *lte, const char *filename);
16static void do_close_elf(struct ltelf *lte);
17static void add_library_symbol(GElf_Addr addr, const char *name,
18 struct library_symbol **library_symbolspp,
19 enum toplt type_of_plt, int is_weak);
20static int in_load_libraries(const char *name, struct ltelf *lte);
21static GElf_Addr opd2addr(struct ltelf *ltc, GElf_Addr addr);
22
23#ifdef PLT_REINITALISATION_BP
24extern char *PLTs_initialized_by_here;
25#endif
26
27static void
28do_init_elf(struct ltelf *lte, const char *filename) {
29 int i;
30 GElf_Addr relplt_addr = 0;
31 size_t relplt_size = 0;
32
33 debug(DEBUG_FUNCTION, "do_init_elf(filename=%s)", filename);
34 debug(1, "Reading ELF from %s...", filename);
35
36 memset(lte, 0, sizeof(*lte));
37 lte->fd = open(filename, O_RDONLY);
38 if (lte->fd == -1)
39 error(EXIT_FAILURE, errno, "Can't open \"%s\"", filename);
40
41#ifdef HAVE_ELF_C_READ_MMAP
42 lte->elf = elf_begin(lte->fd, ELF_C_READ_MMAP, NULL);
43#else
44 lte->elf = elf_begin(lte->fd, ELF_C_READ, NULL);
45#endif
46
47 if (lte->elf == NULL || elf_kind(lte->elf) != ELF_K_ELF)
48 error(EXIT_FAILURE, 0, "Can't open ELF file \"%s\"", filename);
49
50 if (gelf_getehdr(lte->elf, &lte->ehdr) == NULL)
51 error(EXIT_FAILURE, 0, "Can't read ELF header of \"%s\"",
52 filename);
53
54 if (lte->ehdr.e_type != ET_EXEC && lte->ehdr.e_type != ET_DYN)
55 error(EXIT_FAILURE, 0,
56 "\"%s\" is not an ELF executable nor shared library",
57 filename);
58
59 if ((lte->ehdr.e_ident[EI_CLASS] != LT_ELFCLASS
60 || lte->ehdr.e_machine != LT_ELF_MACHINE)
61#ifdef LT_ELF_MACHINE2
62 && (lte->ehdr.e_ident[EI_CLASS] != LT_ELFCLASS2
63 || lte->ehdr.e_machine != LT_ELF_MACHINE2)
64#endif
65#ifdef LT_ELF_MACHINE3
66 && (lte->ehdr.e_ident[EI_CLASS] != LT_ELFCLASS3
67 || lte->ehdr.e_machine != LT_ELF_MACHINE3)
68#endif
69 )
70 error(EXIT_FAILURE, 0,
71 "\"%s\" is ELF from incompatible architecture", filename);
72
73 for (i = 1; i < lte->ehdr.e_shnum; ++i) {
74 Elf_Scn *scn;
75 GElf_Shdr shdr;
76 const char *name;
77
78 scn = elf_getscn(lte->elf, i);
79 if (scn == NULL || gelf_getshdr(scn, &shdr) == NULL)
80 error(EXIT_FAILURE, 0,
81 "Couldn't get section header from \"%s\"",
82 filename);
83
84 name = elf_strptr(lte->elf, lte->ehdr.e_shstrndx, shdr.sh_name);
85 if (name == NULL)
86 error(EXIT_FAILURE, 0,
87 "Couldn't get section header from \"%s\"",
88 filename);
89
90 if (shdr.sh_type == SHT_SYMTAB) {
91 Elf_Data *data;
92
93 lte->symtab = elf_getdata(scn, NULL);
94 lte->symtab_count = shdr.sh_size / shdr.sh_entsize;
95 if ((lte->symtab == NULL
96 || elf_getdata(scn, lte->symtab) != NULL)
97 && opt_x != NULL)
98 error(EXIT_FAILURE, 0,
99 "Couldn't get .symtab data from \"%s\"",
100 filename);
101
102 scn = elf_getscn(lte->elf, shdr.sh_link);
103 if (scn == NULL || gelf_getshdr(scn, &shdr) == NULL)
104 error(EXIT_FAILURE, 0,
105 "Couldn't get section header from \"%s\"",
106 filename);
107
108 data = elf_getdata(scn, NULL);
109 if (data == NULL || elf_getdata(scn, data) != NULL
110 || shdr.sh_size != data->d_size || data->d_off)
111 error(EXIT_FAILURE, 0,
112 "Couldn't get .strtab data from \"%s\"",
113 filename);
114
115 lte->strtab = data->d_buf;
116 } else if (shdr.sh_type == SHT_DYNSYM) {
117 Elf_Data *data;
118
119 lte->dynsym = elf_getdata(scn, NULL);
120 lte->dynsym_count = shdr.sh_size / shdr.sh_entsize;
121 if (lte->dynsym == NULL
122 || elf_getdata(scn, lte->dynsym) != NULL)
123 error(EXIT_FAILURE, 0,
124 "Couldn't get .dynsym data from \"%s\"",
125 filename);
126
127 scn = elf_getscn(lte->elf, shdr.sh_link);
128 if (scn == NULL || gelf_getshdr(scn, &shdr) == NULL)
129 error(EXIT_FAILURE, 0,
130 "Couldn't get section header from \"%s\"",
131 filename);
132
133 data = elf_getdata(scn, NULL);
134 if (data == NULL || elf_getdata(scn, data) != NULL
135 || shdr.sh_size != data->d_size || data->d_off)
136 error(EXIT_FAILURE, 0,
137 "Couldn't get .dynstr data from \"%s\"",
138 filename);
139
140 lte->dynstr = data->d_buf;
141 } else if (shdr.sh_type == SHT_DYNAMIC) {
142 Elf_Data *data;
143 size_t j;
144
145 data = elf_getdata(scn, NULL);
146 if (data == NULL || elf_getdata(scn, data) != NULL)
147 error(EXIT_FAILURE, 0,
148 "Couldn't get .dynamic data from \"%s\"",
149 filename);
150
151 for (j = 0; j < shdr.sh_size / shdr.sh_entsize; ++j) {
152 GElf_Dyn dyn;
153
154 if (gelf_getdyn(data, j, &dyn) == NULL)
155 error(EXIT_FAILURE, 0,
156 "Couldn't get .dynamic data from \"%s\"",
157 filename);
158#ifdef __mips__
159/**
160 MIPS ABI Supplement:
161
162 DT_PLTGOT This member holds the address of the .got section.
163
164 DT_MIPS_SYMTABNO This member holds the number of entries in the
165 .dynsym section.
166
167 DT_MIPS_LOCAL_GOTNO This member holds the number of local global
168 offset table entries.
169
170 DT_MIPS_GOTSYM This member holds the index of the first dyamic
171 symbol table entry that corresponds to an entry in the gobal offset
172 table.
173
174 */
175 if(dyn.d_tag==DT_PLTGOT){
176 lte->pltgot_addr=dyn.d_un.d_ptr;
177 }
178 if(dyn.d_tag==DT_MIPS_LOCAL_GOTNO){
179 lte->mips_local_gotno=dyn.d_un.d_val;
180 }
181 if(dyn.d_tag==DT_MIPS_GOTSYM){
182 lte->mips_gotsym=dyn.d_un.d_val;
183 }
184#endif // __mips__
185 if (dyn.d_tag == DT_JMPREL)
186 relplt_addr = dyn.d_un.d_ptr;
187 else if (dyn.d_tag == DT_PLTRELSZ)
188 relplt_size = dyn.d_un.d_val;
189 }
190 } else if (shdr.sh_type == SHT_HASH) {
191 Elf_Data *data;
192 size_t j;
193
194 lte->hash_type = SHT_HASH;
195
196 data = elf_getdata(scn, NULL);
197 if (data == NULL || elf_getdata(scn, data) != NULL
198 || data->d_off || data->d_size != shdr.sh_size)
199 error(EXIT_FAILURE, 0,
200 "Couldn't get .hash data from \"%s\"",
201 filename);
202
203 if (shdr.sh_entsize == 4) {
204 /* Standard conforming ELF. */
205 if (data->d_type != ELF_T_WORD)
206 error(EXIT_FAILURE, 0,
207 "Couldn't get .hash data from \"%s\"",
208 filename);
209 lte->hash = (Elf32_Word *) data->d_buf;
210 } else if (shdr.sh_entsize == 8) {
211 /* Alpha or s390x. */
212 Elf32_Word *dst, *src;
213 size_t hash_count = data->d_size / 8;
214
215 lte->hash = (Elf32_Word *)
216 malloc(hash_count * sizeof(Elf32_Word));
217 if (lte->hash == NULL)
218 error(EXIT_FAILURE, 0,
219 "Couldn't convert .hash section from \"%s\"",
220 filename);
221 lte->lte_flags |= LTE_HASH_MALLOCED;
222 dst = lte->hash;
223 src = (Elf32_Word *) data->d_buf;
224 if ((data->d_type == ELF_T_WORD
225 && __BYTE_ORDER == __BIG_ENDIAN)
226 || (data->d_type == ELF_T_XWORD
227 && lte->ehdr.e_ident[EI_DATA] ==
228 ELFDATA2MSB))
229 ++src;
230 for (j = 0; j < hash_count; ++j, src += 2)
231 *dst++ = *src;
232 } else
233 error(EXIT_FAILURE, 0,
234 "Unknown .hash sh_entsize in \"%s\"",
235 filename);
236 } else if (shdr.sh_type == SHT_GNU_HASH
237 && lte->hash == NULL) {
238 Elf_Data *data;
239
240 lte->hash_type = SHT_GNU_HASH;
241
242 if (shdr.sh_entsize != 0
243 && shdr.sh_entsize != 4) {
244 error(EXIT_FAILURE, 0,
245 ".gnu.hash sh_entsize in \"%s\" should be 4, but is %llu",
246 filename, shdr.sh_entsize);
247 }
248
249 data = elf_getdata(scn, NULL);
250 if (data == NULL || elf_getdata(scn, data) != NULL
251 || data->d_off || data->d_size != shdr.sh_size)
252 error(EXIT_FAILURE, 0,
253 "Couldn't get .gnu.hash data from \"%s\"",
254 filename);
255
256 lte->hash = (Elf32_Word *) data->d_buf;
257 } else if (shdr.sh_type == SHT_PROGBITS
258 || shdr.sh_type == SHT_NOBITS) {
259 if (strcmp(name, ".plt") == 0) {
260 lte->plt_addr = shdr.sh_addr;
261 lte->plt_size = shdr.sh_size;
262 if (shdr.sh_flags & SHF_EXECINSTR) {
263 lte->lte_flags |= LTE_PLT_EXECUTABLE;
264 }
265 }
266#ifdef ARCH_SUPPORTS_OPD
267 else if (strcmp(name, ".opd") == 0) {
268 lte->opd_addr = (GElf_Addr *) (long) shdr.sh_addr;
269 lte->opd_size = shdr.sh_size;
270 lte->opd = elf_rawdata(scn, NULL);
271 }
272#endif
273 }
274 }
275
276 if (lte->dynsym == NULL || lte->dynstr == NULL)
277 error(EXIT_FAILURE, 0,
278 "Couldn't find .dynsym or .dynstr in \"%s\"", filename);
279
280 if (!relplt_addr || !lte->plt_addr) {
281 debug(1, "%s has no PLT relocations", filename);
282 lte->relplt = NULL;
283 lte->relplt_count = 0;
284 } else {
285 for (i = 1; i < lte->ehdr.e_shnum; ++i) {
286 Elf_Scn *scn;
287 GElf_Shdr shdr;
288
289 scn = elf_getscn(lte->elf, i);
290 if (scn == NULL || gelf_getshdr(scn, &shdr) == NULL)
291 error(EXIT_FAILURE, 0,
292 "Couldn't get section header from \"%s\"",
293 filename);
294 if (shdr.sh_addr == relplt_addr
295 && shdr.sh_size == relplt_size) {
296 lte->relplt = elf_getdata(scn, NULL);
297 lte->relplt_count =
298 shdr.sh_size / shdr.sh_entsize;
299 if (lte->relplt == NULL
300 || elf_getdata(scn, lte->relplt) != NULL)
301 error(EXIT_FAILURE, 0,
302 "Couldn't get .rel*.plt data from \"%s\"",
303 filename);
304 break;
305 }
306 }
307
308 if (i == lte->ehdr.e_shnum)
309 error(EXIT_FAILURE, 0,
310 "Couldn't find .rel*.plt section in \"%s\"",
311 filename);
312
313 debug(1, "%s %zd PLT relocations", filename, lte->relplt_count);
314 }
315}
316
317static void
318do_close_elf(struct ltelf *lte) {
319 debug(DEBUG_FUNCTION, "do_close_elf()");
320 if (lte->lte_flags & LTE_HASH_MALLOCED)
321 free((char *)lte->hash);
322 elf_end(lte->elf);
323 close(lte->fd);
324}
325
326static void
327add_library_symbol(GElf_Addr addr, const char *name,
328 struct library_symbol **library_symbolspp,
329 enum toplt type_of_plt, int is_weak) {
330 struct library_symbol *s;
331
332 debug(DEBUG_FUNCTION, "add_library_symbol()");
333
334 s = malloc(sizeof(struct library_symbol) + strlen(name) + 1);
335 if (s == NULL)
336 error(EXIT_FAILURE, errno, "add_library_symbol failed");
337
338 s->needs_init = 1;
339 s->is_weak = is_weak;
340 s->plt_type = type_of_plt;
341 s->next = *library_symbolspp;
342 s->enter_addr = (void *)(uintptr_t) addr;
343 s->name = (char *)(s + 1);
344 strcpy(s->name, name);
345 *library_symbolspp = s;
346
347 debug(2, "addr: %p, symbol: \"%s\"", (void *)(uintptr_t) addr, name);
348}
349
350/* stolen from elfutils-0.123 */
351static unsigned long
352private_elf_gnu_hash(const char *name) {
353 unsigned long h = 5381;
354 const unsigned char *string = (const unsigned char *)name;
355 unsigned char c;
356 for (c = *string; c; c = *++string)
357 h = h * 33 + c;
358 return h & 0xffffffff;
359}
360
361static int
362in_load_libraries(const char *name, struct ltelf *lte) {
363 size_t i;
364 unsigned long hash;
365 unsigned long gnu_hash;
366
367 if (!library_num)
368 return 1;
369
370 hash = elf_hash((const unsigned char *)name);
371 gnu_hash = private_elf_gnu_hash(name);
372 for (i = 1; i <= library_num; ++i) {
373 if (lte[i].hash == NULL)
374 continue;
375
376 if (lte[i].hash_type == SHT_GNU_HASH) {
377 Elf32_Word * hashbase = lte[i].hash;
378 Elf32_Word nbuckets = *hashbase++;
379 Elf32_Word symbias = *hashbase++;
380 Elf32_Word bitmask_nwords = *hashbase++;
381 Elf32_Word * buckets;
382 Elf32_Word * chain_zero;
383 Elf32_Word bucket;
384
385 // +1 for skipped `shift'
386 hashbase += lte[i].ehdr.e_ident[EI_CLASS] * bitmask_nwords + 1;
387 buckets = hashbase;
388 hashbase += nbuckets;
389 chain_zero = hashbase - symbias;
390 bucket = buckets[gnu_hash % nbuckets];
391
392 if (bucket != 0) {
393 const Elf32_Word *hasharr = &chain_zero[bucket];
394 do
395 if ((*hasharr & ~1u) == (gnu_hash & ~1u)) {
396 int symidx = hasharr - chain_zero;
397 GElf_Sym sym;
398
399 if (gelf_getsym(lte[i].dynsym, symidx, &sym) == NULL)
400 error(EXIT_FAILURE, 0,
401 "Couldn't get symbol from .dynsym");
402
403 if (sym.st_value != 0
404 && sym.st_shndx != SHN_UNDEF
405 && strcmp(name, lte[i].dynstr + sym.st_name) == 0)
406 return 1;
407 }
408 while ((*hasharr++ & 1u) == 0);
409 }
410 } else {
411 Elf32_Word nbuckets, symndx;
412 Elf32_Word *buckets, *chain;
413 nbuckets = lte[i].hash[0];
414 buckets = &lte[i].hash[2];
415 chain = &lte[i].hash[2 + nbuckets];
416
417 for (symndx = buckets[hash % nbuckets];
418 symndx != STN_UNDEF; symndx = chain[symndx]) {
419 GElf_Sym sym;
420
421 if (gelf_getsym(lte[i].dynsym, symndx, &sym) == NULL)
422 error(EXIT_FAILURE, 0,
423 "Couldn't get symbol from .dynsym");
424
425 if (sym.st_value != 0
426 && sym.st_shndx != SHN_UNDEF
427 && strcmp(name, lte[i].dynstr + sym.st_name) == 0)
428 return 1;
429 }
430 }
431 }
432 return 0;
433}
434
435static GElf_Addr
436opd2addr(struct ltelf *lte, GElf_Addr addr) {
437#ifdef ARCH_SUPPORTS_OPD
438 unsigned long base, offset;
439
440 if (!lte->opd)
441 return addr;
442
443 base = (unsigned long)lte->opd->d_buf;
444 offset = (unsigned long)addr - (unsigned long)lte->opd_addr;
445 if (offset > lte->opd_size)
446 error(EXIT_FAILURE, 0, "static plt not in .opd");
447
448 return *(GElf_Addr*)(base + offset);
449#else //!ARCH_SUPPORTS_OPD
450 return addr;
451#endif
452}
453
454struct library_symbol *
455read_elf(Process *proc) {
456 struct library_symbol *library_symbols = NULL;
457 struct ltelf lte[MAX_LIBRARIES + 1];
458 size_t i;
459 struct opt_x_t *xptr;
460 struct library_symbol **lib_tail = NULL;
461 int exit_out = 0;
462
463 debug(DEBUG_FUNCTION, "read_elf(file=%s)", proc->filename);
464
465 elf_version(EV_CURRENT);
466
467 do_init_elf(lte, proc->filename);
468 proc->e_machine = lte->ehdr.e_machine;
469 for (i = 0; i < library_num; ++i)
470 do_init_elf(&lte[i + 1], library[i]);
471#ifdef __mips__
472 // MIPS doesn't use the PLT and the GOT entries get changed
473 // on startup.
474 proc->need_to_reinitialize_breakpoints = 1;
475 for(i=lte->mips_gotsym; i<lte->dynsym_count;i++){
476 GElf_Sym sym;
477 const char *name;
478 GElf_Addr addr = arch_plt_sym_val(lte, i, 0);
479 if (gelf_getsym(lte->dynsym, i, &sym) == NULL){
480 error(EXIT_FAILURE, 0,
481 "Couldn't get relocation from \"%s\"",
482 proc->filename);
483 }
484 name=lte->dynstr+sym.st_name;
485 if(ELF64_ST_TYPE(sym.st_info) != STT_FUNC){
486 debug(2,"sym %s not a function",name);
487 continue;
488 }
489 add_library_symbol(addr, name, &library_symbols, 0,
490 ELF64_ST_BIND(sym.st_info) != 0);
491 if (!lib_tail)
492 lib_tail = &(library_symbols->next);
493 }
494#else
495 for (i = 0; i < lte->relplt_count; ++i) {
496 GElf_Rel rel;
497 GElf_Rela rela;
498 GElf_Sym sym;
499 GElf_Addr addr;
500 void *ret;
501 const char *name;
502
503 if (lte->relplt->d_type == ELF_T_REL) {
504 ret = gelf_getrel(lte->relplt, i, &rel);
505 rela.r_offset = rel.r_offset;
506 rela.r_info = rel.r_info;
507 rela.r_addend = 0;
508 } else
509 ret = gelf_getrela(lte->relplt, i, &rela);
510
511 if (ret == NULL
512 || ELF64_R_SYM(rela.r_info) >= lte->dynsym_count
513 || gelf_getsym(lte->dynsym, ELF64_R_SYM(rela.r_info),
514 &sym) == NULL)
515 error(EXIT_FAILURE, 0,
516 "Couldn't get relocation from \"%s\"",
517 proc->filename);
518
519#ifdef PLT_REINITALISATION_BP
520 if (!sym.st_value && PLTs_initialized_by_here)
521 proc->need_to_reinitialize_breakpoints = 1;
522#endif
523
524 name = lte->dynstr + sym.st_name;
525 if (in_load_libraries(name, lte)) {
526 addr = arch_plt_sym_val(lte, i, &rela);
527 add_library_symbol(addr, name, &library_symbols,
528 (PLTS_ARE_EXECUTABLE(lte)
529 ? LS_TOPLT_EXEC : LS_TOPLT_POINT),
530 ELF64_ST_BIND(sym.st_info) == STB_WEAK);
531 if (!lib_tail)
532 lib_tail = &(library_symbols->next);
533 }
534 }
535#endif // !__mips__
536#ifdef PLT_REINITALISATION_BP
537 struct opt_x_t *main_cheat;
538
539 if (proc->need_to_reinitialize_breakpoints) {
540 /* Add "PLTs_initialized_by_here" to opt_x list, if not
541 already there. */
542 main_cheat = (struct opt_x_t *)malloc(sizeof(struct opt_x_t));
543 if (main_cheat == NULL)
544 error(EXIT_FAILURE, 0, "Couldn't allocate memory");
545 main_cheat->next = opt_x;
546 main_cheat->found = 0;
547 main_cheat->name = PLTs_initialized_by_here;
548
549 for (xptr = opt_x; xptr; xptr = xptr->next)
550 if (strcmp(xptr->name, PLTs_initialized_by_here) == 0
551 && main_cheat) {
552 free(main_cheat);
553 main_cheat = NULL;
554 break;
555 }
556 if (main_cheat)
557 opt_x = main_cheat;
558 }
559#endif
560
561 for (i = 0; i < lte->symtab_count; ++i) {
562 GElf_Sym sym;
563 GElf_Addr addr;
564 const char *name;
565
566 if (gelf_getsym(lte->symtab, i, &sym) == NULL)
567 error(EXIT_FAILURE, 0,
568 "Couldn't get symbol from \"%s\"",
569 proc->filename);
570
571 name = lte->strtab + sym.st_name;
572 addr = sym.st_value;
573 if (!addr)
574 continue;
575
576 for (xptr = opt_x; xptr; xptr = xptr->next)
577 if (xptr->name && strcmp(xptr->name, name) == 0) {
578 /* FIXME: Should be able to use &library_symbols as above. But
579 when you do, none of the real library symbols cause breaks. */
580 add_library_symbol(opd2addr(lte, addr),
581 name, lib_tail, LS_TOPLT_NONE, 0);
582 xptr->found = 1;
583 break;
584 }
585 }
586 for (xptr = opt_x; xptr; xptr = xptr->next)
587 if ( ! xptr->found) {
588 char *badthing = "WARNING";
589#ifdef PLT_REINITALISATION_BP
590 if (strcmp(xptr->name, PLTs_initialized_by_here) == 0) {
591 if (lte->ehdr.e_entry) {
592 add_library_symbol (
593 opd2addr (lte, lte->ehdr.e_entry),
594 PLTs_initialized_by_here,
595 lib_tail, 1, 0);
596 fprintf (stderr, "WARNING: Using e_ent"
597 "ry from elf header (%p) for "
598 "address of \"%s\"\n", (void*)
599 (long) lte->ehdr.e_entry,
600 PLTs_initialized_by_here);
601 continue;
602 }
603 badthing = "ERROR";
604 exit_out = 1;
605 }
606#endif
607 fprintf (stderr,
608 "%s: Couldn't find symbol \"%s\" in file \"%s"
609 "\"\n", badthing, xptr->name, proc->filename);
610 }
611 if (exit_out) {
612 exit (1);
613 }
614
615 for (i = 0; i < library_num + 1; ++i)
616 do_close_elf(&lte[i]);
617
618 return library_symbols;
619}
6200
=== removed file 'elf.h'
--- elf.h 2009-07-28 16:44:35 +0000
+++ elf.h 1970-01-01 00:00:00 +0000
@@ -1,49 +0,0 @@
1#ifndef LTRACE_ELF_H
2#define LTRACE_ELF_H
3
4#include <gelf.h>
5#include <stdlib.h>
6
7struct ltelf {
8 int fd;
9 Elf *elf;
10 GElf_Ehdr ehdr;
11 Elf_Data *dynsym;
12 size_t dynsym_count;
13 const char *dynstr;
14 GElf_Addr plt_addr;
15 size_t plt_size;
16 Elf_Data *relplt;
17 size_t relplt_count;
18 Elf_Data *symtab;
19 const char *strtab;
20 size_t symtab_count;
21 Elf_Data *opd;
22 GElf_Addr *opd_addr;
23 size_t opd_size;
24 Elf32_Word *hash;
25 int hash_type;
26 int lte_flags;
27#ifdef __mips__
28 size_t pltgot_addr;
29 size_t mips_local_gotno;
30 size_t mips_gotsym;
31#endif // __mips__
32};
33
34#define LTE_HASH_MALLOCED 1
35#define LTE_PLT_EXECUTABLE 2
36
37#define PLTS_ARE_EXECUTABLE(lte) ((lte->lte_flags & LTE_PLT_EXECUTABLE) != 0)
38
39extern int library_num;
40extern char *library[MAX_LIBRARIES];
41
42extern struct library_symbol *read_elf(Process *);
43
44extern GElf_Addr arch_plt_sym_val(struct ltelf *, size_t, GElf_Rela *);
45
46#ifndef SHT_GNU_HASH
47#define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table. */
48#endif
49#endif
500
=== modified file 'etc/ltrace.conf'
--- etc/ltrace.conf 2009-01-06 17:46:28 +0000
+++ etc/ltrace.conf 2011-03-15 17:56:13 +0000
@@ -317,6 +317,7 @@
317string index(string,char);317string index(string,char);
318addr memchr(string,char,ulong);318addr memchr(string,char,ulong);
319addr memcpy(addr,string3,ulong);319addr memcpy(addr,string3,ulong);
320addr memmove(addr,string3,ulong);
320addr memset(addr,char,long);321addr memset(addr,char,long);
321string rindex(string,char);322string rindex(string,char);
322addr stpcpy(addr,string);323addr stpcpy(addr,string);
323324
=== modified file 'execute_program.c'
--- execute_program.c 2009-07-28 16:44:35 +0000
+++ execute_program.c 2011-03-15 17:56:13 +0000
@@ -1,5 +1,9 @@
1#include "config.h"1#include "config.h"
22
3#if defined(HAVE_LIBUNWIND)
4#include <libunwind-ptrace.h>
5#endif /* defined(HAVE_LIBUNWIND) */
6
3#include <stdio.h>7#include <stdio.h>
4#include <stdlib.h>8#include <stdlib.h>
5#include <sys/types.h>9#include <sys/types.h>
@@ -87,5 +91,9 @@
8791
88 sp->pid = pid;92 sp->pid = pid;
8993
94#if defined(HAVE_LIBUNWIND)
95 sp->unwind_priv = _UPT_create(pid);
96#endif /* defined(HAVE_LIBUNWIND) */
97
90 return;98 return;
91}99}
92100
=== modified file 'handle_event.c'
--- handle_event.c 2009-07-25 16:24:38 +0000
+++ handle_event.c 2011-03-15 17:56:13 +0000
@@ -330,7 +330,7 @@
330 remove_proc(event->proc);330 remove_proc(event->proc);
331 return;331 return;
332 }332 }
333 if (event->proc->state != STATE_IGNORED) {333 if (event->proc->state != STATE_IGNORED && !options.no_signals) {
334 output_line(event->proc, "--- %s (%s) ---",334 output_line(event->proc, "--- %s (%s) ---",
335 shortsignal(event->proc, event->e_un.signum),335 shortsignal(event->proc, event->e_un.signum),
336 strsignal(event->e_un.signum));336 strsignal(event->e_un.signum));
@@ -386,14 +386,14 @@
386handle_syscall(Event *event) {386handle_syscall(Event *event) {
387 debug(DEBUG_FUNCTION, "handle_syscall(pid=%d, sysnum=%d)", event->proc->pid, event->e_un.sysnum);387 debug(DEBUG_FUNCTION, "handle_syscall(pid=%d, sysnum=%d)", event->proc->pid, event->e_un.sysnum);
388 if (event->proc->state != STATE_IGNORED) {388 if (event->proc->state != STATE_IGNORED) {
389 if (options.syscalls) {
390 output_left(LT_TOF_SYSCALL, event->proc,
391 sysname(event->proc, event->e_un.sysnum));
392 }
393 if (event->proc->breakpoints_enabled == 0) {
394 enable_all_breakpoints(event->proc);
395 }
396 callstack_push_syscall(event->proc, event->e_un.sysnum);389 callstack_push_syscall(event->proc, event->e_un.sysnum);
390 if (options.syscalls) {
391 output_left(LT_TOF_SYSCALL, event->proc,
392 sysname(event->proc, event->e_un.sysnum));
393 }
394 if (event->proc->breakpoints_enabled == 0) {
395 enable_all_breakpoints(event->proc);
396 }
397 }397 }
398 continue_process(event->proc->pid);398 continue_process(event->proc->pid);
399}399}
@@ -427,14 +427,14 @@
427handle_arch_syscall(Event *event) {427handle_arch_syscall(Event *event) {
428 debug(DEBUG_FUNCTION, "handle_arch_syscall(pid=%d, sysnum=%d)", event->proc->pid, event->e_un.sysnum);428 debug(DEBUG_FUNCTION, "handle_arch_syscall(pid=%d, sysnum=%d)", event->proc->pid, event->e_un.sysnum);
429 if (event->proc->state != STATE_IGNORED) {429 if (event->proc->state != STATE_IGNORED) {
430 if (options.syscalls) {
431 output_left(LT_TOF_SYSCALL, event->proc,
432 arch_sysname(event->proc, event->e_un.sysnum));
433 }
434 if (event->proc->breakpoints_enabled == 0) {
435 enable_all_breakpoints(event->proc);
436 }
437 callstack_push_syscall(event->proc, 0xf0000 + event->e_un.sysnum);430 callstack_push_syscall(event->proc, 0xf0000 + event->e_un.sysnum);
431 if (options.syscalls) {
432 output_left(LT_TOF_SYSCALL, event->proc,
433 arch_sysname(event->proc, event->e_un.sysnum));
434 }
435 if (event->proc->breakpoints_enabled == 0) {
436 enable_all_breakpoints(event->proc);
437 }
438 }438 }
439 continue_process(event->proc->pid);439 continue_process(event->proc->pid);
440}440}
@@ -470,11 +470,11 @@
470 if (opt_T || options.summary) {470 if (opt_T || options.summary) {
471 calc_time_spent(event->proc);471 calc_time_spent(event->proc);
472 }472 }
473 callstack_pop(event->proc);
474 if (options.syscalls) {473 if (options.syscalls) {
475 output_right(LT_TOF_SYSCALLR, event->proc,474 output_right(LT_TOF_SYSCALLR, event->proc,
476 sysname(event->proc, event->e_un.sysnum));475 sysname(event->proc, event->e_un.sysnum));
477 }476 }
477 callstack_pop(event->proc);
478 }478 }
479 continue_process(event->proc->pid);479 continue_process(event->proc->pid);
480}480}
@@ -486,15 +486,19 @@
486 if (opt_T || options.summary) {486 if (opt_T || options.summary) {
487 calc_time_spent(event->proc);487 calc_time_spent(event->proc);
488 }488 }
489 callstack_pop(event->proc);
490 if (options.syscalls) {489 if (options.syscalls) {
491 output_right(LT_TOF_SYSCALLR, event->proc,490 output_right(LT_TOF_SYSCALLR, event->proc,
492 arch_sysname(event->proc, event->e_un.sysnum));491 arch_sysname(event->proc, event->e_un.sysnum));
493 }492 }
493 callstack_pop(event->proc);
494 }494 }
495 continue_process(event->proc->pid);495 continue_process(event->proc->pid);
496}496}
497497
498#ifdef __powerpc__
499void *get_count_register (Process *proc);
500#endif
501
498static void502static void
499handle_breakpoint(Event *event) {503handle_breakpoint(Event *event) {
500 int i, j;504 int i, j;
@@ -561,25 +565,31 @@
561 libsym);565 libsym);
562 }566 }
563 } else {567 } else {
564 sbp = dict_find_entry(event->proc->breakpoints, sym2addr(event->proc, libsym));568 sbp = dict_find_entry(event->proc->breakpoints, addr);
565 assert(sbp);569 /* On powerpc, the breakpoint address
566 if (addr != sbp->addr) {570 may end up being actual entry point
571 of the library symbol, not the PLT
572 address we computed. In that case,
573 sbp is NULL. */
574 if (sbp == NULL || addr != sbp->addr) {
567 insert_breakpoint(event->proc, addr,575 insert_breakpoint(event->proc, addr,
568 libsym);576 libsym);
569 }577 }
570 }578 }
571#elif defined(__mips__)579#elif defined(__mips__)
572 void *addr;580 void *addr = NULL;
573 void *old_addr;
574 struct library_symbol *sym= event->proc->callstack[i].c_un.libfunc;581 struct library_symbol *sym= event->proc->callstack[i].c_un.libfunc;
582 struct library_symbol *new_sym;
575 assert(sym);583 assert(sym);
576 old_addr = dict_find_entry(event->proc->breakpoints, sym2addr(event->proc, sym))->addr;
577 addr=sym2addr(event->proc,sym);584 addr=sym2addr(event->proc,sym);
578 assert(old_addr !=0 && addr !=0);585 sbp = dict_find_entry(event->proc->breakpoints, addr);
579 if(addr != old_addr){586 if (sbp) {
580 struct library_symbol *new_sym;587 if (addr != sbp->addr) {
581 new_sym=malloc(sizeof(*new_sym));588 insert_breakpoint(event->proc, addr, sym);
582 memcpy(new_sym,sym,sizeof(*new_sym));589 }
590 } else {
591 new_sym=malloc(sizeof(*new_sym) + strlen(sym->name) + 1);
592 memcpy(new_sym,sym,sizeof(*new_sym) + strlen(sym->name) + 1);
583 new_sym->next=event->proc->list_of_symbols;593 new_sym->next=event->proc->list_of_symbols;
584 event->proc->list_of_symbols=new_sym;594 event->proc->list_of_symbols=new_sym;
585 insert_breakpoint(event->proc, addr, new_sym);595 insert_breakpoint(event->proc, addr, new_sym);
@@ -593,12 +603,12 @@
593 calc_time_spent(event->proc);603 calc_time_spent(event->proc);
594 }604 }
595 }605 }
596 callstack_pop(event->proc);
597 event->proc->return_addr = event->e_un.brk_addr;606 event->proc->return_addr = event->e_un.brk_addr;
598 if (event->proc->state != STATE_IGNORED) {607 if (event->proc->state != STATE_IGNORED) {
599 output_right(LT_TOF_FUNCTIONR, event->proc,608 output_right(LT_TOF_FUNCTIONR, event->proc,
600 event->proc->callstack[i].c_un.libfunc->name);609 event->proc->callstack[i].c_un.libfunc->name);
601 }610 }
611 callstack_pop(event->proc);
602 continue_after_breakpoint(event->proc,612 continue_after_breakpoint(event->proc,
603 address2bpstruct(event->proc,613 address2bpstruct(event->proc,
604 event->e_un.brk_addr));614 event->e_un.brk_addr));
@@ -607,12 +617,16 @@
607 }617 }
608618
609 if ((sbp = address2bpstruct(event->proc, event->e_un.brk_addr))) {619 if ((sbp = address2bpstruct(event->proc, event->e_un.brk_addr))) {
620 if (strcmp(sbp->libsym->name, "") == 0) {
621 debug(2, "Hit _dl_debug_state breakpoint!\n");
622 arch_check_dbg(event->proc);
623 }
610 if (event->proc->state != STATE_IGNORED) {624 if (event->proc->state != STATE_IGNORED) {
611 event->proc->stack_pointer = get_stack_pointer(event->proc);625 event->proc->stack_pointer = get_stack_pointer(event->proc);
612 event->proc->return_addr =626 event->proc->return_addr =
613 get_return_addr(event->proc, event->proc->stack_pointer);627 get_return_addr(event->proc, event->proc->stack_pointer);
628 callstack_push_symfunc(event->proc, sbp->libsym);
614 output_left(LT_TOF_FUNCTION, event->proc, sbp->libsym->name);629 output_left(LT_TOF_FUNCTION, event->proc, sbp->libsym->name);
615 callstack_push_symfunc(event->proc, sbp->libsym);
616 }630 }
617#ifdef PLT_REINITALISATION_BP631#ifdef PLT_REINITALISATION_BP
618 if (event->proc->need_to_reinitialize_breakpoints632 if (event->proc->need_to_reinitialize_breakpoints
@@ -625,7 +639,7 @@
625 return;639 return;
626 }640 }
627641
628 if (event->proc->state != STATE_IGNORED) {642 if (event->proc->state != STATE_IGNORED && !options.no_plt) {
629 output_line(event->proc, "unexpected breakpoint at %p",643 output_line(event->proc, "unexpected breakpoint at %p",
630 (void *)event->e_un.brk_addr);644 (void *)event->e_un.brk_addr);
631 }645 }
@@ -639,7 +653,8 @@
639 debug(DEBUG_FUNCTION, "callstack_push_syscall(pid=%d, sysnum=%d)", proc->pid, sysnum);653 debug(DEBUG_FUNCTION, "callstack_push_syscall(pid=%d, sysnum=%d)", proc->pid, sysnum);
640 /* FIXME: not good -- should use dynamic allocation. 19990703 mortene. */654 /* FIXME: not good -- should use dynamic allocation. 19990703 mortene. */
641 if (proc->callstack_depth == MAX_CALLDEPTH - 1) {655 if (proc->callstack_depth == MAX_CALLDEPTH - 1) {
642 fprintf(stderr, "Error: call nesting too deep!\n");656 fprintf(stderr, "%s: Error: call nesting too deep!\n", __func__);
657 abort();
643 return;658 return;
644 }659 }
645660
@@ -657,15 +672,17 @@
657672
658static void673static void
659callstack_push_symfunc(Process *proc, struct library_symbol *sym) {674callstack_push_symfunc(Process *proc, struct library_symbol *sym) {
660 struct callstack_element *elem;675 struct callstack_element *elem, *prev;
661676
662 debug(DEBUG_FUNCTION, "callstack_push_symfunc(pid=%d, symbol=%s)", proc->pid, sym->name);677 debug(DEBUG_FUNCTION, "callstack_push_symfunc(pid=%d, symbol=%s)", proc->pid, sym->name);
663 /* FIXME: not good -- should use dynamic allocation. 19990703 mortene. */678 /* FIXME: not good -- should use dynamic allocation. 19990703 mortene. */
664 if (proc->callstack_depth == MAX_CALLDEPTH - 1) {679 if (proc->callstack_depth == MAX_CALLDEPTH - 1) {
665 fprintf(stderr, "Error: call nesting too deep!\n");680 fprintf(stderr, "%s: Error: call nesting too deep!\n", __func__);
681 abort();
666 return;682 return;
667 }683 }
668684
685 prev = &proc->callstack[proc->callstack_depth-1];
669 elem = &proc->callstack[proc->callstack_depth];686 elem = &proc->callstack[proc->callstack_depth];
670 elem->is_syscall = 0;687 elem->is_syscall = 0;
671 elem->c_un.libfunc = sym;688 elem->c_un.libfunc = sym;
@@ -675,7 +692,9 @@
675 insert_breakpoint(proc, elem->return_addr, 0);692 insert_breakpoint(proc, elem->return_addr, 0);
676 }693 }
677694
678 proc->callstack_depth++;695 /* handle functions like atexit() on mips which have no return */
696 if (elem->return_addr != prev->return_addr)
697 proc->callstack_depth++;
679 if (opt_T || options.summary) {698 if (opt_T || options.summary) {
680 struct timezone tz;699 struct timezone tz;
681 gettimeofday(&elem->time_spent, &tz);700 gettimeofday(&elem->time_spent, &tz);
@@ -692,5 +711,9 @@
692 if (!elem->is_syscall && elem->return_addr) {711 if (!elem->is_syscall && elem->return_addr) {
693 delete_breakpoint(proc, elem->return_addr);712 delete_breakpoint(proc, elem->return_addr);
694 }713 }
714 if (elem->arch_ptr != NULL) {
715 free(elem->arch_ptr);
716 elem->arch_ptr = NULL;
717 }
695 proc->callstack_depth--;718 proc->callstack_depth--;
696}719}
697720
=== added file 'ltrace-elf.c'
--- ltrace-elf.c 1970-01-01 00:00:00 +0000
+++ ltrace-elf.c 2011-03-15 17:56:13 +0000
@@ -0,0 +1,827 @@
1#include "config.h"
2
3#include <endian.h>
4#include <errno.h>
5#include <error.h>
6#include <fcntl.h>
7#include <gelf.h>
8#include <inttypes.h>
9#include <stdint.h>
10#include <stdlib.h>
11#include <string.h>
12#include <unistd.h>
13#include <assert.h>
14
15#include "common.h"
16
17void do_init_elf(struct ltelf *lte, const char *filename);
18void do_close_elf(struct ltelf *lte);
19void add_library_symbol(GElf_Addr addr, const char *name,
20 struct library_symbol **library_symbolspp,
21 enum toplt type_of_plt, int is_weak);
22int in_load_libraries(const char *name, struct ltelf *lte, size_t count, GElf_Sym *sym);
23static GElf_Addr opd2addr(struct ltelf *ltc, GElf_Addr addr);
24
25struct library_symbol *library_symbols = NULL;
26struct ltelf main_lte;
27
28#ifdef PLT_REINITALISATION_BP
29extern char *PLTs_initialized_by_here;
30#endif
31
32#ifndef DT_PPC_GOT
33# define DT_PPC_GOT (DT_LOPROC + 0)
34#endif
35
36#define PPC_PLT_STUB_SIZE 16
37
38static Elf_Data *loaddata(Elf_Scn *scn, GElf_Shdr *shdr)
39{
40 Elf_Data *data = elf_getdata(scn, NULL);
41 if (data == NULL || elf_getdata(scn, data) != NULL
42 || data->d_off || data->d_size != shdr->sh_size)
43 return NULL;
44 return data;
45}
46
47static int inside(GElf_Addr addr, GElf_Shdr *shdr)
48{
49 return addr >= shdr->sh_addr
50 && addr < shdr->sh_addr + shdr->sh_size;
51}
52
53static int maybe_pick_section(GElf_Addr addr,
54 Elf_Scn *in_sec, GElf_Shdr *in_shdr,
55 Elf_Scn **tgt_sec, GElf_Shdr *tgt_shdr)
56{
57 if (inside (addr, in_shdr)) {
58 *tgt_sec = in_sec;
59 *tgt_shdr = *in_shdr;
60 return 1;
61 }
62 return 0;
63}
64
65static int get_section_covering(struct ltelf *lte, GElf_Addr addr,
66 Elf_Scn **tgt_sec, GElf_Shdr *tgt_shdr)
67{
68 int i;
69 for (i = 1; i < lte->ehdr.e_shnum; ++i) {
70 Elf_Scn *scn;
71 GElf_Shdr shdr;
72
73 scn = elf_getscn(lte->elf, i);
74 if (scn == NULL || gelf_getshdr(scn, &shdr) == NULL) {
75 debug(1, "Couldn't read section or header.");
76 return 0;
77 }
78
79 if (maybe_pick_section(addr, scn, &shdr, tgt_sec, tgt_shdr))
80 return 1;
81 }
82
83 return 0;
84}
85
86static GElf_Addr read32be(Elf_Data *data, size_t offset)
87{
88 if (data->d_size < offset + 4) {
89 debug(1, "Not enough data to read 32bit value at offset %zd.",
90 offset);
91 return 0;
92 }
93
94 unsigned char const *buf = data->d_buf + offset;
95 return ((Elf32_Word)buf[0] << 24)
96 | ((Elf32_Word)buf[1] << 16)
97 | ((Elf32_Word)buf[2] << 8)
98 | ((Elf32_Word)buf[3]);
99}
100
101static GElf_Addr get_glink_vma(struct ltelf *lte, GElf_Addr ppcgot,
102 Elf_Data *plt_data)
103{
104 Elf_Scn *ppcgot_sec = NULL;
105 GElf_Shdr ppcgot_shdr;
106 if (ppcgot != 0
107 && !get_section_covering(lte, ppcgot, &ppcgot_sec, &ppcgot_shdr))
108 // xxx should be the log out
109 fprintf(stderr,
110 "DT_PPC_GOT=%#" PRIx64 ", but no such section found.\n",
111 ppcgot);
112
113 if (ppcgot_sec != NULL) {
114 Elf_Data *data = loaddata(ppcgot_sec, &ppcgot_shdr);
115 if (data == NULL
116 || data->d_size < 8 )
117 debug(1, "Couldn't read GOT data.");
118 else {
119 // where PPCGOT begins in .got
120 size_t offset = ppcgot - ppcgot_shdr.sh_addr;
121 GElf_Addr glink_vma = read32be(data, offset + 4);
122 if (glink_vma != 0) {
123 debug(1, "PPC GOT glink_vma address: %#" PRIx64,
124 glink_vma);
125 return glink_vma;
126 }
127 }
128 }
129
130 if (plt_data != NULL) {
131 GElf_Addr glink_vma = read32be(plt_data, 0);
132 debug(1, ".plt glink_vma address: %#" PRIx64, glink_vma);
133 return glink_vma;
134 }
135
136 return 0;
137}
138
139void
140do_init_elf(struct ltelf *lte, const char *filename) {
141 int i;
142 GElf_Addr relplt_addr = 0;
143 size_t relplt_size = 0;
144
145 debug(DEBUG_FUNCTION, "do_init_elf(filename=%s)", filename);
146 debug(1, "Reading ELF from %s...", filename);
147
148 lte->fd = open(filename, O_RDONLY);
149 if (lte->fd == -1)
150 error(EXIT_FAILURE, errno, "Can't open \"%s\"", filename);
151
152#ifdef HAVE_ELF_C_READ_MMAP
153 lte->elf = elf_begin(lte->fd, ELF_C_READ_MMAP, NULL);
154#else
155 lte->elf = elf_begin(lte->fd, ELF_C_READ, NULL);
156#endif
157
158 if (lte->elf == NULL || elf_kind(lte->elf) != ELF_K_ELF)
159 error(EXIT_FAILURE, 0, "Can't open ELF file \"%s\"", filename);
160
161 if (gelf_getehdr(lte->elf, &lte->ehdr) == NULL)
162 error(EXIT_FAILURE, 0, "Can't read ELF header of \"%s\"",
163 filename);
164
165 if (lte->ehdr.e_type != ET_EXEC && lte->ehdr.e_type != ET_DYN)
166 error(EXIT_FAILURE, 0,
167 "\"%s\" is not an ELF executable nor shared library",
168 filename);
169
170 if ((lte->ehdr.e_ident[EI_CLASS] != LT_ELFCLASS
171 || lte->ehdr.e_machine != LT_ELF_MACHINE)
172#ifdef LT_ELF_MACHINE2
173 && (lte->ehdr.e_ident[EI_CLASS] != LT_ELFCLASS2
174 || lte->ehdr.e_machine != LT_ELF_MACHINE2)
175#endif
176#ifdef LT_ELF_MACHINE3
177 && (lte->ehdr.e_ident[EI_CLASS] != LT_ELFCLASS3
178 || lte->ehdr.e_machine != LT_ELF_MACHINE3)
179#endif
180 )
181 error(EXIT_FAILURE, 0,
182 "\"%s\" is ELF from incompatible architecture", filename);
183
184 Elf_Data *plt_data = NULL;
185 GElf_Addr ppcgot = 0;
186
187 for (i = 1; i < lte->ehdr.e_shnum; ++i) {
188 Elf_Scn *scn;
189 GElf_Shdr shdr;
190 const char *name;
191
192 scn = elf_getscn(lte->elf, i);
193 if (scn == NULL || gelf_getshdr(scn, &shdr) == NULL)
194 error(EXIT_FAILURE, 0,
195 "Couldn't get section header from \"%s\"",
196 filename);
197
198 name = elf_strptr(lte->elf, lte->ehdr.e_shstrndx, shdr.sh_name);
199 if (name == NULL)
200 error(EXIT_FAILURE, 0,
201 "Couldn't get section header from \"%s\"",
202 filename);
203
204 if (shdr.sh_type == SHT_SYMTAB) {
205 Elf_Data *data;
206
207 lte->symtab = elf_getdata(scn, NULL);
208 lte->symtab_count = shdr.sh_size / shdr.sh_entsize;
209 if ((lte->symtab == NULL
210 || elf_getdata(scn, lte->symtab) != NULL)
211 && opt_x != NULL)
212 error(EXIT_FAILURE, 0,
213 "Couldn't get .symtab data from \"%s\"",
214 filename);
215
216 scn = elf_getscn(lte->elf, shdr.sh_link);
217 if (scn == NULL || gelf_getshdr(scn, &shdr) == NULL)
218 error(EXIT_FAILURE, 0,
219 "Couldn't get section header from \"%s\"",
220 filename);
221
222 data = elf_getdata(scn, NULL);
223 if (data == NULL || elf_getdata(scn, data) != NULL
224 || shdr.sh_size != data->d_size || data->d_off)
225 error(EXIT_FAILURE, 0,
226 "Couldn't get .strtab data from \"%s\"",
227 filename);
228
229 lte->strtab = data->d_buf;
230 } else if (shdr.sh_type == SHT_DYNSYM) {
231 Elf_Data *data;
232
233 lte->dynsym = elf_getdata(scn, NULL);
234 lte->dynsym_count = shdr.sh_size / shdr.sh_entsize;
235 if (lte->dynsym == NULL
236 || elf_getdata(scn, lte->dynsym) != NULL)
237 error(EXIT_FAILURE, 0,
238 "Couldn't get .dynsym data from \"%s\"",
239 filename);
240
241 scn = elf_getscn(lte->elf, shdr.sh_link);
242 if (scn == NULL || gelf_getshdr(scn, &shdr) == NULL)
243 error(EXIT_FAILURE, 0,
244 "Couldn't get section header from \"%s\"",
245 filename);
246
247 data = elf_getdata(scn, NULL);
248 if (data == NULL || elf_getdata(scn, data) != NULL
249 || shdr.sh_size != data->d_size || data->d_off)
250 error(EXIT_FAILURE, 0,
251 "Couldn't get .dynstr data from \"%s\"",
252 filename);
253
254 lte->dynstr = data->d_buf;
255 } else if (shdr.sh_type == SHT_DYNAMIC) {
256 Elf_Data *data;
257 size_t j;
258
259 lte->dyn_addr = shdr.sh_addr;
260 lte->dyn_sz = shdr.sh_size;
261
262 data = elf_getdata(scn, NULL);
263 if (data == NULL || elf_getdata(scn, data) != NULL)
264 error(EXIT_FAILURE, 0,
265 "Couldn't get .dynamic data from \"%s\"",
266 filename);
267
268 for (j = 0; j < shdr.sh_size / shdr.sh_entsize; ++j) {
269 GElf_Dyn dyn;
270
271 if (gelf_getdyn(data, j, &dyn) == NULL)
272 error(EXIT_FAILURE, 0,
273 "Couldn't get .dynamic data from \"%s\"",
274 filename);
275#ifdef __mips__
276/**
277 MIPS ABI Supplement:
278
279 DT_PLTGOT This member holds the address of the .got section.
280
281 DT_MIPS_SYMTABNO This member holds the number of entries in the
282 .dynsym section.
283
284 DT_MIPS_LOCAL_GOTNO This member holds the number of local global
285 offset table entries.
286
287 DT_MIPS_GOTSYM This member holds the index of the first dyamic
288 symbol table entry that corresponds to an entry in the gobal offset
289 table.
290
291 */
292 if(dyn.d_tag==DT_PLTGOT){
293 lte->pltgot_addr=dyn.d_un.d_ptr;
294 }
295 if(dyn.d_tag==DT_MIPS_LOCAL_GOTNO){
296 lte->mips_local_gotno=dyn.d_un.d_val;
297 }
298 if(dyn.d_tag==DT_MIPS_GOTSYM){
299 lte->mips_gotsym=dyn.d_un.d_val;
300 }
301#endif // __mips__
302 if (dyn.d_tag == DT_JMPREL)
303 relplt_addr = dyn.d_un.d_ptr;
304 else if (dyn.d_tag == DT_PLTRELSZ)
305 relplt_size = dyn.d_un.d_val;
306 else if (dyn.d_tag == DT_PPC_GOT) {
307 ppcgot = dyn.d_un.d_val;
308 debug(1, "ppcgot %#" PRIx64, ppcgot);
309 }
310 }
311 } else if (shdr.sh_type == SHT_HASH) {
312 Elf_Data *data;
313 size_t j;
314
315 lte->hash_type = SHT_HASH;
316
317 data = elf_getdata(scn, NULL);
318 if (data == NULL || elf_getdata(scn, data) != NULL
319 || data->d_off || data->d_size != shdr.sh_size)
320 error(EXIT_FAILURE, 0,
321 "Couldn't get .hash data from \"%s\"",
322 filename);
323
324 if (shdr.sh_entsize == 4) {
325 /* Standard conforming ELF. */
326 if (data->d_type != ELF_T_WORD)
327 error(EXIT_FAILURE, 0,
328 "Couldn't get .hash data from \"%s\"",
329 filename);
330 lte->hash = (Elf32_Word *) data->d_buf;
331 } else if (shdr.sh_entsize == 8) {
332 /* Alpha or s390x. */
333 Elf32_Word *dst, *src;
334 size_t hash_count = data->d_size / 8;
335
336 lte->hash = (Elf32_Word *)
337 malloc(hash_count * sizeof(Elf32_Word));
338 if (lte->hash == NULL)
339 error(EXIT_FAILURE, 0,
340 "Couldn't convert .hash section from \"%s\"",
341 filename);
342 lte->lte_flags |= LTE_HASH_MALLOCED;
343 dst = lte->hash;
344 src = (Elf32_Word *) data->d_buf;
345 if ((data->d_type == ELF_T_WORD
346 && __BYTE_ORDER == __BIG_ENDIAN)
347 || (data->d_type == ELF_T_XWORD
348 && lte->ehdr.e_ident[EI_DATA] ==
349 ELFDATA2MSB))
350 ++src;
351 for (j = 0; j < hash_count; ++j, src += 2)
352 *dst++ = *src;
353 } else
354 error(EXIT_FAILURE, 0,
355 "Unknown .hash sh_entsize in \"%s\"",
356 filename);
357 } else if (shdr.sh_type == SHT_GNU_HASH
358 && lte->hash == NULL) {
359 Elf_Data *data;
360
361 lte->hash_type = SHT_GNU_HASH;
362
363 if (shdr.sh_entsize != 0
364 && shdr.sh_entsize != 4) {
365 error(EXIT_FAILURE, 0,
366 ".gnu.hash sh_entsize in \"%s\" "
367 "should be 4, but is %#" PRIx64,
368 filename, shdr.sh_entsize);
369 }
370
371 data = loaddata(scn, &shdr);
372 if (data == NULL)
373 error(EXIT_FAILURE, 0,
374 "Couldn't get .gnu.hash data from \"%s\"",
375 filename);
376
377 lte->hash = (Elf32_Word *) data->d_buf;
378 } else if (shdr.sh_type == SHT_PROGBITS
379 || shdr.sh_type == SHT_NOBITS) {
380 if (strcmp(name, ".plt") == 0) {
381 lte->plt_addr = shdr.sh_addr;
382 lte->plt_size = shdr.sh_size;
383 if (shdr.sh_flags & SHF_EXECINSTR) {
384 lte->lte_flags |= LTE_PLT_EXECUTABLE;
385 }
386 if (lte->ehdr.e_machine == EM_PPC) {
387 plt_data = loaddata(scn, &shdr);
388 if (plt_data == NULL)
389 fprintf(stderr,
390 "Can't load .plt data\n");
391 }
392 }
393#ifdef ARCH_SUPPORTS_OPD
394 else if (strcmp(name, ".opd") == 0) {
395 lte->opd_addr = (GElf_Addr *) (long) shdr.sh_addr;
396 lte->opd_size = shdr.sh_size;
397 lte->opd = elf_rawdata(scn, NULL);
398 }
399#endif
400 }
401 }
402
403 if (lte->dynsym == NULL || lte->dynstr == NULL)
404 error(EXIT_FAILURE, 0,
405 "Couldn't find .dynsym or .dynstr in \"%s\"", filename);
406
407 if (!relplt_addr || !lte->plt_addr) {
408 debug(1, "%s has no PLT relocations", filename);
409 lte->relplt = NULL;
410 lte->relplt_count = 0;
411 } else if (relplt_size == 0) {
412 debug(1, "%s has unknown PLT size", filename);
413 lte->relplt = NULL;
414 lte->relplt_count = 0;
415 } else {
416 if (lte->ehdr.e_machine == EM_PPC) {
417 GElf_Addr glink_vma
418 = get_glink_vma(lte, ppcgot, plt_data);
419
420 assert (relplt_size % 12 == 0);
421 size_t count = relplt_size / 12; // size of RELA entry
422 lte->plt_stub_vma = glink_vma
423 - (GElf_Addr)count * PPC_PLT_STUB_SIZE;
424 debug(1, "stub_vma is %#" PRIx64, lte->plt_stub_vma);
425 }
426
427 for (i = 1; i < lte->ehdr.e_shnum; ++i) {
428 Elf_Scn *scn;
429 GElf_Shdr shdr;
430
431 scn = elf_getscn(lte->elf, i);
432 if (scn == NULL || gelf_getshdr(scn, &shdr) == NULL)
433 error(EXIT_FAILURE, 0,
434 "Couldn't get section header from \"%s\"",
435 filename);
436 if (shdr.sh_addr == relplt_addr
437 && shdr.sh_size == relplt_size) {
438 lte->relplt = elf_getdata(scn, NULL);
439 lte->relplt_count =
440 shdr.sh_size / shdr.sh_entsize;
441 if (lte->relplt == NULL
442 || elf_getdata(scn, lte->relplt) != NULL)
443 error(EXIT_FAILURE, 0,
444 "Couldn't get .rel*.plt data from \"%s\"",
445 filename);
446 break;
447 }
448 }
449
450 if (i == lte->ehdr.e_shnum)
451 error(EXIT_FAILURE, 0,
452 "Couldn't find .rel*.plt section in \"%s\"",
453 filename);
454
455 debug(1, "%s %zd PLT relocations", filename, lte->relplt_count);
456 }
457}
458
459void
460do_close_elf(struct ltelf *lte) {
461 debug(DEBUG_FUNCTION, "do_close_elf()");
462 if (lte->lte_flags & LTE_HASH_MALLOCED)
463 free((char *)lte->hash);
464 elf_end(lte->elf);
465 close(lte->fd);
466}
467
468void
469add_library_symbol(GElf_Addr addr, const char *name,
470 struct library_symbol **library_symbolspp,
471 enum toplt type_of_plt, int is_weak) {
472 struct library_symbol *s;
473
474 debug(DEBUG_FUNCTION, "add_library_symbol()");
475
476 s = malloc(sizeof(struct library_symbol) + strlen(name) + 1);
477 if (s == NULL)
478 error(EXIT_FAILURE, errno, "add_library_symbol failed");
479
480 s->needs_init = 1;
481 s->is_weak = is_weak;
482 s->plt_type = type_of_plt;
483 s->next = *library_symbolspp;
484 s->enter_addr = (void *)(uintptr_t) addr;
485 s->name = (char *)(s + 1);
486 strcpy(s->name, name);
487 *library_symbolspp = s;
488
489 debug(2, "addr: %p, symbol: \"%s\"", (void *)(uintptr_t) addr, name);
490}
491
492/* stolen from elfutils-0.123 */
493static unsigned long
494private_elf_gnu_hash(const char *name) {
495 unsigned long h = 5381;
496 const unsigned char *string = (const unsigned char *)name;
497 unsigned char c;
498 for (c = *string; c; c = *++string)
499 h = h * 33 + c;
500 return h & 0xffffffff;
501}
502
503static int
504symbol_matches(struct ltelf *lte, size_t lte_i, GElf_Sym *sym,
505 size_t symidx, const char *name)
506{
507 GElf_Sym tmp_sym;
508 GElf_Sym *tmp;
509
510 tmp = (sym) ? (sym) : (&tmp_sym);
511
512 if (gelf_getsym(lte[lte_i].dynsym, symidx, tmp) == NULL)
513 error(EXIT_FAILURE, 0, "Couldn't get symbol from .dynsym");
514 else {
515 tmp->st_value += lte[lte_i].base_addr;
516 debug(2, "symbol found: %s, %zd, %#" PRIx64,
517 name, lte_i, tmp->st_value);
518 }
519 return tmp->st_value != 0
520 && tmp->st_shndx != SHN_UNDEF
521 && strcmp(name, lte[lte_i].dynstr + tmp->st_name) == 0;
522}
523
524int
525in_load_libraries(const char *name, struct ltelf *lte, size_t count, GElf_Sym *sym) {
526 size_t i;
527 unsigned long hash;
528 unsigned long gnu_hash;
529
530 if (!count)
531 return 1;
532
533#ifdef ELF_HASH_TAKES_SIGNED_CHAR
534 hash = elf_hash(name);
535#else
536 hash = elf_hash((const unsigned char *)name);
537#endif
538 gnu_hash = private_elf_gnu_hash(name);
539
540 for (i = 0; i < count; ++i) {
541 if (lte[i].hash == NULL)
542 continue;
543
544 if (lte[i].hash_type == SHT_GNU_HASH) {
545 Elf32_Word * hashbase = lte[i].hash;
546 Elf32_Word nbuckets = *hashbase++;
547 Elf32_Word symbias = *hashbase++;
548 Elf32_Word bitmask_nwords = *hashbase++;
549 Elf32_Word * buckets;
550 Elf32_Word * chain_zero;
551 Elf32_Word bucket;
552
553 // +1 for skipped `shift'
554 hashbase += lte[i].ehdr.e_ident[EI_CLASS] * bitmask_nwords + 1;
555 buckets = hashbase;
556 hashbase += nbuckets;
557 chain_zero = hashbase - symbias;
558 bucket = buckets[gnu_hash % nbuckets];
559
560 if (bucket != 0) {
561 const Elf32_Word *hasharr = &chain_zero[bucket];
562 do
563 if ((*hasharr & ~1u) == (gnu_hash & ~1u)) {
564 int symidx = hasharr - chain_zero;
565 if (symbol_matches(lte, i,
566 sym, symidx,
567 name))
568 return 1;
569 }
570 while ((*hasharr++ & 1u) == 0);
571 }
572 } else {
573 Elf32_Word nbuckets, symndx;
574 Elf32_Word *buckets, *chain;
575 nbuckets = lte[i].hash[0];
576 buckets = &lte[i].hash[2];
577 chain = &lte[i].hash[2 + nbuckets];
578
579 for (symndx = buckets[hash % nbuckets];
580 symndx != STN_UNDEF; symndx = chain[symndx])
581 if (symbol_matches(lte, i, sym, symndx, name))
582 return 1;
583 }
584 }
585 return 0;
586}
587
588static GElf_Addr
589opd2addr(struct ltelf *lte, GElf_Addr addr) {
590#ifdef ARCH_SUPPORTS_OPD
591 unsigned long base, offset;
592
593 if (!lte->opd)
594 return addr;
595
596 base = (unsigned long)lte->opd->d_buf;
597 offset = (unsigned long)addr - (unsigned long)lte->opd_addr;
598 if (offset > lte->opd_size)
599 error(EXIT_FAILURE, 0, "static plt not in .opd");
600
601 return *(GElf_Addr*)(base + offset);
602#else //!ARCH_SUPPORTS_OPD
603 return addr;
604#endif
605}
606
607struct library_symbol *
608read_elf(Process *proc) {
609 struct ltelf lte[MAX_LIBRARIES + 1];
610 size_t i;
611 struct opt_x_t *xptr;
612 struct library_symbol **lib_tail = NULL;
613 int exit_out = 0;
614 int count = 0;
615
616 debug(DEBUG_FUNCTION, "read_elf(file=%s)", proc->filename);
617
618 memset(lte, 0, sizeof(*lte));
619 library_symbols = NULL;
620 library_num = 0;
621 proc->libdl_hooked = 0;
622
623 elf_version(EV_CURRENT);
624
625 do_init_elf(lte, proc->filename);
626
627 memcpy(&main_lte, lte, sizeof(struct ltelf));
628
629 if (opt_p && opt_p->pid > 0) {
630 linkmap_init(proc, lte);
631 proc->libdl_hooked = 1;
632 }
633
634 proc->e_machine = lte->ehdr.e_machine;
635
636 for (i = 0; i < library_num; ++i) {
637 do_init_elf(&lte[i + 1], library[i]);
638 }
639
640 if (!options.no_plt) {
641#ifdef __mips__
642 // MIPS doesn't use the PLT and the GOT entries get changed
643 // on startup.
644 proc->need_to_reinitialize_breakpoints = 1;
645 for(i=lte->mips_gotsym; i<lte->dynsym_count;i++){
646 GElf_Sym sym;
647 const char *name;
648 GElf_Addr addr = arch_plt_sym_val(lte, i, 0);
649 if (gelf_getsym(lte->dynsym, i, &sym) == NULL){
650 error(EXIT_FAILURE, 0,
651 "Couldn't get relocation from \"%s\"",
652 proc->filename);
653 }
654 name=lte->dynstr+sym.st_name;
655 if(ELF64_ST_TYPE(sym.st_info) != STT_FUNC){
656 debug(2,"sym %s not a function",name);
657 continue;
658 }
659 add_library_symbol(addr, name, &library_symbols, 0,
660 ELF64_ST_BIND(sym.st_info) != 0);
661 if (!lib_tail)
662 lib_tail = &(library_symbols->next);
663 }
664#else
665 for (i = 0; i < lte->relplt_count; ++i) {
666 GElf_Rel rel;
667 GElf_Rela rela;
668 GElf_Sym sym;
669 GElf_Addr addr;
670 void *ret;
671 const char *name;
672
673 if (lte->relplt->d_type == ELF_T_REL) {
674 ret = gelf_getrel(lte->relplt, i, &rel);
675 rela.r_offset = rel.r_offset;
676 rela.r_info = rel.r_info;
677 rela.r_addend = 0;
678 } else
679 ret = gelf_getrela(lte->relplt, i, &rela);
680
681 if (ret == NULL
682 || ELF64_R_SYM(rela.r_info) >= lte->dynsym_count
683 || gelf_getsym(lte->dynsym, ELF64_R_SYM(rela.r_info),
684 &sym) == NULL)
685 error(EXIT_FAILURE, 0,
686 "Couldn't get relocation from \"%s\"",
687 proc->filename);
688
689#ifdef PLT_REINITALISATION_BP
690 if (!sym.st_value && PLTs_initialized_by_here)
691 proc->need_to_reinitialize_breakpoints = 1;
692#endif
693
694 name = lte->dynstr + sym.st_name;
695 count = library_num ? library_num+1 : 0;
696
697 if (in_load_libraries(name, lte, count, NULL)) {
698 enum toplt pltt;
699 if (sym.st_value == 0 && lte->plt_stub_vma != 0) {
700 pltt = LS_TOPLT_EXEC;
701 addr = lte->plt_stub_vma + PPC_PLT_STUB_SIZE * i;
702 }
703 else {
704 pltt = PLTS_ARE_EXECUTABLE(lte)
705 ? LS_TOPLT_EXEC : LS_TOPLT_POINT;
706 addr = arch_plt_sym_val(lte, i, &rela);
707 }
708
709 add_library_symbol(addr, name, &library_symbols, pltt,
710 ELF64_ST_BIND(sym.st_info) == STB_WEAK);
711 if (!lib_tail)
712 lib_tail = &(library_symbols->next);
713 }
714 }
715#endif // !__mips__
716#ifdef PLT_REINITALISATION_BP
717 struct opt_x_t *main_cheat;
718
719 if (proc->need_to_reinitialize_breakpoints) {
720 /* Add "PLTs_initialized_by_here" to opt_x list, if not
721 already there. */
722 main_cheat = (struct opt_x_t *)malloc(sizeof(struct opt_x_t));
723 if (main_cheat == NULL)
724 error(EXIT_FAILURE, 0, "Couldn't allocate memory");
725 main_cheat->next = opt_x;
726 main_cheat->found = 0;
727 main_cheat->name = PLTs_initialized_by_here;
728
729 for (xptr = opt_x; xptr; xptr = xptr->next)
730 if (strcmp(xptr->name, PLTs_initialized_by_here) == 0
731 && main_cheat) {
732 free(main_cheat);
733 main_cheat = NULL;
734 break;
735 }
736 if (main_cheat)
737 opt_x = main_cheat;
738 }
739#endif
740 } else {
741 lib_tail = &library_symbols;
742 }
743
744 for (i = 0; i < lte->symtab_count; ++i) {
745 GElf_Sym sym;
746 GElf_Addr addr;
747 const char *name;
748
749 if (gelf_getsym(lte->symtab, i, &sym) == NULL)
750 error(EXIT_FAILURE, 0,
751 "Couldn't get symbol from \"%s\"",
752 proc->filename);
753
754 name = lte->strtab + sym.st_name;
755 addr = sym.st_value;
756 if (!addr)
757 continue;
758
759 for (xptr = opt_x; xptr; xptr = xptr->next)
760 if (xptr->name && strcmp(xptr->name, name) == 0) {
761 /* FIXME: Should be able to use &library_symbols as above. But
762 when you do, none of the real library symbols cause breaks. */
763 add_library_symbol(opd2addr(lte, addr),
764 name, lib_tail, LS_TOPLT_NONE, 0);
765 xptr->found = 1;
766 break;
767 }
768 }
769
770 unsigned found_count = 0;
771
772 for (xptr = opt_x; xptr; xptr = xptr->next) {
773 if (xptr->found)
774 continue;
775
776 GElf_Sym sym;
777 GElf_Addr addr;
778 if (in_load_libraries(xptr->name, lte, library_num+1, &sym)) {
779 debug(2, "found symbol %s @ %#" PRIx64 ", adding it.",
780 xptr->name, sym.st_value);
781 addr = sym.st_value;
782 if (ELF32_ST_TYPE (sym.st_info) == STT_FUNC) {
783 add_library_symbol(addr, xptr->name, lib_tail, LS_TOPLT_NONE, 0);
784 xptr->found = 1;
785 found_count++;
786 }
787 }
788 if (found_count == opt_x_cnt){
789 debug(2, "done, found everything: %d\n", found_count);
790 break;
791 }
792 }
793
794 for (xptr = opt_x; xptr; xptr = xptr->next)
795 if ( ! xptr->found) {
796 char *badthing = "WARNING";
797#ifdef PLT_REINITALISATION_BP
798 if (strcmp(xptr->name, PLTs_initialized_by_here) == 0) {
799 if (lte->ehdr.e_entry) {
800 add_library_symbol (
801 opd2addr (lte, lte->ehdr.e_entry),
802 PLTs_initialized_by_here,
803 lib_tail, 1, 0);
804 fprintf (stderr, "WARNING: Using e_ent"
805 "ry from elf header (%p) for "
806 "address of \"%s\"\n", (void*)
807 (long) lte->ehdr.e_entry,
808 PLTs_initialized_by_here);
809 continue;
810 }
811 badthing = "ERROR";
812 exit_out = 1;
813 }
814#endif
815 fprintf (stderr,
816 "%s: Couldn't find symbol \"%s\" in file \"%s\" assuming it will be loaded by libdl!"
817 "\n", badthing, xptr->name, proc->filename);
818 }
819 if (exit_out) {
820 exit (1);
821 }
822
823 for (i = 0; i < library_num + 1; ++i)
824 do_close_elf(&lte[i]);
825
826 return library_symbols;
827}
0828
=== added file 'ltrace-elf.h'
--- ltrace-elf.h 1970-01-01 00:00:00 +0000
+++ ltrace-elf.h 2011-03-15 17:56:13 +0000
@@ -0,0 +1,63 @@
1#ifndef LTRACE_ELF_H
2#define LTRACE_ELF_H
3
4#include <gelf.h>
5#include <stdlib.h>
6
7struct ltelf {
8 int fd;
9 Elf *elf;
10 GElf_Ehdr ehdr;
11 Elf_Data *dynsym;
12 size_t dynsym_count;
13 const char *dynstr;
14 GElf_Addr plt_addr;
15 size_t plt_size;
16 Elf_Data *relplt;
17 size_t relplt_count;
18 Elf_Data *symtab;
19 const char *strtab;
20 size_t symtab_count;
21 Elf_Data *opd;
22 GElf_Addr *opd_addr;
23 size_t opd_size;
24 Elf32_Word *hash;
25 int hash_type;
26 int lte_flags;
27 GElf_Addr dyn_addr;
28 size_t dyn_sz;
29 GElf_Addr base_addr;
30#ifdef __mips__
31 size_t pltgot_addr;
32 size_t mips_local_gotno;
33 size_t mips_gotsym;
34#endif // __mips__
35 GElf_Addr plt_stub_vma;
36};
37
38#define ELF_MAX_SEGMENTS 50
39#define LTE_HASH_MALLOCED 1
40#define LTE_PLT_EXECUTABLE 2
41
42#define PLTS_ARE_EXECUTABLE(lte) ((lte->lte_flags & LTE_PLT_EXECUTABLE) != 0)
43
44extern size_t library_num;
45extern char *library[MAX_LIBRARIES];
46
47extern struct library_symbol *read_elf(Process *);
48
49extern GElf_Addr arch_plt_sym_val(struct ltelf *, size_t, GElf_Rela *);
50
51#ifndef SHT_GNU_HASH
52#define SHT_GNU_HASH 0x6ffffff6 /* GNU-style hash table. */
53#endif
54
55#if __WORDSIZE == 32
56#define PRI_ELF_ADDR PRIx32
57#define GELF_ADDR_CAST(x) (void *)(uint32_t)(x)
58#else
59#define PRI_ELF_ADDR PRIx64
60#define GELF_ADDR_CAST(x) (void *)(x)
61#endif
62
63#endif
064
=== modified file 'ltrace.1'
--- ltrace.1 2009-07-28 16:44:35 +0000
+++ ltrace.1 2011-03-15 17:56:13 +0000
@@ -6,7 +6,7 @@
66
7.SH SYNOPSIS7.SH SYNOPSIS
8.B ltrace8.B ltrace
9.I "[-CfhiLrStttV] [-a column] [-A maxelts] [-D level] [-e expr] [-l filename] [-n nr] [-o filename] [-p pid] ... [-s strsize] [-u username] [-X extern] [-x extern] ... [--align=column] [--debug=level] [--demangle] [--help] [--indent=nr] [--library=filename] [--output=filename] [--version] [command [arg ...]]"9.I "[-bCfghiLrStttV] [-a column] [-A maxelts] [-D level] [-e expr] [-l filename] [-n nr] [-o filename] [-p pid] ... [-s strsize] [-u username] [-w count] [-X extern] [-x extern] ... [--align=column] [--debug=level] [--demangle] [--help] [--indent=nr] [--library=filename] [--no-signals] [--output=filename] [--version] [--where=NR] [command [arg ...]]"
1010
11.SH DESCRIPTION11.SH DESCRIPTION
12.B ltrace12.B ltrace
@@ -23,11 +23,16 @@
23.SH OPTIONS23.SH OPTIONS
24.TP24.TP
25.I \-a, \-\-align column25.I \-a, \-\-align column
26Align return values in a specific column (default column is 5/8 of screen width).26Align return values in a specific
27.IR column
28(default column is 5/8 of screen width).
27.TP29.TP
28.I \-A maxelts30.I \-A maxelts
29Maximum number of array elements to print before suppressing the rest with an ellipsis ("...")31Maximum number of array elements to print before suppressing the rest with an ellipsis ("...")
30.TP32.TP
33.I \-b, \-\-no-signals
34Disable printing of signals recieved by the traced process.
35.TP
31.I \-c36.I \-c
32Count time and calls for each library call and report a summary on program exit.37Count time and calls for each library call and report a summary on program exit.
33.TP38.TP
@@ -82,6 +87,11 @@
82or clone(2) system calls.87or clone(2) system calls.
83The new process is attached immediately.88The new process is attached immediately.
84.TP89.TP
90.I \-g
91Do not place breakpoints on PLT entries. This option reduces
92the output of ltrace. This is commonly used to avoid tracing
93libc functions.
94.TP
85.I \-F95.I \-F
86Load an alternate config file. Normally, /etc/ltrace.conf and96Load an alternate config file. Normally, /etc/ltrace.conf and
87~/.ltrace.conf will be read (the latter only if it exists).97~/.ltrace.conf will be read (the latter only if it exists).
@@ -153,6 +163,10 @@
153This option is only useful when running as root and enables the163This option is only useful when running as root and enables the
154correct execution of setuid and/or setgid binaries.164correct execution of setuid and/or setgid binaries.
155.TP165.TP
166.I \-w, --where NR
167Show backtrace of NR stack frames for each traced function. This option enabled
168only if libunwind support was enabled at compile time.
169.TP
156.I \-X extern170.I \-X extern
157Some architectures need to know where to set a breakpoint that will be hit171Some architectures need to know where to set a breakpoint that will be hit
158after the dynamic linker has run. If this flag is used, then the breakpoint172after the dynamic linker has run. If this flag is used, then the breakpoint
@@ -164,6 +178,8 @@
164.I \-x extern178.I \-x extern
165Trace the external function179Trace the external function
166.IR extern .180.IR extern .
181This option will search the symbol table and lib-dl loaded libraries when
182attempting to match the given symbol name.
167This option may be repeated.183This option may be repeated.
168.TP184.TP
169.I \-V, \-\-version185.I \-V, \-\-version
@@ -179,9 +195,6 @@
179.LP195.LP
180It only works on Linux and in a small subset of architectures.196It only works on Linux and in a small subset of architectures.
181.LP197.LP
182Only ELF32 binaries are supported.
183.LP
184Calls to dlopen()ed libraries will not be traced.
185.PP198.PP
186If you would like to report a bug, send a message to the mailing list199If you would like to report a bug, send a message to the mailing list
187(ltrace-devel@lists.alioth.debian.org), or use the200(ltrace-devel@lists.alioth.debian.org), or use the
188201
=== removed file 'mkdist'
--- mkdist 2009-07-25 16:24:38 +0000
+++ mkdist 1970-01-01 00:00:00 +0000
@@ -1,19 +0,0 @@
1#!/bin/sh -e
2
3# Create ltrace-${version}.tar.gz from a GIT repository
4
5if [ ! -d .git -o ! -f libltrace.c ]
6then
7 echo "This must be called inside a ltrace GIT repository" 1>&2
8 exit 1
9fi
10
11VERSION=$( cat VERSION )
12
13echo Building ltrace-$VERSION.tar.gz ...
14rm -rf ltrace-$VERSION
15git clone ./ ltrace-$VERSION >/dev/null
16GZIP=-9 tar --exclude .git -zcf ltrace-$VERSION.tar.gz ltrace-$VERSION
17rm -rf ltrace-$VERSION
18echo Done.
19
200
=== modified file 'options.c'
--- options.c 2009-07-28 16:44:35 +0000
+++ options.c 2011-03-15 17:56:13 +0000
@@ -37,7 +37,7 @@
37};37};
3838
39char *library[MAX_LIBRARIES];39char *library[MAX_LIBRARIES];
40int library_num = 0;40size_t library_num = 0;
41static char *progname; /* Program name (`ltrace') */41static char *progname; /* Program name (`ltrace') */
42int opt_i = 0; /* instruction pointer */42int opt_i = 0; /* instruction pointer */
43int opt_r = 0; /* print relative timestamp */43int opt_r = 0; /* print relative timestamp */
@@ -53,6 +53,7 @@
5353
54/* List of global function names given to -x: */54/* List of global function names given to -x: */
55struct opt_x_t *opt_x = NULL;55struct opt_x_t *opt_x = NULL;
56unsigned int opt_x_cnt = 0;
5657
57/* List of filenames give to option -F: */58/* List of filenames give to option -F: */
58struct opt_F_t *opt_F = NULL; /* alternate configuration file(s) */59struct opt_F_t *opt_F = NULL; /* alternate configuration file(s) */
@@ -75,6 +76,7 @@
75 "Trace library calls of a given program.\n\n"76 "Trace library calls of a given program.\n\n"
76 " -a, --align=COLUMN align return values in a secific column.\n"77 " -a, --align=COLUMN align return values in a secific column.\n"
77 " -A ARRAYLEN maximum number of array elements to print.\n"78 " -A ARRAYLEN maximum number of array elements to print.\n"
79 " -b, --no-signals don't print signals.\n"
78 " -c count time and calls, and report a summary on exit.\n"80 " -c count time and calls, and report a summary on exit.\n"
79# ifdef USE_DEMANGLE81# ifdef USE_DEMANGLE
80 " -C, --demangle decode low-level symbol names into user-level names.\n"82 " -C, --demangle decode low-level symbol names into user-level names.\n"
@@ -84,6 +86,7 @@
84 " -e expr modify which events to trace.\n"86 " -e expr modify which events to trace.\n"
85 " -f trace children (fork() and clone()).\n"87 " -f trace children (fork() and clone()).\n"
86 " -F, --config=FILE load alternate configuration file (may be repeated).\n"88 " -F, --config=FILE load alternate configuration file (may be repeated).\n"
89 " -g, --no-plt disable breakpoints on PLT entries.\n"
87 " -h, --help display this help and exit.\n"90 " -h, --help display this help and exit.\n"
88 " -i print instruction pointer at time of library call.\n"91 " -i print instruction pointer at time of library call.\n"
89 " -l, --library=FILE print library calls from this library only.\n"92 " -l, --library=FILE print library calls from this library only.\n"
@@ -98,6 +101,9 @@
98 " -T show the time spent inside each call.\n"101 " -T show the time spent inside each call.\n"
99 " -u USERNAME run command with the userid, groupid of username.\n"102 " -u USERNAME run command with the userid, groupid of username.\n"
100 " -V, --version output version information and exit.\n"103 " -V, --version output version information and exit.\n"
104#if defined(HAVE_LIBUNWIND)
105 " -w=NR, --where=NR print backtrace showing NR stack frames at most.\n"
106#endif /* defined(HAVE_LIBUNWIND) */
101 " -x NAME treat the global NAME like a library subroutine.\n"107 " -x NAME treat the global NAME like a library subroutine.\n"
102#ifdef PLT_REINITALISATION_BP108#ifdef PLT_REINITALISATION_BP
103 " -X NAME same as -x; and PLT's will be initialized by here.\n"109 " -X NAME same as -x; and PLT's will be initialized by here.\n"
@@ -179,6 +185,11 @@
179process_options(int argc, char **argv) {185process_options(int argc, char **argv) {
180 progname = argv[0];186 progname = argv[0];
181 options.output = stderr;187 options.output = stderr;
188 options.no_plt = 0;
189 options.no_signals = 0;
190#if defined(HAVE_LIBUNWIND)
191 options.bt_depth = -1;
192#endif /* defined(HAVE_LIBUNWIND) */
182193
183 guess_cols();194 guess_cols();
184195
@@ -198,13 +209,22 @@
198 {"library", 1, 0, 'l'},209 {"library", 1, 0, 'l'},
199 {"output", 1, 0, 'o'},210 {"output", 1, 0, 'o'},
200 {"version", 0, 0, 'V'},211 {"version", 0, 0, 'V'},
212 {"no-plt", 0, 0, 'g'},
213 {"no-signals", 0, 0, 'b'},
214#if defined(HAVE_LIBUNWIND)
215 {"where", 1, 0, 'w'},
216#endif /* defined(HAVE_LIBUNWIND) */
201 {0, 0, 0, 0}217 {0, 0, 0, 0}
202 };218 };
203 c = getopt_long(argc, argv, "+cfhiLrStTV"219 c = getopt_long(argc, argv, "+cfhiLrStTVgb"
204# ifdef USE_DEMANGLE220# ifdef USE_DEMANGLE
205 "C"221 "C"
206# endif222# endif
223#if defined(HAVE_LIBUNWIND)
224 "a:A:D:e:F:l:n:o:p:s:u:x:X:w:", long_options,
225#else /* !defined(HAVE_LIBUNWIND) */
207 "a:A:D:e:F:l:n:o:p:s:u:x:X:", long_options,226 "a:A:D:e:F:l:n:o:p:s:u:x:X:", long_options,
227#endif
208 &option_index);228 &option_index);
209 if (c == -1) {229 if (c == -1) {
210 break;230 break;
@@ -216,6 +236,9 @@
216 case 'A':236 case 'A':
217 options.arraylen = atoi(optarg);237 options.arraylen = atoi(optarg);
218 break;238 break;
239 case 'b':
240 options.no_signals = 1;
241 break;
219 case 'c':242 case 'c':
220 options.summary++;243 options.summary++;
221 break;244 break;
@@ -283,6 +306,9 @@
283 opt_F = tmp;306 opt_F = tmp;
284 break;307 break;
285 }308 }
309 case 'g':
310 options.no_plt = 1;
311 break;
286 case 'h':312 case 'h':
287 usage();313 usage();
288 exit(0);314 exit(0);
@@ -351,6 +377,12 @@
351 "This is free software; see the GNU General Public Licence\n"377 "This is free software; see the GNU General Public Licence\n"
352 "version 2 or later for copying conditions. There is NO warranty.\n");378 "version 2 or later for copying conditions. There is NO warranty.\n");
353 exit(0);379 exit(0);
380 break;
381#if defined(HAVE_LIBUNWIND)
382 case 'w':
383 options.bt_depth = atoi(optarg);
384 break;
385#endif /* defined(HAVE_LIBUNWIND) */
354 case 'X':386 case 'X':
355#ifdef PLT_REINITALISATION_BP387#ifdef PLT_REINITALISATION_BP
356 PLTs_initialized_by_here = optarg;388 PLTs_initialized_by_here = optarg;
@@ -378,9 +410,11 @@
378 perror("ltrace: malloc");410 perror("ltrace: malloc");
379 exit(1);411 exit(1);
380 }412 }
413 opt_x_cnt++;
381 p->name = optarg;414 p->name = optarg;
382 p->found = 0;415 p->found = 0;
383 p->next = opt_x;416 p->next = opt_x;
417 p->hash = ~(0UL);
384 opt_x = p;418 opt_x = p;
385 break;419 break;
386 }420 }
387421
=== modified file 'options.h'
--- options.h 2009-07-28 16:44:35 +0000
+++ options.h 2011-03-15 17:56:13 +0000
@@ -2,18 +2,23 @@
2#include <sys/types.h>2#include <sys/types.h>
33
4struct options_t {4struct options_t {
5 int align; /* -a: default alignment column for results */5 int align; /* -a: default alignment column for results */
6 char * user; /* -u: username to run command as */6 char * user; /* -u: username to run command as */
7 int syscalls; /* -S: display system calls */7 int syscalls; /* -S: display system calls */
8 int libcalls; /* -L: display library calls */8 int libcalls; /* -L: display library calls */
9 int demangle; /* -C: demangle low-level names into user-level names */9 int demangle; /* -C: demangle low-level names into user-level names */
10 int indent; /* -n: indent trace output according to program flow */10 int indent; /* -n: indent trace output according to program flow */
11 FILE *output; /* output to a specific file */11 FILE *output; /* output to a specific file */
12 int summary; /* count time, calls, and report a summary on program exit */12 int summary; /* count time, calls, and report a summary on program exit */
13 int debug; /* debug */13 int debug; /* debug */
14 int arraylen; /* default maximum # of array elements printed */14 size_t arraylen; /* default maximum # of array elements printed */
15 int strlen; /* default maximum # of bytes printed in strings */15 size_t strlen; /* default maximum # of bytes printed in strings */
16 int follow; /* trace child processes */16 int follow; /* trace child processes */
17 int no_plt; /* set bps on PLT entries */
18 int no_signals; /* don't print signals */
19#if defined(HAVE_LIBUNWIND)
20 int bt_depth; /* how may levels of stack frames to show */
21#endif /* defined(HAVE_LIBUNWIND) */
17};22};
18extern struct options_t options;23extern struct options_t options;
1924
@@ -40,6 +45,7 @@
40struct opt_x_t {45struct opt_x_t {
41 char *name;46 char *name;
42 int found;47 int found;
48 unsigned long hash;
43 struct opt_x_t *next;49 struct opt_x_t *next;
44};50};
4551
@@ -51,5 +57,6 @@
51extern struct opt_F_t *opt_F; /* alternate configuration file(s) */57extern struct opt_F_t *opt_F; /* alternate configuration file(s) */
5258
53extern struct opt_x_t *opt_x; /* list of functions to break at */59extern struct opt_x_t *opt_x; /* list of functions to break at */
60extern unsigned int opt_x_cnt;
5461
55extern char **process_options(int argc, char **argv);62extern char **process_options(int argc, char **argv);
5663
=== modified file 'output.c'
--- output.c 2009-07-28 16:44:35 +0000
+++ output.c 2011-03-15 17:56:13 +0000
@@ -164,7 +164,6 @@
164 }164 }
165 if (current_proc) {165 if (current_proc) {
166 fprintf(options.output, " <unfinished ...>\n");166 fprintf(options.output, " <unfinished ...>\n");
167 current_proc = 0;
168 current_column = 0;167 current_column = 0;
169 }168 }
170 current_proc = proc;169 current_proc = proc;
@@ -298,6 +297,28 @@
298 (int)current_time_spent.tv_usec);297 (int)current_time_spent.tv_usec);
299 }298 }
300 fprintf(options.output, "\n");299 fprintf(options.output, "\n");
300
301#if defined(HAVE_LIBUNWIND)
302 if (options.bt_depth > 0) {
303 unw_cursor_t cursor;
304 unw_word_t ip, sp;
305 int unwind_depth = options.bt_depth;
306 char fn_name[100];
307
308 unw_init_remote(&cursor, proc->unwind_as, proc->unwind_priv);
309 while (unwind_depth) {
310 unw_get_reg(&cursor, UNW_REG_IP, &ip);
311 unw_get_reg(&cursor, UNW_REG_SP, &sp);
312 unw_get_proc_name(&cursor, fn_name, 100, NULL);
313 fprintf(options.output, "\t\t\t%s (ip = 0x%lx)\n", fn_name, (long) ip);
314 if (unw_step(&cursor) <= 0)
315 break;
316 unwind_depth--;
317 }
318 fprintf(options.output, "\n");
319 }
320#endif /* defined(HAVE_LIBUNWIND) */
321
301 current_proc = 0;322 current_proc = 0;
302 current_column = 0;323 current_column = 0;
303}324}
304325
=== modified file 'proc.c'
--- proc.c 2009-07-28 16:44:35 +0000
+++ proc.c 2011-03-15 17:56:13 +0000
@@ -1,3 +1,10 @@
1#include "config.h"
2
3#if defined(HAVE_LIBUNWIND)
4#include <libunwind.h>
5#include <libunwind-ptrace.h>
6#endif /* defined(HAVE_LIBUNWIND) */
7
1#include <sys/types.h>8#include <sys/types.h>
2#include <string.h>9#include <string.h>
3#include <stdio.h>10#include <stdio.h>
@@ -18,11 +25,21 @@
18 proc->breakpoints_enabled = -1;25 proc->breakpoints_enabled = -1;
19 if (pid) {26 if (pid) {
20 proc->pid = pid;27 proc->pid = pid;
28#if defined(HAVE_LIBUNWIND)
29 proc->unwind_priv = _UPT_create(pid);
30 } else {
31 proc->unwind_priv = NULL;
32#endif /* defined(HAVE_LIBUNWIND) */
21 }33 }
34
22 breakpoints_init(proc);35 breakpoints_init(proc);
2336
24 proc->next = list_of_processes;37 proc->next = list_of_processes;
25 list_of_processes = proc;38 list_of_processes = proc;
39
40#if defined(HAVE_LIBUNWIND)
41 proc->unwind_as = unw_create_addr_space(&_UPT_accessors, 0);
42#endif /* defined(HAVE_LIBUNWIND) */
26 return proc;43 return proc;
27}44}
2845
2946
=== added file 'sysdeps/Makefile.am'
--- sysdeps/Makefile.am 1970-01-01 00:00:00 +0000
+++ sysdeps/Makefile.am 2011-03-15 17:56:13 +0000
@@ -0,0 +1,11 @@
1DIST_SUBDIRS = \
2 linux-gnu
3
4SUBDIRS = \
5 $(HOST_OS)
6
7noinst_HEADERS = \
8 sysdep.h
9
10MAINTAINERCLEANFILES = \
11 Makefile.in
012
=== modified file 'sysdeps/README'
--- sysdeps/README 2009-07-28 16:44:35 +0000
+++ sysdeps/README 2011-03-15 17:56:13 +0000
@@ -30,3 +30,4 @@
30void trace_me(void);30void trace_me(void);
31int trace_pid(pid_t pid);31int trace_pid(pid_t pid);
32void untrace_pid(pid_t pid);32void untrace_pid(pid_t pid);
33void linkmap_init(Process *, struct ltelf *);
3334
=== removed file 'sysdeps/linux-gnu/Makefile'
--- sysdeps/linux-gnu/Makefile 2009-07-28 16:44:35 +0000
+++ sysdeps/linux-gnu/Makefile 1970-01-01 00:00:00 +0000
@@ -1,60 +0,0 @@
1ARCH := $(shell uname -m | sed \
2 -e s/i.86/i386/ \
3 -e s/sun4u/sparc64/ \
4 -e s/sparc64/sparc/ \
5 -e s/arm.*/arm/ \
6 -e s/sa110/arm/ \
7 -e s/ppc64/ppc/ \
8 -e s/s390x/s390/ \
9 )
10
11CPPFLAGS += -I$(TOPDIR)/sysdeps/linux-gnu/$(ARCH)
12
13OBJ = events.o trace.o proc.o breakpoint.o
14
15all: sysdep.h signalent.h syscallent.h arch_syscallent.h signalent1.h syscallent1.h ../sysdep.o
16
17sysdep.h: $(ARCH)/arch.h
18 cat $(ARCH)/arch.h > sysdep.h
19
20signalent.h:
21 cp $(ARCH)/signalent.h signalent.h
22signalent1.h:
23 if [ -f $(ARCH)/signalent1.h ]; then \
24 cp $(ARCH)/signalent1.h signalent1.h; \
25 else \
26 > signalent1.h; \
27 fi
28
29syscallent.h:
30 cp $(ARCH)/syscallent.h syscallent.h
31
32syscallent1.h:
33 if [ -f $(ARCH)/syscallent1.h ]; then \
34 cp $(ARCH)/syscallent1.h syscallent1.h; \
35 else \
36 > syscallent1.h; \
37 fi
38
39arch_syscallent.h:
40 if [ -f $(ARCH)/arch_syscallent.h ]; then \
41 cp $(ARCH)/arch_syscallent.h arch_syscallent.h; \
42 else \
43 > arch_syscallent.h; \
44 fi
45
46../sysdep.o: os.o $(ARCH)/arch.o
47 $(CC) -nostdlib -r -o ../sysdep.o os.o $(ARCH)/arch.o
48
49os.o: $(OBJ)
50 $(CC) -nostdlib -r -o os.o $(OBJ)
51
52$(ARCH)/arch.o: dummy
53 $(MAKE) -C $(ARCH)
54
55clean:
56 $(MAKE) -C $(ARCH) clean
57 rm -f $(OBJ) sysdep.h signalent.h signalent1.h syscallent.h arch_syscallent.h
58 rm -f syscallent1.h os.o sysdep.o ../sysdep.o
59
60dummy:
610
=== added file 'sysdeps/linux-gnu/Makefile.am'
--- sysdeps/linux-gnu/Makefile.am 1970-01-01 00:00:00 +0000
+++ sysdeps/linux-gnu/Makefile.am 2011-03-15 17:56:13 +0000
@@ -0,0 +1,40 @@
1DIST_SUBDIRS = \
2 alpha \
3 arm \
4 i386 \
5 ia64 \
6 m68k \
7 mipsel \
8 ppc \
9 s390 \
10 sparc \
11 x86_64
12
13SUBDIRS = \
14 $(HOST_CPU)
15
16noinst_LTLIBRARIES = \
17 ../libos.la
18
19___libos_la_SOURCES = \
20 events.c \
21 trace.c \
22 proc.c \
23 breakpoint.c
24
25___libos_la_LIBADD = \
26 libcpu.la
27
28noinst_HEADERS = \
29 arch_syscallent.h \
30 signalent1.h \
31 syscallent1.h
32
33EXTRA_DIST = \
34 arch_mksyscallent \
35 mksignalent \
36 mksyscallent \
37 mksyscallent_s390
38
39MAINTAINERCLEANFILES = \
40 Makefile.in
041
=== removed file 'sysdeps/linux-gnu/alpha/Makefile'
--- sysdeps/linux-gnu/alpha/Makefile 2008-05-27 10:51:22 +0000
+++ sysdeps/linux-gnu/alpha/Makefile 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1OBJ = trace.o regs.o plt.o
2
3all: arch.o
4
5arch.o: $(OBJ)
6 $(CC) -nostdlib -r -o arch.o $(OBJ)
7
8clean:
9 $(RM) $(OBJ) arch.o
10
110
=== added file 'sysdeps/linux-gnu/alpha/Makefile.am'
--- sysdeps/linux-gnu/alpha/Makefile.am 1970-01-01 00:00:00 +0000
+++ sysdeps/linux-gnu/alpha/Makefile.am 2011-03-15 17:56:13 +0000
@@ -0,0 +1,16 @@
1noinst_LTLIBRARIES = \
2 ../libcpu.la
3
4___libcpu_la_SOURCES = \
5 plt.c \
6 regs.c \
7 trace.c
8
9noinst_HEADERS = \
10 arch.h \
11 ptrace.h \
12 signalent.h \
13 syscallent.h
14
15MAINTAINERCLEANFILES = \
16 Makefile.in
017
=== added file 'sysdeps/linux-gnu/arch_syscallent.h'
--- sysdeps/linux-gnu/arch_syscallent.h 1970-01-01 00:00:00 +0000
+++ sysdeps/linux-gnu/arch_syscallent.h 2011-03-15 17:56:13 +0000
@@ -0,0 +1,1 @@
1/* This file is intentionally left blank */
02
=== removed file 'sysdeps/linux-gnu/arm/Makefile'
--- sysdeps/linux-gnu/arm/Makefile 2009-01-06 17:46:28 +0000
+++ sysdeps/linux-gnu/arm/Makefile 1970-01-01 00:00:00 +0000
@@ -1,10 +0,0 @@
1OBJ = trace.o regs.o plt.o breakpoint.o
2
3all: arch.o
4
5arch.o: $(OBJ) arch.h
6 $(CC) -nostdlib -r -o arch.o $(OBJ)
7
8clean:
9 $(RM) $(OBJ) arch.o
10
110
=== added file 'sysdeps/linux-gnu/arm/Makefile.am'
--- sysdeps/linux-gnu/arm/Makefile.am 1970-01-01 00:00:00 +0000
+++ sysdeps/linux-gnu/arm/Makefile.am 2011-03-15 17:56:13 +0000
@@ -0,0 +1,18 @@
1noinst_LTLIBRARIES = \
2 ../libcpu.la
3
4___libcpu_la_SOURCES = \
5 breakpoint.c \
6 plt.c \
7 regs.c \
8 trace.c
9
10noinst_HEADERS = \
11 arch.h \
12 arch_syscallent.h \
13 ptrace.h \
14 signalent.h \
15 syscallent.h
16
17MAINTAINERCLEANFILES = \
18 Makefile.in
019
=== modified file 'sysdeps/linux-gnu/arm/plt.c'
--- sysdeps/linux-gnu/arm/plt.c 2009-07-28 16:44:35 +0000
+++ sysdeps/linux-gnu/arm/plt.c 2011-03-15 17:56:13 +0000
@@ -1,9 +1,21 @@
1#include <gelf.h>1#include <gelf.h>
2#include "common.h"2#include "common.h"
33
4static int
5arch_plt_entry_has_stub(struct ltelf *lte, size_t off) {
6 uint16_t op = *(uint16_t *)((char *)lte->relplt->d_buf + off);
7 return op == 0x4778;
8}
9
4GElf_Addr10GElf_Addr
5arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela * rela) {11arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela * rela) {
6 return lte->plt_addr + 20 + ndx * 12;12 size_t start = lte->relplt->d_size + 12;
13 size_t off = start + 20, i;
14 for (i = 0; i < ndx; i++)
15 off += arch_plt_entry_has_stub(lte, off) ? 16 : 12;
16 if (arch_plt_entry_has_stub(lte, off))
17 off += 4;
18 return lte->plt_addr + off - start;
7}19}
820
9void *21void *
1022
=== modified file 'sysdeps/linux-gnu/arm/regs.c'
--- sysdeps/linux-gnu/arm/regs.c 2009-07-28 16:44:35 +0000
+++ sysdeps/linux-gnu/arm/regs.c 2011-03-15 17:56:13 +0000
@@ -47,5 +47,6 @@
4747
48void48void
49set_return_addr(Process *proc, void *addr) {49set_return_addr(Process *proc, void *addr) {
50 ptrace(PTRACE_POKEUSER, proc->pid, off_lr, addr);50 long iaddr = (int)addr | proc->thumb_mode;
51 ptrace(PTRACE_POKEUSER, proc->pid, off_lr, (void *)iaddr);
51}52}
5253
=== modified file 'sysdeps/linux-gnu/arm/trace.c'
--- sysdeps/linux-gnu/arm/trace.c 2010-10-01 16:06:14 +0000
+++ sysdeps/linux-gnu/arm/trace.c 2011-03-15 17:56:13 +0000
@@ -46,7 +46,7 @@
46 /* get the user's pc (plus 8) */46 /* get the user's pc (plus 8) */
47 int pc = ptrace(PTRACE_PEEKUSER, proc->pid, off_pc, 0);47 int pc = ptrace(PTRACE_PEEKUSER, proc->pid, off_pc, 0);
48 /* fetch the SWI instruction */48 /* fetch the SWI instruction */
49 int insn = ptrace(PTRACE_PEEKTEXT, proc->pid, pc - 4, 0);49 unsigned insn = ptrace(PTRACE_PEEKTEXT, proc->pid, pc - 4, 0);
50 int ip = ptrace(PTRACE_PEEKUSER, proc->pid, off_ip, 0);50 int ip = ptrace(PTRACE_PEEKUSER, proc->pid, off_ip, 0);
5151
52 if (insn == 0xef000000 || insn == 0x0f00000052 if (insn == 0xef000000 || insn == 0x0f000000
@@ -63,7 +63,7 @@
63 * PC does not point to the instruction just after the63 * PC does not point to the instruction just after the
64 * "swi" one. */64 * "swi" one. */
65 output_line(proc, "unexpected instruction 0x%x at %p", insn, pc - 4);65 output_line(proc, "unexpected instruction 0x%x at %p", insn, pc - 4);
66 return -1;66 return 0;
67 }67 }
68 if ((*sysnum & 0xf0000) == 0xf0000) {68 if ((*sysnum & 0xf0000) == 0xf0000) {
69 /* arch-specific syscall */69 /* arch-specific syscall */
7070
=== added directory 'sysdeps/linux-gnu/cris'
=== added file 'sysdeps/linux-gnu/cris/Makefile'
--- sysdeps/linux-gnu/cris/Makefile 1970-01-01 00:00:00 +0000
+++ sysdeps/linux-gnu/cris/Makefile 2011-03-15 17:56:13 +0000
@@ -0,0 +1,10 @@
1OBJ = trace.o regs.o plt.o
2
3all: arch.o
4
5arch.o: $(OBJ)
6 $(CC) -nostdlib -r -o arch.o $(OBJ)
7
8clean:
9 $(RM) $(OBJ) arch.o
10
011
=== added file 'sysdeps/linux-gnu/cris/arch.h'
--- sysdeps/linux-gnu/cris/arch.h 1970-01-01 00:00:00 +0000
+++ sysdeps/linux-gnu/cris/arch.h 2011-03-15 17:56:13 +0000
@@ -0,0 +1,6 @@
1#define BREAKPOINT_VALUE { 0x38, 0xe9 }
2#define BREAKPOINT_LENGTH 2
3#define DECR_PC_AFTER_BREAK 0
4
5#define LT_ELFCLASS ELFCLASS32
6#define LT_ELF_MACHINE EM_CRIS
07
=== added file 'sysdeps/linux-gnu/cris/plt.c'
--- sysdeps/linux-gnu/cris/plt.c 1970-01-01 00:00:00 +0000
+++ sysdeps/linux-gnu/cris/plt.c 2011-03-15 17:56:13 +0000
@@ -0,0 +1,12 @@
1#include <gelf.h>
2#include "common.h"
3
4GElf_Addr arch_plt_sym_val(struct ltelf *lte, size_t ndx, GElf_Rela * rela)
5{
6 return lte->plt_addr + 0x20 + (ndx * 26);
7}
8
9void *sym2addr(Process *proc, struct library_symbol *sym)
10{
11 return sym->enter_addr;
12}
013
=== added file 'sysdeps/linux-gnu/cris/ptrace.h'
--- sysdeps/linux-gnu/cris/ptrace.h 1970-01-01 00:00:00 +0000
+++ sysdeps/linux-gnu/cris/ptrace.h 2011-03-15 17:56:13 +0000
@@ -0,0 +1,1 @@
1#include <sys/ptrace.h>
02
=== added file 'sysdeps/linux-gnu/cris/regs.c'
--- sysdeps/linux-gnu/cris/regs.c 1970-01-01 00:00:00 +0000
+++ sysdeps/linux-gnu/cris/regs.c 2011-03-15 17:56:13 +0000
@@ -0,0 +1,37 @@
1#if HAVE_CONFIG_H
2#include "config.h"
3#endif
4
5#include <sys/types.h>
6#include <sys/ptrace.h>
7#include <asm/ptrace.h>
8
9#include "common.h"
10
11#if (!defined(PTRACE_PEEKUSER) && defined(PTRACE_PEEKUSR))
12# define PTRACE_PEEKUSER PTRACE_PEEKUSR
13#endif
14
15#if (!defined(PTRACE_POKEUSER) && defined(PTRACE_POKEUSR))
16# define PTRACE_POKEUSER PTRACE_POKEUSR
17#endif
18
19void *get_instruction_pointer(Process *proc)
20{
21 return (void *)ptrace(PTRACE_PEEKUSER, proc->pid, 4 * PT_PPC, 0);
22}
23
24void set_instruction_pointer(Process *proc, void *addr)
25{
26 ptrace(PTRACE_POKEUSER, proc->pid, 4 * PT_PPC, addr);
27}
28
29void *get_stack_pointer(Process *proc)
30{
31 return (void *)ptrace(PTRACE_PEEKUSER, proc->pid, 4 * PT_USP, 0);
32}
33
34void *get_return_addr(Process *proc, void *stack_pointer)
35{
36 return (void *)ptrace(PTRACE_PEEKUSER, proc->pid, 4 * PT_SRP, 0);
37}
038
=== added file 'sysdeps/linux-gnu/cris/signalent.h'
--- sysdeps/linux-gnu/cris/signalent.h 1970-01-01 00:00:00 +0000
+++ sysdeps/linux-gnu/cris/signalent.h 2011-03-15 17:56:13 +0000
@@ -0,0 +1,32 @@
1 "SIG_0", /* 0 */
2 "SIGHUP", /* 1 */
3 "SIGINT", /* 2 */
4 "SIGQUIT", /* 3 */
5 "SIGILL", /* 4 */
6 "SIGTRAP", /* 5 */
7 "SIGABRT", /* 6 */
8 "SIGBUS", /* 7 */
9 "SIGFPE", /* 8 */
10 "SIGKILL", /* 9 */
11 "SIGUSR1", /* 10 */
12 "SIGSEGV", /* 11 */
13 "SIGUSR2", /* 12 */
14 "SIGPIPE", /* 13 */
15 "SIGALRM", /* 14 */
16 "SIGTERM", /* 15 */
17 "SIGSTKFLT", /* 16 */
18 "SIGCHLD", /* 17 */
19 "SIGCONT", /* 18 */
20 "SIGSTOP", /* 19 */
21 "SIGTSTP", /* 20 */
22 "SIGTTIN", /* 21 */
23 "SIGTTOU", /* 22 */
24 "SIGURG", /* 23 */
25 "SIGXCPU", /* 24 */
26 "SIGXFSZ", /* 25 */
27 "SIGVTALRM", /* 26 */
28 "SIGPROF", /* 27 */
29 "SIGWINCH", /* 28 */
30 "SIGIO", /* 29 */
31 "SIGPWR", /* 30 */
32 "SIGSYS", /* 31 */
033
=== added file 'sysdeps/linux-gnu/cris/syscallent.h'
--- sysdeps/linux-gnu/cris/syscallent.h 1970-01-01 00:00:00 +0000
+++ sysdeps/linux-gnu/cris/syscallent.h 2011-03-15 17:56:13 +0000
@@ -0,0 +1,325 @@
1"0", /* 0 */
2 "exit",
3"fork",
4"read",
5"write",
6"open",
7"close",
8"waitpid",
9"creat",
10"link",
11"unlink",
12"execve",
13"chdir",
14"time",
15"mknod",
16"chmod",
17"lchown",
18"break",
19"oldstat",
20"lseek",
21"getpid",
22"mount",
23"umount",
24"setuid",
25"getuid",
26"stime",
27"ptrace",
28"alarm",
29"oldfstat",
30"pause",
31"utime",
32"stty",
33"gtty",
34"access",
35"nice",
36"ftime",
37"sync",
38"kill",
39"rename",
40"mkdir",
41"rmdir",
42"dup",
43"pipe",
44"times",
45"prof",
46"brk",
47"setgid",
48"getgid",
49"signal",
50"geteuid",
51"getegid",
52"acct",
53"umount2",
54"lock",
55"ioctl",
56"fcntl",
57"mpx",
58"setpgid",
59"ulimit",
60"oldolduname",
61"umask",
62"chroot",
63"ustat",
64"dup2",
65"getppid",
66"getpgrp",
67"setsid",
68"sigaction",
69"sgetmask",
70"ssetmask",
71"setreuid",
72"setregid",
73"sigsuspend",
74"sigpending",
75"sethostname",
76"setrlimit",
77"getrlimit",
78"getrusage",
79"gettimeofday",
80"settimeofday",
81"getgroups",
82"setgroups",
83"select",
84"symlink",
85"oldlstat",
86"readlink",
87"uselib",
88"swapon",
89"reboot",
90"readdir",
91"mmap",
92"munmap",
93"truncate",
94"ftruncate",
95"fchmod",
96"fchown",
97"getpriority",
98"setpriority",
99"profil",
100"statfs",
101"fstatfs",
102"ioperm",
103"socketcall",
104"syslog",
105"setitimer",
106"getitimer",
107"stat",
108"lstat",
109"fstat",
110"olduname",
111"iopl",
112"vhangup",
113"idle",
114"vm86",
115"wait4",
116"swapoff",
117"sysinfo",
118"ipc",
119"fsync",
120"sigreturn",
121"clone",
122"setdomainname",
123"uname",
124"modify_ldt",
125"adjtimex",
126"mprotect",
127"sigprocmask",
128"create_module",
129"init_module",
130"delete_module",
131"get_kernel_syms",
132"quotactl",
133"getpgid",
134"fchdir",
135"bdflush",
136"sysfs",
137"personality",
138"afs_syscall",
139"setfsuid",
140"setfsgid",
141"_llseek",
142"getdents",
143"_newselect",
144"flock",
145"msync",
146"readv",
147"writev",
148"getsid",
149"fdatasync",
150"_sysctl",
151"mlock",
152"munlock",
153"mlockall",
154"munlockall",
155"sched_setparam",
156"sched_getparam",
157"sched_setscheduler",
158"sched_getscheduler",
159"sched_yield",
160"sched_get_priority_max",
161"sched_get_priority_min",
162"sched_rr_get_interval",
163"nanosleep",
164"mremap",
165"setresuid",
166"getresuid",
167"invalid",
168"query_module",
169"poll",
170"nfsservctl",
171"setresgid",
172"getresgid",
173"prctl",
174"rt_sigreturn",
175"rt_sigaction",
176"rt_sigprocmask",
177"rt_sigpending",
178"rt_sigtimedwait",
179"rt_sigqueueinfo",
180"rt_sigsuspend",
181"pread64",
182"pwrite64",
183"chown",
184"getcwd",
185"capget",
186"capset",
187"sigaltstack",
188"sendfile",
189"getpmsg",
190"putpmsg",
191"vfork",
192"ugetrlimit",
193"mmap2",
194"truncate64",
195"ftruncate64",
196"stat64",
197"lstat64",
198"fstat64",
199"lchown32",
200"getuid32",
201"getgid32",
202"geteuid32",
203"getegid32",
204"setreuid32",
205"setregid32",
206"getgroups32",
207"setgroups32",
208"fchown32",
209"setresuid32",
210"getresuid32",
211"setresgid32",
212"getresgid32",
213"chown32",
214"setuid32",
215"setgid32",
216"setfsuid32",
217"setfsgid32",
218"pivot_root",
219"mincore",
220"madvise",
221"getdents64",
222"fcntl64",
223"invalid",
224"invalid",
225"gettid",
226"readahead",
227"setxattr",
228"lsetxattr",
229"fsetxattr",
230"getxattr",
231"lgetxattr",
232"fgetxattr",
233"listxattr",
234"llistxattr",
235"flistxattr",
236"removexattr",
237"lremovexattr",
238"fremovexattr",
239"tkill",
240"sendfile64",
241"futex",
242"sched_setaffinity",
243"sched_getaffinity",
244"set_thread_area",
245"get_thread_area",
246"io_setup",
247"io_destroy",
248"io_getevents",
249"io_submit",
250"io_cancel",
251"fadvise64",
252"invalid",
253"exit_group",
254"lookup_dcookie",
255"epoll_create",
256"epoll_ctl",
257"epoll_wait",
258"remap_file_pages",
259"set_tid_address",
260"timer_create",
261"timer_settime",
The diff has been truncated for viewing.

Subscribers

People subscribed via source and target branches

to all changes: