This is an archive of the discontinued LLVM Phabricator instance.

[LLD] [COFF] Fix alignment of thunks for ARM/ARM64
ClosedPublic

Authored by mstorsjo on Apr 9 2020, 6:17 AM.

Details

Summary

The alignment of ARM64 range extension thunks was fixed in 7c816492197a, but ARM range extension thunks, and import and delay import thunks for both also need aligning (like all code on ARM platforms).

I'm adding a test for alignment of ARM64 import thunks - not specifically adding tests for misalignment of all of them though.

Diff Detail

Event Timeline

mstorsjo created this revision.Apr 9 2020, 6:17 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 9 2020, 6:17 AM
rnk added a comment.Apr 9 2020, 2:20 PM

I seem to recall we had some logic for boosting the alignment of known executable sections. Is it appropriate to reuse that for these thunks? It seems like each ISA has its own minimum code alignment.

Otherwise, sounds good, just wanted to check if there is a way to factor this more tightly.

In D77796#1972959, @rnk wrote:

I seem to recall we had some logic for boosting the alignment of known executable sections. Is it appropriate to reuse that for these thunks? It seems like each ISA has its own minimum code alignment.

Hmm, I don't think I remember seeing that - do you remember more in detail where that would be?

In D77796#1972959, @rnk wrote:

I seem to recall we had some logic for boosting the alignment of known executable sections. Is it appropriate to reuse that for these thunks? It seems like each ISA has its own minimum code alignment.

Hmm, I don't think I remember seeing that - do you remember more in detail where that would be?

I tried grepping around a bit more but didn't really see anything such in LLD - @rnk?

rnk accepted this revision.Apr 13 2020, 12:26 PM

lgtm

I must have been thinking of the /functionpadmin code:
https://github.com/llvm/llvm-project/blob/master/lld/COFF/Writer.cpp#L1262
It has nothing to do with alignment, just padding. We could add logic there to enforce a minimum ISA code alignment, but that seems separable.

This revision is now accepted and ready to land.Apr 13 2020, 12:26 PM
This revision was automatically updated to reflect the committed changes.

@tstellar - I think this one would be good for a backport to 10.0.1 - is it enough to tag you here, or do you want me to open a bug for backporting it?