This is an archive of the discontinued LLVM Phabricator instance.

[lld] [COFF] Align import address chunks to the pointer size
ClosedPublic

Authored by mstorsjo on Jul 19 2017, 1:32 PM.

Details

Summary

This fixes cases on ARM64 when importing from more than one DLL, in case the imports from the first DLL ended up unaligned.

When fixing up a IMAGE_REL_ARM64_PAGEOFFSET_12L, which shifts the offset by the load/store size, check that the shift doesn't discard any bits. (This would also detect if the import address chunks were unaligned.)

Diff Detail

Repository
rL LLVM

Event Timeline

mstorsjo created this revision.Jul 19 2017, 1:32 PM
ruiu added inline comments.Jul 19 2017, 2:00 PM
COFF/Chunks.cpp
186 ↗(On Diff #107365)

It is better to use uint32_t so that you don't need to think about sign-extended shift.

187 ↗(On Diff #107365)

Use llvm::isPowerOf2_32.

188 ↗(On Diff #107365)

Error messages should start with lowercase letter.

mstorsjo marked an inline comment as done.Jul 19 2017, 2:08 PM
mstorsjo added inline comments.
COFF/Chunks.cpp
186 ↗(On Diff #107365)

Sure - do you want that change separately in a different change, or squashed into this one?

187 ↗(On Diff #107365)

Doesn't that check a different thing? This tests if the lowest Size bits of Imm are nonzero, while llvm::isPowerOf2_32 checks if the value is a power of two?

ruiu added inline comments.Jul 19 2017, 2:13 PM
COFF/Chunks.cpp
186 ↗(On Diff #107365)

It's probably better to do in a separate patch, even though I don't care if you do that as passed-by change with this patch.

187 ↗(On Diff #107365)

Ah, that's right.

188 ↗(On Diff #107365)

Please fix.

mstorsjo updated this revision to Diff 107378.Jul 19 2017, 2:18 PM

Made the error message lower case (will change the variable type in a separate change).

ruiu accepted this revision.Jul 19 2017, 2:20 PM

LGTM

This revision is now accepted and ready to land.Jul 19 2017, 2:20 PM
mstorsjo updated this revision to Diff 107379.Jul 19 2017, 2:20 PM

Updated with the right diff with the uint32_t change removed from here.

ruiu added inline comments.Jul 19 2017, 2:21 PM
COFF/Chunks.cpp
189–190 ↗(On Diff #107378)

It is probably better to write this as applyArm64Imm(Off, Imm >> Size)

mstorsjo marked an inline comment as done.Jul 19 2017, 2:40 PM
mstorsjo added inline comments.
COFF/Chunks.cpp
189–190 ↗(On Diff #107378)

Addressing this in https://reviews.llvm.org/D35646 as well.

This revision was automatically updated to reflect the committed changes.
mstorsjo marked an inline comment as done.
yinma added a subscriber: yinma.Oct 12 2018, 4:38 PM
This comment was removed by yinma.