From: Shankar Easwaran Date: Sat, 21 Feb 2015 04:42:43 +0000 (+0000) Subject: [ELF] Fix References being ignored. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b8301da4a18c41d73be4d60e273022feffb05fe2;p=platform%2Fupstream%2Fllvm.git [ELF] Fix References being ignored. The ELFReader was skipping references for sections that contained relocations. This fixes the bug. llvm-svn: 230127 --- diff --git a/lld/lib/ReaderWriter/ELF/ELFFile.h b/lld/lib/ReaderWriter/ELF/ELFFile.h index 7d2a4a3..6a74bd5 100644 --- a/lld/lib/ReaderWriter/ELF/ELFFile.h +++ b/lld/lib/ReaderWriter/ELF/ELFFile.h @@ -930,8 +930,8 @@ ELFFile::createSectionAtom(const Elf_Shdr *section, StringRef sectionName, sym->st_shndx = 0; sym->st_value = 0; sym->st_size = 0; - auto *newAtom = new (_readerStorage) ELFDefinedAtom( - *this, "", sectionName, sym, section, content, 0, 0, _references); + auto *newAtom = createDefinedAtomAndAssignRelocations( + "", sectionName, sym, section, content, content); newAtom->setOrdinal(++_ordinal); return newAtom; } diff --git a/lld/test/elf/X86_64/mergesimilarstrings.test b/lld/test/elf/X86_64/mergesimilarstrings.test index 5c868ac..3836f0b 100644 --- a/lld/test/elf/X86_64/mergesimilarstrings.test +++ b/lld/test/elf/X86_64/mergesimilarstrings.test @@ -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