[PATCH] D51454: [LLD] [COFF] Make sections with runtime pseudo relocations writable
Martin Storsjö via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 29 12:48:17 PDT 2018
mstorsjo created this revision.
mstorsjo added reviewers: rnk, ruiu, pcc.
If there are runtime pseudo relocations in a section that isn't writable, the relocation code will try to make the section writable first by calling VirtualProtect, and restore it to read only mode afterwards, before giving the control over to user code.
In Windows Store apps, the VirtualProtect function isn't allowed (and can be stubbed out with a dummy that just returns an error).
To avoid having to use this function, the linker can move all section chunks that require runtime relocations to a writable section. When moving data from .rdata to .data, this works ideally. If there are runtime pseudo relocs in the .text section though, we create a separate writable text section .wtext. As long as the compiler produces .refptr stubs from all variables that might be imported from another dll, we shouldn't ever need to make the text section writable.
Repository:
rLLD LLVM Linker
https://reviews.llvm.org/D51454
Files:
COFF/Chunks.cpp
COFF/Chunks.h
COFF/Writer.cpp
test/COFF/autoimport-x86.s
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D51454.163163.patch
Type: text/x-patch
Size: 8888 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180829/44a9bd2f/attachment.bin>
More information about the llvm-commits
mailing list