This is an archive of the discontinued LLVM Phabricator instance.

Object/COFF: Support large relocation table.
ClosedPublic

Authored by ruiu on Mar 20 2014, 5:03 PM.

Details

Summary

NumberOfRelocations field in COFF section table is only 16-bit wide. If an
object has more than 65535 relocations, the number of relocations is stored
to VirtualAddress field in the first relocation field, and a special flag
(IMAGE_SCN_LNK_NRELOC_OVFL) is set to Characteristics field.

In test we cheated a bit. I made up a test file so that it has
IMAGE_SCN_LNK_NRELOC_OVFL flag but the number of relocations is much smaller
than 65535. This is to avoid checking in a large test file just to test a
file with many relocations.

Diff Detail

Event Timeline

majnemer accepted this revision.Mar 20 2014, 5:22 PM

LGTM

lib/Object/COFFObjectFile.cpp
376 ↗(On Diff #8002)

coff_section should gain a method that contains this logic instead of duplicating it here and in getNumberOfRelocations.

ruiu added inline comments.Mar 20 2014, 5:27 PM
lib/Object/COFFObjectFile.cpp
376 ↗(On Diff #8002)

I'll add hasExtendedRelocations() to coff_section.

ruiu closed this revision.Mar 20 2014, 5:51 PM

Closed by commit rL204418 (authored by @ruiu).