This is an archive of the discontinued LLVM Phabricator instance.

Do not allow delay-importing data symbols.
ClosedPublic

Authored by ruiu on May 25 2017, 10:49 AM.

Details

Summary

If you pass /delayload:<dllname> to the COFF linker, it creates thunks
so that DLLs are loaded when they are used for the first time instead of
load-time.

This mechanism do not work for data symbols as there's no way to trap
acccesses to data imported from DLLs. (Technically, I think if we make
dllimport table read-only, we could actually trap accesses and delay-load
data symbols, but that's not what Windows usually do.)

This patch is to report an error when you try to delay-load data symbols.

Fixes https://bugs.llvm.org/show_bug.cgi?id=33106

Diff Detail

Repository
rL LLVM

Event Timeline

ruiu created this revision.May 25 2017, 10:49 AM
pcc accepted this revision.May 25 2017, 10:59 AM

LGTM

I think if we make dllimport table read-only, we could actually trap accesses

If you wanted to trap a read, it wouldn't work to make it read-only, right?

This revision is now accepted and ready to land.May 25 2017, 10:59 AM
ruiu added a comment.May 25 2017, 11:02 AM

I was trying to say is to not map pages so that we can trap memory accesses.

pcc added a comment.May 25 2017, 11:03 AM
In D33557#764664, @ruiu wrote:

I was trying to say is to not map pages so that we can trap memory accesses.

Yeah, that's what I thought you meant.

This revision was automatically updated to reflect the committed changes.