Skip to content

Commit f717ac1

Browse files
committed
Some versions of autoreconf insist on README
and ignore README.md. So reintroducing README (a copy of README.md) new file: README
1 parent df4cc3f commit f717ac1

File tree

1 file changed

+371
-0
lines changed

1 file changed

+371
-0
lines changed

README

Lines changed: 371 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,371 @@
1+
# This is libdwarf README[.md]
2+
3+
Updated 20 September 2023
4+
5+
ci runs builds on Linux, Freebsd, msys2, and MacOS
6+
using configure,cmake, and meson.
7+
8+
[![ci](https://github.com/davea42/libdwarf-code/actions/workflows/test.yml/badge.svg)](https://github.com/davea42/libdwarf-code/actions/workflows/test.yml)
9+
10+
[![OpenSSF Best Practices](https://bestpractices.coreinfrastructure.org/projects/7275/badge)](https://bestpractices.coreinfrastructure.org/projects/7275)
11+
12+
Version 0.8.0 Released 20 September 2023.
13+
Version 0.7.0 Released 20 May 2023.
14+
Version 0.6.0 Released 20 February 2023.
15+
Version 0.5.0 Released 22 November 2022.
16+
17+
## NOTE on linking against libdwarf.a
18+
19+
If you are linking code against a static
20+
library libdwarf.a You must arrange to define the
21+
macro LIBDWARF_STATIC in compiling your code that
22+
does a #include "libdwarf.h".
23+
See also READMEwin-msys2.md
24+
25+
## REQUIREMENTS from a libdwarf<name>.tar.xz
26+
27+
Mentioning some that might not be automatically
28+
in your base OS release. Restricting attention
29+
here to just building libdwarf and dwarfdump.
30+
31+
Nothing in the project requires or references
32+
elf.h, libelf.h, or libelf as of 29 June 2023,
33+
version 0.8.0.
34+
35+
If the objects you work with do not have
36+
section content compressed
37+
with zlib(libz) or libzstd
38+
neither those libraries nor their header files
39+
are required for building/using
40+
libdwarf/dwarfdump.
41+
42+
Ubuntu:
43+
sudo apt install xz pkgconf zlib1g zlib1g-dev libzstd1
44+
# Use of libzstd1 is new in 0.4.3
45+
# zlib1g zlib1g-dev libzstd1 are all optional but
46+
# are required to read any DWARF data in compressed
47+
# sections.
48+
optional add: cmake meson ninja doxygen
49+
50+
FreeBSD:
51+
pkg install bash xz python3 gmake liblz4 zstd
52+
# libzstd is likely in /usr/local/lib and zstd.h
53+
# in /usr/local/include and the compiler may not look there
54+
# by default. All will still build fine without it and
55+
# without lzib too, though compressed DWARF sections
56+
# may not be readable.
57+
# example:
58+
CPPFLAGS="-I/usr/local/include/" LDFLAGS="-L/usr/local/lib" ./configure
59+
optional add: binutils cmake meson ninja doxygen
60+
61+
Ensure that all the needed programs are in $PATH,
62+
including python3.
63+
# candidate commane to make python3 visible (as root)
64+
# something like:
65+
cd /usr/local/bin ; ln -s python3.9 python3
66+
67+
## BUILDING from a libdwarf<name>.tar.xz
68+
69+
This is always recommended as it's not necessary
70+
to have GNU autotools installed.
71+
These examples show doing a build in a directory
72+
different than the source as that is generally
73+
recommended practice.
74+
75+
### GNU configure/autotools build
76+
77+
Note: if you get a build failure that mentions
78+
something about test/ and missing .Po object files
79+
add --disable-dependency-tracking to the configure
80+
command.
81+
82+
rm -rf /tmp/build
83+
mkdir /tmp/build
84+
cd /tmp
85+
tar xf <path to>/libdwarf-0.4.2.tar.xz
86+
cd /tmp/build
87+
/tmp/libdwarf-0.4.2/configure
88+
make
89+
make check
90+
91+
### cmake build
92+
93+
README.cmake has details on the available cmake options.
94+
95+
We suggest that you will find meson a more satisfactory
96+
tool.
97+
98+
### meson build
99+
100+
meson 0.45.1 on Ubuntu 18.04 fails.
101+
meson 0.55.2 on Ubuntu 20.04 works.
102+
meson 0.60.3 on Freebsd 12.2 and Freebsd 13.0 works.
103+
104+
See READMEwin-msys2.md for the mingw64 msys2 packages to install
105+
and the command(s) to do that in msys2.
106+
The tools listed there are also for msys2 meson and
107+
autotools/configure.
108+
109+
The msys2 meson ninja install not only installs libdwarf-0.dll
110+
and dwarfdump.exe it updates the executables in
111+
the build tree linking to that dll so all such
112+
executables in the build tree work too.
113+
114+
For example (all build environments):
115+
116+
meson /tmp/libdwarf-0.4.2
117+
ninja
118+
ninja install
119+
ninja test
120+
121+
For a faster build, adding additional checks:
122+
123+
export CFLAGS="-g -pipe"
124+
export CXXFLAGS="-g -pipe"
125+
meson /tmp/libdwarf-0.4.2 -Ddwarfexample=true
126+
ninja -j8
127+
ninja install
128+
ninja test
129+
130+
## BUILDING on linux from a git clone with configure/autotools
131+
132+
Ignore this section if using meson (or cmake).
133+
134+
This is not recommended as it requires you have more
135+
software installed.
136+
137+
For Ubuntu configure, install additional packages:
138+
139+
autoconf
140+
automake
141+
libtool
142+
pkg-config
143+
144+
For FreeBSD configure, install additional packages:
145+
autoconf
146+
automake
147+
libtool
148+
pkgconf
149+
150+
Here we assume the source is in a directory named
151+
/path/to/code
152+
153+
For example, on Ubuntu 20.04
154+
```
155+
sudo apt-get install autoconf libtool pkg-config
156+
```
157+
158+
Note: if you get a build failure that mentions
159+
something about test/ and missing .Po object files
160+
add --disable-dependency-tracking to the configure
161+
command.
162+
163+
Using the source/build directories from above as examples,
164+
do :
165+
166+
# Standard Linux Build
167+
cd /path/to/code
168+
sh autogen.sh
169+
cd /tmp/build
170+
/path/to/code/configure
171+
make
172+
make check
173+
174+
## BUILDING on MacOS from a git clone configure
175+
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
176+
brew install autoconf automake libtool
177+
# Then use the Standard Linux Build lines above.
178+
179+
### Options to meson on Linux/Unix
180+
181+
For the basic configuration options list , do:
182+
meson configure /path/to/code
183+
184+
To set options and show the resulting actual options:
185+
186+
# Here just setting one option.
187+
meson setup -Ddwarfexample=true . /home/davea/dwarf/code
188+
meson configure .
189+
190+
The meson configure output is very wide (just letting you know).
191+
192+
### Options to configure/autotools on Linux/Unix
193+
194+
For the full options list , do:
195+
196+
/path/to/code/configure --help
197+
198+
By default configure compiles and uses libdwarf.a.
199+
With `--enable-shared --disable-sttic"
200+
appended to the configure step,
201+
libdwarf.so is built and the runtimes
202+
built will reference libdwarf.so.
203+
204+
If you get a build failure that mentions
205+
something about test/ and missing .Po object files
206+
add --disable-dependency-tracking to the configure
207+
command. With that option do not assume you can
208+
alter source files and have make rebuild all
209+
necessary.
210+
211+
See:
212+
https://www.gnu.org/savannah-checkouts/gnu/automake/history/automake-history.html#Dependency-Tracking-Evolution
213+
214+
215+
Other options of possible interest:
216+
217+
--enable-wall to turn on compiler diagnostics
218+
--enable-dwarfexample to compile the example programs.
219+
220+
configure -h shows the options available.
221+
222+
Sanity checking:
223+
224+
gcc has some checks that can be done at runtime.
225+
-fsanitize=undefined is turned on for
226+
configure by --enable-sanitize
227+
228+
### Options to meson on Windows (Msys2)
229+
230+
As of 0.8.0 meson builds default to be
231+
shared-library builds.
232+
the default can be explicity chosen with:
233+
234+
--default-library shared
235+
236+
237+
### Options to configure on Windows (Msys2)
238+
239+
All libdwarf builds are automatically shared object (dll)
240+
builds. No static libdwarf.a can be built.
241+
If you need static libdwarf.a use meson or cmake.
242+
243+
Has the same meson setup reporting as on Linux (above).
244+
245+
See READMEwin-msys2.md
246+
247+
### Distributing via configure/autotools
248+
249+
When ready to create a new source distribution do
250+
a build and then
251+
252+
make distcheck
253+
254+
# INCOMPATIBILITIES. Changes to interfaces
255+
256+
### Comparing libdwarf-0.9.0 to libdwarf-0.8.0
257+
258+
New interfaces allow full support for
259+
Mach-O (Apple) universal binaries:
260+
dwarf_init_path_a(), dwarf_init_path_dl_a(), and
261+
dwarf_get_universalbinary_count().
262+
263+
### Comparing libdwarf-0.8.0 to libdwarf-0.7.0
264+
265+
The default build (with meson) is shared-library.
266+
to build with static (archive) libdwarf
267+
add
268+
269+
--default-library static
270+
271+
to the meson command line (applies to meson
272+
builds in Linux,Macos, and Windows-mingw).
273+
274+
On Windows-mingw one can build static libdwarf
275+
when using cmake or meson (configure will
276+
not allow a static libdwarf to be built
277+
on Windows).
278+
279+
See Options to meson on Windows (Msys2) above.
280+
281+
### Comparing libdwarf-0.7.0 to libdwarf-0.6.0
282+
struct Dwarf\_Obj\_Access\_Methods\_a\_s changed
283+
for extended ELF so the library can handle section count values
284+
larger than 16bits.
285+
dwarf\_dnames\_abbrev\_by\_code() and
286+
dwarf\_dnames\_abbrev\_form\_by\_index()
287+
were removed from the API, better alternatives
288+
already existed.
289+
290+
### Comparing libdwarf-0.6.0 to libdwarf-0.5.0
291+
The dealloc required by dwarf\_offset\_list()
292+
was wrong, use dwarf\_dealloc(dbg, offsetlistptr, DW_DLA_UARRAY).
293+
The function dwarf\_dietype\_offset() has a revised
294+
argument list so it can work correctly with DWARF4.
295+
dwarf\_get\_pubtypes() and similar changed
296+
to eliminate messy code duplication.
297+
Fixed memory leaks and treatment of DW\_FORM\_strx3
298+
and DW\_FORM\_addrx3.
299+
300+
### Comparing libdwarf-0.5.0 to libdwarf-0.4.2
301+
dwarf\_get\_globals() is compatible but it now
302+
returns data from .debug\_names in addition
303+
to .debug\_pubnames (either or both
304+
could be in an object file).
305+
New function dwarf\_global\_tag\_number()
306+
makes the data from .debug\_names a bit
307+
more useful (if a library user wants it).
308+
Three new functions were added to enable
309+
printing of the .debug_addr section
310+
independent of other sections
311+
and the new dwarfdump option --print-debug-addr
312+
prints that section.
313+
314+
### Comparing libdwarf-0.4.2 to libdwarf-0.4.1
315+
No incompatibilities.
316+
317+
### Comparing libdwarf-0.4.1 to libdwarf-0.4.0
318+
Added a new function dwarf\_suppress\_debuglink\_crc()
319+
which speeds up gnu debuglink (only use it if
320+
you are sure the debuglink name-check alone is sufficient).
321+
322+
### Comparing libdwarf-0.4.0 to libdwarf-0.3.4
323+
A few dealloc() functions changed name to have
324+
a consistent pattern for all such.
325+
Access to the DWARF5 .debug\_names section
326+
is now fully implemented.
327+
328+
See the <strong>Recent Changes</strong> section in
329+
libdwarf.pdf (in the release).
330+
331+
[dwhtml]: https://www.prevanders.net/libdwarfdoc/index.html
332+
[dwpdf]: https://www.prevanders.net/libdwarf.pdf
333+
334+
Or see the latest online html version [dwhtml] for the details..
335+
Or see (via download) the latest pdf html version [dwpdf].
336+
337+
Notice the table of contents at the right edge of the html page.
338+
339+
## Reading DWARF from memory
340+
341+
If one has DWARF bytes in memory or in a
342+
kind of file system libdwarf cannot understand
343+
one should use
344+
345+
dwarf_object_init_b()
346+
...call libdwarf functions...
347+
dwarf_object_finish()
348+
349+
and create source to provide
350+
functions and data for the three struct
351+
types:
352+
353+
struct Dwarf_Obj_Access_Interface_a_s
354+
struct Dwarf_Obj_Access_Methods_a_s
355+
struct Dwarf_Obj_Access_Section_a_s
356+
357+
These functions and structs now seem complete
358+
(unlike the earlier libdwarf versions), hence
359+
the name and content changes.
360+
361+
For a worked out example of reading DWARF direct from memory
362+
with no file system involved
363+
see
364+
365+
src/bin/dwarfexample/jitreader.c
366+
367+
and see the html [dwhtml] (www.prevanders.net/libdwarfdoc/index.html).
368+
369+
The latest pdf is [dwpdf] (www.prevanders.net/libdwarf.pdf)
370+
371+
David Anderson.

0 commit comments

Comments
 (0)