[lld] r230127 - [ELF] Fix References being ignored.

Shankar Easwaran shankare at codeaurora.org
Fri Feb 20 20:42:43 PST 2015


Author: shankare
Date: Fri Feb 20 22:42:43 2015
New Revision: 230127

URL: http://llvm.org/viewvc/llvm-project?rev=230127&view=rev
Log:
[ELF] Fix References being ignored.

The ELFReader was skipping references for sections that contained relocations.

This fixes the bug.

Modified:
    lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
    lld/trunk/test/elf/X86_64/mergesimilarstrings.test

Modified: lld/trunk/lib/ReaderWriter/ELF/ELFFile.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/ReaderWriter/ELF/ELFFile.h?rev=230127&r1=230126&r2=230127&view=diff
==============================================================================
--- lld/trunk/lib/ReaderWriter/ELF/ELFFile.h (original)
+++ lld/trunk/lib/ReaderWriter/ELF/ELFFile.h Fri Feb 20 22:42:43 2015
@@ -930,8 +930,8 @@ ELFFile<ELFT>::createSectionAtom(const E
   sym->st_shndx = 0;
   sym->st_value = 0;
   sym->st_size = 0;
-  auto *newAtom = new (_readerStorage) ELFDefinedAtom<ELFT>(
-      *this, "", sectionName, sym, section, content, 0, 0, _references);
+  auto *newAtom = createDefinedAtomAndAssignRelocations(
+      "", sectionName, sym, section, content, content);
   newAtom->setOrdinal(++_ordinal);
   return newAtom;
 }

Modified: lld/trunk/test/elf/X86_64/mergesimilarstrings.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/elf/X86_64/mergesimilarstrings.test?rev=230127&r1=230126&r2=230127&view=diff
==============================================================================
--- lld/trunk/test/elf/X86_64/mergesimilarstrings.test (original)
+++ lld/trunk/test/elf/X86_64/mergesimilarstrings.test Fri Feb 20 22:42:43 2015
@@ -4,6 +4,8 @@
 # RUN: yaml2obj -format=elf %s > %t.o
 # RUN: lld -flavor gnu -target x86_64 %t.o --noinhibit-exec -o %t1.out
 # RUN: llvm-readobj -sections %t1.out | FileCheck %s
+# RUN: lld -flavor gnu -target x86_64 %t.o --noinhibit-exec -o %t2.out --output-filetype=yaml
+# RUN: FileCheck %s -check-prefix=CHECKRELOCS < %t2.out
 
 FileHeader:
   Class:           ELFCLASS64
@@ -38,3 +40,8 @@ Symbols:
 
 #CHECK:    Name: .rodata
 #CHECK:    Size: 18
+#CHECKRELOCS:   references:
+#CHECKRELOCS:     - kind:            R_X86_64_PC32
+#CHECKRELOCS:       offset:          7
+#CHECKRELOCS:       target:          .rodata
+#CHECKRELOCS:       addend:          -4





More information about the llvm-commits mailing list