Make //folly/tracing/test:static_tracepoint_test work if compiled as PIE.
Summary: A tracepoint semaphore address is written to the notes section as either the absolute address (if binary is compiled as non-PIE) or the relative address (if binary is compiled as PIE) of the semaphore. In the former case, the test passes; in the latter case, the test as it was could not possibly pass because the binary is mapped to some random base address. This diff makes a guess: if the addresses are equal, then we're non-PIE; otherwise check if the address offset is valid - that offset is the address at which the binary is mapped, so it always begins with the ELF header, so we can check against that. If someone knows how to easily figure out that random address or to detect whether the binary is PIE (thereby disabling the test) that'd be great too. This fixes TSAN for the test, as TSAN binaries are built as PIE. Reviewed By: yfeldblum Differential Revision: D22752824 fbshipit-source-id: cd320f9fb8355a20f65e2385f0a1ab1c24ec0b81
Showing
Please register or sign in to comment