Disallow building static librairies
[lttng-ust.git] / tests / unit / ust-elf / README.md
CommitLineData
22609c7a
AB
1lttng_ust_elf unit tests
2========================
3
4This is a series of unit tests for LTTng UST's ELF parser. The parser
5is used to retrieve memory size, build ID, and debug link information
6from ELF objects (standalone executable or shared object) for base
7address statedump or dl events.
8
9The parser should technically be able to read ELF files from any 32-
10or 64-bit architecture, little- or big- endian.
11
12However, to restrict the total amount of testing done, only 4
13architectures representing all combinations of bitness and endianness
14are currently tested:
15
16* x86
17* x86_64
18* armeb
19* aarch64_be
20
21For each architecture, there is a corresponding subdirectory under
22`data`, and each of these directories contains exactly 2 files,
23`main.elf` and `main.elf.debug`.
24
25The ELF files are generated from the trivial `main.c` program found in
26`data/`, using GNU toolchains. The program contains a static array in
27order to ensure the creation of a `.bss` section in the ELF file,
28which is one of the multiple factors leading to different file and
29in-memory size.
30
31The program is compiled with `gcc -g main.c -o main.elf`. On certain
32architectures, it is necessary to explicitly specify the
33`-Wl,--build-id=sha1` flags to include a build ID in the resulting
34executable.
35
36The debug information bundled in `main.elf` is then copied into
37`main.elf.debug` and stripped, and a debug link pointing to this file
38is added to the executable. The commands used are as follow:
39
40 $ objcopy --only-keep-debug main.elf main.elf.debug
41 $ strip -g main.elf
42 $ objcopy --add-gnu-debuglink=main.elf.debug main.elf
968f523d
AB
43
44There is also a series of tests used to check detection of
45position-independent code (PIC). These tests use three pre-compiled
46ELF files found under `data/pic/`, namely `hello.exec`, `hello.pie`,
47and `hello.pic`. These can be re-generated using the files `hello.c`
48and `libhello.c`, with the following commands:
49
50 $ gcc hello.c -o hello.exec
51 $ gcc hello.c -fPIC -pie -o hello.pie
52 $ gcc -shared -o hello.pic -fPIC libhello.c
This page took 0.031196 seconds and 4 git commands to generate.