[llvm-dev] Building an array in a section from multiple object files

Dean Michael Berris via llvm-dev llvm-dev at lists.llvm.org
Thu Jun 23 10:26:14 PDT 2016


As part of working on XRay, I'm trying to accomplish the following: create
a section that contains an array of entries pertaining to the
instrumentation map (nop sleds) in an object file, and have those merged
into a single section in the final binary where the contents are
concatenated. The trick though is I'd like to be able to reference the
whole array with a single symbol (or two, one to mark the start and the
other to mark the end). I'm trying to get this to work initially on x86 and
Linux (ELF).

What I've got currently in http://reviews.llvm.org/D19904 creates this
section (.xray_instr_map) and defines two globals in that section named
"__xray_instr_map" and "__xray_instr_map_end". The problem inevitably with
this approach is that having multiple object files have these definitions
cause issues with multiple definition violations at link time.

I *think* the solution involves having COMDAT sections per-function that
has the instrumentation points, then have those concatenated into a single
.xray_instr_map section.

What I'm not sure about is how to define the "__xray_instr_map" and
"__xray_instr_map" symbols such that they refer to the contents of the
section in the final binary.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160623/34a1a493/attachment.html>

More information about the llvm-dev mailing list