[XRay] Synthesize a reference to the xray_instr_map
authorDean Michael Berris <dberris@google.com>
Fri, 19 Aug 2016 04:44:30 +0000 (04:44 +0000)
committerDean Michael Berris <dberris@google.com>
Fri, 19 Aug 2016 04:44:30 +0000 (04:44 +0000)
commit1dd1ca9727c612032daa66e35bd1b81233a92322
treefca17d6eb617e504cb1024c4274ba6eabde1a506
parent49178e5efee844ba2a9ea6b2877e8b0ceadc1a8b
[XRay] Synthesize a reference to the xray_instr_map

Without the synthesized reference to a symbol in the xray_instr_map,
linker section garbage collection will helpfully remove the whole
xray_instr_map section from the final executable (or archive). This will
cause the runtime to not be able to identify the sleds and hot-patch the
calls/jumps into the runtime trampolines.

This change adds a reference from the text section at the end of the
function to keep around the associated xray_instr_map section as well.

We also make sure that we catch this reference in the test.

Reviewers: chandlerc, echristo, majnemer, mehdi_amini

Subscribers: mehdi_amini, llvm-commits, dberris

Differential Revision: https://reviews.llvm.org/D23398

llvm-svn: 279204
llvm/lib/Target/X86/X86MCInstLower.cpp
llvm/test/CodeGen/X86/xray-attribute-instrumentation.ll