[lld] r308920 - [LTO] Make sure symbol ordering is honoured also for data.
Davide Italiano via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 24 13:15:07 PDT 2017
Author: davide
Date: Mon Jul 24 13:15:07 2017
New Revision: 308920
URL: http://llvm.org/viewvc/llvm-project?rev=308920&view=rev
Log:
[LTO] Make sure symbol ordering is honoured also for data.
Follow-up to r308915 suggested by Rafael and Peter.
Added:
lld/trunk/test/ELF/lto/Inputs/data-ordering-lto.ll
lld/trunk/test/ELF/lto/data-ordering-lto.s
Modified:
lld/trunk/ELF/LTO.cpp
Modified: lld/trunk/ELF/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LTO.cpp?rev=308920&r1=308919&r2=308920&view=diff
==============================================================================
--- lld/trunk/ELF/LTO.cpp (original)
+++ lld/trunk/ELF/LTO.cpp Mon Jul 24 13:15:07 2017
@@ -73,8 +73,9 @@ static std::unique_ptr<lto::LTO> createL
Conf.Options = InitTargetOptionsFromCodeGenFlags();
Conf.Options.RelaxELFRelocations = true;
- // Always emit a section per function with LTO.
+ // Always emit a section per function/datum with LTO.
Conf.Options.FunctionSections = true;
+ Conf.Options.DataSections = true;
if (Config->Relocatable)
Conf.RelocModel = None;
Added: lld/trunk/test/ELF/lto/Inputs/data-ordering-lto.ll
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/Inputs/data-ordering-lto.ll?rev=308920&view=auto
==============================================================================
--- lld/trunk/test/ELF/lto/Inputs/data-ordering-lto.ll (added)
+++ lld/trunk/test/ELF/lto/Inputs/data-ordering-lto.ll Mon Jul 24 13:15:07 2017
@@ -0,0 +1,6 @@
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-scei-ps4"
+
+ at pat = global i32 33, align 4
+ at tin = global i32 33, align 4
+ at dipsy = global i32 33, align 4
Added: lld/trunk/test/ELF/lto/data-ordering-lto.s
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/data-ordering-lto.s?rev=308920&view=auto
==============================================================================
--- lld/trunk/test/ELF/lto/data-ordering-lto.s (added)
+++ lld/trunk/test/ELF/lto/data-ordering-lto.s Mon Jul 24 13:15:07 2017
@@ -0,0 +1,27 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-scei-ps4 %s -o %t.o
+# RUN: llvm-as %p/Inputs/data-ordering-lto.ll -o %t.bc
+
+# Set up the symbol file
+# RUN: echo "tin " > %t_order_lto.txt
+# RUN: echo "dipsy " >> %t_order_lto.txt
+# RUN: echo "pat " >> %t_order_lto.txt
+
+# RUN: ld.lld --symbol-ordering-file %t_order_lto.txt %t.o %t.bc -o %t2.out
+# RUN: llvm-readobj -elf-output-style=GNU -t %t2.out| FileCheck %s
+
+# Check that the order is tin -> dipsy -> pat.
+
+# CHECK: Symbol table '.symtab' contains 5 entries:
+# CHECK-NEXT: Num: Value Size Type Bind Vis Ndx Name
+# CHECK-NEXT: 0: 0000000000000000 0 NOTYPE LOCAL DEFAULT UND
+# CHECK-NEXT: 1: 0000000000201000 0 NOTYPE GLOBAL DEFAULT 1 _start
+# CHECK-NEXT: 2: 0000000000202004 4 OBJECT GLOBAL DEFAULT 2 dipsy
+# CHECK-NEXT: 3: 0000000000202008 4 OBJECT GLOBAL DEFAULT 2 pat
+# CHECK-NEXT: 4: 0000000000202000 4 OBJECT GLOBAL DEFAULT 2 tin
+
+.globl _start
+_start:
+ movl $pat, %ecx
+ movl $dipsy, %ebx
+ movl $tin, %eax
More information about the llvm-commits
mailing list