[PATCH] ELF/ARM: Ignore R_ARM_V4BX for ARMv4 but allow linking

Adhemerval Zanella adhemerval.zanella at linaro.org
Wed Apr 22 12:43:37 PDT 2015

Indeed, I though the testcase should catch the same case I was originally testing, but seems it is not stressing correctly this code path.  I see the best approach is in fact to make the target Atom reference to point to itself instead to an undefined one (which will trigger an assert of nameless undefined Atom and later failure of linking):

diff --git a/lib/ReaderWriter/ELF/ELFFile.cpp b/lib/ReaderWriter/ELF/ELFFile.cpp
index ab2ec60..8fe2d30 100644

- a/lib/ReaderWriter/ELF/ELFFile.cpp

+++ b/lib/ReaderWriter/ELF/ELFFile.cpp
@@ -36,8 +36,15 @@ std::error_code ELFFile<ELFT>::isCompatible(const MemoryBuffer &mb,
 template <typename ELFT>
 Atom *ELFFile<ELFT>::findAtom(const Elf_Sym *sourceSym,

  const Elf_Sym *targetSym) {

+  StringRef targetName;

  // Return the atom for targetSym if we can do so.
  Atom *target = _symbolToAtomMapping.lookup(targetSym);

+  if (!target)
+    // Some realocations (R_ARM_V4BX) do not have a defined
+    // target.  For this cases make it points to itself.
+    target = _symbolToAtomMapping.lookup(sourceSym);

  if (target->definition() != Atom::definitionRegular)
    return target;
  Atom::Scope scope = llvm::cast<DefinedAtom>(target)->scope();

@@ -47,7 +54,7 @@ Atom *ELFFile<ELFT>::findAtom(const Elf_Sym *sourceSym,

    return target;
  // Otherwise, create a new undefined symbol and returns it.

- StringRef targetName = target->name();

+  targetName = target->name();

  auto it = _undefAtomsForGroupChild.find(targetName);
  if (it != _undefAtomsForGroupChild.end())
    return it->getValue();

What do you think?



More information about the llvm-commits mailing list