Assemble calls to constant addresses.

Finally address this TODO in the assembler. This will help translate
non-IRT using programs (no ABI stability). The default scons testing
mode is non-IRT, so this helps with that. I haven't actually tested
this against scons yet, but I'm filling in the tests based on how
LLVM translates the same bitcode.

The filetype=asm is adjusted to omit the "*" and the "$".

The filetype=obj is adjusted to check for fixups with NullSymbols,
and also fill the assembler buffer at the instruction's immediate
field w/ the right constant.

The filetype=iasm is still TODO (hits an new assert in the Fixup's emit() function).

Reverts 7ad1bed99d058199a3ba246a5383458518596fbc:
"Allow stubbing of called constant addresses using command line argument."
since this is now handled (except for iasm).

BUG= https://code.google.com/p/nativeclient/issues/detail?id=4080
R=stichnot@chromium.org

Review URL: https://codereview.chromium.org/1017373002
diff --git a/src/IceELFSection.h b/src/IceELFSection.h
index 0bfccca..c2ef9bf 100644
--- a/src/IceELFSection.h
+++ b/src/IceELFSection.h
@@ -163,7 +163,11 @@
   ELFSymbolTableSection &operator=(const ELFSymbolTableSection &) = delete;
 
 public:
-  using ELFSection::ELFSection;
+  ELFSymbolTableSection(const IceString &Name, Elf64_Word ShType,
+                        Elf64_Xword ShFlags, Elf64_Xword ShAddralign,
+                        Elf64_Xword ShEntsize)
+      : ELFSection(Name, ShType, ShFlags, ShAddralign, ShEntsize),
+        NullSymbol(nullptr) {}
 
   // Create initial entry for a symbol when it is defined.
   // Each entry should only be defined once.
@@ -179,6 +183,9 @@
 
   const ELFSym *findSymbol(const IceString &Name) const;
 
+  void createNullSymbol(ELFSection *NullSection);
+  const ELFSym *getNullSymbol() const { return NullSymbol; }
+
   size_t getSectionDataSize() const {
     return (LocalSymbols.size() + GlobalSymbols.size()) * Header.sh_entsize;
   }
@@ -198,6 +205,7 @@
   template <bool IsELF64>
   void writeSymbolMap(ELFStreamer &Str, const SymMap &Map);
 
+  const ELFSym *NullSymbol;
   // Keep Local and Global symbols separate, since the sh_info needs to
   // know the index of the last LOCAL.
   SymMap LocalSymbols;
@@ -211,7 +219,11 @@
   ELFRelocationSection &operator=(const ELFRelocationSection &) = delete;
 
 public:
-  using ELFSection::ELFSection;
+  ELFRelocationSection(const IceString &Name, Elf64_Word ShType,
+                       Elf64_Xword ShFlags, Elf64_Xword ShAddralign,
+                       Elf64_Xword ShEntsize)
+      : ELFSection(Name, ShType, ShFlags, ShAddralign, ShEntsize),
+        RelatedSection(nullptr) {}
 
   const ELFSection *getRelatedSection() const { return RelatedSection; }
   void setRelatedSection(const ELFSection *Section) {
@@ -340,7 +352,11 @@
 void ELFRelocationSection::writeData(const GlobalContext &Ctx, ELFStreamer &Str,
                                      const ELFSymbolTableSection *SymTab) {
   for (const AssemblerFixup &Fixup : Fixups) {
-    const ELFSym *Symbol = SymTab->findSymbol(Fixup.symbol(&Ctx));
+    const ELFSym *Symbol;
+    if (Fixup.isNullSymbol())
+      Symbol = SymTab->getNullSymbol();
+    else
+      Symbol = SymTab->findSymbol(Fixup.symbol(&Ctx));
     if (!Symbol)
       llvm::report_fatal_error("Missing symbol mentioned in reloc");