2018-06-06 21:56:51 +08:00
|
|
|
# REQUIRES: x86
|
[COFF] Improve synthetic symbol handling
Summary:
The main change is that we can have SECREL and SECTION relocations
against ___safe_se_handler_table, which is important for handling the
debug info in the MSVCRT.
Previously we were using DefinedRelative for __safe_se_handler_table and
__ImageBase, and after we implement CFGuard, we plan to extend it to
handle __guard_fids_table, __guard_longjmp_table, and more. However,
DefinedRelative is really only suitable for implementing __ImageBase,
because it lacks a Chunk, which you need in order to figure out the
output section index and output section offset when resolving SECREl and
SECTION relocations.
This change renames DefinedRelative to DefinedSynthetic and gives it a
Chunk. One wart is that __ImageBase doesn't have a chunk. It points to
the PE header, effectively. We could split DefinedRelative and
DefinedSynthetic if we think that's cleaner and creates fewer special
cases.
I also added safeseh.s, which checks that we don't emit a safe seh table
entries pointing to garbage collected handlers and that we don't emit a
table at all when there are no handlers.
Reviewers: ruiu
Reviewed By: ruiu
Subscribers: inglorion, pcc, llvm-commits, aprantl
Differential Revision: https://reviews.llvm.org/D34577
llvm-svn: 306293
2017-06-26 23:39:52 +08:00
|
|
|
# RUN: llvm-mc -triple i686-windows-msvc %s -filetype=obj -o %t.obj
|
|
|
|
# RUN: lld-link %t.obj -safeseh -out:%t.exe -opt:noref -entry:main
|
2019-05-01 13:49:01 +08:00
|
|
|
# RUN: llvm-readobj --coff-basereloc --coff-load-config --file-headers %t.exe | FileCheck %s --check-prefix=CHECK-NOGC
|
2018-05-30 03:07:47 +08:00
|
|
|
# RUN: lld-link %t.obj -safeseh -out:%t.exe -opt:noref -entry:main -debug:dwarf
|
2019-05-01 13:49:01 +08:00
|
|
|
# RUN: llvm-readobj --coff-basereloc --coff-load-config --file-headers %t.exe | FileCheck %s --check-prefix=CHECK-NOGC
|
[COFF] Improve synthetic symbol handling
Summary:
The main change is that we can have SECREL and SECTION relocations
against ___safe_se_handler_table, which is important for handling the
debug info in the MSVCRT.
Previously we were using DefinedRelative for __safe_se_handler_table and
__ImageBase, and after we implement CFGuard, we plan to extend it to
handle __guard_fids_table, __guard_longjmp_table, and more. However,
DefinedRelative is really only suitable for implementing __ImageBase,
because it lacks a Chunk, which you need in order to figure out the
output section index and output section offset when resolving SECREl and
SECTION relocations.
This change renames DefinedRelative to DefinedSynthetic and gives it a
Chunk. One wart is that __ImageBase doesn't have a chunk. It points to
the PE header, effectively. We could split DefinedRelative and
DefinedSynthetic if we think that's cleaner and creates fewer special
cases.
I also added safeseh.s, which checks that we don't emit a safe seh table
entries pointing to garbage collected handlers and that we don't emit a
table at all when there are no handlers.
Reviewers: ruiu
Reviewed By: ruiu
Subscribers: inglorion, pcc, llvm-commits, aprantl
Differential Revision: https://reviews.llvm.org/D34577
llvm-svn: 306293
2017-06-26 23:39:52 +08:00
|
|
|
# RUN: lld-link %t.obj -safeseh -out:%t.exe -opt:ref -entry:main
|
2019-05-01 13:49:01 +08:00
|
|
|
# RUN: llvm-readobj --coff-basereloc --coff-load-config --file-headers %t.exe | FileCheck %s --check-prefix=CHECK-GC
|
[COFF] Improve synthetic symbol handling
Summary:
The main change is that we can have SECREL and SECTION relocations
against ___safe_se_handler_table, which is important for handling the
debug info in the MSVCRT.
Previously we were using DefinedRelative for __safe_se_handler_table and
__ImageBase, and after we implement CFGuard, we plan to extend it to
handle __guard_fids_table, __guard_longjmp_table, and more. However,
DefinedRelative is really only suitable for implementing __ImageBase,
because it lacks a Chunk, which you need in order to figure out the
output section index and output section offset when resolving SECREl and
SECTION relocations.
This change renames DefinedRelative to DefinedSynthetic and gives it a
Chunk. One wart is that __ImageBase doesn't have a chunk. It points to
the PE header, effectively. We could split DefinedRelative and
DefinedSynthetic if we think that's cleaner and creates fewer special
cases.
I also added safeseh.s, which checks that we don't emit a safe seh table
entries pointing to garbage collected handlers and that we don't emit a
table at all when there are no handlers.
Reviewers: ruiu
Reviewed By: ruiu
Subscribers: inglorion, pcc, llvm-commits, aprantl
Differential Revision: https://reviews.llvm.org/D34577
llvm-svn: 306293
2017-06-26 23:39:52 +08:00
|
|
|
|
2017-11-08 07:24:10 +08:00
|
|
|
# __safe_se_handler_table needs to be relocated against ImageBase.
|
|
|
|
# check that the relocation is present.
|
2018-04-19 06:37:10 +08:00
|
|
|
#
|
2017-12-16 04:53:03 +08:00
|
|
|
# CHECK-NOGC-NOT: IMAGE_DLL_CHARACTERISTICS_NO_SEH
|
2017-11-08 07:24:10 +08:00
|
|
|
# CHECK-NOGC: BaseReloc [
|
|
|
|
# CHECK-NOGC: Entry {
|
|
|
|
# CHECK-NOGC: Type: HIGHLOW
|
[COFF] Improve synthetic symbol handling
Summary:
The main change is that we can have SECREL and SECTION relocations
against ___safe_se_handler_table, which is important for handling the
debug info in the MSVCRT.
Previously we were using DefinedRelative for __safe_se_handler_table and
__ImageBase, and after we implement CFGuard, we plan to extend it to
handle __guard_fids_table, __guard_longjmp_table, and more. However,
DefinedRelative is really only suitable for implementing __ImageBase,
because it lacks a Chunk, which you need in order to figure out the
output section index and output section offset when resolving SECREl and
SECTION relocations.
This change renames DefinedRelative to DefinedSynthetic and gives it a
Chunk. One wart is that __ImageBase doesn't have a chunk. It points to
the PE header, effectively. We could split DefinedRelative and
DefinedSynthetic if we think that's cleaner and creates fewer special
cases.
I also added safeseh.s, which checks that we don't emit a safe seh table
entries pointing to garbage collected handlers and that we don't emit a
table at all when there are no handlers.
Reviewers: ruiu
Reviewed By: ruiu
Subscribers: inglorion, pcc, llvm-commits, aprantl
Differential Revision: https://reviews.llvm.org/D34577
llvm-svn: 306293
2017-06-26 23:39:52 +08:00
|
|
|
# CHECK-NOGC: LoadConfig [
|
|
|
|
# CHECK-NOGC: Size: 0x48
|
2018-05-30 03:07:47 +08:00
|
|
|
# CHECK-NOGC: SEHandlerTable: 0x
|
[COFF] Improve synthetic symbol handling
Summary:
The main change is that we can have SECREL and SECTION relocations
against ___safe_se_handler_table, which is important for handling the
debug info in the MSVCRT.
Previously we were using DefinedRelative for __safe_se_handler_table and
__ImageBase, and after we implement CFGuard, we plan to extend it to
handle __guard_fids_table, __guard_longjmp_table, and more. However,
DefinedRelative is really only suitable for implementing __ImageBase,
because it lacks a Chunk, which you need in order to figure out the
output section index and output section offset when resolving SECREl and
SECTION relocations.
This change renames DefinedRelative to DefinedSynthetic and gives it a
Chunk. One wart is that __ImageBase doesn't have a chunk. It points to
the PE header, effectively. We could split DefinedRelative and
DefinedSynthetic if we think that's cleaner and creates fewer special
cases.
I also added safeseh.s, which checks that we don't emit a safe seh table
entries pointing to garbage collected handlers and that we don't emit a
table at all when there are no handlers.
Reviewers: ruiu
Reviewed By: ruiu
Subscribers: inglorion, pcc, llvm-commits, aprantl
Differential Revision: https://reviews.llvm.org/D34577
llvm-svn: 306293
2017-06-26 23:39:52 +08:00
|
|
|
# CHECK-NOGC: SEHandlerCount: 1
|
|
|
|
# CHECK-NOGC: ]
|
|
|
|
# CHECK-NOGC: SEHTable [
|
2018-04-05 03:15:55 +08:00
|
|
|
# CHECK-NOGC-NEXT: 0x401006
|
[COFF] Improve synthetic symbol handling
Summary:
The main change is that we can have SECREL and SECTION relocations
against ___safe_se_handler_table, which is important for handling the
debug info in the MSVCRT.
Previously we were using DefinedRelative for __safe_se_handler_table and
__ImageBase, and after we implement CFGuard, we plan to extend it to
handle __guard_fids_table, __guard_longjmp_table, and more. However,
DefinedRelative is really only suitable for implementing __ImageBase,
because it lacks a Chunk, which you need in order to figure out the
output section index and output section offset when resolving SECREl and
SECTION relocations.
This change renames DefinedRelative to DefinedSynthetic and gives it a
Chunk. One wart is that __ImageBase doesn't have a chunk. It points to
the PE header, effectively. We could split DefinedRelative and
DefinedSynthetic if we think that's cleaner and creates fewer special
cases.
I also added safeseh.s, which checks that we don't emit a safe seh table
entries pointing to garbage collected handlers and that we don't emit a
table at all when there are no handlers.
Reviewers: ruiu
Reviewed By: ruiu
Subscribers: inglorion, pcc, llvm-commits, aprantl
Differential Revision: https://reviews.llvm.org/D34577
llvm-svn: 306293
2017-06-26 23:39:52 +08:00
|
|
|
# CHECK-NOGC-NEXT: ]
|
|
|
|
|
2018-04-19 06:37:10 +08:00
|
|
|
# If we enable GC, the exception handler should be removed, and we should add
|
|
|
|
# the DLL characteristic flag that indicates that there are no exception
|
|
|
|
# handlers in this DLL. The exception handler table in the load config should
|
|
|
|
# be empty and there should be no relocations for it.
|
|
|
|
#
|
|
|
|
# CHECK-GC: Characteristics [
|
|
|
|
# CHECK-GC: IMAGE_DLL_CHARACTERISTICS_NO_SEH
|
|
|
|
# CHECK-GC: ]
|
2017-11-08 07:24:10 +08:00
|
|
|
# CHECK-GC: BaseReloc [
|
|
|
|
# CHECK-GC-NEXT: ]
|
[COFF] Improve synthetic symbol handling
Summary:
The main change is that we can have SECREL and SECTION relocations
against ___safe_se_handler_table, which is important for handling the
debug info in the MSVCRT.
Previously we were using DefinedRelative for __safe_se_handler_table and
__ImageBase, and after we implement CFGuard, we plan to extend it to
handle __guard_fids_table, __guard_longjmp_table, and more. However,
DefinedRelative is really only suitable for implementing __ImageBase,
because it lacks a Chunk, which you need in order to figure out the
output section index and output section offset when resolving SECREl and
SECTION relocations.
This change renames DefinedRelative to DefinedSynthetic and gives it a
Chunk. One wart is that __ImageBase doesn't have a chunk. It points to
the PE header, effectively. We could split DefinedRelative and
DefinedSynthetic if we think that's cleaner and creates fewer special
cases.
I also added safeseh.s, which checks that we don't emit a safe seh table
entries pointing to garbage collected handlers and that we don't emit a
table at all when there are no handlers.
Reviewers: ruiu
Reviewed By: ruiu
Subscribers: inglorion, pcc, llvm-commits, aprantl
Differential Revision: https://reviews.llvm.org/D34577
llvm-svn: 306293
2017-06-26 23:39:52 +08:00
|
|
|
# CHECK-GC: LoadConfig [
|
|
|
|
# CHECK-GC: Size: 0x48
|
|
|
|
# CHECK-GC: SEHandlerTable: 0x0
|
|
|
|
# CHECK-GC: SEHandlerCount: 0
|
|
|
|
# CHECK-GC: ]
|
|
|
|
# CHECK-GC-NOT: SEHTable
|
|
|
|
|
|
|
|
|
|
|
|
.def @feat.00;
|
|
|
|
.scl 3;
|
|
|
|
.type 0;
|
|
|
|
.endef
|
|
|
|
.globl @feat.00
|
|
|
|
@feat.00 = 1
|
|
|
|
|
|
|
|
.def _main;
|
|
|
|
.scl 2;
|
|
|
|
.type 32;
|
|
|
|
.endef
|
|
|
|
.section .text,"xr",one_only,_main
|
|
|
|
.globl _main
|
|
|
|
_main:
|
|
|
|
movl $42, %eax
|
|
|
|
ret
|
|
|
|
|
|
|
|
# This handler can be GCd, which will make the safeseh table empty, so it should
|
|
|
|
# appear null.
|
|
|
|
.def _my_handler;
|
|
|
|
.scl 3;
|
|
|
|
.type 32;
|
|
|
|
.endef
|
|
|
|
.section .text,"xr",one_only,_my_handler
|
|
|
|
_my_handler:
|
|
|
|
ret
|
|
|
|
|
|
|
|
.safeseh _my_handler
|
|
|
|
|
|
|
|
|
|
|
|
.section .rdata,"dr"
|
|
|
|
.globl __load_config_used
|
|
|
|
__load_config_used:
|
|
|
|
.long 72
|
|
|
|
.fill 60, 1, 0
|
|
|
|
.long ___safe_se_handler_table
|
|
|
|
.long ___safe_se_handler_count
|