2018-06-06 21:56:51 +08:00
|
|
|
# REQUIRES: x86
|
[COFF] Allow debug info to relocate against discarded symbols
Summary:
In order to do this without switching on the symbol kind multiple times,
I created Defined::getChunkAndOffset and use that instead of
SymbolBody::getRVA in the inner relocation loop.
Now we get the symbol's chunk before switching over relocation types, so
we can test if it has been discarded outside the inner relocation type
switch. This also simplifies application of section relative
relocations. Previously we would switch on symbol kind to compute the
RVA, then the relocation type, and then the symbol kind again to get the
output section so we could subtract that from the symbol RVA. Now we
*always* have an OutputSection, so applying SECREL and SECTION
relocations isn't as much of a special case.
I'm still not quite happy with the cleanliness of this code. I'm not
sure what offsets and bases we should be using during the relocation
processing loop: VA, RVA, or OutputSectionOffset.
Reviewers: ruiu, pcc
Reviewed By: ruiu
Subscribers: majnemer, inglorion, llvm-commits, aprantl
Differential Revision: https://reviews.llvm.org/D34650
llvm-svn: 306566
2017-06-29 01:06:35 +08:00
|
|
|
# RUN: echo -e '.section .bss,"bw",discard,main_global\n.global main_global\n main_global:\n .long 0' | \
|
|
|
|
# RUN: llvm-mc - -filetype=obj -o %t1.obj -triple x86_64-windows-msvc
|
|
|
|
# RUN: llvm-mc %s -filetype=obj -o %t2.obj -triple x86_64-windows-msvc
|
|
|
|
|
|
|
|
# LLD should report an error and not assert regardless of whether we are doing
|
|
|
|
# GC.
|
|
|
|
|
|
|
|
# RUN: not lld-link -entry:main -nodefaultlib %t1.obj %t2.obj -out:%t.exe -opt:ref 2>&1 | FileCheck %s
|
|
|
|
# RUN: not lld-link -entry:main -nodefaultlib %t1.obj %t2.obj -out:%t.exe -opt:noref 2>&1 | FileCheck %s
|
|
|
|
|
|
|
|
# CHECK: error: relocation against symbol in discarded section: assoc_global
|
2018-11-09 02:38:17 +08:00
|
|
|
# CHECK: >>> referenced by {{.*}}reloc-discarded{{.*}}.obj:(main)
|
[COFF] Allow debug info to relocate against discarded symbols
Summary:
In order to do this without switching on the symbol kind multiple times,
I created Defined::getChunkAndOffset and use that instead of
SymbolBody::getRVA in the inner relocation loop.
Now we get the symbol's chunk before switching over relocation types, so
we can test if it has been discarded outside the inner relocation type
switch. This also simplifies application of section relative
relocations. Previously we would switch on symbol kind to compute the
RVA, then the relocation type, and then the symbol kind again to get the
output section so we could subtract that from the symbol RVA. Now we
*always* have an OutputSection, so applying SECREL and SECTION
relocations isn't as much of a special case.
I'm still not quite happy with the cleanliness of this code. I'm not
sure what offsets and bases we should be using during the relocation
processing loop: VA, RVA, or OutputSectionOffset.
Reviewers: ruiu, pcc
Reviewed By: ruiu
Subscribers: majnemer, inglorion, llvm-commits, aprantl
Differential Revision: https://reviews.llvm.org/D34650
llvm-svn: 306566
2017-06-29 01:06:35 +08:00
|
|
|
|
|
|
|
.section .bss,"bw",discard,main_global
|
|
|
|
.globl main_global
|
|
|
|
.p2align 2
|
|
|
|
main_global:
|
|
|
|
.long 0
|
|
|
|
|
|
|
|
.section .CRT$XCU,"dr",associative,main_global
|
|
|
|
.p2align 3
|
|
|
|
assoc_global:
|
|
|
|
.quad main_global
|
|
|
|
|
|
|
|
.text
|
|
|
|
.globl main
|
|
|
|
main:
|
|
|
|
movq assoc_global(%rip), %rax
|
|
|
|
movl (%rax), %eax
|
|
|
|
retq
|