This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [COFF] Add initial support for some ARM64 relocations and import thunks
ClosedPublic

Authored by mstorsjo on Jul 3 2017, 1:39 PM.

Details

Summary

This is enough to link a working hello world executable, with a call to an imported function, a string constant passed to the imported function, and loads from a global variable.

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Jul 3 2017, 1:39 PM
mstorsjo updated this revision to Diff 105332.Jul 5 2017, 1:49 PM
mstorsjo edited the summary of this revision. (Show Details)

Added support for the IMAGE_REL_ARM64_PAGEOFFSET_12L relocation as well (and testing of it), improved parts of the test.

martell added a subscriber: martell.Jul 5 2017, 2:19 PM
mstorsjo updated this revision to Diff 105678.Jul 7 2017, 12:58 PM

Added support for yet another few relocations, added a missed ARM64 part for getBaserelType (tested with wine, loading the exe at a non-default address so the base relocations need to be applied).

ruiu edited edge metadata.Jul 10 2017, 10:58 AM

Generally looking good.

COFF/Chunks.cpp
388–389 ↗(On Diff #105678)

Is this a to-do, or really empty?

mstorsjo added inline comments.Jul 10 2017, 1:36 PM
COFF/Chunks.cpp
388–389 ↗(On Diff #105678)

I think it's ok to leave it empty; the instructions in the import thunk load the actual target address using position independent addressing. I've tested this with wine, with the exe loaded at a different address than the base address, and they run fine.

mstorsjo updated this revision to Diff 105916.Jul 10 2017, 1:38 PM

Minor tweaks to the test, made the PAGEOFFSET_12A/L relocations read the existing immediate value and add that into the value from the relocation.

ruiu added inline comments.Jul 10 2017, 1:53 PM
COFF/Chunks.h
314 ↗(On Diff #105916)

Then do not override this function. The base class provides a function that does nothing.

mstorsjo updated this revision to Diff 105921.Jul 10 2017, 1:58 PM

No longer overriding getBaserels with an empty implementation.

ruiu accepted this revision.Jul 10 2017, 2:00 PM

LGTM

This revision is now accepted and ready to land.Jul 10 2017, 2:00 PM
This revision was automatically updated to reflect the committed changes.