diff options
author | Rui Ueyama <ruiu@google.com> | 2014-03-21 00:44:19 +0000 |
---|---|---|
committer | Rui Ueyama <ruiu@google.com> | 2014-03-21 00:44:19 +0000 |
commit | 99995267aec69859a039670e3ba76c64f969b2bf (patch) | |
tree | 52728200aec3dfb7ab0c42e73ab4a26fc7b289f6 /include/llvm/Object/COFF.h | |
parent | fab1a40a7b6133dec43fc9de7a6a36c7c719ed30 (diff) | |
download | llvm-99995267aec69859a039670e3ba76c64f969b2bf.tar.gz llvm-99995267aec69859a039670e3ba76c64f969b2bf.tar.bz2 llvm-99995267aec69859a039670e3ba76c64f969b2bf.tar.xz |
Object/COFF: Support large relocation table.
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.
Differential Revision: http://llvm-reviews.chandlerc.com/D3139
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@204418 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Object/COFF.h')
-rw-r--r-- | include/llvm/Object/COFF.h | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/include/llvm/Object/COFF.h b/include/llvm/Object/COFF.h index 31b7d6ea17..c2e7d52b91 100644 --- a/include/llvm/Object/COFF.h +++ b/include/llvm/Object/COFF.h @@ -250,6 +250,13 @@ struct coff_section { support::ulittle16_t NumberOfRelocations; support::ulittle16_t NumberOfLinenumbers; support::ulittle32_t Characteristics; + + // Returns true if the actual number of relocations is stored in + // VirtualAddress field of the first relocation table entry. + bool hasExtendedRelocations() const { + return Characteristics & COFF::IMAGE_SCN_LNK_NRELOC_OVFL && + NumberOfRelocations == UINT16_MAX; + }; }; struct coff_relocation { |