[PATCH] D11266: LLD: ELF: Correctly identify SHT_NOTE sections with !SHF_ALLOC as type*Note

Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 7 07:36:46 PDT 2015


This revision was automatically updated to reflect the committed changes.
Closed by commit rL244317: ELF: Correctly identify SHT_NOTE sections with !SHF_ALLOC as type*Note (authored by tstellar).

Changed prior to commit:
  http://reviews.llvm.org/D11266?vs=29911&id=31511#toc

Repository:
  rL LLVM

http://reviews.llvm.org/D11266

Files:
  lld/trunk/lib/ReaderWriter/ELF/Atoms.cpp
  lld/trunk/test/elf/note.test

Index: lld/trunk/lib/ReaderWriter/ELF/Atoms.cpp
===================================================================
--- lld/trunk/lib/ReaderWriter/ELF/Atoms.cpp
+++ lld/trunk/lib/ReaderWriter/ELF/Atoms.cpp
@@ -71,8 +71,13 @@
     return typeGnuLinkOnce;
 
   uint64_t flags = _section->sh_flags;
-  if (!(flags & SHF_ALLOC))
+
+  if (!(flags & SHF_ALLOC)) {
+    if (_section->sh_type == SHT_NOTE)
+      return (flags == SHF_WRITE) ? typeRWNote : typeRONote;
     return _contentType = typeNoAlloc;
+  }
+
   if (_section->sh_flags == (SHF_ALLOC | SHF_WRITE | SHF_TLS))
     return _section->sh_type == SHT_NOBITS ? typeThreadZeroFill
                                            : typeThreadData;
Index: lld/trunk/test/elf/note.test
===================================================================
--- lld/trunk/test/elf/note.test
+++ lld/trunk/test/elf/note.test
@@ -1,9 +1,11 @@
 # Check that the linker is not ignoring input sections.
 # RUN: yaml2obj -format=elf %s > %t.obj
 # RUN: lld -flavor gnu -target x86_64 %t.obj -o %t.exe --noinhibit-exec
-# RUN: llvm-objdump -h %t.exe | FileCheck %s
+# RUN: llvm-readobj -s %t.exe | FileCheck %s
 
-# CHECK: {{[0-9]+}} .note
+# CHECK: Section {
+# CHECK: Name: .note
+# CHECK-NEXT: Type: SHT_NOTE
 
 ---
 FileHeader:


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D11266.31511.patch
Type: text/x-patch
Size: 1269 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150807/c7292a63/attachment.bin>


More information about the llvm-commits mailing list