Add is_pic field to statedump soinfo event
authorAntoine Busque <abusque@efficios.com>
Wed, 13 Apr 2016 21:31:57 +0000 (17:31 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 15 Apr 2016 21:43:22 +0000 (17:43 -0400)
This field indicates whether the executable or library is position
independent code (PIC). The field is not added to the similar dlopen
event from liblttng-ust-dl because in that case all dlopened libraries
are necessarily PIC.

This allows a posteriori analyses to be performed without having to
read the executable file to know whether adresses are relative to the
base address or absolute.

Signed-off-by: Antoine Busque <abusque@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
doc/man/lttng-ust.3.txt
include/lttng/ust-elf.h
liblttng-ust/lttng-ust-elf.c
liblttng-ust/lttng-ust-statedump-provider.h
liblttng-ust/lttng-ust-statedump.c

index 1f4d7e481e95fb1f0957a8dc86fa5a4817654b66..c7b82c1a61876762a0026b183b8c3d1aabdce890 100644 (file)
@@ -777,18 +777,20 @@ This event has no fields.
 This event has no fields.
 
 `lttng_ust_statedump:soinfo`::
-    Emitted when information about a currently loaded shared object is
-    found.
+    Emitted when information about a currently loaded executable or
+    shared object is found.
 +
 Fields:
 +
 [options="header"]
-|==============================================================
+|==================================================================
 | Field name                 | Description
-| `baddr`                    | Base address of loaded library
-| `memsz`                    | Size of loaded library in memory
-| `sopath`                   | Path to loaded library file
-|==============================================================
+| `baddr`                    | Base address of loaded executable
+| `memsz`                    | Size of loaded executable in memory
+| `sopath`                   | Path to loaded executable file
+| `is_pic`                   | Whether the executable is
+                               position-independent code
+|==================================================================
 
 `lttng_ust_statedump:build_id`::
     Emitted when a build ID is found in a currently loaded shared
index 6e9d99518dce20027b11e9a2ebf343a8dec42d25..e9b0ac7b4e3ea22b86a53781b908f26f27749623 100644 (file)
@@ -219,6 +219,7 @@ int is_elf_native_endian(struct lttng_ust_elf *elf)
 
 struct lttng_ust_elf *lttng_ust_elf_create(const char *path);
 void lttng_ust_elf_destroy(struct lttng_ust_elf *elf);
+uint8_t lttng_ust_elf_is_pic(struct lttng_ust_elf *elf);
 int lttng_ust_elf_get_memsz(struct lttng_ust_elf *elf, uint64_t *memsz);
 int lttng_ust_elf_get_build_id(struct lttng_ust_elf *elf, uint8_t **build_id,
                        size_t *length, int *found);
index e90626906b6ea72c24d19bbcd4a3b7cee92e0821..346545583c3a23b399b9a71911c59e5ded6bc387 100644 (file)
@@ -316,6 +316,18 @@ error:
        return NULL;
 }
 
+/*
+ * Test whether the ELF file is position independent code (PIC)
+ */
+uint8_t lttng_ust_elf_is_pic(struct lttng_ust_elf *elf)
+{
+       /*
+        * PIC has and e_type value of ET_DYN, see ELF specification
+        * version 1.1 p. 1-3.
+        */
+       return elf->ehdr->e_type == ET_DYN;
+}
+
 /*
  * Destroy the given lttng_ust_elf instance.
  */
index 5e212d9e3cce0e79cd6f8ffb9b4807c5b64fc825..427ba2710d7643674d082a8170485155bfd8e773 100644 (file)
@@ -48,12 +48,14 @@ TRACEPOINT_EVENT(lttng_ust_statedump, soinfo,
                struct lttng_session *, session,
                void *, baddr,
                const char*, sopath,
-               uint64_t, memsz
+               uint64_t, memsz,
+               uint8_t, is_pic
        ),
        TP_FIELDS(
                ctf_integer_hex(void *, baddr, baddr)
                ctf_integer(uint64_t, memsz, memsz)
                ctf_string(sopath, sopath)
+               ctf_integer(uint8_t, is_pic, is_pic)
        )
 )
 
index 93a035b35a0ead7032e2ae121d8168f5c624c6da..b160e197376f70116ad6a34e304f399a92daeea0 100644 (file)
@@ -52,6 +52,7 @@ struct soinfo_data {
        size_t build_id_len;
        int vdso;
        uint32_t crc;
+       uint8_t is_pic;
 };
 
 typedef void (*tracepoint_cb)(struct lttng_session *session, void *priv);
@@ -84,7 +85,7 @@ void trace_soinfo_cb(struct lttng_session *session, void *priv)
 
        tracepoint(lttng_ust_statedump, soinfo,
                session, so_data->base_addr_ptr,
-               so_data->resolved_path, so_data->memsz);
+               so_data->resolved_path, so_data->memsz, so_data->is_pic);
 }
 
 static
@@ -147,6 +148,8 @@ int get_elf_info(struct soinfo_data *so_data, int *has_build_id,
                goto end;
        }
 
+       so_data->is_pic = lttng_ust_elf_is_pic(elf);
+
 end:
        lttng_ust_elf_destroy(elf);
        return ret;
This page took 0.0286 seconds and 4 git commands to generate.