Fix handling of null stap semaphores
authorGeorge Barrett <bob@bob131.so>
Fri, 10 Jan 2020 19:30:28 +0000 (06:30 +1100)
committerSimon Marchi <simon.marchi@efficios.com>
Fri, 10 Jan 2020 19:58:37 +0000 (14:58 -0500)
commit7f0ae84c80aae6fe8f7573343fe1ab455d18b5d8
tree16de1a790fb014f27a7c09d634df9f5215961da3
parent47e9d49d2d795224f4b3f04c89c268627b850be4
Fix handling of null stap semaphores

According to the SystemTap documentation on user-space probes[0], stap
probe points without semaphores are denoted by setting the semaphore
address in the probe's note to zero. At present the code does do a
comparison of the semaphore address against zero, but only after it's
been relocated; as such it will (almost?) always fail, commonly
resulting in GDB trying to overwrite the ELF magic located at the
image's base address.

This commit tests the address as specified in the SDT note rather than
the relocated value in order to correctly detect absent probe
semaphores.

[0]: https://sourceware.org/systemtap/wiki/UserSpaceProbeImplementation

gdb/Changelog:
2020-01-11  George Barrett  <bob@bob131.so>

* stap-probe.c (stap_modify_semaphore): Don't check for null
semaphores.
(stap_probe::set_semaphore, stap_probe::clear_semaphore): Check
for null semaphores.

gdb/testsuite/ChangeLog:
2020-01-11  George Barrett  <bob@bob131.so>

* gdb.base/stap-probe.c (relocation_marker): Add dummy variable
to help in finding the image relocation offset.
* gdb.base/stap-probe.exp (stap_test): Accept arbitrary compile
options in arguments.
(stap_test_no_debuginfo): Likewise.
(stap-probe-nosem-noopt-pie, stap-probe-nosem-noopt-nopie): Add
test variants.
(stap_test): Add null semaphore relocation test.
gdb/ChangeLog
gdb/stap-probe.c
gdb/testsuite/ChangeLog
gdb/testsuite/gdb.base/stap-probe.c
gdb/testsuite/gdb.base/stap-probe.exp
This page took 0.026161 seconds and 4 git commands to generate.