Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Nov 2018 14:42:21 +0000 (UTC)
From:      Dimitry Andric <dim@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-vendor@freebsd.org
Subject:   svn commit: r340122 - in vendor/lld/dist-release_70: COFF ELF test/COFF test/ELF test/ELF/linkerscript
Message-ID:  <201811041442.wA4EgLxj062090@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: dim
Date: Sun Nov  4 14:42:21 2018
New Revision: 340122
URL: https://svnweb.freebsd.org/changeset/base/340122

Log:
  Vendor import of lld release_70 branch r346007:
  https://llvm.org/svn/llvm-project/lld/branches/release_70@346007

Added:
  vendor/lld/dist-release_70/test/COFF/arm64-localimport-align.s   (contents, props changed)
  vendor/lld/dist-release_70/test/ELF/linkerscript/memory-include.test
  vendor/lld/dist-release_70/test/ELF/linkerscript/output-section-include.test
  vendor/lld/dist-release_70/test/ELF/linkerscript/section-include.test
  vendor/lld/dist-release_70/test/ELF/local-ver-preemptible.s   (contents, props changed)
  vendor/lld/dist-release_70/test/ELF/relocatable-rel-iplt.s   (contents, props changed)
Modified:
  vendor/lld/dist-release_70/COFF/Chunks.h
  vendor/lld/dist-release_70/ELF/ScriptParser.cpp
  vendor/lld/dist-release_70/ELF/Symbols.cpp
  vendor/lld/dist-release_70/ELF/Writer.cpp

Modified: vendor/lld/dist-release_70/COFF/Chunks.h
==============================================================================
--- vendor/lld/dist-release_70/COFF/Chunks.h	Sun Nov  4 14:42:17 2018	(r340121)
+++ vendor/lld/dist-release_70/COFF/Chunks.h	Sun Nov  4 14:42:21 2018	(r340122)
@@ -345,7 +345,9 @@ class ImportThunkChunkARM64 : public Chunk { (private)
 // See comments for DefinedLocalImport class.
 class LocalImportChunk : public Chunk {
 public:
-  explicit LocalImportChunk(Defined *S) : Sym(S) {}
+  explicit LocalImportChunk(Defined *S) : Sym(S) {
+    Alignment = Config->is64() ? 8 : 4;
+  }
   size_t getSize() const override;
   void getBaserels(std::vector<Baserel> *Res) override;
   void writeTo(uint8_t *Buf) const override;

Modified: vendor/lld/dist-release_70/ELF/ScriptParser.cpp
==============================================================================
--- vendor/lld/dist-release_70/ELF/ScriptParser.cpp	Sun Nov  4 14:42:17 2018	(r340121)
+++ vendor/lld/dist-release_70/ELF/ScriptParser.cpp	Sun Nov  4 14:42:21 2018	(r340122)
@@ -497,6 +497,9 @@ void ScriptParser::readSections() {
       for (BaseCommand *Cmd : readOverlay())
         V.push_back(Cmd);
       continue;
+    } else if (Tok == "INCLUDE") {
+      readInclude();
+      continue;
     }
 
     if (BaseCommand *Cmd = readAssignment(Tok))
@@ -778,6 +781,8 @@ OutputSection *ScriptParser::readOutputSectionDescript
       Cmd->Filler = readFill();
     } else if (Tok == "SORT") {
       readSort();
+    } else if (Tok == "INCLUDE") {
+      readInclude();
     } else if (peek() == "(") {
       Cmd->SectionCommands.push_back(readInputSectionDescription(Tok));
     } else {
@@ -1404,7 +1409,11 @@ uint64_t ScriptParser::readMemoryAssignment(StringRef 
 void ScriptParser::readMemory() {
   expect("{");
   while (!errorCount() && !consume("}")) {
-    StringRef Name = next();
+    StringRef Tok = next();
+    if (Tok == "INCLUDE") {
+      readInclude();
+      continue;
+    }
 
     uint32_t Flags = 0;
     uint32_t NegFlags = 0;
@@ -1419,10 +1428,9 @@ void ScriptParser::readMemory() {
     uint64_t Length = readMemoryAssignment("LENGTH", "len", "l");
 
     // Add the memory region to the region map.
-    MemoryRegion *MR =
-        make<MemoryRegion>(Name, Origin, Length, Flags, NegFlags);
-    if (!Script->MemoryRegions.insert({Name, MR}).second)
-      setError("region '" + Name + "' already defined");
+    MemoryRegion *MR = make<MemoryRegion>(Tok, Origin, Length, Flags, NegFlags);
+    if (!Script->MemoryRegions.insert({Tok, MR}).second)
+      setError("region '" + Tok + "' already defined");
   }
 }
 

Modified: vendor/lld/dist-release_70/ELF/Symbols.cpp
==============================================================================
--- vendor/lld/dist-release_70/ELF/Symbols.cpp	Sun Nov  4 14:42:17 2018	(r340121)
+++ vendor/lld/dist-release_70/ELF/Symbols.cpp	Sun Nov  4 14:42:21 2018	(r340122)
@@ -209,7 +209,7 @@ uint8_t Symbol::computeBinding() const {
     return Binding;
   if (Visibility != STV_DEFAULT && Visibility != STV_PROTECTED)
     return STB_LOCAL;
-  if (VersionId == VER_NDX_LOCAL && isDefined())
+  if (VersionId == VER_NDX_LOCAL && isDefined() && !IsPreemptible)
     return STB_LOCAL;
   if (!Config->GnuUnique && Binding == STB_GNU_UNIQUE)
     return STB_GLOBAL;

Modified: vendor/lld/dist-release_70/ELF/Writer.cpp
==============================================================================
--- vendor/lld/dist-release_70/ELF/Writer.cpp	Sun Nov  4 14:42:17 2018	(r340121)
+++ vendor/lld/dist-release_70/ELF/Writer.cpp	Sun Nov  4 14:42:21 2018	(r340122)
@@ -874,7 +874,7 @@ void PhdrEntry::add(OutputSection *Sec) {
 // need these symbols, since IRELATIVE relocs are resolved through GOT
 // and PLT. For details, see http://www.airs.com/blog/archives/403.
 template <class ELFT> void Writer<ELFT>::addRelIpltSymbols() {
-  if (needsInterpSection())
+  if (Config->Relocatable || needsInterpSection())
     return;
   StringRef S = Config->IsRela ? "__rela_iplt_start" : "__rel_iplt_start";
   addOptionalRegular(S, InX::RelaIplt, 0, STV_HIDDEN, STB_WEAK);

Added: vendor/lld/dist-release_70/test/COFF/arm64-localimport-align.s
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/lld/dist-release_70/test/COFF/arm64-localimport-align.s	Sun Nov  4 14:42:21 2018	(r340122)
@@ -0,0 +1,24 @@
+// REQUIRES: aarch64
+// RUN: llvm-mc -filetype=obj -triple=aarch64-windows %s -o %t.obj
+// RUN: lld-link -entry:main -subsystem:console %t.obj -out:%t.exe
+// Don't check the output, just make sure it links fine and doesn't
+// error out due to a misaligned load.
+    .text
+    .globl main
+    .globl myfunc
+main:
+    adrp x8, __imp_myfunc
+    ldr  x0, [x8, :lo12:__imp_myfunc]
+    br   x0
+    ret
+myfunc:
+    ret
+
+    .section .rdata, "dr"
+    // Start the .rdata section with a 4 byte chunk, to expose the alignment
+    // of the next chunk in the section.
+mydata:
+    .byte 42
+    // The synthesized LocalImportChunk gets stored here in the .rdata
+    // section, but needs to get proper 8 byte alignment since it is a
+    // pointer, just like regular LookupChunks in the IAT.

Added: vendor/lld/dist-release_70/test/ELF/linkerscript/memory-include.test
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/lld/dist-release_70/test/ELF/linkerscript/memory-include.test	Sun Nov  4 14:42:21 2018	(r340122)
@@ -0,0 +1,23 @@
+# REQUIRES: x86
+
+# RUN: echo '.section .text,"ax"; .global _start; nop' > %t.s
+# RUN: echo '.section .data,"aw"; .quad 0' >> %t.s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t.s -o %t.o
+
+# RUN: echo "RAM2 (rwx): ORIGIN = 0x3000, LENGTH = 0x100" > %t.inc
+# RUN: ld.lld -o %t.elf --script %s %t.o -L %T
+# RUN: llvm-objdump -section-headers %t.elf | FileCheck %s
+# CHECK: .data         00000008 0000000000002000 DATA
+# CHECK: .data2        00000008 0000000000003000 DATA
+
+MEMORY {
+  ROM (rwx): ORIGIN = 0x1000, LENGTH = 0x100
+  RAM (rwx): ORIGIN = 0x2000, LENGTH = 0x100
+  INCLUDE "memory-include.test.tmp.inc"
+}
+
+SECTIONS {
+  .text : { *(.text*) } > ROM
+  .data : { *(.data*) } > RAM
+  .data2 : { QUAD(0) } > RAM2
+}

Added: vendor/lld/dist-release_70/test/ELF/linkerscript/output-section-include.test
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/lld/dist-release_70/test/ELF/linkerscript/output-section-include.test	Sun Nov  4 14:42:21 2018	(r340122)
@@ -0,0 +1,30 @@
+# REQUIRES: x86
+
+# RUN: echo '.section .text,"ax"; .global _start; nop' > %t.s
+# RUN: echo '.section .data,"aw"; .quad 0' >> %t.s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t.s -o %t.o
+
+## Empty include file.
+# RUN: echo "" > %t.inc
+# RUN: ld.lld -o %t.elf --script %s %t.o -L %T
+# RUN: llvm-objdump -section-headers %t.elf | FileCheck %s --check-prefix=CHECK1
+# CHECK1: .data         00000008 0000000000002000 DATA
+
+## Non-empty include file.
+# RUN: echo "QUAD(0)" > %t.inc
+# RUN: ld.lld -o %t.elf --script %s %t.o -L %T
+# RUN: llvm-objdump -section-headers %t.elf | FileCheck %s --check-prefix=CHECK2
+# CHECK2: .data         00000010 0000000000002000 DATA
+
+MEMORY {
+  ROM (rwx): ORIGIN = 0x1000, LENGTH = 0x100
+  RAM (rwx): ORIGIN = 0x2000, LENGTH = 0x100
+}
+
+SECTIONS {
+  .text : { *(.text*) } > ROM
+  .data : {
+    *(.data*)
+    INCLUDE "output-section-include.test.tmp.inc"
+  } > RAM
+}

Added: vendor/lld/dist-release_70/test/ELF/linkerscript/section-include.test
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/lld/dist-release_70/test/ELF/linkerscript/section-include.test	Sun Nov  4 14:42:21 2018	(r340122)
@@ -0,0 +1,32 @@
+# REQUIRES: x86
+
+# RUN: echo '.section .text,"ax"; .global _start; nop' > %t.s
+# RUN: echo '.section .data,"aw"; .quad 0' >> %t.s
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %t.s -o %t.o
+
+## Empty include file.
+# RUN: echo "" > %t.inc
+# RUN: ld.lld -o %t.elf --script %s %t.o -L %T
+# RUN: llvm-objdump -section-headers %t.elf | FileCheck %s --check-prefix=CHECK1
+# CHECK1:      .data         00000008 0000000000002000 DATA
+# CHECK1-NEXT: .data3        00000008 0000000000002008 DATA
+
+## Non-empty include file.
+# RUN: echo ".data2 : { QUAD(0) } > RAM" > %t.inc
+# RUN: ld.lld -o %t.elf --script %s %t.o -L %T
+# RUN: llvm-objdump -section-headers %t.elf | FileCheck %s --check-prefix=CHECK2
+# CHECK2:      .data         00000008 0000000000002000 DATA
+# CHECK2-NEXT: .data2        00000008 0000000000002008 DATA
+# CHECK2-NEXT: .data3        00000008 0000000000002010 DATA
+
+MEMORY {
+  ROM (rwx): ORIGIN = 0x1000, LENGTH = 0x100
+  RAM (rwx): ORIGIN = 0x2000, LENGTH = 0x100
+}
+
+SECTIONS {
+  .text : { *(.text*) } > ROM
+  .data : { *(.data*) } > RAM
+  INCLUDE "section-include.test.tmp.inc"
+  .data3 : { QUAD(0) } > RAM
+}

Added: vendor/lld/dist-release_70/test/ELF/local-ver-preemptible.s
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/lld/dist-release_70/test/ELF/local-ver-preemptible.s	Sun Nov  4 14:42:21 2018	(r340122)
@@ -0,0 +1,22 @@
+# REQUIRES: x86
+# RUN: echo '.global foo; .type foo, @function; foo:' | \
+# RUN:   llvm-mc -filetype=obj -triple=x86_64-unknown-linux - -o %t.so.o
+# RUN: ld.lld %t.so.o -o %t.so -shared
+
+# RUN: echo "{ global: main; local: *; };" > %t.script
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld %t.o %t.so -o %t -version-script %t.script
+# RUN: llvm-readelf -r --symbols %t | FileCheck %s
+
+# CHECK:      Relocation section '.rela.plt' at offset {{.*}} contains 1 entries:
+# CHECK:        R_X86_64_JUMP_SLOT 0000000000201020 foo + 0
+
+# CHECK:      Symbol table '.dynsym' contains 2 entries:
+# CHECK-NEXT:   Num:    Value          Size Type    Bind   Vis      Ndx Name
+# CHECK-NEXT:     0: 0000000000000000     0 NOTYPE  LOCAL  DEFAULT  UND @
+# CHECK-NEXT:     1: 0000000000201020     0 FUNC    GLOBAL DEFAULT  UND foo@
+
+.globl _start
+_start:
+  movl $foo - ., %eax

Added: vendor/lld/dist-release_70/test/ELF/relocatable-rel-iplt.s
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ vendor/lld/dist-release_70/test/ELF/relocatable-rel-iplt.s	Sun Nov  4 14:42:21 2018	(r340122)
@@ -0,0 +1,56 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=i686-- %s -o %t1.o
+# RUN: ld.lld -r %t1.o -o %t2.o
+# RUN: llvm-readobj -t %t2.o | FileCheck %s
+
+// CHECK:      Symbols [
+// CHECK-NEXT:   Symbol {
+// CHECK-NEXT:     Name:  (0)
+// CHECK-NEXT:     Value: 0x0
+// CHECK-NEXT:     Size: 0
+// CHECK-NEXT:     Binding: Local (0x0)
+// CHECK-NEXT:     Type: None (0x0)
+// CHECK-NEXT:     Other: 0
+// CHECK-NEXT:     Section: Undefined (0x0)
+// CHECK-NEXT:   }
+// CHECK-NEXT:   Symbol {
+// CHECK-NEXT:     Name:  (0)
+// CHECK-NEXT:     Value: 0x0
+// CHECK-NEXT:     Size: 0
+// CHECK-NEXT:     Binding: Local (0x0)
+// CHECK-NEXT:     Type: Section (0x3)
+// CHECK-NEXT:     Other: 0
+// CHECK-NEXT:     Section: .text (0x1)
+// CHECK-NEXT:   }
+// CHECK-NEXT:   Symbol {
+// CHECK-NEXT:     Name: __rel_iplt_end (1)
+// CHECK-NEXT:     Value: 0x0
+// CHECK-NEXT:     Size: 0
+// CHECK-NEXT:     Binding: Weak (0x2)
+// CHECK-NEXT:     Type: None (0x0)
+// CHECK-NEXT:     Other [ (0x2)
+// CHECK-NEXT:       STV_HIDDEN (0x2)
+// CHECK-NEXT:     ]
+// CHECK-NEXT:     Section: Undefined (0x0)
+// CHECK-NEXT:   }
+// CHECK-NEXT:   Symbol {
+// CHECK-NEXT:     Name: __rel_iplt_start (16)
+// CHECK-NEXT:     Value: 0x0
+// CHECK-NEXT:     Size: 0
+// CHECK-NEXT:     Binding: Weak (0x2)
+// CHECK-NEXT:     Type: None (0x0)
+// CHECK-NEXT:     Other [ (0x2)
+// CHECK-NEXT:       STV_HIDDEN (0x2)
+// CHECK-NEXT:     ]
+// CHECK-NEXT:     Section: Undefined (0x0)
+// CHECK-NEXT:   }
+// CHECK-NEXT: ]
+
+	movl	__rel_iplt_start, %eax
+	movl	__rel_iplt_end, %eax
+	ret
+
+	.hidden	__rel_iplt_start
+	.hidden	__rel_iplt_end
+	.weak	__rel_iplt_start
+	.weak	__rel_iplt_end



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201811041442.wA4EgLxj062090>