3726 libdtrace's use of libelf is non-portable
Reviewed by: Adam Leventhal <ahl@delphix.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>
libdtrace: Track symtab/strtab indices correctly

libelf references things in terms of indices into data descriptors.
st_name, however, is an index into the strtab itself.  We thus need to:

- Reset the index for the new symbol each time we create a new
  descriptor in the symtab
- reset the index for the symbol name
- keep the total size of the relevant string table around so we can
  calculate the offset to use in st_name

While here, make sure that each symtab descriptor has the correct type,
which is probably paranoia
libdtrace: use GElf to create the DOF object, rather than doing it by hand.

Rather than creating the ELF container for DOF largely by hand, use
libelf's generic elf functions and commonize a lot of code.
dtrace: add runtime support for objects that can't load their own DOF

The regular D runtime is linked into each ELF container object by dtrace -G,
and bound hidden.  This means that each each object contains support for
loading itself at runtime regardless of how many such objects are
involved in a link -- if there are 2 providers, there are 2 copies of
the runtime.

We need support for ELF containers that cannot load their own DOF, but
require a single external runtime to load all of their DOF (from however
many providers, etc, exist).

We do this by placing a symbol __SUNW_dof_array into the output object,
which is a NULL-terminated array of pointers to all DOF which must be
loaded by the new runtime object (ldrti.o), as well as libdtrace and
libdtrace_forceload.

The __SUNW_dof_array symbol is placed into a new .SUNW_dof_array section
of type SHT_SUNW_DOF_ARRAY, similar to the .initarray and .finiarray
sections in concept though this is an implementation detail (and one
that it's hoped will change).
ld/dtrace: Support provider and helper definitions from relocatable objects

- Add support to 'dtrace -h' such that the actual provider (or helper)
  definition is encoded into the produced header file as a
  __dtrace_script_NNNNN symbol placed in a new .SUNW_dscript section in
  any object built from sources including this header.

  This script must -- unfortunately -- be placed into a dummy function
  due to limitations of the Sun Studio compiler.  While the script
  content, symbols, and .SUNW_dscript section will not appear in output
  objects, these dummy functions will.

- In the link-editor, compiler the scripts in any __dtrace_script and
  generate an ELF container in memory for the resulting DOF.

  We then add this memory image and the __SUNW_dof_array runtime
  (ldrti.o) to the link-edit, and store the address of the DOF symbol
  (now named __SUNW_dof_N, counting from 0) to __SUNW_dof_array.

  Discard (by name) the .SUNW_dscript section used to contain the script
  sources.