summaryrefslogtreecommitdiff
path: root/test/ELF
diff options
context:
space:
mode:
Diffstat (limited to 'test/ELF')
-rw-r--r--test/ELF/Inputs/rodynamic.s4
-rw-r--r--test/ELF/amdgpu-globals.s26
-rw-r--r--test/ELF/build-id.s4
-rw-r--r--test/ELF/gc-sections.s12
-rw-r--r--test/ELF/gdb-index-dup-types.s60
-rw-r--r--test/ELF/i386-tls-ie-shared.s68
-rw-r--r--test/ELF/linkerscript/arm-lscript.s9
-rw-r--r--test/ELF/linkerscript/sections-constraint.s2
-rw-r--r--test/ELF/lto/Inputs/relocation-model-pic.ll11
-rw-r--r--test/ELF/lto/relocation-model.ll46
-rw-r--r--test/ELF/relocatable-comdat.s45
-rw-r--r--test/ELF/relocation-size-shared.s72
-rw-r--r--test/ELF/relocation-size.s132
-rw-r--r--test/ELF/reproduce.s2
-rw-r--r--test/ELF/rodynamic.s35
-rw-r--r--test/ELF/section-layout.s7
-rw-r--r--test/ELF/tls-i686.s48
17 files changed, 400 insertions, 183 deletions
diff --git a/test/ELF/Inputs/rodynamic.s b/test/ELF/Inputs/rodynamic.s
new file mode 100644
index 0000000000000..a06f4bef0084a
--- /dev/null
+++ b/test/ELF/Inputs/rodynamic.s
@@ -0,0 +1,4 @@
+.global foo
+.type foo, @function
+foo:
+ ret
diff --git a/test/ELF/amdgpu-globals.s b/test/ELF/amdgpu-globals.s
index f30c0ed40157a..17dfc82ef8f30 100644
--- a/test/ELF/amdgpu-globals.s
+++ b/test/ELF/amdgpu-globals.s
@@ -41,6 +41,19 @@ program_global_readonly:
.long 0 ; 0x0
# CHECK: Section {
+# CHECK: Name: .hsatext
+# CHECK: Type: SHT_PROGBITS
+# CHECK: Flags [ (0xC00007)
+# CHECK: SHF_ALLOC (0x2)
+# CHECK: SHF_AMDGPU_HSA_AGENT (0x800000)
+# CHECK: SHF_AMDGPU_HSA_CODE (0x400000)
+# CHECK: SHF_EXECINSTR (0x4)
+# CHECK: SHF_WRITE (0x1)
+# CHECK: ]
+# CHECK: Address: [[HSATEXT_ADDR:[0-9xa-f]+]]
+# CHECK: }
+
+# CHECK: Section {
# CHECK: Name: .hsadata_global_program
# CHECK: Type: SHT_PROGBITS (0x1)
# CHECK: Flags [ (0x100003)
@@ -62,19 +75,6 @@ program_global_readonly:
# CHECK: ]
# CHECK: }
-# CHECK: Section {
-# CHECK: Name: .hsatext
-# CHECK: Type: SHT_PROGBITS
-# CHECK: Flags [ (0xC00007)
-# CHECK: SHF_ALLOC (0x2)
-# CHECK: SHF_AMDGPU_HSA_AGENT (0x800000)
-# CHECK: SHF_AMDGPU_HSA_CODE (0x400000)
-# CHECK: SHF_EXECINSTR (0x4)
-# CHECK: SHF_WRITE (0x1)
-# CHECK: ]
-# CHECK: Address: [[HSATEXT_ADDR:[0-9xa-f]+]]
-# CHECK: }
-
# CHECK: Symbol {
# CHECK: Name: module_global_agent
# CHECK: Value:
diff --git a/test/ELF/build-id.s b/test/ELF/build-id.s
index ffd8d7744f702..2d193478df710 100644
--- a/test/ELF/build-id.s
+++ b/test/ELF/build-id.s
@@ -33,6 +33,10 @@
# RUN: ld.lld --build-id=md5 --build-id=none %t -o %t2
# RUN: llvm-objdump -s %t2 | FileCheck -check-prefix=NONE %s
+# RUN: ld.lld --build-id --build-id=none %t -o %t2
+# RUN: llvm-objdump -s %t2 | FileCheck -check-prefix=NONE %s
+# RUN: ld.lld --build-id=none --build-id %t -o %t2
+# RUN: llvm-objdump -s %t2 | FileCheck -check-prefix=DEFAULT %s
.globl _start
_start:
diff --git a/test/ELF/gc-sections.s b/test/ELF/gc-sections.s
index f100153ec3586..0ae6fa4f06de2 100644
--- a/test/ELF/gc-sections.s
+++ b/test/ELF/gc-sections.s
@@ -10,10 +10,10 @@
# NOGC: Name: .eh_frame
# NOGC: Name: .text
-# NOGC: Name: .ctors
-# NOGC: Name: .dtors
# NOGC: Name: .init
# NOGC: Name: .fini
+# NOGC: Name: .ctors
+# NOGC: Name: .dtors
# NOGC: Name: .debug_pubtypes
# NOGC: Name: .comment
# NOGC: Name: a
@@ -25,10 +25,10 @@
# GC1: Name: .eh_frame
# GC1: Name: .text
-# GC1: Name: .ctors
-# GC1: Name: .dtors
# GC1: Name: .init
# GC1: Name: .fini
+# GC1: Name: .ctors
+# GC1: Name: .dtors
# GC1: Name: .debug_pubtypes
# GC1: Name: .comment
# GC1: Name: a
@@ -40,10 +40,10 @@
# GC2: Name: .eh_frame
# GC2: Name: .text
-# GC2: Name: .ctors
-# GC2: Name: .dtors
# GC2: Name: .init
# GC2: Name: .fini
+# GC2: Name: .ctors
+# GC2: Name: .dtors
# GC2: Name: .debug_pubtypes
# GC2: Name: .comment
# GC2: Name: a
diff --git a/test/ELF/gdb-index-dup-types.s b/test/ELF/gdb-index-dup-types.s
new file mode 100644
index 0000000000000..e0bed33eed4dc
--- /dev/null
+++ b/test/ELF/gdb-index-dup-types.s
@@ -0,0 +1,60 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: ld.lld --gdb-index %t.o -o %t
+# RUN: llvm-dwarfdump -debug-dump=gdb_index %t | FileCheck %s
+
+## Testcase is based on output produced by gcc version 5.4.1 20160904
+## it has duplicate entries in .debug_gnu_pubtypes which seems to be
+## compiler bug. In that case it is useless to have them in .gdb_index
+## and we filter such entries out to reduce size of .gdb_index.
+
+## CHECK: Constant pool offset = {{.*}}, has 1 CU vectors:
+## CHECK-NOT: 0(0x0): 0x90000000 0x90000000
+
+.section .debug_abbrev,"",@progbits
+ .byte 1 # Abbreviation Code
+ .byte 17 # DW_TAG_compile_unit
+ .byte 0 # DW_CHILDREN_no
+ .byte 16 # DW_AT_stmt_list
+ .byte 23 # DW_FORM_sec_offset
+ .ascii "\260B" # DW_AT_GNU_dwo_name
+ .byte 14 # DW_FORM_strp
+ .byte 27 # DW_AT_comp_dir
+ .byte 14 # DW_FORM_strp
+ .ascii "\264B" # DW_AT_GNU_pubnames
+ .byte 25 # DW_FORM_flag_present
+ .ascii "\261B" # DW_AT_GNU_dwo_id
+ .byte 7 # DW_FORM_data8
+ .ascii "\263B" # DW_AT_GNU_addr_base
+ .byte 23 # DW_FORM_sec_offset
+ .byte 0 # EOM(1)
+ .byte 0 # EOM(2)
+ .byte 0 # EOM(3)
+
+.section .debug_info,"",@progbits
+.Lcu_begin0:
+ .long 32 # 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:0x19 DW_TAG_compile_unit
+ .long 0 # DW_AT_stmt_list
+ .long 0 # DW_AT_GNU_dwo_name
+ .long 0 # DW_AT_comp_dir
+ .quad 0 # DW_AT_GNU_dwo_id
+ .long 0 # DW_AT_GNU_addr_base
+
+.section .debug_gnu_pubtypes,"",@progbits
+.long .LpubTypes_end0-.LpubTypes_begin0 # Length of Public Types Info
+.LpubTypes_begin0:
+ .short 2 # DWARF Version
+ .long .Lcu_begin0 # Offset of Compilation Unit Info
+ .long 36 # Compilation Unit Length
+ .long 36 # DIE offset
+ .byte 144 # Kind: TYPE, STATIC
+ .asciz "int" # External Name
+ .long 36 # DIE offset
+ .byte 144 # Kind: TYPE, STATIC
+ .asciz "int" # External Name
+ .long 0 # End Mark
+.LpubTypes_end0:
diff --git a/test/ELF/i386-tls-ie-shared.s b/test/ELF/i386-tls-ie-shared.s
index 8becc3199f956..f419eb45dfb97 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: 0x1058
-// GOTRELSHARED-NEXT: Offset: 0x1058
+// GOTRELSHARED-NEXT: Address: 0x2058
+// GOTRELSHARED-NEXT: Offset: 0x2058
// GOTRELSHARED-NEXT: Size: 16
// GOTRELSHARED-NEXT: Link: 0
// GOTRELSHARED-NEXT: Info: 0
@@ -23,44 +23,44 @@
// GOTRELSHARED-NEXT: }
// GOTRELSHARED: Relocations [
// GOTRELSHARED-NEXT: Section ({{.*}}) .rel.dyn {
-// GOTRELSHARED-NEXT: 0x2002 R_386_RELATIVE - 0x0
-// GOTRELSHARED-NEXT: 0x200A R_386_RELATIVE - 0x0
-// GOTRELSHARED-NEXT: 0x2013 R_386_RELATIVE - 0x0
-// GOTRELSHARED-NEXT: 0x201C R_386_RELATIVE - 0x0
-// GOTRELSHARED-NEXT: 0x2024 R_386_RELATIVE - 0x0
-// GOTRELSHARED-NEXT: 0x202D R_386_RELATIVE - 0x0
-// GOTRELSHARED-NEXT: 0x2036 R_386_RELATIVE - 0x0
-// GOTRELSHARED-NEXT: 0x203F R_386_RELATIVE - 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: 0x1002 R_386_RELATIVE - 0x0
+// GOTRELSHARED-NEXT: 0x100A R_386_RELATIVE - 0x0
+// GOTRELSHARED-NEXT: 0x1013 R_386_RELATIVE - 0x0
+// GOTRELSHARED-NEXT: 0x101C R_386_RELATIVE - 0x0
+// GOTRELSHARED-NEXT: 0x1024 R_386_RELATIVE - 0x0
+// GOTRELSHARED-NEXT: 0x102D R_386_RELATIVE - 0x0
+// GOTRELSHARED-NEXT: 0x1036 R_386_RELATIVE - 0x0
+// GOTRELSHARED-NEXT: 0x103F R_386_RELATIVE - 0x0
+// GOTRELSHARED-NEXT: 0x2058 R_386_TLS_TPOFF tlslocal0 0x0
+// GOTRELSHARED-NEXT: 0x205C R_386_TLS_TPOFF tlslocal1 0x0
+// GOTRELSHARED-NEXT: 0x2060 R_386_TLS_TPOFF tlsshared0 0x0
+// GOTRELSHARED-NEXT: 0x2064 R_386_TLS_TPOFF tlsshared1 0x0
// GOTRELSHARED-NEXT: }
// GOTRELSHARED-NEXT: ]
// GOTRELSHARED: 0x6FFFFFFA RELCOUNT 8
// DISASMSHARED: Disassembly of section test:
// DISASMSHARED-NEXT: _start:
-// (.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
+// (.got)[0] = 0x2058 = 8280
+// (.got)[1] = 0x205C = 8284
+// (.got)[2] = 0x2060 = 8288
+// (.got)[3] = 0x2064 = 8292
+// DISASMSHARED-NEXT: 1000: 8b 0d 58 20 00 00 movl 8280, %ecx
+// DISASMSHARED-NEXT: 1006: 65 8b 01 movl %gs:(%ecx), %eax
+// DISASMSHARED-NEXT: 1009: a1 58 20 00 00 movl 8280, %eax
+// DISASMSHARED-NEXT: 100e: 65 8b 00 movl %gs:(%eax), %eax
+// DISASMSHARED-NEXT: 1011: 03 0d 58 20 00 00 addl 8280, %ecx
+// DISASMSHARED-NEXT: 1017: 65 8b 01 movl %gs:(%ecx), %eax
+// DISASMSHARED-NEXT: 101a: 8b 0d 5c 20 00 00 movl 8284, %ecx
+// DISASMSHARED-NEXT: 1020: 65 8b 01 movl %gs:(%ecx), %eax
+// DISASMSHARED-NEXT: 1023: a1 5c 20 00 00 movl 8284, %eax
+// DISASMSHARED-NEXT: 1028: 65 8b 00 movl %gs:(%eax), %eax
+// DISASMSHARED-NEXT: 102b: 03 0d 5c 20 00 00 addl 8284, %ecx
+// DISASMSHARED-NEXT: 1031: 65 8b 01 movl %gs:(%ecx), %eax
+// DISASMSHARED-NEXT: 1034: 8b 0d 60 20 00 00 movl 8288, %ecx
+// DISASMSHARED-NEXT: 103a: 65 8b 01 movl %gs:(%ecx), %eax
+// DISASMSHARED-NEXT: 103d: 03 0d 64 20 00 00 addl 8292, %ecx
+// DISASMSHARED-NEXT: 1043: 65 8b 01 movl %gs:(%ecx), %eax
.type tlslocal0,@object
.section .tbss,"awT",@nobits
diff --git a/test/ELF/linkerscript/arm-lscript.s b/test/ELF/linkerscript/arm-lscript.s
new file mode 100644
index 0000000000000..c377764e9776a
--- /dev/null
+++ b/test/ELF/linkerscript/arm-lscript.s
@@ -0,0 +1,9 @@
+// REQUIRES: arm
+// RUN: llvm-mc -filetype=obj -triple=armv7a-none-linux-gnueabi %s -o %t.o
+// RUN: echo "SECTIONS { \
+// RUN: .rel.dyn : { } \
+// RUN: .zed : { PROVIDE_HIDDEN (foobar = .); } \
+// RUN: }" > %t.script
+// This is a test case for PR33029. Making sure that linker can digest
+// the above script without dumping core.
+// RUN: ld.lld -emit-relocs -T %t.script %t.o -shared -o %t.so
diff --git a/test/ELF/linkerscript/sections-constraint.s b/test/ELF/linkerscript/sections-constraint.s
index 7962406271701..4d95ec18336cc 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: .foo.1 00000004
# NO1: .readable 00000004
+# NO1: .foo.1 00000004
.global _start
_start:
diff --git a/test/ELF/lto/Inputs/relocation-model-pic.ll b/test/ELF/lto/Inputs/relocation-model-pic.ll
new file mode 100644
index 0000000000000..e76605435e875
--- /dev/null
+++ b/test/ELF/lto/Inputs/relocation-model-pic.ll
@@ -0,0 +1,11 @@
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@foo = external global i32
+define i32 @main() {
+ %t = load i32, i32* @foo
+ ret i32 %t
+}
+
+!llvm.module.flags = !{!0}
+!0 = !{i32 1, !"PIC Level", i32 2}
diff --git a/test/ELF/lto/relocation-model.ll b/test/ELF/lto/relocation-model.ll
new file mode 100644
index 0000000000000..78334dd5cd2c9
--- /dev/null
+++ b/test/ELF/lto/relocation-model.ll
@@ -0,0 +1,46 @@
+; REQUIRES: x86
+
+; RUN: llvm-as %s -o %t.o
+; RUN: llvm-as %p/Inputs/relocation-model-pic.ll -o %t.pic.o
+
+;; Non-PIC source.
+
+; RUN: ld.lld %t.o -o %t-out -save-temps -shared
+; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=PIC
+
+; RUN: ld.lld %t.o -o %t-out -save-temps --export-dynamic --noinhibit-exec -pie
+; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=PIC
+
+; RUN: ld.lld %t.o -o %t-out -save-temps --export-dynamic --noinhibit-exec
+; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=STATIC
+
+; RUN: ld.lld %t.o -o %t-out -save-temps -r --export-dynamic
+; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=STATIC
+
+
+;; PIC source.
+
+; RUN: ld.lld %t.pic.o -o %t-out -save-temps -shared
+; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=PIC
+
+; RUN: ld.lld %t.pic.o -o %t-out -save-temps --export-dynamic --noinhibit-exec -pie
+; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=PIC
+
+; RUN: ld.lld %t.pic.o -o %t-out -save-temps --export-dynamic --noinhibit-exec
+; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=STATIC
+
+; RUN: ld.lld %t.pic.o -o %t-out -save-temps -r --export-dynamic
+; RUN: llvm-readobj -r %t-out.lto.o | FileCheck %s --check-prefix=PIC
+
+
+; PIC: R_X86_64_REX_GOTPCRELX foo
+; STATIC: R_X86_64_PC32 foo
+
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+@foo = external global i32
+define i32 @main() {
+ %t = load i32, i32* @foo
+ ret i32 %t
+}
diff --git a/test/ELF/relocatable-comdat.s b/test/ELF/relocatable-comdat.s
new file mode 100644
index 0000000000000..24504d23884f4
--- /dev/null
+++ b/test/ELF/relocatable-comdat.s
@@ -0,0 +1,45 @@
+# REQUIRES: x86
+# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
+# RUN: ld.lld -r %t.o %t.o -o %t
+# RUN: llvm-readobj -elf-section-groups -sections %t | FileCheck %s
+
+# CHECK: Name: .text.bar
+# CHECK-NEXT: Type: SHT_PROGBITS
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: SHF_ALLOC
+# CHECK-NEXT: SHF_EXECINSTR
+# CHECK-NEXT: SHF_GROUP
+# CHECK-NEXT: ]
+# CHECK-NEXT: Address:
+# CHECK-NEXT: Offset:
+# CHECK-NEXT: Size: 8
+# CHECK: Section {
+# CHECK-NEXT: Index: 4
+# CHECK-NEXT: Name: .text.foo
+# CHECK-NEXT: Type: SHT_PROGBITS
+# CHECK-NEXT: Flags [
+# CHECK-NEXT: SHF_ALLOC
+# CHECK-NEXT: SHF_EXECINSTR
+# CHECK-NEXT: SHF_GROUP
+# CHECK-NEXT: ]
+# CHECK-NEXT: Address:
+# CHECK-NEXT: Offset:
+# CHECK-NEXT: Size: 4
+
+# CHECK: Groups {
+# CHECK-NEXT: Group {
+# CHECK-NEXT: Name: .group
+# CHECK-NEXT: Index: 2
+# CHECK-NEXT: Type: COMDAT
+# CHECK-NEXT: Signature: abc
+# CHECK-NEXT: Section(s) in group [
+# CHECK-NEXT: .text.bar
+# CHECK-NEXT: .text.foo
+# CHECK-NEXT: ]
+# CHECK-NEXT: }
+# CHECK-NEXT: }
+
+.section .text.bar,"axG",@progbits,abc,comdat
+.quad 42
+.section .text.foo,"axG",@progbits,abc,comdat
+.long 42
diff --git a/test/ELF/relocation-size-shared.s b/test/ELF/relocation-size-shared.s
index 7b700ad74401f..cea9e64d58ed9 100644
--- a/test/ELF/relocation-size-shared.s
+++ b/test/ELF/relocation-size-shared.s
@@ -7,48 +7,48 @@
// RELOCSHARED: Relocations [
// RELOCSHARED-NEXT: Section ({{.*}}) .rela.dyn {
-// RELOCSHARED-NEXT: 0x203018 R_X86_64_SIZE64 fooshared 0xFFFFFFFFFFFFFFFF
-// RELOCSHARED-NEXT: 0x203020 R_X86_64_SIZE64 fooshared 0x0
-// RELOCSHARED-NEXT: 0x203028 R_X86_64_SIZE64 fooshared 0x1
-// RELOCSHARED-NEXT: 0x203048 R_X86_64_SIZE32 fooshared 0xFFFFFFFFFFFFFFFF
-// RELOCSHARED-NEXT: 0x20304F R_X86_64_SIZE32 fooshared 0x0
-// RELOCSHARED-NEXT: 0x203056 R_X86_64_SIZE32 fooshared 0x1
+// RELOCSHARED-NEXT: 0x201018 R_X86_64_SIZE64 fooshared 0xFFFFFFFFFFFFFFFF
+// RELOCSHARED-NEXT: 0x201020 R_X86_64_SIZE64 fooshared 0x0
+// RELOCSHARED-NEXT: 0x201028 R_X86_64_SIZE64 fooshared 0x1
+// RELOCSHARED-NEXT: 0x201048 R_X86_64_SIZE32 fooshared 0xFFFFFFFFFFFFFFFF
+// RELOCSHARED-NEXT: 0x20104F R_X86_64_SIZE32 fooshared 0x0
+// RELOCSHARED-NEXT: 0x201056 R_X86_64_SIZE32 fooshared 0x1
// RELOCSHARED-NEXT: }
// RELOCSHARED-NEXT:]
// DISASM: Disassembly of section test
// DISASM: _data:
-// DISASM-NEXT: 203000: 19 00
-// DISASM-NEXT: 203002: 00 00
-// DISASM-NEXT: 203004: 00 00
-// DISASM-NEXT: 203006: 00 00
-// DISASM-NEXT: 203008: 1a 00
-// DISASM-NEXT: 20300a: 00 00
-// DISASM-NEXT: 20300c: 00 00
-// DISASM-NEXT: 20300e: 00 00
-// DISASM-NEXT: 203010: 1b 00
-// DISASM-NEXT: 203012: 00 00
-// DISASM-NEXT: 203014: 00 00
-// DISASM-NEXT: 203016: 00 00
-// DISASM-NEXT: 203018: 00 00
-// DISASM-NEXT: 20301a: 00 00
-// DISASM-NEXT: 20301c: 00 00
-// DISASM-NEXT: 20301e: 00 00
-// DISASM-NEXT: 203020: 00 00
-// DISASM-NEXT: 203022: 00 00
-// DISASM-NEXT: 203024: 00 00
-// DISASM-NEXT: 203026: 00 00
-// DISASM-NEXT: 203028: 00 00
-// DISASM-NEXT: 20302a: 00 00
-// DISASM-NEXT: 20302c: 00 00
-// DISASM-NEXT: 20302e: 00 00
+// DISASM-NEXT: 201000: 19 00
+// DISASM-NEXT: 201002: 00 00
+// DISASM-NEXT: 201004: 00 00
+// DISASM-NEXT: 201006: 00 00
+// DISASM-NEXT: 201008: 1a 00
+// DISASM-NEXT: 20100a: 00 00
+// DISASM-NEXT: 20100c: 00 00
+// DISASM-NEXT: 20100e: 00 00
+// DISASM-NEXT: 201010: 1b 00
+// DISASM-NEXT: 201012: 00 00
+// DISASM-NEXT: 201014: 00 00
+// DISASM-NEXT: 201016: 00 00
+// DISASM-NEXT: 201018: 00 00
+// DISASM-NEXT: 20101a: 00 00
+// DISASM-NEXT: 20101c: 00 00
+// DISASM-NEXT: 20101e: 00 00
+// DISASM-NEXT: 201020: 00 00
+// DISASM-NEXT: 201022: 00 00
+// DISASM-NEXT: 201024: 00 00
+// DISASM-NEXT: 201026: 00 00
+// DISASM-NEXT: 201028: 00 00
+// DISASM-NEXT: 20102a: 00 00
+// DISASM-NEXT: 20102c: 00 00
+// DISASM-NEXT: 20102e: 00 00
// DISASM: _start:
-// DISASM-NEXT: 203030: 8b 04 25 19 00 00 00 movl 25, %eax
-// DISASM-NEXT: 203037: 8b 04 25 1a 00 00 00 movl 26, %eax
-// DISASM-NEXT: 20303e: 8b 04 25 1b 00 00 00 movl 27, %eax
-// DISASM-NEXT: 203045: 8b 04 25 00 00 00 00 movl 0, %eax
-// DISASM-NEXT: 20304c: 8b 04 25 00 00 00 00 movl 0, %eax
-// DISASM-NEXT: 203053: 8b 04 25 00 00 00 00 movl 0, %eax
+// DISASM-NEXT: 201030: 8b 04 25 19 00 00 00 movl 25, %eax
+// DISASM-NEXT: 201037: 8b 04 25 1a 00 00 00 movl 26, %eax
+// DISASM-NEXT: 20103e: 8b 04 25 1b 00 00 00 movl 27, %eax
+// DISASM-NEXT: 201045: 8b 04 25 00 00 00 00 movl 0, %eax
+// DISASM-NEXT: 20104c: 8b 04 25 00 00 00 00 movl 0, %eax
+// DISASM-NEXT: 201053: 8b 04 25 00 00 00 00 movl 0, %eax
.data
.global foo
diff --git a/test/ELF/relocation-size.s b/test/ELF/relocation-size.s
index 2256be67df060..419b8a17fad9e 100644
--- a/test/ELF/relocation-size.s
+++ b/test/ELF/relocation-size.s
@@ -11,82 +11,82 @@
// DISASM: Disassembly of section test:
// DISASM-NEXT: _data:
-// DISASM-NEXT: 202000: 19 00
-// DISASM-NEXT: 202002: 00 00
-// DISASM-NEXT: 202004: 00 00
-// DISASM-NEXT: 202006: 00 00
-// DISASM-NEXT: 202008: 1a 00
-// DISASM-NEXT: 20200a: 00 00
-// DISASM-NEXT: 20200c: 00 00
-// DISASM-NEXT: 20200e: 00 00
-// DISASM-NEXT: 202010: 1b 00
-// DISASM-NEXT: 202012: 00 00
-// DISASM-NEXT: 202014: 00 00
-// DISASM-NEXT: 202016: 00 00
-// DISASM-NEXT: 202018: 19 00
-// DISASM-NEXT: 20201a: 00 00
-// DISASM-NEXT: 20201c: 00 00
-// DISASM-NEXT: 20201e: 00 00
-// DISASM-NEXT: 202020: 1a 00
-// DISASM-NEXT: 202022: 00 00
-// DISASM-NEXT: 202024: 00 00
-// DISASM-NEXT: 202026: 00 00
-// DISASM-NEXT: 202028: 1b 00
-// DISASM-NEXT: 20202a: 00 00
-// DISASM-NEXT: 20202c: 00 00
-// DISASM-NEXT: 20202e: 00 00
+// DISASM-NEXT: 201000: 19 00
+// DISASM-NEXT: 201002: 00 00
+// DISASM-NEXT: 201004: 00 00
+// DISASM-NEXT: 201006: 00 00
+// DISASM-NEXT: 201008: 1a 00
+// DISASM-NEXT: 20100a: 00 00
+// DISASM-NEXT: 20100c: 00 00
+// DISASM-NEXT: 20100e: 00 00
+// DISASM-NEXT: 201010: 1b 00
+// DISASM-NEXT: 201012: 00 00
+// DISASM-NEXT: 201014: 00 00
+// DISASM-NEXT: 201016: 00 00
+// DISASM-NEXT: 201018: 19 00
+// DISASM-NEXT: 20101a: 00 00
+// DISASM-NEXT: 20101c: 00 00
+// DISASM-NEXT: 20101e: 00 00
+// DISASM-NEXT: 201020: 1a 00
+// DISASM-NEXT: 201022: 00 00
+// DISASM-NEXT: 201024: 00 00
+// DISASM-NEXT: 201026: 00 00
+// DISASM-NEXT: 201028: 1b 00
+// DISASM-NEXT: 20102a: 00 00
+// DISASM-NEXT: 20102c: 00 00
+// DISASM-NEXT: 20102e: 00 00
// DISASM: _start:
-// DISASM-NEXT: 202030: 8b 04 25 19 00 00 00 movl 25, %eax
-// DISASM-NEXT: 202037: 8b 04 25 1a 00 00 00 movl 26, %eax
-// DISASM-NEXT: 20203e: 8b 04 25 1b 00 00 00 movl 27, %eax
-// DISASM-NEXT: 202045: 8b 04 25 19 00 00 00 movl 25, %eax
-// DISASM-NEXT: 20204c: 8b 04 25 1a 00 00 00 movl 26, %eax
-// DISASM-NEXT: 202053: 8b 04 25 1b 00 00 00 movl 27, %eax
+// DISASM-NEXT: 201030: 8b 04 25 19 00 00 00 movl 25, %eax
+// DISASM-NEXT: 201037: 8b 04 25 1a 00 00 00 movl 26, %eax
+// DISASM-NEXT: 20103e: 8b 04 25 1b 00 00 00 movl 27, %eax
+// DISASM-NEXT: 201045: 8b 04 25 19 00 00 00 movl 25, %eax
+// DISASM-NEXT: 20104c: 8b 04 25 1a 00 00 00 movl 26, %eax
+// DISASM-NEXT: 201053: 8b 04 25 1b 00 00 00 movl 27, %eax
// RELOCSHARED: Relocations [
// RELOCSHARED-NEXT: Section ({{.*}}) .rela.dyn {
-// RELOCSHARED-NEXT: 0x3000 R_X86_64_SIZE64 foo 0xFFFFFFFFFFFFFFFF
-// RELOCSHARED-NEXT: 0x3008 R_X86_64_SIZE64 foo 0x0
-// RELOCSHARED-NEXT: 0x3010 R_X86_64_SIZE64 foo 0x1
-// RELOCSHARED-NEXT: 0x3033 R_X86_64_SIZE32 foo 0xFFFFFFFFFFFFFFFF
-// RELOCSHARED-NEXT: 0x303A R_X86_64_SIZE32 foo 0x0
-// RELOCSHARED-NEXT: 0x3041 R_X86_64_SIZE32 foo 0x1
+// RELOCSHARED-NEXT: 0x1000 R_X86_64_SIZE64 foo 0xFFFFFFFFFFFFFFFF
+// RELOCSHARED-NEXT: 0x1008 R_X86_64_SIZE64 foo 0x0
+// RELOCSHARED-NEXT: 0x1010 R_X86_64_SIZE64 foo 0x1
+// RELOCSHARED-NEXT: 0x1033 R_X86_64_SIZE32 foo 0xFFFFFFFFFFFFFFFF
+// RELOCSHARED-NEXT: 0x103A R_X86_64_SIZE32 foo 0x0
+// RELOCSHARED-NEXT: 0x1041 R_X86_64_SIZE32 foo 0x1
// RELOCSHARED-NEXT: }
// RELOCSHARED-NEXT: ]
// DISASMSHARED: Disassembly of section test:
// DISASMSHARED-NEXT: _data:
-// DISASMSHARED-NEXT: 3000: 00 00
-// DISASMSHARED-NEXT: 3002: 00 00
-// DISASMSHARED-NEXT: 3004: 00 00
-// DISASMSHARED-NEXT: 3006: 00 00
-// DISASMSHARED-NEXT: 3008: 00 00
-// DISASMSHARED-NEXT: 300a: 00 00
-// DISASMSHARED-NEXT: 300c: 00 00
-// DISASMSHARED-NEXT: 300e: 00 00
-// DISASMSHARED-NEXT: 3010: 00 00
-// DISASMSHARED-NEXT: 3012: 00 00
-// DISASMSHARED-NEXT: 3014: 00 00
-// DISASMSHARED-NEXT: 3016: 00 00
-// DISASMSHARED-NEXT: 3018: 19 00
-// DISASMSHARED-NEXT: 301a: 00 00
-// DISASMSHARED-NEXT: 301c: 00 00
-// DISASMSHARED-NEXT: 301e: 00 00
-// DISASMSHARED-NEXT: 3020: 1a 00
-// DISASMSHARED-NEXT: 3022: 00 00
-// DISASMSHARED-NEXT: 3024: 00 00
-// DISASMSHARED-NEXT: 3026: 00 00
-// DISASMSHARED-NEXT: 3028: 1b 00
-// DISASMSHARED-NEXT: 302a: 00 00
-// DISASMSHARED-NEXT: 302c: 00 00
-// DISASMSHARED-NEXT: 302e: 00 00
+// DISASMSHARED-NEXT: 1000: 00 00
+// DISASMSHARED-NEXT: 1002: 00 00
+// DISASMSHARED-NEXT: 1004: 00 00
+// DISASMSHARED-NEXT: 1006: 00 00
+// DISASMSHARED-NEXT: 1008: 00 00
+// DISASMSHARED-NEXT: 100a: 00 00
+// DISASMSHARED-NEXT: 100c: 00 00
+// DISASMSHARED-NEXT: 100e: 00 00
+// DISASMSHARED-NEXT: 1010: 00 00
+// DISASMSHARED-NEXT: 1012: 00 00
+// DISASMSHARED-NEXT: 1014: 00 00
+// DISASMSHARED-NEXT: 1016: 00 00
+// DISASMSHARED-NEXT: 1018: 19 00
+// DISASMSHARED-NEXT: 101a: 00 00
+// DISASMSHARED-NEXT: 101c: 00 00
+// DISASMSHARED-NEXT: 101e: 00 00
+// DISASMSHARED-NEXT: 1020: 1a 00
+// DISASMSHARED-NEXT: 1022: 00 00
+// DISASMSHARED-NEXT: 1024: 00 00
+// DISASMSHARED-NEXT: 1026: 00 00
+// DISASMSHARED-NEXT: 1028: 1b 00
+// DISASMSHARED-NEXT: 102a: 00 00
+// DISASMSHARED-NEXT: 102c: 00 00
+// DISASMSHARED-NEXT: 102e: 00 00
// DISASMSHARED: _start:
-// DISASMSHARED-NEXT: 3030: 8b 04 25 00 00 00 00 movl 0, %eax
-// DISASMSHARED-NEXT: 3037: 8b 04 25 00 00 00 00 movl 0, %eax
-// DISASMSHARED-NEXT: 303e: 8b 04 25 00 00 00 00 movl 0, %eax
-// DISASMSHARED-NEXT: 3045: 8b 04 25 19 00 00 00 movl 25, %eax
-// DISASMSHARED-NEXT: 304c: 8b 04 25 1a 00 00 00 movl 26, %eax
-// DISASMSHARED-NEXT: 3053: 8b 04 25 1b 00 00 00 movl 27, %eax
+// DISASMSHARED-NEXT: 1030: 8b 04 25 00 00 00 00 movl 0, %eax
+// DISASMSHARED-NEXT: 1037: 8b 04 25 00 00 00 00 movl 0, %eax
+// DISASMSHARED-NEXT: 103e: 8b 04 25 00 00 00 00 movl 0, %eax
+// DISASMSHARED-NEXT: 1045: 8b 04 25 19 00 00 00 movl 25, %eax
+// DISASMSHARED-NEXT: 104c: 8b 04 25 1a 00 00 00 movl 26, %eax
+// DISASMSHARED-NEXT: 1053: 8b 04 25 1b 00 00 00 movl 27, %eax
.data
.global foo
diff --git a/test/ELF/reproduce.s b/test/ELF/reproduce.s
index 94823d6d377f5..0a93be08d0408 100644
--- a/test/ELF/reproduce.s
+++ b/test/ELF/reproduce.s
@@ -63,7 +63,7 @@
## Check that directory path is stripped from -o <file-path>
# RUN: mkdir -p %t.dir/build3/a/b/c
# RUN: cd %t.dir
-# RUN: ld.lld build1/foo.o -o build3/a/b/c/bar -shared --as-needed --reproduce repro3.tar
+# RUN: ld.lld build1/foo.o -o build3/a/b/c/bar -shared --as-needed --reproduce=repro3.tar
# RUN: tar xf repro3.tar
# RUN: FileCheck %s --check-prefix=RSP3 < repro3/response.txt
# RSP3: -o bar
diff --git a/test/ELF/rodynamic.s b/test/ELF/rodynamic.s
new file mode 100644
index 0000000000000..441e5c395e7cb
--- /dev/null
+++ b/test/ELF/rodynamic.s
@@ -0,0 +1,35 @@
+# RUN: llvm-mc %s -o %t.o -filetype=obj -triple=x86_64-pc-linux
+# RUN: llvm-mc %p/Inputs/rodynamic.s -o %t.so.o -filetype=obj -triple=x86_64-pc-linux
+
+# RUN: ld.lld -shared %t.so.o -o %t.so
+# RUN: ld.lld %t.o %t.so -o %t.exe
+# RUN: llvm-readobj -dynamic-table %t.exe | FileCheck -check-prefix=DEFDEBUG %s
+# RUN: llvm-readobj -sections %t.exe | FileCheck -check-prefix=DEFSEC %s
+
+# RUN: ld.lld -shared -z rodynamic %t.so.o -o %t.so
+# RUN: ld.lld -z rodynamic %t.o %t.so -o %t.exe
+# RUN: llvm-readobj -dynamic-table %t.exe | FileCheck -check-prefix=RODEBUG %s
+# RUN: llvm-readobj -sections %t.exe | FileCheck -check-prefix=ROSEC %s
+
+.globl _start
+_start:
+ call foo
+
+# DEFDEBUG: DEBUG
+
+# DEFSEC: Section {
+# DEFSEC: Name: .dynamic
+# DEFSEC-NEXT: Type: SHT_DYNAMIC
+# DEFSEC-NEXT: Flags [
+# DEFSEC-NEXT: SHF_ALLOC
+# DEFSEC-NEXT: SHF_WRITE
+# DEFSEC-NEXT: ]
+
+# RODEBUG-NOT: DEBUG
+
+# ROSEC: Section {
+# ROSEC: Name: .dynamic
+# ROSEC-NEXT: Type: SHT_DYNAMIC
+# ROSEC-NEXT: Flags [
+# ROSEC-NEXT: SHF_ALLOC
+# ROSEC-NEXT: ]
diff --git a/test/ELF/section-layout.s b/test/ELF/section-layout.s
index f63066e0d9265..7febec85a6297 100644
--- a/test/ELF/section-layout.s
+++ b/test/ELF/section-layout.s
@@ -34,6 +34,11 @@ _start:
// CHECK: Name: c
// CHECK: Name: d
+// Sections that are both writable and executable appear before
+// sections that are only writable.
+// CHECK: Name: k
+// CHECK: Name: l
+
// Writable sections appear before TLS and other relro sections.
// CHECK: Name: i
@@ -42,8 +47,6 @@ _start:
// CHECK: Name: g
// CHECK: Name: j
-// CHECK: Name: k
-// CHECK: Name: l
// Non allocated sections are in input order.
// CHECK: Name: t
diff --git a/test/ELF/tls-i686.s b/test/ELF/tls-i686.s
index 2a04a555865aa..7f2dd605cacda 100644
--- a/test/ELF/tls-i686.s
+++ b/test/ELF/tls-i686.s
@@ -32,38 +32,38 @@ _start:
// DIS: Disassembly of section test:
// DIS-NEXT: _start:
-// DIS-NEXT: 12000: ba 08 00 00 00 movl $8, %edx
-// DIS-NEXT: 12005: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
-// DIS-NEXT: 1200c: 29 d0 subl %edx, %eax
-// DIS-NEXT: 1200e: ba 04 00 00 00 movl $4, %edx
-// DIS-NEXT: 12013: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
-// DIS-NEXT: 1201a: 29 d0 subl %edx, %eax
-// DIS-NEXT: 1201c: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
-// DIS-NEXT: 12023: 8d 81 f8 ff ff ff leal -8(%ecx), %eax
-// DIS-NEXT: 12029: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
-// DIS-NEXT: 12030: 8d 81 77 00 00 00 leal 119(%ecx), %eax
+// DIS-NEXT: 11000: ba 08 00 00 00 movl $8, %edx
+// DIS-NEXT: 11005: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
+// DIS-NEXT: 1100c: 29 d0 subl %edx, %eax
+// DIS-NEXT: 1100e: ba 04 00 00 00 movl $4, %edx
+// DIS-NEXT: 11013: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
+// DIS-NEXT: 1101a: 29 d0 subl %edx, %eax
+// DIS-NEXT: 1101c: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
+// DIS-NEXT: 11023: 8d 81 f8 ff ff ff leal -8(%ecx), %eax
+// DIS-NEXT: 11029: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
+// DIS-NEXT: 11030: 8d 81 77 00 00 00 leal 119(%ecx), %eax
// RELOC: Relocations [
// RELOC-NEXT: ]
// DISSHARED: Disassembly of section test:
// DISSHARED-NEXT: _start:
-// DISSHARED-NEXT: 2000: ba 00 00 00 00 movl $0, %edx
-// DISSHARED-NEXT: 2005: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
-// DISSHARED-NEXT: 200c: 29 d0 subl %edx, %eax
-// DISSHARED-NEXT: 200e: ba 00 00 00 00 movl $0, %edx
-// DISSHARED-NEXT: 2013: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
-// DISSHARED-NEXT: 201a: 29 d0 subl %edx, %eax
-// DISSHARED-NEXT: 201c: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
-// DISSHARED-NEXT: 2023: 8d 81 00 00 00 00 leal (%ecx), %eax
-// DISSHARED-NEXT: 2029: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
-// DISSHARED-NEXT: 2030: 8d 81 7b 00 00 00 leal 123(%ecx), %eax
+// DISSHARED-NEXT: 1000: ba 00 00 00 00 movl $0, %edx
+// DISSHARED-NEXT: 1005: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
+// DISSHARED-NEXT: 100c: 29 d0 subl %edx, %eax
+// DISSHARED-NEXT: 100e: ba 00 00 00 00 movl $0, %edx
+// DISSHARED-NEXT: 1013: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
+// DISSHARED-NEXT: 101a: 29 d0 subl %edx, %eax
+// DISSHARED-NEXT: 101c: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
+// DISSHARED-NEXT: 1023: 8d 81 00 00 00 00 leal (%ecx), %eax
+// DISSHARED-NEXT: 1029: 65 8b 0d 00 00 00 00 movl %gs:0, %ecx
+// DISSHARED-NEXT: 1030: 8d 81 7b 00 00 00 leal 123(%ecx), %eax
// RELOCSHARED: Relocations [
// RELOCSHARED-NEXT: Section (4) .rel.dyn {
-// RELOCSHARED-NEXT: 0x2001 R_386_TLS_TPOFF32 var 0x0
-// RELOCSHARED-NEXT: 0x2025 R_386_TLS_TPOFF var 0x0
-// RELOCSHARED-NEXT: 0x200F R_386_TLS_TPOFF32 var1 0x0
-// RELOCSHARED-NEXT: 0x2032 R_386_TLS_TPOFF var1 0x0
+// RELOCSHARED-NEXT: 0x1001 R_386_TLS_TPOFF32 var 0x0
+// RELOCSHARED-NEXT: 0x1025 R_386_TLS_TPOFF var 0x0
+// RELOCSHARED-NEXT: 0x100F R_386_TLS_TPOFF32 var1 0x0
+// RELOCSHARED-NEXT: 0x1032 R_386_TLS_TPOFF var1 0x0
// RELOCSHARED-NEXT: }
// RELOCSHARED-NEXT: ]