Index: COFF/Driver.cpp =================================================================== --- COFF/Driver.cpp +++ COFF/Driver.cpp @@ -1102,6 +1102,12 @@ 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()); Index: test/COFF/arm64-relocs-imports.test =================================================================== --- test/COFF/arm64-relocs-imports.test +++ test/COFF/arm64-relocs-imports.test @@ -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 Index: test/COFF/delayimports-armnt.yaml =================================================================== --- test/COFF/delayimports-armnt.yaml +++ test/COFF/delayimports-armnt.yaml @@ -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 Index: test/COFF/delayimports.test =================================================================== --- test/COFF/delayimports.test +++ test/COFF/delayimports.test @@ -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 @@ 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: } Index: test/COFF/delayimports32.test =================================================================== --- test/COFF/delayimports32.test +++ test/COFF/delayimports32.test @@ -15,7 +15,7 @@ IMPORT-NEXT: Attributes: 0x1 IMPORT-NEXT: ModuleHandle: 0x3018 IMPORT-NEXT: ImportAddressTable: 0x3020 -IMPORT-NEXT: ImportNameTable: 0x4040 +IMPORT-NEXT: ImportNameTable: 0x20DC IMPORT-NEXT: BoundDelayImportTable: 0x0 IMPORT-NEXT: UnloadDelayImportTable: 0x0 IMPORT-NEXT: Import { @@ -72,7 +72,7 @@ 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 9c 20 40 00 pushl $4202652 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: 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 9c 20 40 00 pushl $4202652 DISASM-NEXT: 104a: e8 b1 ff ff ff calll -79 <.text> DISASM-NEXT: 104f: 5a popl %edx DISASM-NEXT: 1050: 59 popl %ecx Index: test/COFF/export-armnt.yaml =================================================================== --- test/COFF/export-armnt.yaml +++ test/COFF/export-armnt.yaml @@ -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 Index: test/COFF/hello32.test =================================================================== --- test/COFF/hello32.test +++ test/COFF/hello32.test @@ -57,7 +57,7 @@ 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: 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: 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: } Index: test/COFF/imports.test =================================================================== --- test/COFF/imports.test +++ test/COFF/imports.test @@ -15,21 +15,21 @@ 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) Index: test/COFF/pdb-publics-import.test =================================================================== --- test/COFF/pdb-publics-import.test +++ test/COFF/pdb-publics-import.test @@ -19,9 +19,9 @@ 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:0240 CHECK-NEXT: 0 | S_PUB32 [size = 32] `__imp_exportfn1` -CHECK-NEXT: flags = none, addr = 0003:0064 +CHECK-NEXT: flags = none, addr = 0002:0232 CHECK: Section Contributions CHECK-NEXT: ============================================================ Index: test/COFF/symtab.test =================================================================== --- test/COFF/symtab.test +++ test/COFF/symtab.test @@ -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)