Page MenuHomePhabricator

[RFC] [LLD] [COFF] Support options for enabling/disabling autoimport and pseudo relocs in .drectve sections
AbandonedPublic

Authored by mstorsjo on Thu, May 14, 3:35 AM.

Details

Reviewers
rnk
ruiu
Summary

This is the other bit I split out from D78923 as mentioned there. However since I wrote this, I'm less convinced that it's a good idea.

Firstly, it makes the lld private option (used on the lld-link interface - the one on the mingw driver interface is public) essentially public, if projects would be to start embedding it in .drectve sections.

Secondly, placing such an option in an object file is tricky, because it's essentially impossible to override it by linker options, as the linker options are read first and the object file is parsed later, overriding it.

Thirdly, after remembering more of the details about this, it turned out that the full pseudo reloc mechanism should be usable even in restricted UWP mode, as long as VirtualProtect is remapped to VirtualProtectFromApp (which already is done in https://sourceforge.net/p/mingw-w64/mingw-w64/ci/8f078a256769c84a021f5512ba0400f1eb8d0c05/), and as long as all places needing fixup is in data sections. If the executable code is generated with LLVM, it should avoid placing any such references within code sections, but always use .refptr stubs - so then this shouldn't really be an issue.

In any case, posting this for discussion as it was mentioned in D78923 - but I'm less convinced about its necessity now. Or what does @jacek think?

Diff Detail

Unit TestsFailed

TimeTest
200 mslld.COFF::autoimport-drectve.s
Script: -- : 'RUN: at line 3'; echo -e ".global variable\n.global DllMainCRTStartup\n.text\nDllMainCRTStartup:\nret\n.data\nvariable:\n.long 42" > C:\ws\prod\llvm-project\build\tools\lld\test\COFF\Output\autoimport-drectve.s.tmp-lib.s
270 mslld.COFF::autoimport-x86.s
Script: -- : 'RUN: at line 3'; echo -e ".global variable\n.global DllMainCRTStartup\n.text\nDllMainCRTStartup:\nret\n.data\nvariable:\n.long 42" > C:\ws\prod\llvm-project\build\tools\lld\test\COFF\Output\autoimport-x86.s.tmp-lib.s

Event Timeline

mstorsjo created this revision.Thu, May 14, 3:35 AM
Herald added a project: Restricted Project. · View Herald TranscriptThu, May 14, 3:35 AM
jacek added a comment.Thu, May 14, 3:57 AM

With the solution for UWP, we don't have a use case .drectve change, so dropping that part sounds reasonable.

rnk added a comment.Thu, May 21, 12:34 PM

I guess I would prefer not to add .drectve support for this unless there is a use case for it. It is a somewhat fragile interface.

mstorsjo abandoned this revision.Thu, May 21, 1:03 PM

Yeah, let's shelve this one for now.