[llvm] [BOLT] Support instrumentation hook via DT_FINI_ARRAY (PR #67348)

Job Noorman via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 11 02:34:27 PDT 2023


================
@@ -0,0 +1,94 @@
+## Test the different ways of hooking the fini function for instrumentation (via
+## DT_FINI and via DT_FINI_ARRAY). We test the latter for both PIE and non-PIE
+## binaries because of the different ways of handling relocations (static or
+## dynamic).
+## All tests perform the following steps:
+## - Compile and link for the case to be tested
+## - Some sanity-checks on the dynamic section and relocations in the binary to
+##   verify it has the shape we want for testing:
+##   - DT_FINI or DT_FINI_ARRAY in dynamic section
+##   - No relative relocations for non-PIE
+## - Instrument
+## - Verify generated binary
+# REQUIRES: system-linux,bolt-runtime
+
+# RUN: %clang  %s -Wl,-q -o %t.exe
----------------
mtvec wrote:

I got this mostly working. There is an issue though with the no-pie test: without pie and when not linking against shared libraries, no dynamic section is generated. This means that the current implementation doesn't support these binaries. I think this is fine but it means we cannot write tests for the non-pie case. Do you see a solution for this?

https://github.com/llvm/llvm-project/pull/67348


More information about the llvm-commits mailing list