[lld] r330233 - Reland r330223, "COFF: Merge .idata, .didat and .edata into .rdata by default.", which was reverted in r330228.

Peter Collingbourne via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 17 16:28:52 PDT 2018


Author: pcc
Date: Tue Apr 17 16:28:52 2018
New Revision: 330233

URL: http://llvm.org/viewvc/llvm-project?rev=330233&view=rev
Log:
Reland r330223, "COFF: Merge .idata, .didat and .edata into .rdata by default.", which was reverted in r330228.

In this reland I removed an unnecessary use of /debug in the test
delayimports32.test and used the /pdbaltpath flag in the test
pdb-publics-import.test, both of which avoid embedding absolute PDB
paths in executables which could affect later RVAs.

Original commit message:
> COFF: Merge .idata, .didat and .edata into .rdata by default.
>
> This saves a little space and matches what link.exe does.
>
> Tested using the chromium Windows trybots:
> https://chromium-review.googlesource.com/c/chromium/src/+/1014784

Differential Revision: https://reviews.llvm.org/D45737

Modified:
    lld/trunk/COFF/Driver.cpp
    lld/trunk/test/COFF/arm64-relocs-imports.test
    lld/trunk/test/COFF/delayimports-armnt.yaml
    lld/trunk/test/COFF/delayimports.test
    lld/trunk/test/COFF/delayimports32.test
    lld/trunk/test/COFF/export-armnt.yaml
    lld/trunk/test/COFF/hello32.test
    lld/trunk/test/COFF/imports.test
    lld/trunk/test/COFF/pdb-publics-import.test
    lld/trunk/test/COFF/symtab.test

Modified: lld/trunk/COFF/Driver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/COFF/Driver.cpp?rev=330233&r1=330232&r2=330233&view=diff
==============================================================================
--- lld/trunk/COFF/Driver.cpp (original)
+++ lld/trunk/COFF/Driver.cpp Tue Apr 17 16:28:52 2018
@@ -1104,6 +1104,12 @@ void LinkerDriver::link(ArrayRef<const c
   for (auto *Arg : Args.filtered(OPT_merge))
     parseMerge(Arg->getValue());
 
+  // Add default section merging rules after user rules. User rules take
+  // precedence, but we will emit a warning if there is a conflict.
+  parseMerge(".idata=.rdata");
+  parseMerge(".didat=.rdata");
+  parseMerge(".edata=.rdata");
+
   // Handle /section
   for (auto *Arg : Args.filtered(OPT_section))
     parseSection(Arg->getValue());

Modified: lld/trunk/test/COFF/arm64-relocs-imports.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/arm64-relocs-imports.test?rev=330233&r1=330232&r2=330233&view=diff
==============================================================================
--- lld/trunk/test/COFF/arm64-relocs-imports.test (original)
+++ lld/trunk/test/COFF/arm64-relocs-imports.test Tue Apr 17 16:28:52 2018
@@ -78,8 +78,8 @@
 # AFTER:  140001080:      00 20 0e 91     add     x0, x0, #904
 # AFTER:  140001084:      00 04 40 91     add     x0, x0, #1, lsl #12
 # AFTER:  140001088:      00 c4 41 f9     ldr     x0, [x0, #904]
-# AFTER:  14000108c:      10 00 00 d0     adrp    x16, #8192
-# AFTER:  140001090:      10 1e 40 f9     ldr     x16, [x16, #56]
+# AFTER:  14000108c:      10 00 00 b0     adrp    x16, #4096
+# AFTER:  140001090:      10 2a 40 f9     ldr     x16, [x16, #80]
 # AFTER:  140001094:      00 02 1f d6     br      x16
 
 --- !COFF

Modified: lld/trunk/test/COFF/delayimports-armnt.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/delayimports-armnt.yaml?rev=330233&r1=330232&r2=330233&view=diff
==============================================================================
--- lld/trunk/test/COFF/delayimports-armnt.yaml (original)
+++ lld/trunk/test/COFF/delayimports-armnt.yaml Tue Apr 17 16:28:52 2018
@@ -13,9 +13,9 @@
 # IMPORT-NEXT: DelayImport {
 # IMPORT-NEXT:   Name: library.dll
 # IMPORT-NEXT:   Attributes: 0x1
-# IMPORT-NEXT:   ModuleHandle: 0x2000
-# IMPORT-NEXT:   ImportAddressTable: 0x2008
-# IMPORT-NEXT:   ImportNameTable: 0x3040
+# IMPORT-NEXT:   ModuleHandle: 0x3000
+# IMPORT-NEXT:   ImportAddressTable: 0x3008
+# IMPORT-NEXT:   ImportNameTable: 0x2040
 # IMPORT-NEXT:   BoundDelayImportTable: 0x0
 # IMPORT-NEXT:   UnloadDelayImportTable: 0x0
 # IMPORT-NEXT:   Import {
@@ -43,21 +43,21 @@
 # BASEREL-NEXT:   }
 # BASEREL-NEXT:   Entry {
 # BASEREL-NEXT:     Type: HIGHLOW
-# BASEREL-NEXT:     Address: 0x2008
+# BASEREL-NEXT:     Address: 0x3008
 # BASEREL-NEXT:   }
 # BASEREL-NEXT:   Entry {
 # BASEREL-NEXT:     Type: ABSOLUTE
-# BASEREL-NEXT:     Address: 0x2000
+# BASEREL-NEXT:     Address: 0x3000
 # BASEREL-NEXT:   }
 # BASEREL-NEXT: ]
 #
-# DISASM:      401018:       42 f2 08 0c     movw r12, #8200
+# DISASM:      401018:       43 f2 08 0c     movw r12, #12296
 # DISASM-NEXT: 40101c:       c0 f2 40 0c     movt    r12, #64
 # DISASM-NEXT: 401020:       2d e9 0f 48     push.w  {r0, r1, r2, r3, r11, lr}
 # DISASM-NEXT: 401024:       0d f2 10 0b     addw    r11, sp, #16
 # DISASM-NEXT: 401028:       2d ed 10 0b     vpush   {d0, d1, d2, d3, d4, d5, d6, d7}
 # DISASM-NEXT: 40102c:       61 46           mov     r1, r12
-# DISASM-NEXT: 40102e:       43 f2 00 00     movw r0, #12288
+# DISASM-NEXT: 40102e:       42 f2 00 00     movw r0, #8192
 # DISASM-NEXT: 401032:       c0 f2 40 00     movt    r0, #64
 # DISASM-NEXT: 401036:       ff f7 e3 ff     bl      #-58
 # DISASM-NEXT: 40103a:       84 46           mov     r12, r0

Modified: lld/trunk/test/COFF/delayimports.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/delayimports.test?rev=330233&r1=330232&r2=330233&view=diff
==============================================================================
--- lld/trunk/test/COFF/delayimports.test (original)
+++ lld/trunk/test/COFF/delayimports.test Tue Apr 17 16:28:52 2018
@@ -7,9 +7,9 @@
 IMPORT:      DelayImport {
 IMPORT-NEXT:   Name: std64.dll
 IMPORT-NEXT:   Attributes: 0x1
-IMPORT-NEXT:   ModuleHandle: 0x2018
-IMPORT-NEXT:   ImportAddressTable: 0x2020
-IMPORT-NEXT:   ImportNameTable: 0x3040
+IMPORT-NEXT:   ModuleHandle: 0x3018
+IMPORT-NEXT:   ImportAddressTable: 0x3020
+IMPORT-NEXT:   ImportNameTable: 0x2040
 IMPORT-NEXT:   BoundDelayImportTable: 0x0
 IMPORT-NEXT:   UnloadDelayImportTable: 0x0
 IMPORT-NEXT:   Import {
@@ -29,13 +29,13 @@ IMPORT-NEXT: }
 BASEREL:      BaseReloc [
 BASEREL-NEXT:   Entry {
 BASEREL-NEXT:     Type: DIR64
-BASEREL-NEXT:     Address: 0x2020
+BASEREL-NEXT:     Address: 0x3020
 BASEREL-NEXT:   }
 BASEREL-NEXT:   Entry {
 BASEREL-NEXT:     Type: DIR64
-BASEREL-NEXT:     Address: 0x2028
+BASEREL-NEXT:     Address: 0x3028
 BASEREL-NEXT:   }
 BASEREL-NEXT:   Entry {
 BASEREL-NEXT:     Type: DIR64
-BASEREL-NEXT:     Address: 0x2030
+BASEREL-NEXT:     Address: 0x3030
 BASEREL-NEXT:   }

Modified: lld/trunk/test/COFF/delayimports32.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/delayimports32.test?rev=330233&r1=330232&r2=330233&view=diff
==============================================================================
--- lld/trunk/test/COFF/delayimports32.test (original)
+++ lld/trunk/test/COFF/delayimports32.test Tue Apr 17 16:28:52 2018
@@ -2,7 +2,7 @@
 # RUN: yaml2obj < %p/Inputs/hello32.yaml > %t.obj
 # RUN: lld-link %t.obj %p/Inputs/std32.lib /subsystem:console \
 # RUN:   /entry:main at 0 /alternatename:___delayLoadHelper2 at 8=_main at 0 \
-# RUN:   /debug /delayload:std32.dll /out:%t.exe
+# RUN:   /delayload:std32.dll /out:%t.exe
 # RUN: llvm-readobj -coff-imports %t.exe | FileCheck -check-prefix=IMPORT %s
 # RUN: llvm-readobj -coff-basereloc %t.exe | FileCheck -check-prefix=BASEREL %s
 # RUN: llvm-objdump -d %t.exe | FileCheck -check-prefix=DISASM %s
@@ -15,7 +15,7 @@ IMPORT-NEXT:   Name: std32.dll
 IMPORT-NEXT:   Attributes: 0x1
 IMPORT-NEXT:   ModuleHandle: 0x3018
 IMPORT-NEXT:   ImportAddressTable: 0x3020
-IMPORT-NEXT:   ImportNameTable: 0x4040
+IMPORT-NEXT:   ImportNameTable: 0x2040
 IMPORT-NEXT:   BoundDelayImportTable: 0x0
 IMPORT-NEXT:   UnloadDelayImportTable: 0x0
 IMPORT-NEXT:   Import {
@@ -72,7 +72,7 @@ BASEREL-NEXT:   }
 BASEREL-NEXT: ]
 
 DISASM:      102b:      68 20 30 40 00  pushl   $4206624
-DISASM-NEXT: 1030:      68 00 40 40 00  pushl   $4210688
+DISASM-NEXT: 1030:      68 00 20 40 00  pushl   $4202496
 DISASM-NEXT: 1035:      e8 c6 ff ff ff  calll   -58 <.text>
 DISASM-NEXT: 103a:      5a      popl    %edx
 DISASM-NEXT: 103b:      59      popl    %ecx
@@ -80,7 +80,7 @@ DISASM-NEXT: 103c:      ff e0   jmpl
 DISASM-NEXT: 103e:      51      pushl   %ecx
 DISASM-NEXT: 103f:      52      pushl   %edx
 DISASM-NEXT: 1040:      68 24 30 40 00  pushl   $4206628
-DISASM-NEXT: 1045:      68 00 40 40 00  pushl   $4210688
+DISASM-NEXT: 1045:      68 00 20 40 00  pushl   $4202496
 DISASM-NEXT: 104a:      e8 b1 ff ff ff  calll   -79 <.text>
 DISASM-NEXT: 104f:      5a      popl    %edx
 DISASM-NEXT: 1050:      59      popl    %ecx

Modified: lld/trunk/test/COFF/export-armnt.yaml
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/export-armnt.yaml?rev=330233&r1=330232&r2=330233&view=diff
==============================================================================
--- lld/trunk/test/COFF/export-armnt.yaml (original)
+++ lld/trunk/test/COFF/export-armnt.yaml Tue Apr 17 16:28:52 2018
@@ -9,7 +9,7 @@
 # CHECK:      DLL name: export-armnt.yaml.tmp.dll
 # CHECK:      Ordinal      RVA  Name
 # CHECK-NEXT:       0        0
-# CHECK-NEXT:       1   0x2000  exportdata
+# CHECK-NEXT:       1   0x3000  exportdata
 # CHECK-NEXT:       2   0x1005  exportfn1
 # CHECK-NEXT:       3   0x1009  exportfn2
 # CHECK-NEXT:       4   0x1009  exportfn3

Modified: lld/trunk/test/COFF/hello32.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/hello32.test?rev=330233&r1=330232&r2=330233&view=diff
==============================================================================
--- lld/trunk/test/COFF/hello32.test (original)
+++ lld/trunk/test/COFF/hello32.test Tue Apr 17 16:28:52 2018
@@ -57,7 +57,7 @@ HEADER-NEXT:   NumberOfRvaAndSize: 16
 HEADER-NEXT:   DataDirectory {
 HEADER-NEXT:     ExportTableRVA: 0x0
 HEADER-NEXT:     ExportTableSize: 0x0
-HEADER-NEXT:     ImportTableRVA: 0x3000
+HEADER-NEXT:     ImportTableRVA: 0x2000
 HEADER-NEXT:     ImportTableSize: 0x28
 HEADER-NEXT:     ResourceTableRVA: 0x0
 HEADER-NEXT:     ResourceTableSize: 0x0
@@ -79,7 +79,7 @@ HEADER-NEXT:     LoadConfigTableRVA: 0x0
 HEADER-NEXT:     LoadConfigTableSize: 0x0
 HEADER-NEXT:     BoundImportRVA: 0x0
 HEADER-NEXT:     BoundImportSize: 0x0
-HEADER-NEXT:     IATRVA: 0x3034
+HEADER-NEXT:     IATRVA: 0x2034
 HEADER-NEXT:     IATSize: 0xC
 HEADER-NEXT:     DelayImportDescriptorRVA: 0x0
 HEADER-NEXT:     DelayImportDescriptorSize: 0x0
@@ -114,8 +114,8 @@ IMPORTS: Arch: i386
 IMPORTS: AddressSize: 32bit
 IMPORTS: Import {
 IMPORTS:   Name: std32.dll
-IMPORTS:   ImportLookupTableRVA: 0x3028
-IMPORTS:   ImportAddressTableRVA: 0x3034
+IMPORTS:   ImportLookupTableRVA: 0x2028
+IMPORTS:   ImportAddressTableRVA: 0x2034
 IMPORTS:   Symbol: ExitProcess (0)
 IMPORTS:   Symbol: MessageBoxA (1)
 IMPORTS: }

Modified: lld/trunk/test/COFF/imports.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/imports.test?rev=330233&r1=330232&r2=330233&view=diff
==============================================================================
--- lld/trunk/test/COFF/imports.test (original)
+++ lld/trunk/test/COFF/imports.test Tue Apr 17 16:28:52 2018
@@ -15,21 +15,21 @@ TEXT: Disassembly of section .text:
 TEXT-NEXT: .text:
 TEXT-NEXT: subq    $40, %rsp
 TEXT-NEXT: movq    $0, %rcx
-TEXT-NEXT: leaq    4084(%rip), %rdx
-TEXT-NEXT: leaq    4071(%rip), %r8
+TEXT-NEXT: leaq    8180(%rip), %rdx
+TEXT-NEXT: leaq    8167(%rip), %r8
 TEXT-NEXT: movl    $0, %r9d
 TEXT-NEXT: callq   60
 TEXT-NEXT: movl    $0, %ecx
 TEXT-NEXT: callq   18
 TEXT-NEXT: callq   29
-TEXT:      jmpq    *8194(%rip)
-TEXT:      jmpq    *8186(%rip)
-TEXT:      jmpq    *8178(%rip)
+TEXT:      jmpq    *4098(%rip)
+TEXT:      jmpq    *4090(%rip)
+TEXT:      jmpq    *4082(%rip)
 
 IMPORT:      Import {
 IMPORT-NEXT:   Name: std64.dll
-IMPORT-NEXT:   ImportLookupTableRVA: 0x3028
-IMPORT-NEXT:   ImportAddressTableRVA: 0x3048
+IMPORT-NEXT:   ImportLookupTableRVA: 0x2028
+IMPORT-NEXT:   ImportAddressTableRVA: 0x2048
 IMPORT-NEXT:   Symbol: ExitProcess (0)
 IMPORT-NEXT:   Symbol:  (50)
 IMPORT-NEXT:   Symbol: MessageBoxA (1)

Modified: lld/trunk/test/COFF/pdb-publics-import.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/pdb-publics-import.test?rev=330233&r1=330232&r2=330233&view=diff
==============================================================================
--- lld/trunk/test/COFF/pdb-publics-import.test (original)
+++ lld/trunk/test/COFF/pdb-publics-import.test Tue Apr 17 16:28:52 2018
@@ -6,7 +6,8 @@ RUN: yaml2obj < %p/Inputs/export.yaml >
 RUN: lld-link /out:%t1.dll /dll %t1.obj /implib:%t1.lib \
 RUN:   /export:exportfn1 /export:exportfn2
 RUN: yaml2obj < %p/Inputs/import.yaml > %t2.obj
-RUN: lld-link /out:%t2.exe /pdb:%t2.pdb /debug /entry:main %t2.obj %t1.lib
+RUN: lld-link /out:%t2.exe /pdb:%t2.pdb /pdbaltpath:test.pdb \
+RUN:   /debug /entry:main %t2.obj %t1.lib
 RUN: llvm-pdbutil dump %t2.pdb -publics -section-contribs | FileCheck %s
 
 CHECK:                             Public Symbols
@@ -19,9 +20,9 @@ CHECK-NEXT:            flags = function,
 CHECK-NEXT:       88 | S_PUB32 [size = 24] `exportfn2`
 CHECK-NEXT:            flags = function, addr = 0001:0032
 CHECK-NEXT:       32 | S_PUB32 [size = 32] `__imp_exportfn2`
-CHECK-NEXT:            flags = none, addr = 0003:0072
+CHECK-NEXT:            flags = none, addr = 0002:0136
 CHECK-NEXT:        0 | S_PUB32 [size = 32] `__imp_exportfn1`
-CHECK-NEXT:            flags = none, addr = 0003:0064
+CHECK-NEXT:            flags = none, addr = 0002:0128
 
 CHECK:                         Section Contributions
 CHECK-NEXT: ============================================================
@@ -38,5 +39,5 @@ CHECK-NEXT:                 IMAGE_SCN_CN
     .rdata debug directory data chunks
 CHECK-NEXT:   SC[.rdata]  | mod = 1, 0002:0000, size = 28, data crc = 0, reloc crc = 0
 CHECK-NEXT:                 IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ
-CHECK-NEXT:   SC[.rdata]  | mod = 1, 0002:0028, size = {{.*}}, data crc = 0, reloc crc = 0
+CHECK-NEXT:   SC[.rdata]  | mod = 1, 0002:0028, size = 33, data crc = 0, reloc crc = 0
 CHECK-NEXT:                 IMAGE_SCN_CNT_INITIALIZED_DATA | IMAGE_SCN_MEM_READ

Modified: lld/trunk/test/COFF/symtab.test
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/COFF/symtab.test?rev=330233&r1=330232&r2=330233&view=diff
==============================================================================
--- lld/trunk/test/COFF/symtab.test (original)
+++ lld/trunk/test/COFF/symtab.test Tue Apr 17 16:28:52 2018
@@ -56,7 +56,7 @@
 # CHECK-NEXT:   Symbol {
 # CHECK-NEXT:     Name: message
 # CHECK-NEXT:     Value: 6
-# CHECK-NEXT:     Section: .text2 (5)
+# CHECK-NEXT:     Section: .text2
 # CHECK-NEXT:     BaseType: Null (0x0)
 # CHECK-NEXT:     ComplexType: Null (0x0)
 # CHECK-NEXT:     StorageClass: Static (0x3)
@@ -74,7 +74,7 @@
 # CHECK-NEXT:   Symbol {
 # CHECK-NEXT:     Name: caption
 # CHECK-NEXT:     Value: 0
-# CHECK-NEXT:     Section: .text2 (5)
+# CHECK-NEXT:     Section: .text2
 # CHECK-NEXT:     BaseType: Null (0x0)
 # CHECK-NEXT:     ComplexType: Null (0x0)
 # CHECK-NEXT:     StorageClass: Static (0x3)




More information about the llvm-commits mailing list