[PECOFF] Emit the import table to .idata section.

Emitting idata atoms to their own section would make debugging easier.
The Windows loader do not really care about whether the DLL import table is
in .rdata or its own .idata section, so there is no change in functionality.

llvm-svn: 196458
This commit is contained in:
Rui Ueyama 2013-12-05 02:27:30 +00:00
parent 57b20a7e54
commit 6cfe07b9eb
2 changed files with 33 additions and 23 deletions

View File

@ -69,6 +69,8 @@ struct Context {
/// The root class of all idata atoms.
class IdataAtom : public COFFLinkerInternalAtom {
public:
virtual SectionChoice sectionChoice() const { return sectionCustomRequired; }
virtual StringRef customSectionName() const { return ".idata"; };
virtual ContentType contentType() const { return typeData; }
virtual ContentPermissions permissions() const { return permR__; }

View File

@ -4,35 +4,43 @@
# RUN: yaml2obj %p/Inputs/vars-main.obj.yaml > %t.obj
#
# RUN: lld -flavor link /out:%t1 /subsystem:console /entry:main /opt:noref \
# RUN: -- %t.obj %p/Inputs/vars.lib && llvm-objdump -d %t1 | FileCheck %s
# RUN: -- %t.obj %p/Inputs/vars.lib
# RUN: llvm-objdump -d %t1 | FileCheck -check-prefix=TEXT %s
# RUN: llvm-readobj -sections %t1 | FileCheck -check-prefix=SECTION %s
#
# RUN: lld -flavor link /out:%t1 /subsystem:console /entry:main /opt:noref \
# RUN: /libpath:%p/Inputs -- %t.obj vars.lib && llvm-objdump -d %t1 \
# RUN: | FileCheck %s
# RUN: /libpath:%p/Inputs -- %t.obj vars.lib
# RUN: llvm-objdump -d %t1 | FileCheck -check-prefix=TEXT %s
# RUN: llvm-readobj -sections %t1 | FileCheck -check-prefix=SECTION %s
#
# RUN: lld -flavor link /out:%t1 /subsystem:console /entry:main /opt:noref \
# RUN: /libpath:%p/Inputs /defaultlib:vars.lib -- %t.obj \
# RUN: && llvm-objdump -d %t1 | FileCheck %s
# RUN: /libpath:%p/Inputs /defaultlib:vars.lib -- %t.obj
# RUN: llvm-objdump -d %t1 | FileCheck -check-prefix=TEXT %s
# RUN: llvm-readobj -sections %t1 | FileCheck -check-prefix=SECTION %s
#
# RUN: env LIB=%p/Inputs lld -flavor link /out:%t1 /subsystem:console \
# RUN: /opt:noref /entry:main -- %t.obj vars.lib \
# RUN: && llvm-objdump -d %t1 | FileCheck %s
# RUN: /opt:noref /entry:main -- %t.obj vars.lib
# RUN: llvm-objdump -d %t1 | FileCheck -check-prefix=TEXT %s
# RUN: llvm-readobj -sections %t1 | FileCheck -check-prefix=SECTION %s
#
# RUN: env LINK="/out:%t1 /subsystem:console /entry:main /opt:noref \
# RUN: -- %t.obj" lld -flavor link %p/Inputs/vars.lib \
# RUN: && llvm-objdump -d %t1 | FileCheck %s
# RUN: -- %t.obj" lld -flavor link %p/Inputs/vars.lib
# RUN: llvm-objdump -d %t1 | FileCheck -check-prefix=TEXT %s
# RUN: llvm-readobj -sections %t1 | FileCheck -check-prefix=SECTION %s
CHECK: Disassembly of section .text:
CHECK-NEXT: .text:
CHECK-NEXT: pushl %ebp
CHECK-NEXT: movl %esp, %ebp
CHECK-NEXT: pushl %esi
CHECK-NEXT: calll *{{[0-9]+}}
CHECK-NEXT: movl {{[0-9]+}}, %ecx
CHECK-NEXT: movl (%ecx), %esi
CHECK-NEXT: addl %eax, %esi
CHECK-NEXT: calll *{{[0-9]+}}
CHECK-NEXT: addl %esi, %eax
CHECK-NEXT: popl %esi
CHECK-NEXT: popl %ebp
CHECK-NEXT: ret
TEXT: Disassembly of section .text:
TEXT-NEXT: .text:
TEXT-NEXT: pushl %ebp
TEXT-NEXT: movl %esp, %ebp
TEXT-NEXT: pushl %esi
TEXT-NEXT: calll *{{[0-9]+}}
TEXT-NEXT: movl {{[0-9]+}}, %ecx
TEXT-NEXT: movl (%ecx), %esi
TEXT-NEXT: addl %eax, %esi
TEXT-NEXT: calll *{{[0-9]+}}
TEXT-NEXT: addl %esi, %eax
TEXT-NEXT: popl %esi
TEXT-NEXT: popl %ebp
TEXT-NEXT: ret
SECTION: Name: .idata (2E 69 64 61 74 61 00 00)