File tree Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Expand file tree Collapse file tree 2 files changed +47
-0
lines changed Original file line number Diff line number Diff line change @@ -2060,6 +2060,10 @@ void Writer::createRuntimePseudoRelocs() {
2060
2060
auto *sc = dyn_cast<SectionChunk>(c);
2061
2061
if (!sc || !sc->live )
2062
2062
continue ;
2063
+ // Don't create pseudo relocations for sections that won't be
2064
+ // mapped at runtime.
2065
+ if (sc->header ->Characteristics & IMAGE_SCN_MEM_DISCARDABLE)
2066
+ continue ;
2063
2067
sc->getRuntimePseudoRelocs (rels);
2064
2068
}
2065
2069
Original file line number Diff line number Diff line change
1
+ # REQUIRES: x86
2
+ # RUN: split-file %s %t.dir
3
+
4
+ ## We've got references to variable both in a .refptr and in .debug_info.
5
+ ## The .debug_info section should be discardable, so no pseudo relocations
6
+ ## need to be created in it. The .refptr section should be elimiated
7
+ ## and redirected to __imp_variable instead, so we shouldn't need to
8
+ ## create any runtime pseudo relocations. Thus, test that we can link
9
+ ## successfully with -runtime-pseudo-reloc:no, while keeping the
10
+ ## debug info.
11
+
12
+ # RUN: llvm-mc -triple=x86_64-windows-gnu %t.dir/lib.s -filetype=obj -o %t.dir/lib.obj
13
+ # RUN: lld-link -out:%t.dir/lib.dll -dll -entry:DllMainCRTStartup %t.dir/lib.obj -lldmingw -implib:%t.dir/lib.lib
14
+
15
+ # RUN: llvm-mc -triple=x86_64-windows-gnu %t.dir/main.s -filetype=obj -o %t.dir/main.obj
16
+ # RUN: lld-link -lldmingw -out:%t.dir/main.exe -entry:main %t.dir/main.obj %t.dir/lib.lib -opt:noref -debug:dwarf -runtime-pseudo-reloc:no
17
+
18
+ #--- main.s
19
+ .global main
20
+ .text
21
+ main:
22
+ movq .refptr.variable(%rip ), %rax
23
+ ret
24
+
25
+ .section .rdata$.refptr.variable,"dr" ,discard ,.refptr.variable
26
+ .global .refptr.variable
27
+ .refptr.variable:
28
+ .quad variable
29
+
30
+ .section .debug_info
31
+ .long 1
32
+ .quad variable
33
+ .long 2
34
+
35
+ #--- lib.s
36
+ .global variable
37
+ .global DllMainCRTStartup
38
+ .text
39
+ DllMainCRTStartup:
40
+ ret
41
+ .data
42
+ variable:
43
+ .long 42
You can’t perform that action at this time.
0 commit comments