This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [COFF] Store import symbol pointers as pointers to the base class
ClosedPublic

Authored by mstorsjo on Jul 4 2018, 2:13 PM.

Details

Summary

Future symbol insertions can potentially change the type of these symbols - keep pointers to the base class to reflect this, and use dynamic casts to inspect them before using as the subclass type.

This fixes crashes that were possible before, by touching these symbols that now are populated as e.g. a DefinedRegular, via the old pointers with DefinedImportThunk type.

Alternatively, just disallow the replacements of these symbols (implemented in D48952).

Diff Detail

Repository
rLLD LLVM Linker

Event Timeline

mstorsjo created this revision.Jul 4 2018, 2:13 PM
mstorsjo retitled this revision from [COFF] Store import symbol pointers as pointers to the base class to [LLD] [COFF] Store import symbol pointers as pointers to the base class.Jul 4 2018, 2:16 PM
mstorsjo updated this revision to Diff 154152.Jul 4 2018, 2:26 PM

Fixed a case where ImpSym was assumed to be non-null, using cast_or_null instead.

ruiu accepted this revision.Jul 5 2018, 9:50 AM

LGTM

This revision is now accepted and ready to land.Jul 5 2018, 9:50 AM

LGTM

Thanks! Just to be sure, did you look at D48952 as well, but prefer this alternative?

LGTM

Thanks! Just to be sure, did you look at D48952 as well, but prefer this alternative?

Ping @ruiu, just a quick check if you looked at both alternatives to this solution, before I'll commit it.

ruiu added a comment.Jul 9 2018, 2:53 PM

Sorry for the belated response. Yes, I did read the other patch too, and I prefer this one because this patch doesn't change the code for symbol name resolution.

Sorry for the belated response. Yes, I did read the other patch too, and I prefer this one because this patch doesn't change the code for symbol name resolution.

Ok, thanks for confirming and clarifying! I'll land this one soon then.

This revision was automatically updated to reflect the committed changes.