This is an archive of the discontinued LLVM Phabricator instance.

[COFF] Use 32-bit jump table entries in .rdata for Win64
ClosedPublic

Authored by rnk on Dec 28 2016, 1:42 PM.

Details

Summary

We were already using 32-bit jump table entries, but this was a
consequence of the default PIC model on Win64, and not an intentional
design decision. This patch ensures that we always use 32-bit label
difference jump table entries on Win64 regardless of the PIC model. This
is a good idea because it saves executable size and object file size.

Moving the jump tables to .rdata cleans up the disassembled object code
and reduces the available ROP targets, but it requires adding one more
RIP-relative lea to the code. COFF doesn't have relocations to express
the difference between two arbitrary symbols, so we can't use the jump
table label in the label difference like we do elsewhere.

Fixes PR31488

Diff Detail

Repository
rL LLVM

Event Timeline

rnk updated this revision to Diff 82616.Dec 28 2016, 1:42 PM
rnk retitled this revision from to [COFF] Use 32-bit jump table entries in .rdata for Win64.
rnk updated this object.
rnk added reviewers: majnemer, compnerd.
rnk added a subscriber: llvm-commits.
majnemer accepted this revision.Dec 28 2016, 3:14 PM
majnemer edited edge metadata.

LGTM

This revision is now accepted and ready to land.Dec 28 2016, 3:14 PM
This revision was automatically updated to reflect the committed changes.
wxiao3 added a subscriber: wxiao3.Feb 21 2023, 7:22 PM

@rnk do you have plan to bring this back?

Herald added projects: Restricted Project, Restricted Project. · View Herald TranscriptFeb 21 2023, 7:22 PM
Herald added a subscriber: pengfei. · View Herald Transcript
rnk added a comment.May 3 2023, 1:08 PM

@rnk do you have plan to bring this back?

As far as I can tell, the issue is currently fixed, see the usage of .section .rdata and .long directives from llc here: https://gcc.godbolt.org/z/1znoroP74

wxiao3 added a comment.May 4 2023, 2:45 AM
In D28141#4316637, @rnk wrote:

@rnk do you have plan to bring this back?

As far as I can tell, the issue is currently fixed, see the usage of .section .rdata and .long directives from llc here: https://gcc.godbolt.org/z/1znoroP74

Yes, I fix it at: https://reviews.llvm.org/D144701