summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/COFF/constant-export.test85
-rw-r--r--test/COFF/constant-export.yaml83
-rw-r--r--test/ELF/Inputs/i386-static-tls-model1.s10
-rw-r--r--test/ELF/Inputs/i386-static-tls-model2.s9
-rw-r--r--test/ELF/Inputs/i386-static-tls-model3.s9
-rw-r--r--test/ELF/Inputs/i386-static-tls-model4.s9
-rw-r--r--test/ELF/gdb-index-empty.s116
-rw-r--r--test/ELF/gdb-index-gc-sections.s157
-rw-r--r--test/ELF/i386-static-tls-model.s20
-rw-r--r--test/ELF/i386-tls-ie-shared.s52
-rw-r--r--test/ELF/incompatible-section-types2.s6
-rw-r--r--test/ELF/linkerscript/early-assign-symbol.s14
-rw-r--r--test/ELF/linkerscript/ehdr_start.s14
-rw-r--r--test/ELF/linkerscript/sections-constraint.s2
-rw-r--r--test/ELF/linkerscript/sections.s5
-rw-r--r--test/ELF/linkerscript/symbol-memoryexpr.s33
-rw-r--r--test/ELF/many-alloc-sections.s106
-rw-r--r--test/ELF/many-sections.s9
-rw-r--r--test/ELF/tls-dynamic-i686.s46
-rw-r--r--test/ELF/tls-opt-iele-i686-nopic.s44
-rw-r--r--test/ELF/x86-64-reloc-tpoff32-fpic.s14
21 files changed, 622 insertions, 221 deletions
diff --git a/test/COFF/constant-export.test b/test/COFF/constant-export.test
index 18b1f5e30d29..80597660ce19 100644
--- a/test/COFF/constant-export.test
+++ b/test/COFF/constant-export.test
@@ -1,5 +1,5 @@
# RUN: mkdir -p %t
-# RUN: yaml2obj -o %t/constant-export.obj %S/constant-export.yaml
+# RUN: yaml2obj -o %t/constant-export.obj %s
# RUN: lld-link /machine:x86 /dll /entry:__CFConstantStringClassReference -out:%t/constant-export.dll %t/constant-export.obj
# RUN: llvm-readobj -coff-exports %t/constant-export.lib | FileCheck %s
@@ -7,3 +7,86 @@
# CHECK: Name type: noprefix
# CHECK: Symbol: __imp____CFConstantStringClassReference
+--- !COFF
+header:
+ Machine: IMAGE_FILE_MACHINE_I386
+ Characteristics: [ ]
+sections:
+ - Name: .text
+ Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
+ Alignment: 4
+ SectionData: ''
+ - Name: .data
+ Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
+ Alignment: 4
+ SectionData: ''
+ - Name: .bss
+ Characteristics: [ IMAGE_SCN_CNT_UNINITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
+ Alignment: 4
+ SectionData: ''
+ - Name: .drectve
+ Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ]
+ Alignment: 1
+ SectionData: 20202D6578706F72743A5F5F5F4346436F6E7374616E74537472696E67436C6173735265666572656E63652C434F4E5354414E54
+symbols:
+ - Name: .text
+ Value: 0
+ SectionNumber: 1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 0
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 0
+ Number: 1
+ - Name: .data
+ Value: 0
+ SectionNumber: 2
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 0
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 0
+ Number: 2
+ - Name: .bss
+ Value: 0
+ SectionNumber: 3
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 0
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 0
+ Number: 3
+ - Name: .drectve
+ Value: 0
+ SectionNumber: 4
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ SectionDefinition:
+ Length: 52
+ NumberOfRelocations: 0
+ NumberOfLinenumbers: 0
+ CheckSum: 1983959296
+ Number: 4
+ - Name: '@feat.00'
+ Value: 1
+ SectionNumber: -1
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_STATIC
+ - Name: ___CFConstantStringClassReference
+ Value: 128
+ SectionNumber: 0
+ SimpleType: IMAGE_SYM_TYPE_NULL
+ ComplexType: IMAGE_SYM_DTYPE_NULL
+ StorageClass: IMAGE_SYM_CLASS_EXTERNAL
+...
diff --git a/test/COFF/constant-export.yaml b/test/COFF/constant-export.yaml
deleted file mode 100644
index 7e44bb70c9d7..000000000000
--- a/test/COFF/constant-export.yaml
+++ /dev/null
@@ -1,83 +0,0 @@
---- !COFF
-header:
- Machine: IMAGE_FILE_MACHINE_I386
- Characteristics: [ ]
-sections:
- - Name: .text
- Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
- Alignment: 4
- SectionData: ''
- - Name: .data
- Characteristics: [ IMAGE_SCN_CNT_INITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
- Alignment: 4
- SectionData: ''
- - Name: .bss
- Characteristics: [ IMAGE_SCN_CNT_UNINITIALIZED_DATA, IMAGE_SCN_MEM_READ, IMAGE_SCN_MEM_WRITE ]
- Alignment: 4
- SectionData: ''
- - Name: .drectve
- Characteristics: [ IMAGE_SCN_LNK_INFO, IMAGE_SCN_LNK_REMOVE ]
- Alignment: 1
- SectionData: 20202D6578706F72743A5F5F5F4346436F6E7374616E74537472696E67436C6173735265666572656E63652C434F4E5354414E54
-symbols:
- - Name: .text
- Value: 0
- SectionNumber: 1
- SimpleType: IMAGE_SYM_TYPE_NULL
- ComplexType: IMAGE_SYM_DTYPE_NULL
- StorageClass: IMAGE_SYM_CLASS_STATIC
- SectionDefinition:
- Length: 0
- NumberOfRelocations: 0
- NumberOfLinenumbers: 0
- CheckSum: 0
- Number: 1
- - Name: .data
- Value: 0
- SectionNumber: 2
- SimpleType: IMAGE_SYM_TYPE_NULL
- ComplexType: IMAGE_SYM_DTYPE_NULL
- StorageClass: IMAGE_SYM_CLASS_STATIC
- SectionDefinition:
- Length: 0
- NumberOfRelocations: 0
- NumberOfLinenumbers: 0
- CheckSum: 0
- Number: 2
- - Name: .bss
- Value: 0
- SectionNumber: 3
- SimpleType: IMAGE_SYM_TYPE_NULL
- ComplexType: IMAGE_SYM_DTYPE_NULL
- StorageClass: IMAGE_SYM_CLASS_STATIC
- SectionDefinition:
- Length: 0
- NumberOfRelocations: 0
- NumberOfLinenumbers: 0
- CheckSum: 0
- Number: 3
- - Name: .drectve
- Value: 0
- SectionNumber: 4
- SimpleType: IMAGE_SYM_TYPE_NULL
- ComplexType: IMAGE_SYM_DTYPE_NULL
- StorageClass: IMAGE_SYM_CLASS_STATIC
- SectionDefinition:
- Length: 52
- NumberOfRelocations: 0
- NumberOfLinenumbers: 0
- CheckSum: 1983959296
- Number: 4
- - Name: '@feat.00'
- Value: 1
- SectionNumber: -1
- SimpleType: IMAGE_SYM_TYPE_NULL
- ComplexType: IMAGE_SYM_DTYPE_NULL
- StorageClass: IMAGE_SYM_CLASS_STATIC
- - Name: ___CFConstantStringClassReference
- Value: 128
- SectionNumber: 0
- SimpleType: IMAGE_SYM_TYPE_NULL
- ComplexType: IMAGE_SYM_DTYPE_NULL
- StorageClass: IMAGE_SYM_CLASS_EXTERNAL
-...
diff --git a/test/ELF/Inputs/i386-static-tls-model1.s b/test/ELF/Inputs/i386-static-tls-model1.s
deleted file mode 100644
index e7e584c1fcf1..000000000000
--- a/test/ELF/Inputs/i386-static-tls-model1.s
+++ /dev/null
@@ -1,10 +0,0 @@
-.section ".tdata", "awT", @progbits
-.globl var
-var:
-
-.section .foo, "aw"
-.global _start
-_start:
- movl $var@tpoff, %edx # R_386_TLS_LE_32
- movl %gs:0, %ecx
- subl %edx, %eax
diff --git a/test/ELF/Inputs/i386-static-tls-model2.s b/test/ELF/Inputs/i386-static-tls-model2.s
deleted file mode 100644
index b28a1458742d..000000000000
--- a/test/ELF/Inputs/i386-static-tls-model2.s
+++ /dev/null
@@ -1,9 +0,0 @@
-.section ".tdata", "awT", @progbits
-.globl var
-var:
-
-.section .foo, "aw"
-.global _start
-_start:
- movl %gs:0, %eax
- addl var@gotntpoff(%ebx),%eax # R_386_TLS_GOTIE
diff --git a/test/ELF/Inputs/i386-static-tls-model3.s b/test/ELF/Inputs/i386-static-tls-model3.s
deleted file mode 100644
index f92267ecbdd0..000000000000
--- a/test/ELF/Inputs/i386-static-tls-model3.s
+++ /dev/null
@@ -1,9 +0,0 @@
-.section ".tdata", "awT", @progbits
-.globl var
-var:
-
-.section .foo, "aw"
-.global _start
-_start:
- movl %gs:0, %eax
- addl var@indntpoff, %eax #R_386_TLS_IE
diff --git a/test/ELF/Inputs/i386-static-tls-model4.s b/test/ELF/Inputs/i386-static-tls-model4.s
deleted file mode 100644
index ffb20def4fab..000000000000
--- a/test/ELF/Inputs/i386-static-tls-model4.s
+++ /dev/null
@@ -1,9 +0,0 @@
-.section ".tdata", "awT", @progbits
-.globl var
-var:
-
-.section .foo, "aw"
-.global _start
-_start:
- movl %gs:0, %eax
- leal var@ntpoff(%eax), %eax #R_386_TLS_LE
diff --git a/test/ELF/gdb-index-empty.s b/test/ELF/gdb-index-empty.s
new file mode 100644
index 000000000000..933afed33e2f
--- /dev/null
+++ b/test/ELF/gdb-index-empty.s
@@ -0,0 +1,116 @@
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux -o %t %s
+# RUN: ld.lld --gdb-index --gc-sections -o %t2 %t
+# RUN: llvm-dwarfdump -debug-dump=gdb_index %t2 | FileCheck %s
+
+# CHECK: Address area offset = 0x28, has 0 entries:
+
+# Generated with: (clang r302976)
+# echo "void _start() { __builtin_unreachable(); }" | \
+# clang -Os -g -S -o gdb-index-empty.s -x c - -Xclang -fdebug-compilation-dir -Xclang .
+
+ .text
+ .file "-"
+ .globl _start
+ .type _start,@function
+_start: # @_start
+.Lfunc_begin0:
+ .cfi_startproc
+# BB#0: # %entry
+.Lfunc_end0:
+ .size _start, .Lfunc_end0-_start
+ .cfi_endproc
+
+ .file 1 "<stdin>"
+ .section .debug_str,"MS",@progbits,1
+.Linfo_string0:
+ .asciz "clang version 5.0.0 " # string offset=0
+.Linfo_string1:
+ .asciz "-" # string offset=21
+.Linfo_string2:
+ .asciz "." # string offset=23
+.Linfo_string3:
+ .asciz "_start" # string offset=25
+ .section .debug_loc,"",@progbits
+ .section .debug_abbrev,"",@progbits
+ .byte 1 # Abbreviation Code
+ .byte 17 # DW_TAG_compile_unit
+ .byte 1 # DW_CHILDREN_yes
+ .byte 37 # DW_AT_producer
+ .byte 14 # DW_FORM_strp
+ .byte 19 # DW_AT_language
+ .byte 5 # DW_FORM_data2
+ .byte 3 # DW_AT_name
+ .byte 14 # DW_FORM_strp
+ .byte 16 # DW_AT_stmt_list
+ .byte 23 # DW_FORM_sec_offset
+ .byte 27 # DW_AT_comp_dir
+ .byte 14 # DW_FORM_strp
+ .byte 17 # DW_AT_low_pc
+ .byte 1 # DW_FORM_addr
+ .byte 18 # DW_AT_high_pc
+ .byte 6 # DW_FORM_data4
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 2 # Abbreviation Code
+ .byte 46 # DW_TAG_subprogram
+ .byte 0 # DW_CHILDREN_no
+ .byte 17 # DW_AT_low_pc
+ .byte 1 # DW_FORM_addr
+ .byte 18 # DW_AT_high_pc
+ .byte 6 # DW_FORM_data4
+ .byte 64 # DW_AT_frame_base
+ .byte 24 # DW_FORM_exprloc
+ .byte 3 # DW_AT_name
+ .byte 14 # DW_FORM_strp
+ .byte 58 # DW_AT_decl_file
+ .byte 11 # DW_FORM_data1
+ .byte 59 # DW_AT_decl_line
+ .byte 11 # DW_FORM_data1
+ .byte 63 # DW_AT_external
+ .byte 25 # DW_FORM_flag_present
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 0 # EOM(3)
+ .section .debug_info,"",@progbits
+.Lcu_begin0:
+ .long 60 # Length of Unit
+ .short 4 # DWARF version number
+ .long .debug_abbrev # Offset Into Abbrev. Section
+ .byte 8 # Address Size (in bytes)
+ .byte 1 # Abbrev [1] 0xb:0x35 DW_TAG_compile_unit
+ .long .Linfo_string0 # DW_AT_producer
+ .short 12 # DW_AT_language
+ .long .Linfo_string1 # DW_AT_name
+ .long .Lline_table_start0 # DW_AT_stmt_list
+ .long .Linfo_string2 # DW_AT_comp_dir
+ .quad .Lfunc_begin0 # DW_AT_low_pc
+ .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
+ .byte 2 # Abbrev [2] 0x2a:0x15 DW_TAG_subprogram
+ .quad .Lfunc_begin0 # DW_AT_low_pc
+ .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
+ .byte 1 # DW_AT_frame_base
+ .byte 87
+ .long .Linfo_string3 # DW_AT_name
+ .byte 1 # DW_AT_decl_file
+ .byte 1 # DW_AT_decl_line
+ # DW_AT_external
+ .byte 0 # End Of Children Mark
+ .section .debug_ranges,"",@progbits
+ .section .debug_macinfo,"",@progbits
+.Lcu_macro_begin0:
+ .byte 0 # End Of Macro List Mark
+ .section .debug_pubnames,"",@progbits
+ .long .LpubNames_end0-.LpubNames_begin0 # Length of Public Names Info
+.LpubNames_begin0:
+ .short 2 # DWARF Version
+ .long .Lcu_begin0 # Offset of Compilation Unit Info
+ .long 64 # Compilation Unit Length
+ .long 42 # DIE offset
+ .asciz "_start" # External Name
+ .long 0 # End Mark
+.LpubNames_end0:
+
+ .ident "clang version 5.0.0 "
+ .section ".note.GNU-stack","",@progbits
+ .section .debug_line,"",@progbits
+.Lline_table_start0:
diff --git a/test/ELF/gdb-index-gc-sections.s b/test/ELF/gdb-index-gc-sections.s
new file mode 100644
index 000000000000..70a14754656c
--- /dev/null
+++ b/test/ELF/gdb-index-gc-sections.s
@@ -0,0 +1,157 @@
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux -o %t %s
+# RUN: ld.lld --gdb-index --gc-sections -o %t2 %t
+# RUN: llvm-dwarfdump -debug-dump=gdb_index %t2 | FileCheck %s
+
+# CHECK: Address area offset = 0x28, has 1 entries:
+# CHECK-NEXT: Low/High address = [0x201000, 0x201001) (Size: 0x1), CU id = 0
+
+# Generated with: (clang r302976)
+# echo "void _start() {} void dead() {}" | \
+# clang -Os -g -S -ffunction-sections -o gdb-index-gc-sections.s -x c - -Xclang -fdebug-compilation-dir -Xclang .
+
+ .text
+ .file "-"
+ .section .text._start,"ax",@progbits
+ .globl _start
+ .type _start,@function
+_start: # @_start
+.Lfunc_begin0:
+ .file 1 "<stdin>"
+ .loc 1 1 0 # <stdin>:1:0
+ .cfi_startproc
+# BB#0: # %entry
+ .loc 1 1 16 prologue_end # <stdin>:1:16
+ retq
+.Ltmp0:
+.Lfunc_end0:
+ .size _start, .Lfunc_end0-_start
+ .cfi_endproc
+
+ .section .text.dead,"ax",@progbits
+ .globl dead
+ .type dead,@function
+dead: # @dead
+.Lfunc_begin1:
+ .loc 1 1 0 # <stdin>:1:0
+ .cfi_startproc
+# BB#0: # %entry
+ .loc 1 1 31 prologue_end # <stdin>:1:31
+ retq
+.Ltmp1:
+.Lfunc_end1:
+ .size dead, .Lfunc_end1-dead
+ .cfi_endproc
+
+ .section .debug_str,"MS",@progbits,1
+.Linfo_string0:
+ .asciz "clang version 5.0.0 " # string offset=0
+.Linfo_string1:
+ .asciz "-" # string offset=21
+.Linfo_string2:
+ .asciz "." # string offset=23
+.Linfo_string3:
+ .asciz "_start" # string offset=25
+.Linfo_string4:
+ .asciz "dead" # string offset=32
+ .section .debug_loc,"",@progbits
+ .section .debug_abbrev,"",@progbits
+ .byte 1 # Abbreviation Code
+ .byte 17 # DW_TAG_compile_unit
+ .byte 1 # DW_CHILDREN_yes
+ .byte 37 # DW_AT_producer
+ .byte 14 # DW_FORM_strp
+ .byte 19 # DW_AT_language
+ .byte 5 # DW_FORM_data2
+ .byte 3 # DW_AT_name
+ .byte 14 # DW_FORM_strp
+ .byte 16 # DW_AT_stmt_list
+ .byte 23 # DW_FORM_sec_offset
+ .byte 27 # DW_AT_comp_dir
+ .byte 14 # DW_FORM_strp
+ .byte 17 # DW_AT_low_pc
+ .byte 1 # DW_FORM_addr
+ .byte 85 # DW_AT_ranges
+ .byte 23 # DW_FORM_sec_offset
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 2 # Abbreviation Code
+ .byte 46 # DW_TAG_subprogram
+ .byte 0 # DW_CHILDREN_no
+ .byte 17 # DW_AT_low_pc
+ .byte 1 # DW_FORM_addr
+ .byte 18 # DW_AT_high_pc
+ .byte 6 # DW_FORM_data4
+ .byte 64 # DW_AT_frame_base
+ .byte 24 # DW_FORM_exprloc
+ .byte 3 # DW_AT_name
+ .byte 14 # DW_FORM_strp
+ .byte 58 # DW_AT_decl_file
+ .byte 11 # DW_FORM_data1
+ .byte 59 # DW_AT_decl_line
+ .byte 11 # DW_FORM_data1
+ .byte 63 # DW_AT_external
+ .byte 25 # DW_FORM_flag_present
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 0 # EOM(3)
+ .section .debug_info,"",@progbits
+.Lcu_begin0:
+ .long 81 # Length of Unit
+ .short 4 # DWARF version number
+ .long .debug_abbrev # Offset Into Abbrev. Section
+ .byte 8 # Address Size (in bytes)
+ .byte 1 # Abbrev [1] 0xb:0x4a DW_TAG_compile_unit
+ .long .Linfo_string0 # DW_AT_producer
+ .short 12 # DW_AT_language
+ .long .Linfo_string1 # DW_AT_name
+ .long .Lline_table_start0 # DW_AT_stmt_list
+ .long .Linfo_string2 # DW_AT_comp_dir
+ .quad 0 # DW_AT_low_pc
+ .long .Ldebug_ranges0 # DW_AT_ranges
+ .byte 2 # Abbrev [2] 0x2a:0x15 DW_TAG_subprogram
+ .quad .Lfunc_begin0 # DW_AT_low_pc
+ .long .Lfunc_end0-.Lfunc_begin0 # DW_AT_high_pc
+ .byte 1 # DW_AT_frame_base
+ .byte 87
+ .long .Linfo_string3 # DW_AT_name
+ .byte 1 # DW_AT_decl_file
+ .byte 1 # DW_AT_decl_line
+ # DW_AT_external
+ .byte 2 # Abbrev [2] 0x3f:0x15 DW_TAG_subprogram
+ .quad .Lfunc_begin1 # DW_AT_low_pc
+ .long .Lfunc_end1-.Lfunc_begin1 # DW_AT_high_pc
+ .byte 1 # DW_AT_frame_base
+ .byte 87
+ .long .Linfo_string4 # DW_AT_name
+ .byte 1 # DW_AT_decl_file
+ .byte 1 # DW_AT_decl_line
+ # DW_AT_external
+ .byte 0 # End Of Children Mark
+ .section .debug_ranges,"",@progbits
+.Ldebug_ranges0:
+ .quad .Lfunc_begin0
+ .quad .Lfunc_end0
+ .quad .Lfunc_begin1
+ .quad .Lfunc_end1
+ .quad 0
+ .quad 0
+ .section .debug_macinfo,"",@progbits
+.Lcu_macro_begin0:
+ .byte 0 # End Of Macro List Mark
+ .section .debug_pubnames,"",@progbits
+ .long .LpubNames_end0-.LpubNames_begin0 # Length of Public Names Info
+.LpubNames_begin0:
+ .short 2 # DWARF Version
+ .long .Lcu_begin0 # Offset of Compilation Unit Info
+ .long 85 # Compilation Unit Length
+ .long 42 # DIE offset
+ .asciz "_start" # External Name
+ .long 63 # DIE offset
+ .asciz "dead" # External Name
+ .long 0 # End Mark
+.LpubNames_end0:
+
+ .ident "clang version 5.0.0 "
+ .section ".note.GNU-stack","",@progbits
+ .section .debug_line,"",@progbits
+.Lline_table_start0:
diff --git a/test/ELF/i386-static-tls-model.s b/test/ELF/i386-static-tls-model.s
deleted file mode 100644
index b2799c4c722f..000000000000
--- a/test/ELF/i386-static-tls-model.s
+++ /dev/null
@@ -1,20 +0,0 @@
-# REQUIRES: x86
-
-# RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %S/Inputs/i386-static-tls-model1.s -o %t.o
-# RUN: ld.lld %t.o -o %t1 -shared
-# RUN: llvm-readobj -dynamic-table %t1 | FileCheck %s
-
-# RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %S/Inputs/i386-static-tls-model2.s -o %t.o
-# RUN: ld.lld %t.o -o %t2 -shared
-# RUN: llvm-readobj -dynamic-table %t2 | FileCheck %s
-
-# RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %S/Inputs/i386-static-tls-model3.s -o %t.o
-# RUN: ld.lld %t.o -o %t3 -shared
-# RUN: llvm-readobj -dynamic-table %t3 | FileCheck %s
-
-# RUN: llvm-mc -filetype=obj -triple=i686-pc-linux %S/Inputs/i386-static-tls-model4.s -o %t.o
-# RUN: ld.lld %t.o -o %t4 -shared
-# RUN: llvm-readobj -dynamic-table %t4 | FileCheck %s
-
-# CHECK: DynamicSection [
-# CHECK: FLAGS STATIC_TLS
diff --git a/test/ELF/i386-tls-ie-shared.s b/test/ELF/i386-tls-ie-shared.s
index c6dccf84a216..8becc3199f95 100644
--- a/test/ELF/i386-tls-ie-shared.s
+++ b/test/ELF/i386-tls-ie-shared.s
@@ -13,8 +13,8 @@
// GOTRELSHARED-NEXT: SHF_ALLOC
// GOTRELSHARED-NEXT: SHF_WRITE
// GOTRELSHARED-NEXT: ]
-// GOTRELSHARED-NEXT: Address: 0x1060
-// GOTRELSHARED-NEXT: Offset: 0x1060
+// GOTRELSHARED-NEXT: Address: 0x1058
+// GOTRELSHARED-NEXT: Offset: 0x1058
// GOTRELSHARED-NEXT: Size: 16
// GOTRELSHARED-NEXT: Link: 0
// GOTRELSHARED-NEXT: Info: 0
@@ -31,36 +31,36 @@
// GOTRELSHARED-NEXT: 0x202D R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x2036 R_386_RELATIVE - 0x0
// GOTRELSHARED-NEXT: 0x203F R_386_RELATIVE - 0x0
-// GOTRELSHARED-NEXT: 0x1060 R_386_TLS_TPOFF tlslocal0 0x0
-// GOTRELSHARED-NEXT: 0x1064 R_386_TLS_TPOFF tlslocal1 0x0
-// GOTRELSHARED-NEXT: 0x1068 R_386_TLS_TPOFF tlsshared0 0x0
-// GOTRELSHARED-NEXT: 0x106C R_386_TLS_TPOFF tlsshared1 0x0
+// GOTRELSHARED-NEXT: 0x1058 R_386_TLS_TPOFF tlslocal0 0x0
+// GOTRELSHARED-NEXT: 0x105C R_386_TLS_TPOFF tlslocal1 0x0
+// GOTRELSHARED-NEXT: 0x1060 R_386_TLS_TPOFF tlsshared0 0x0
+// GOTRELSHARED-NEXT: 0x1064 R_386_TLS_TPOFF tlsshared1 0x0
// GOTRELSHARED-NEXT: }
// GOTRELSHARED-NEXT: ]
// GOTRELSHARED: 0x6FFFFFFA RELCOUNT 8
// DISASMSHARED: Disassembly of section test:
// DISASMSHARED-NEXT: _start:
-// (.got)[0] = 0x1060 = 4192
-// (.got)[1] = 0x1064 = 4196
-// (.got)[2] = 0x1068 = 4200
-// (.got)[3] = 0x106C = 4204
-// DISASMSHARED-NEXT: 2000: {{.*}} movl 4192, %ecx
-// DISASMSHARED-NEXT: 2006: {{.*}} movl %gs:(%ecx), %eax
-// DISASMSHARED-NEXT: 2009: {{.*}} movl 4192, %eax
-// DISASMSHARED-NEXT: 200e: {{.*}} movl %gs:(%eax), %eax
-// DISASMSHARED-NEXT: 2011: {{.*}} addl 4192, %ecx
-// DISASMSHARED-NEXT: 2017: {{.*}} movl %gs:(%ecx), %eax
-// DISASMSHARED-NEXT: 201a: {{.*}} movl 4196, %ecx
-// DISASMSHARED-NEXT: 2020: {{.*}} movl %gs:(%ecx), %eax
-// DISASMSHARED-NEXT: 2023: {{.*}} movl 4196, %eax
-// DISASMSHARED-NEXT: 2028: {{.*}} movl %gs:(%eax), %eax
-// DISASMSHARED-NEXT: 202b: {{.*}} addl 4196, %ecx
-// DISASMSHARED-NEXT: 2031: {{.*}} movl %gs:(%ecx), %eax
-// DISASMSHARED-NEXT: 2034: {{.*}} movl 4200, %ecx
-// DISASMSHARED-NEXT: 203a: {{.*}} movl %gs:(%ecx), %eax
-// DISASMSHARED-NEXT: 203d: {{.*}} addl 4204, %ecx
-// DISASMSHARED-NEXT: 2043: {{.*}} movl %gs:(%ecx), %eax
+// (.got)[0] = 0x2050 = 8272
+// (.got)[1] = 0x2054 = 8276
+// (.got)[2] = 0x2058 = 8280
+// (.got)[3] = 0x205C = 8284
+// DISASMSHARED-NEXT: 2000: 8b 0d 58 10 00 00 movl 4184, %ecx
+// DISASMSHARED-NEXT: 2006: 65 8b 01 movl %gs:(%ecx), %eax
+// DISASMSHARED-NEXT: 2009: a1 58 10 00 00 movl 4184, %eax
+// DISASMSHARED-NEXT: 200e: 65 8b 00 movl %gs:(%eax), %eax
+// DISASMSHARED-NEXT: 2011: 03 0d 58 10 00 00 addl 4184, %ecx
+// DISASMSHARED-NEXT: 2017: 65 8b 01 movl %gs:(%ecx), %eax
+// DISASMSHARED-NEXT: 201a: 8b 0d 5c 10 00 00 movl 4188, %ecx
+// DISASMSHARED-NEXT: 2020: 65 8b 01 movl %gs:(%ecx), %eax
+// DISASMSHARED-NEXT: 2023: a1 5c 10 00 00 movl 4188, %eax
+// DISASMSHARED-NEXT: 2028: 65 8b 00 movl %gs:(%eax), %eax
+// DISASMSHARED-NEXT: 202b: 03 0d 5c 10 00 00 addl 4188, %ecx
+// DISASMSHARED-NEXT: 2031: 65 8b 01 movl %gs:(%ecx), %eax
+// DISASMSHARED-NEXT: 2034: 8b 0d 60 10 00 00 movl 4192, %ecx
+// DISASMSHARED-NEXT: 203a: 65 8b 01 movl %gs:(%ecx), %eax
+// DISASMSHARED-NEXT: 203d: 03 0d 64 10 00 00 addl 4196, %ecx
+// DISASMSHARED-NEXT: 2043: 65 8b 01 movl %gs:(%ecx), %eax
.type tlslocal0,@object
.section .tbss,"awT",@nobits
diff --git a/test/ELF/incompatible-section-types2.s b/test/ELF/incompatible-section-types2.s
index 2cf9b8548aa1..146e680ab271 100644
--- a/test/ELF/incompatible-section-types2.s
+++ b/test/ELF/incompatible-section-types2.s
@@ -1,7 +1,9 @@
// RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
// RUN: not ld.lld %t.o -o %t 2>&1 | FileCheck %s
-// CHECK: error: Section has different type from others with the same name <internal>:(.shstrtab)
+// CHECK: error: section type mismatch for .shstrtab
+// CHECK-NEXT: >>> <internal>:(.shstrtab): SHT_STRTAB
+// CHECK-NEXT: >>> output section .shstrtab: Unknown
-.section .shstrtab,""
+.section .shstrtab,"",@12345
.short 20
diff --git a/test/ELF/linkerscript/early-assign-symbol.s b/test/ELF/linkerscript/early-assign-symbol.s
new file mode 100644
index 000000000000..21940c088393
--- /dev/null
+++ b/test/ELF/linkerscript/early-assign-symbol.s
@@ -0,0 +1,14 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+
+# RUN: echo "SECTIONS { aaa = 1 + ABSOLUTE(foo - 1); .text : { *(.text*) } }" > %t1.script
+# RUN: not ld.lld -o %t --script %t1.script %t.o 2>&1 | FileCheck %s
+
+# RUN: echo "SECTIONS { aaa = ABSOLUTE(foo - 1) + 1; .text : { *(.text*) } }" > %t2.script
+# RUN: not ld.lld -o %t --script %t2.script %t.o 2>&1 | FileCheck %s
+
+# CHECK: error: unable to evaluate expression: input section .text has no output section assigned
+
+.section .text
+.globl foo
+foo:
diff --git a/test/ELF/linkerscript/ehdr_start.s b/test/ELF/linkerscript/ehdr_start.s
index 935fa2bf3391..4da158a83956 100644
--- a/test/ELF/linkerscript/ehdr_start.s
+++ b/test/ELF/linkerscript/ehdr_start.s
@@ -2,9 +2,17 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
# RUN: echo "SECTIONS { }" > %t.script
-# RUN: not ld.lld %t.o -script %t.script -o %t 2>&1 | FileCheck %s
-# CHECK: error: undefined symbol: __ehdr_start
-# CHECK: >>> referenced by {{.*}}:(.text+0x0)
+# RUN: ld.lld %t.o -script %t.script -o %t
+# RUN: llvm-readobj -symbols %t | FileCheck %s
+# CHECK: Name: __ehdr_start (1)
+# CHECK-NEXT: Value: 0x0
+# CHECK-NEXT: Size: 0
+# CHECK-NEXT: Binding: Local (0x0)
+# CHECK-NEXT: Type: None (0x0)
+# CHECK-NEXT: Other [ (0x2)
+# CHECK-NEXT: STV_HIDDEN (0x2)
+# CHECK-NEXT: ]
+# CHECK-NEXT: Section: .text (0x1)
.text
.global _start, __ehdr_start
diff --git a/test/ELF/linkerscript/sections-constraint.s b/test/ELF/linkerscript/sections-constraint.s
index 4d95ec18336c..796240627170 100644
--- a/test/ELF/linkerscript/sections-constraint.s
+++ b/test/ELF/linkerscript/sections-constraint.s
@@ -24,8 +24,8 @@
# NO1-NEXT: 0 00000000
# NO1: .writable 00000004
# NO1: .foo.2 00000004
-# NO1: .readable 00000004
# NO1: .foo.1 00000004
+# NO1: .readable 00000004
.global _start
_start:
diff --git a/test/ELF/linkerscript/sections.s b/test/ELF/linkerscript/sections.s
index 69c6f19d078d..d5645c303754 100644
--- a/test/ELF/linkerscript/sections.s
+++ b/test/ELF/linkerscript/sections.s
@@ -45,8 +45,9 @@
# SEC-ORDER: 3 .shstrtab 0000003b {{[0-9a-f]*}}
# SEC-ORDER: 4 .symtab 00000030 {{[0-9a-f]*}}
# SEC-ORDER: 5 .strtab 00000008 {{[0-9a-f]*}}
-# SEC-ORDER: 6 .data 00000020 {{[0-9a-f]*}} DATA
-# SEC-ORDER: 7 .text 0000000e {{[0-9a-f]*}} TEXT DATA
+# SEC-ORDER: 6 .comment 00000008 {{[0-9a-f]*}}
+# SEC-ORDER: 7 .data 00000020 {{[0-9a-f]*}} DATA
+# SEC-ORDER: 8 .text 0000000e {{[0-9a-f]*}} TEXT DATA
# .text and .data have swapped names but proper sizes and types.
# RUN: echo "SECTIONS { \
diff --git a/test/ELF/linkerscript/symbol-memoryexpr.s b/test/ELF/linkerscript/symbol-memoryexpr.s
new file mode 100644
index 000000000000..9c75274e1644
--- /dev/null
+++ b/test/ELF/linkerscript/symbol-memoryexpr.s
@@ -0,0 +1,33 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t
+
+# RUN: echo "MEMORY { \
+# RUN: ram (rwx) : ORIGIN = 0x8000, LENGTH = 256K \
+# RUN: } \
+# RUN: SECTIONS { \
+# RUN: origin = ORIGIN(ram); \
+# RUN: length = LENGTH(ram); \
+# RUN: end = ORIGIN(ram) + LENGTH(ram); \
+# RUN: }" > %t.script
+# RUN: ld.lld -o %t1 --script %t.script %t
+# RUN: llvm-objdump -t %t1 | FileCheck %s
+
+# CHECK: SYMBOL TABLE:
+# CHECK-NEXT: 0000000000000000 *UND* 00000000
+# CHECK-NEXT: 0000000000008000 .text 00000000 _start
+# CHECK-NEXT: 0000000000008000 *ABS* 00000000 origin
+# CHECK-NEXT: 0000000000040000 *ABS* 00000000 length
+# CHECK-NEXT: 0000000000048000 *ABS* 00000000 end
+
+# RUN: echo "SECTIONS { \
+# RUN: no_exist_origin = ORIGIN(ram); \
+# RUN: no_exist_length = LENGTH(ram); \
+# RUN: }" > %t2.script
+# RUN: not ld.lld -o %t2 --script %t2.script %t 2>&1 \
+# RUN: | FileCheck -check-prefix=ERR %s
+# ERR: {{.*}}.script:1: memory region not defined: ram
+
+
+.global _start
+_start:
+ nop
diff --git a/test/ELF/many-alloc-sections.s b/test/ELF/many-alloc-sections.s
new file mode 100644
index 000000000000..441e5ff32d08
--- /dev/null
+++ b/test/ELF/many-alloc-sections.s
@@ -0,0 +1,106 @@
+// RUN: llvm-mc -filetype=obj -triple x86_64-pc-linux-gnu %s -o %t.o
+// RUN: echo "SECTIONS { . = SIZEOF_HEADERS; .text : { *(.text) } }" > %t.script
+// FIXME: threads are disable because the test is too slow with them (PR32942).
+// RUN: ld.lld -T %t.script %t.o -o %t --no-threads
+// RUN: llvm-readobj -t %t | FileCheck %s
+
+// Test that _start is in the correct section.
+// CHECK: Name: _start
+// CHECK-NEXT: Value: 0x120
+// CHECK-NEXT: Size: 0
+// CHECK-NEXT: Binding: Global
+// CHECK-NEXT: Type: None
+// CHECK-NEXT: Other: 0
+// CHECK-NEXT: Section: dm
+
+.macro gen_sections4 x
+ .section a\x,"a"
+ .section b\x,"a"
+ .section c\x,"a"
+ .section d\x,"a"
+.endm
+
+.macro gen_sections8 x
+ gen_sections4 a\x
+ gen_sections4 b\x
+.endm
+
+.macro gen_sections16 x
+ gen_sections8 a\x
+ gen_sections8 b\x
+.endm
+
+.macro gen_sections32 x
+ gen_sections16 a\x
+ gen_sections16 b\x
+.endm
+
+.macro gen_sections64 x
+ gen_sections32 a\x
+ gen_sections32 b\x
+.endm
+
+.macro gen_sections128 x
+ gen_sections64 a\x
+ gen_sections64 b\x
+.endm
+
+.macro gen_sections256 x
+ gen_sections128 a\x
+ gen_sections128 b\x
+.endm
+
+.macro gen_sections512 x
+ gen_sections256 a\x
+ gen_sections256 b\x
+.endm
+
+.macro gen_sections1024 x
+ gen_sections512 a\x
+ gen_sections512 b\x
+.endm
+
+.macro gen_sections2048 x
+ gen_sections1024 a\x
+ gen_sections1024 b\x
+.endm
+
+.macro gen_sections4096 x
+ gen_sections2048 a\x
+ gen_sections2048 b\x
+.endm
+
+.macro gen_sections8192 x
+ gen_sections4096 a\x
+ gen_sections4096 b\x
+.endm
+
+.macro gen_sections16384 x
+ gen_sections8192 a\x
+ gen_sections8192 b\x
+.endm
+
+.macro gen_sections32768 x
+ gen_sections16384 a\x
+ gen_sections16384 b\x
+.endm
+
+ .bss
+ .section bar
+
+gen_sections32768 a
+gen_sections16384 b
+gen_sections8192 c
+gen_sections4096 d
+gen_sections2048 e
+gen_sections1024 f
+gen_sections512 g
+gen_sections128 h
+gen_sections64 i
+gen_sections32 j
+gen_sections16 k
+gen_sections8 l
+gen_sections4 m
+
+.global _start
+_start:
diff --git a/test/ELF/many-sections.s b/test/ELF/many-sections.s
index 77e76c20a60d..ae923889ddc1 100644
--- a/test/ELF/many-sections.s
+++ b/test/ELF/many-sections.s
@@ -11,7 +11,14 @@
// CHECK-NEXT: Section: dm (0xFF00)
-// RUN: ld.lld %t -o %t2
+// FIXME: threads are disable because the test is too slow with them (PR32942).
+// RUN: ld.lld %t -o %t2 --no-threads
+// RUN: llvm-readobj -t %t2 | FileCheck --check-prefix=LINKED %s
+
+// Test also with a linker script.
+// RUN: echo "SECTIONS { . = SIZEOF_HEADERS; .text : { *(.text) } }" > %t.script
+// FIXME: threads are disable because the test is too slow with them (PR32942).
+// RUN: ld.lld -T %t.script %t -o %t2 --no-threads
// RUN: llvm-readobj -t %t2 | FileCheck --check-prefix=LINKED %s
// Test that _start is in the correct section.
diff --git a/test/ELF/tls-dynamic-i686.s b/test/ELF/tls-dynamic-i686.s
index 04fd13822530..ac88e6eaed31 100644
--- a/test/ELF/tls-dynamic-i686.s
+++ b/test/ELF/tls-dynamic-i686.s
@@ -56,8 +56,8 @@ addl tls1@gotntpoff(%ebx),%eax
// CHECK-NEXT: SHF_ALLOC
// CHECK-NEXT: SHF_WRITE
// CHECK-NEXT: ]
-// CHECK-NEXT: Address: 0x3070
-// CHECK-NEXT: Offset: 0x3070
+// CHECK-NEXT: Address: 0x3068
+// CHECK-NEXT: Offset: 0x3068
// CHECK-NEXT: Size: 32
// CHECK-NEXT: Link: 0
// CHECK-NEXT: Info: 0
@@ -66,13 +66,13 @@ addl tls1@gotntpoff(%ebx),%eax
// CHECK: Relocations [
// CHECK: Section ({{.+}}) .rel.dyn {
-// CHECK-NEXT: 0x3080 R_386_TLS_DTPMOD32 - 0x0
-// CHECK-NEXT: 0x3070 R_386_TLS_DTPMOD32 tls0 0x0
-// CHECK-NEXT: 0x3074 R_386_TLS_DTPOFF32 tls0 0x0
-// CHECK-NEXT: 0x3088 R_386_TLS_TPOFF tls0 0x0
-// CHECK-NEXT: 0x3078 R_386_TLS_DTPMOD32 tls1 0x0
-// CHECK-NEXT: 0x307C R_386_TLS_DTPOFF32 tls1 0x0
-// CHECK-NEXT: 0x308C R_386_TLS_TPOFF tls1 0x0
+// CHECK-NEXT: 0x3078 R_386_TLS_DTPMOD32 - 0x0
+// CHECK-NEXT: 0x3068 R_386_TLS_DTPMOD32 tls0 0x0
+// CHECK-NEXT: 0x306C R_386_TLS_DTPOFF32 tls0 0x0
+// CHECK-NEXT: 0x3080 R_386_TLS_TPOFF tls0 0x0
+// CHECK-NEXT: 0x3070 R_386_TLS_DTPMOD32 tls1 0x0
+// CHECK-NEXT: 0x3074 R_386_TLS_DTPOFF32 tls1 0x0
+// CHECK-NEXT: 0x3084 R_386_TLS_TPOFF tls1 0x0
// CHECK-NEXT: }
// DIS: Disassembly of section .text:
@@ -80,20 +80,20 @@ addl tls1@gotntpoff(%ebx),%eax
// General dynamic model:
// -32 and -24 are first and second GOT entries offsets.
// Each one is a pair of records.
-// DIS-NEXT: 1000: {{.*}} leal -32(,%ebx), %eax
-// DIS-NEXT: 1007: {{.*}} calll 100
-// DIS-NEXT: 100c: {{.*}} leal -24(,%ebx), %eax
-// DIS-NEXT: 1013: {{.*}} calll 88
+// DIS-NEXT: 1000: 8d 04 1d e0 ff ff ff leal -32(,%ebx), %eax
+// DIS-NEXT: 1007: e8 64 00 00 00 calll 100
+// DIS-NEXT: 100c: 8d 04 1d e8 ff ff ff leal -24(,%ebx), %eax
+// DIS-NEXT: 1013: e8 58 00 00 00 calll 88
// Local dynamic model:
// -16 is a local module tls index offset.
-// DIS-NEXT: 1018: {{.*}} leal -16(%ebx), %eax
-// DIS-NEXT: 101e: {{.*}} calll 77
-// DIS-NEXT: 1023: {{.*}} leal 8(%eax), %edx
-// DIS-NEXT: 1029: {{.*}} leal -16(%ebx), %eax
-// DIS-NEXT: 102f: {{.*}} calll 60
-// DIS-NEXT: 1034: {{.*}} leal 12(%eax), %edx
+// DIS-NEXT: 1018: 8d 83 f0 ff ff ff leal -16(%ebx), %eax
+// DIS-NEXT: 101e: e8 4d 00 00 00 calll 77
+// DIS-NEXT: 1023: 8d 90 08 00 00 00 leal 8(%eax), %edx
+// DIS-NEXT: 1029: 8d 83 f0 ff ff ff leal -16(%ebx), %eax
+// DIS-NEXT: 102f: e8 3c 00 00 00 calll 60
+// DIS-NEXT: 1034: 8d 90 0c 00 00 00 leal 12(%eax), %edx
// Initial exec model:
-// DIS-NEXT: 103a: {{.*}} movl %gs:0, %eax
-// DIS-NEXT: 1040: {{.*}} addl -8(%ebx), %eax
-// DIS-NEXT: 1046: {{.*}} movl %gs:0, %eax
-// DIS-NEXT: 104c: {{.*}} addl -4(%ebx), %eax
+// DIS-NEXT: 103a: 65 a1 00 00 00 00 movl %gs:0, %eax
+// DIS-NEXT: 1040: 03 83 f8 ff ff ff addl -8(%ebx), %eax
+// DIS-NEXT: 1046: 65 a1 00 00 00 00 movl %gs:0, %eax
+// DIS-NEXT: 104c: 03 83 fc ff ff ff addl -4(%ebx), %eax
diff --git a/test/ELF/tls-opt-iele-i686-nopic.s b/test/ELF/tls-opt-iele-i686-nopic.s
index a883bce511a6..b6608c16551c 100644
--- a/test/ELF/tls-opt-iele-i686-nopic.s
+++ b/test/ELF/tls-opt-iele-i686-nopic.s
@@ -13,8 +13,8 @@
// GOTREL-NEXT: SHF_ALLOC
// GOTREL-NEXT: SHF_WRITE
// GOTREL-NEXT: ]
-// GOTREL-NEXT: Address: 0x12060
-// GOTREL-NEXT: Offset: 0x2060
+// GOTREL-NEXT: Address: 0x12058
+// GOTREL-NEXT: Offset: 0x2058
// GOTREL-NEXT: Size: 8
// GOTREL-NEXT: Link: 0
// GOTREL-NEXT: Info: 0
@@ -23,8 +23,8 @@
// GOTREL-NEXT: }
// GOTREL: Relocations [
// GOTREL-NEXT: Section ({{.*}}) .rel.dyn {
-// GOTREL-NEXT: 0x12060 R_386_TLS_TPOFF tlsshared0 0x0
-// GOTREL-NEXT: 0x12064 R_386_TLS_TPOFF tlsshared1 0x0
+// GOTREL-NEXT: 0x12058 R_386_TLS_TPOFF tlsshared0 0x0
+// GOTREL-NEXT: 0x1205C R_386_TLS_TPOFF tlsshared1 0x0
// GOTREL-NEXT: }
// GOTREL-NEXT: ]
@@ -32,24 +32,24 @@
// DISASM-NEXT: _start:
// 4294967288 = 0xFFFFFFF8
// 4294967292 = 0xFFFFFFFC
-// 73824 = (.got)[0] = 0x12060
-// 73828 = (.got)[1] = 0x12064
-// DISASM-NEXT: 11000: {{.*}} movl $4294967288, %ecx
-// DISASM-NEXT: 11006: {{.*}} movl %gs:(%ecx), %eax
-// DISASM-NEXT: 11009: {{.*}} movl $4294967288, %eax
-// DISASM-NEXT: 1100e: {{.*}} movl %gs:(%eax), %eax
-// DISASM-NEXT: 11011: {{.*}} addl $4294967288, %ecx
-// DISASM-NEXT: 11017: {{.*}} movl %gs:(%ecx), %eax
-// DISASM-NEXT: 1101a: {{.*}} movl $4294967292, %ecx
-// DISASM-NEXT: 11020: {{.*}} movl %gs:(%ecx), %eax
-// DISASM-NEXT: 11023: {{.*}} movl $4294967292, %eax
-// DISASM-NEXT: 11028: {{.*}} movl %gs:(%eax), %eax
-// DISASM-NEXT: 1102b: {{.*}} addl $4294967292, %ecx
-// DISASM-NEXT: 11031: {{.*}} movl %gs:(%ecx), %eax
-// DISASM-NEXT: 11034: {{.*}} movl 73824, %ecx
-// DISASM-NEXT: 1103a: {{.*}} movl %gs:(%ecx), %eax
-// DISASM-NEXT: 1103d: {{.*}} addl 73828, %ecx
-// DISASM-NEXT: 11043: {{.*}} movl %gs:(%ecx), %eax
+// 73808 = (.got)[0] = 0x12058
+// 73812 = (.got)[1] = 0x1205C
+// DISASM-NEXT: 11000: c7 c1 f8 ff ff ff movl $4294967288, %ecx
+// DISASM-NEXT: 11006: 65 8b 01 movl %gs:(%ecx), %eax
+// DISASM-NEXT: 11009: b8 f8 ff ff ff movl $4294967288, %eax
+// DISASM-NEXT: 1100e: 65 8b 00 movl %gs:(%eax), %eax
+// DISASM-NEXT: 11011: 81 c1 f8 ff ff ff addl $4294967288, %ecx
+// DISASM-NEXT: 11017: 65 8b 01 movl %gs:(%ecx), %eax
+// DISASM-NEXT: 1101a: c7 c1 fc ff ff ff movl $4294967292, %ecx
+// DISASM-NEXT: 11020: 65 8b 01 movl %gs:(%ecx), %eax
+// DISASM-NEXT: 11023: b8 fc ff ff ff movl $4294967292, %eax
+// DISASM-NEXT: 11028: 65 8b 00 movl %gs:(%eax), %eax
+// DISASM-NEXT: 1102b: 81 c1 fc ff ff ff addl $4294967292, %ecx
+// DISASM-NEXT: 11031: 65 8b 01 movl %gs:(%ecx), %eax
+// DISASM-NEXT: 11034: 8b 0d 58 20 01 00 movl 73816, %ecx
+// DISASM-NEXT: 1103a: 65 8b 01 movl %gs:(%ecx), %eax
+// DISASM-NEXT: 1103d: 03 0d 5c 20 01 00 addl 73820, %ecx
+// DISASM-NEXT: 11043: 65 8b 01 movl %gs:(%ecx), %eax
.type tlslocal0,@object
.section .tbss,"awT",@nobits
diff --git a/test/ELF/x86-64-reloc-tpoff32-fpic.s b/test/ELF/x86-64-reloc-tpoff32-fpic.s
new file mode 100644
index 000000000000..5be3dc317012
--- /dev/null
+++ b/test/ELF/x86-64-reloc-tpoff32-fpic.s
@@ -0,0 +1,14 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: not ld.lld %t.o -shared -o %t.so 2>&1 | FileCheck %s
+
+# CHECK: relocation R_X86_64_TPOFF32 cannot be used against shared object; recompile with -fPIC
+# CHECK: >>> defined in {{.*}}.o
+# CHECK: >>> referenced by {{.*}}.o:(.tdata+0xC)
+
+.section ".tdata", "awT", @progbits
+.globl var
+var:
+
+movq %fs:0, %rax
+leaq var@TPOFF(%rax),%rax