Markers: make __ust_marker_ptrs PIC
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 19 Apr 2011 01:21:31 +0000 (21:21 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 19 Apr 2011 01:21:31 +0000 (21:21 -0400)
> As I prepared the 0.12 release for Debian, I noticed that libust.so was
> not PIC:
>
>     $ readelf -d libust/.libs/libust.so.0.0.0 | grep TEXTREL
>     0x0000000000000016 (TEXTREL)            0x0
>
> Since all of the objects in libust are built with -fPIC, I thought
> perhaps there was some assembly added between 0.11 and 0.12 that
> contained text relocations. I bisected the two tags down to the
> offending commit:
>
>     eb5d20c68aaf73661ffc02ba8fea3683c0358702
>
> Within that commit, it seems to be a problem in include/ust/marker.h
> with these lines:
>
> @@ -129,7 +124,12 @@ struct marker {
> [...]
> +                       /*".section __markers_ptrs\n\t"*/ \
> +                       ".section __markers_ptrs,\"a\",@progbits\n\t"                           \
>
> If I make the __markers_ptrs section writable, with:
>
>                         ".section __markers_ptrs,\"aw\"\n\t
>
> TEXTREL goes away and everything seems okay, tests pass. Is this
> a correct solution? I don't understand why the section must be writable
> to avoid relocations, can anyone explain?

Oh.. I think I see. __markers_ptrs contains pointers to another section
that must be populated by the dynamic linker (thus at runtime). If the
section is read-only, the linker cannot update them at load time, so a
relocation table is probably needed.

Reported-by: Jon Bernard <jbernard@debian.org>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
include/ust/marker.h

index 4850417946f38fa07ad86433c2329253ba5f7162..1a3d74e9a8ac20e6c03a6b91cff70e0014c9fd48 100644 (file)
@@ -124,7 +124,7 @@ struct ust_marker {
                        _ASM_PTR "(1f)\n\t" /* location */                                              \
                        ".previous\n\t"                                                         \
                        /*".section __ust_marker_ptrs\n\t"*/ \
-                       ".section __ust_marker_ptrs,\"a\"\n\t"                                  \
+                       ".section __ust_marker_ptrs,\"aw\"\n\t"                                 \
                        _ASM_PTR "(2b)\n\t"                                                     \
                        ".previous\n\t"                                                         \
                        "1:\n\t"                                                                \
This page took 0.029776 seconds and 4 git commands to generate.