Index: lld/trunk/ELF/OutputSections.cpp =================================================================== --- lld/trunk/ELF/OutputSections.cpp +++ lld/trunk/ELF/OutputSections.cpp @@ -639,6 +639,9 @@ if (DtFlags1) ++NumEntries; // DT_FLAGS_1 + if (!Config->Entry.empty()) + ++NumEntries; // DT_DEBUG + if (Config->EMachine == EM_MIPS) { ++NumEntries; // DT_MIPS_RLD_VERSION ++NumEntries; // DT_MIPS_FLAGS @@ -737,6 +740,8 @@ WriteVal(DT_FLAGS, DtFlags); if (DtFlags1) WriteVal(DT_FLAGS_1, DtFlags1); + if (!Config->Entry.empty()) + WriteVal(DT_DEBUG, 0); // See "Dynamic Section" in Chapter 5 in the following document // for detailed description: Index: lld/trunk/test/ELF/dynamic-reloc.s =================================================================== --- lld/trunk/test/ELF/dynamic-reloc.s +++ lld/trunk/test/ELF/dynamic-reloc.s @@ -53,6 +53,7 @@ // CHECK-NEXT: 0x000000000000000A STRSZ // CHECK-NEXT: 0x0000000000000004 HASH // CHECK-NEXT: 0x0000000000000001 NEEDED SharedLibrary ({{.*}}2.so) +// CHECK-NEXT: 0x0000000000000015 DEBUG 0x0 // CHECK-NEXT: 0x0000000000000000 NULL 0x0 // CHECK-NEXT: ] Index: lld/trunk/test/ELF/got.s =================================================================== --- lld/trunk/test/ELF/got.s +++ lld/trunk/test/ELF/got.s @@ -12,7 +12,7 @@ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: SHF_WRITE // CHECK-NEXT: ] -// CHECK-NEXT: Address: 0x120A0 +// CHECK-NEXT: Address: 0x120B0 // CHECK-NEXT: Offset: // CHECK-NEXT: Size: 16 // CHECK-NEXT: Link: 0 @@ -21,22 +21,22 @@ // CHECK: Relocations [ // CHECK-NEXT: Section ({{.*}}) .rela.dyn { -// CHECK-NEXT: 0x120A0 R_X86_64_GLOB_DAT bar 0x0 -// CHECK-NEXT: 0x120A8 R_X86_64_GLOB_DAT zed 0x0 +// CHECK-NEXT: 0x120B0 R_X86_64_GLOB_DAT bar 0x0 +// CHECK-NEXT: 0x120B8 R_X86_64_GLOB_DAT zed 0x0 // CHECK-NEXT: } // CHECK-NEXT: ] // Unfortunately FileCheck can't do math, so we have to check for explicit // values: -// 0x120A0 - (0x11000 + 2) - 4 = 4250 -// 0x120A0 - (0x11006 + 2) - 4 = 4244 -// 0x120A8 - (0x1100c + 2) - 4 = 4246 +// 0x120B0 - (0x11000 + 2) - 4 = 4266 +// 0x120B0 - (0x11006 + 2) - 4 = 4260 +// 0x120A8 - (0x1100c + 2) - 4 = 4262 // DISASM: _start: -// DISASM-NEXT: 11000: {{.*}} jmpq *4250(%rip) -// DISASM-NEXT: 11006: {{.*}} jmpq *4244(%rip) -// DISASM-NEXT: 1100c: {{.*}} jmpq *4246(%rip) +// DISASM-NEXT: 11000: {{.*}} jmpq *4266(%rip) +// DISASM-NEXT: 11006: {{.*}} jmpq *4260(%rip) +// DISASM-NEXT: 1100c: {{.*}} jmpq *4262(%rip) .global _start _start: Index: lld/trunk/test/ELF/local-got.s =================================================================== --- lld/trunk/test/ELF/local-got.s +++ lld/trunk/test/ELF/local-got.s @@ -14,11 +14,11 @@ foo: nop -// 0x120A0 - 0x11000 - 5 = 4251 -// 0x120A8 - 0x11005 - 5 = 4254 +// 0x120B0 - 0x11000 - 5 = 4251 +// 0x120B8 - 0x11005 - 5 = 4254 // DISASM: _start: -// DISASM-NEXT: 11000: {{.*}} callq 4251 -// DISASM-NEXT: 11005: {{.*}} callq 4254 +// DISASM-NEXT: 11000: {{.*}} callq 4267 +// DISASM-NEXT: 11005: {{.*}} callq 4270 // DISASM: foo: // DISASM-NEXT: 1100a: {{.*}} nop @@ -29,7 +29,7 @@ // CHECK-NEXT: SHF_ALLOC // CHECK-NEXT: SHF_WRITE // CHECK-NEXT: ] -// CHECK-NEXT: Address: 0x120A0 +// CHECK-NEXT: Address: 0x120B0 // CHECK-NEXT: Offset: // CHECK-NEXT: Size: 16 // CHECK-NEXT: Link: 0 @@ -43,6 +43,6 @@ // CHECK: Relocations [ // CHECK-NEXT: Section ({{.*}}) .rela.dyn { -// CHECK-NEXT: 0x120A0 R_X86_64_GLOB_DAT bar 0x0 +// CHECK-NEXT: 0x120B0 R_X86_64_GLOB_DAT bar 0x0 // CHECK-NEXT: } // CHECK-NEXT: ] Index: lld/trunk/test/ELF/relocation-i686.s =================================================================== --- lld/trunk/test/ELF/relocation-i686.s +++ lld/trunk/test/ELF/relocation-i686.s @@ -55,7 +55,7 @@ // ADDR-NEXT: SHF_ALLOC // ADDR-NEXT: SHF_WRITE // ADDR-NEXT: ] -// ADDR-NEXT: Address: 0x12070 +// ADDR-NEXT: Address: 0x12078 .section .R_386_GOTPC,"ax",@progbits R_386_GOTPC: @@ -65,7 +65,7 @@ // CHECK: Disassembly of section .R_386_GOTPC: // CHECK-NEXT: R_386_GOTPC: -// CHECK-NEXT: 11014: {{.*}} movl $4188, %eax +// CHECK-NEXT: 11014: {{.*}} movl $4196, %eax .section .dynamic_reloc, "ax",@progbits call bar Index: lld/trunk/test/ELF/relocation.s =================================================================== --- lld/trunk/test/ELF/relocation.s +++ lld/trunk/test/ELF/relocation.s @@ -22,7 +22,7 @@ // SEC-NEXT: SHF_ALLOC // SEC-NEXT: SHF_WRITE // SEC-NEXT: ] -// SEC-NEXT: Address: 0x120E0 +// SEC-NEXT: Address: 0x120F0 // SEC-NEXT: Offset: // SEC-NEXT: Size: 8 // SEC-NEXT: Link: 0 @@ -111,7 +111,7 @@ R_X86_64_GOTPCREL: .long zed@gotpcrel -// 0x120E8 - 0x101D8 = 7952 +// 0x120F8 - 0x101D8 = 7952 // 7952 = 0x101f0000 in little endian // CHECK: Contents of section .R_X86_64_GOTPCREL -// CHECK-NEXT: 101d0 101f0000 +// CHECK-NEXT: 101d0 201f0000 Index: lld/trunk/test/ELF/relro.s =================================================================== --- lld/trunk/test/ELF/relro.s +++ lld/trunk/test/ELF/relro.s @@ -17,8 +17,8 @@ // FULLRELRO-NEXT: SHF_ALLOC // FULLRELRO-NEXT: SHF_WRITE // FULLRELRO-NEXT: ] -// FULLRELRO-NEXT: Address: 0x12100 -// FULLRELRO-NEXT: Offset: 0x2100 +// FULLRELRO-NEXT: Address: 0x12110 +// FULLRELRO-NEXT: Offset: 0x2110 // FULLRELRO-NEXT: Size: 8 // FULLRELRO-NEXT: Link: 0 // FULLRELRO-NEXT: Info: 0 @@ -36,8 +36,8 @@ // FULLRELRO-NEXT: SHF_ALLOC // FULLRELRO-NEXT: SHF_WRITE // FULLRELRO-NEXT: ] -// FULLRELRO-NEXT: Address: 0x12108 -// FULLRELRO-NEXT: Offset: 0x2108 +// FULLRELRO-NEXT: Address: 0x12118 +// FULLRELRO-NEXT: Offset: 0x2118 // FULLRELRO-NEXT: Size: 32 // FULLRELRO-NEXT: Link: 0 // FULLRELRO-NEXT: Info: 0 @@ -103,8 +103,8 @@ // FULLRELRO-NEXT: Offset: 0x // FULLRELRO-NEXT: VirtualAddress: [[RWADDR]] // FULLRELRO-NEXT: PhysicalAddress: -// FULLRELRO-NEXT: FileSize: 296 -// FULLRELRO-NEXT: MemSize: 296 +// FULLRELRO-NEXT: FileSize: 312 +// FULLRELRO-NEXT: MemSize: 312 // FULLRELRO-NEXT: Flags [ // FULLRELRO-NEXT: PF_R // FULLRELRO-NEXT: ] @@ -119,8 +119,8 @@ // PARTRELRO-NEXT: SHF_ALLOC // PARTRELRO-NEXT: SHF_WRITE // PARTRELRO-NEXT: ] -// PARTRELRO-NEXT: Address: 0x120E0 -// PARTRELRO-NEXT: Offset: 0x20E0 +// PARTRELRO-NEXT: Address: 0x120F0 +// PARTRELRO-NEXT: Offset: 0x20F0 // PARTRELRO-NEXT: Size: 8 // PARTRELRO-NEXT: Link: 0 // PARTRELRO-NEXT: Info: 0 @@ -219,8 +219,8 @@ // PARTRELRO-NEXT: Offset: 0x2000 // PARTRELRO-NEXT: VirtualAddress: [[RWADDR]] // PARTRELRO-NEXT: PhysicalAddress: -// PARTRELRO-NEXT: FileSize: 232 -// PARTRELRO-NEXT: MemSize: 232 +// PARTRELRO-NEXT: FileSize: 248 +// PARTRELRO-NEXT: MemSize: 248 // PARTRELRO-NEXT: Flags [ // PARTRELRO-NEXT: PF_R // PARTRELRO-NEXT: ] Index: lld/trunk/test/ELF/shared-be.s =================================================================== --- lld/trunk/test/ELF/shared-be.s +++ lld/trunk/test/ELF/shared-be.s @@ -25,6 +25,7 @@ // CHECK-NEXT: 0x0000000000000009 RELAENT [[RELENT]] (bytes) // CHECK: 0x000000000000001D RUNPATH foo:bar // CHECK-NEXT: 0x0000000000000001 NEEDED SharedLibrary ({{.*}}2.so) +// CHECK-NEXT: 0x0000000000000015 DEBUG 0x0 // CHECK-NEXT: 0x0000000000000000 NULL 0x0 // CHECK-NEXT: ] Index: lld/trunk/test/ELF/shared.s =================================================================== --- lld/trunk/test/ELF/shared.s +++ lld/trunk/test/ELF/shared.s @@ -253,6 +253,7 @@ // CHECK-NEXT: 0x00000004 HASH [[HASHADDR]] // CHECK-NEXT: 0x0000001D RUNPATH foo:bar // CHECK-NEXT: 0x00000001 NEEDED SharedLibrary ({{.*}}2.so) +// CHECK-NEXT: 0x00000015 DEBUG 0x0 // CHECK-NEXT: 0x00000000 NULL 0x0 // CHECK-NEXT: ] Index: lld/trunk/test/ELF/tls-got.s =================================================================== --- lld/trunk/test/ELF/tls-got.s +++ lld/trunk/test/ELF/tls-got.s @@ -14,7 +14,7 @@ // CHECK-NEXT: SHF_WRITE // CHECK-NEXT: ] // CHECK-NEXT: Address: [[ADDR:.*]] -// CHECK-NEXT: Offset: 0x20A0 +// CHECK-NEXT: Offset: 0x20B0 // CHECK-NEXT: Size: 16 // CHECK-NEXT: Link: 0 // CHECK-NEXT: Info: 0 @@ -25,20 +25,20 @@ // CHECK: Relocations [ // CHECK-NEXT: Section (4) .rela.dyn { // CHECK-NEXT: [[ADDR]] R_X86_64_TPOFF64 tls1 0x0 -// CHECK-NEXT: 0x120A8 R_X86_64_TPOFF64 tls0 0x0 +// CHECK-NEXT: 0x120B8 R_X86_64_TPOFF64 tls0 0x0 // CHECK-NEXT: } // CHECK-NEXT: ] -//0x11000 + 4249 + 7 = 0x120A0 -//0x1100A + 4247 + 7 = 0x120A8 -//0x11014 + 4237 + 7 = 0x120A8 +//0x11000 + 4249 + 7 = 0x120B0 +//0x1100A + 4247 + 7 = 0x120B8 +//0x11014 + 4237 + 7 = 0x120B8 //DISASM: Disassembly of section .text: //DISASM-NEXT: main: -//DISASM-NEXT: 11000: 48 8b 05 99 10 00 00 movq 4249(%rip), %rax +//DISASM-NEXT: 11000: 48 8b 05 a9 10 00 00 movq 4265(%rip), %rax //DISASM-NEXT: 11007: 64 8b 00 movl %fs:(%rax), %eax -//DISASM-NEXT: 1100a: 48 8b 05 97 10 00 00 movq 4247(%rip), %rax +//DISASM-NEXT: 1100a: 48 8b 05 a7 10 00 00 movq 4263(%rip), %rax //DISASM-NEXT: 11011: 64 8b 00 movl %fs:(%rax), %eax -//DISASM-NEXT: 11014: 48 8b 05 8d 10 00 00 movq 4237(%rip), %rax +//DISASM-NEXT: 11014: 48 8b 05 9d 10 00 00 movq 4253(%rip), %rax //DISASM-NEXT: 1101b: 64 8b 00 movl %fs:(%rax), %eax //DISASM-NEXT: 1101e: c3 retq Index: lld/trunk/test/ELF/tls-opt-gdie.s =================================================================== --- lld/trunk/test/ELF/tls-opt-gdie.s +++ lld/trunk/test/ELF/tls-opt-gdie.s @@ -13,8 +13,8 @@ //RELOC-NEXT: SHF_ALLOC //RELOC-NEXT: SHF_WRITE //RELOC-NEXT: ] -//RELOC-NEXT: Address: 0x120E0 -//RELOC-NEXT: Offset: 0x20E0 +//RELOC-NEXT: Address: 0x120F0 +//RELOC-NEXT: Offset: 0x20F0 //RELOC-NEXT: Size: 16 //RELOC-NEXT: Link: 0 //RELOC-NEXT: Info: 0 @@ -23,22 +23,22 @@ //RELOC-NEXT: } //RELOC: Relocations [ //RELOC-NEXT: Section (4) .rela.dyn { -//RELOC-NEXT: 0x120E0 R_X86_64_TPOFF64 tlsshared0 0x0 -//RELOC-NEXT: 0x120E8 R_X86_64_TPOFF64 tlsshared1 0x0 +//RELOC-NEXT: 0x120F0 R_X86_64_TPOFF64 tlsshared0 0x0 +//RELOC-NEXT: 0x120F8 R_X86_64_TPOFF64 tlsshared1 0x0 //RELOC-NEXT: } //RELOC-NEXT: Section (5) .rela.plt { //RELOC-NEXT: 0x13018 R_X86_64_JUMP_SLOT __tls_get_addr 0x0 //RELOC-NEXT: } //RELOC-NEXT: ] -//0x11009 + (4304 + 7) = 0x120E0 -//0x11019 + (4296 + 7) = 0x120E8 +//0x11009 + (4304 + 7) = 0x120F0 +//0x11019 + (4296 + 7) = 0x120F8 // DISASM: Disassembly of section .text: // DISASM-NEXT: _start: // DISASM-NEXT: 11000: 64 48 8b 04 25 00 00 00 00 movq %fs:0, %rax -// DISASM-NEXT: 11009: 48 03 05 d0 10 00 00 addq 4304(%rip), %rax +// DISASM-NEXT: 11009: 48 03 05 e0 10 00 00 addq 4320(%rip), %rax // DISASM-NEXT: 11010: 64 48 8b 04 25 00 00 00 00 movq %fs:0, %rax -// DISASM-NEXT: 11019: 48 03 05 c8 10 00 00 addq 4296(%rip), %rax +// DISASM-NEXT: 11019: 48 03 05 d8 10 00 00 addq 4312(%rip), %rax .section .text .globl _start Index: lld/trunk/test/ELF/tls-opt-gdiele-i686.s =================================================================== --- lld/trunk/test/ELF/tls-opt-gdiele-i686.s +++ lld/trunk/test/ELF/tls-opt-gdiele-i686.s @@ -7,8 +7,8 @@ // NORELOC: Relocations [ // NORELOC-NEXT: Section ({{.*}}) .rel.dyn { -// NORELOC-NEXT: 0x12050 R_386_TLS_TPOFF tlsshared0 0x0 -// NORELOC-NEXT: 0x12054 R_386_TLS_TPOFF tlsshared1 0x0 +// NORELOC-NEXT: 0x12058 R_386_TLS_TPOFF tlsshared0 0x0 +// NORELOC-NEXT: 0x1205C R_386_TLS_TPOFF tlsshared1 0x0 // NORELOC-NEXT: } // NORELOC-NEXT: ] Index: lld/trunk/test/ELF/tls-opt-iele-i686-nopic.s =================================================================== --- lld/trunk/test/ELF/tls-opt-iele-i686-nopic.s +++ lld/trunk/test/ELF/tls-opt-iele-i686-nopic.s @@ -16,8 +16,8 @@ // GOTREL-NEXT: SHF_ALLOC // GOTREL-NEXT: SHF_WRITE // GOTREL-NEXT: ] -// GOTREL-NEXT: Address: 0x12050 -// GOTREL-NEXT: Offset: 0x2050 +// GOTREL-NEXT: Address: 0x12058 +// GOTREL-NEXT: Offset: 0x2058 // GOTREL-NEXT: Size: 8 // GOTREL-NEXT: Link: 0 // GOTREL-NEXT: Info: 0 @@ -26,8 +26,8 @@ // GOTREL-NEXT: } // GOTREL: Relocations [ // GOTREL-NEXT: Section ({{.*}}) .rel.dyn { -// GOTREL-NEXT: 0x12050 R_386_TLS_TPOFF tlsshared0 0x0 -// GOTREL-NEXT: 0x12054 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: ] @@ -35,8 +35,8 @@ // DISASM-NEXT: _start: // 4294967288 = 0xFFFFFFF8 // 4294967292 = 0xFFFFFFFC -// 73808 = (.got)[0] = 0x12050 -// 73812 = (.got)[1] = 0x12054 +// 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 @@ -49,9 +49,9 @@ // 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 50 20 01 00 movl 73808, %ecx +// 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 54 20 01 00 addl 73812, %ecx +// DISASM-NEXT: 1103d: 03 0d 5c 20 01 00 addl 73820, %ecx // DISASM-NEXT: 11043: 65 8b 01 movl %gs:(%ecx), %eax // GOTRELSHARED: Section {