... how do I calculate the
Relative Virtual Address
of the block, and the Offset (lower 12 bits) on theType
Offset
entry that follows that block header?
Microsoft - Formato PE (30/05/2018):
"Base Relocation Block
Each base relocation block starts with the following structure:
Offset Size Field Description
0 4 RVA The image base plus the page RVA is added to each offset to create the VA where the base relocation must be applied.
4 4 BS The total number of bytes in the base relocation
block, including the Page RVA and Block Size fields and the Type/Offset fields that follow.
The Block Size field is then followed by any number of Type or Offset field entries. Each entry is a WORD (2 bytes) and has the following structure:
Offset Size Field Description
0 4b Type Stored in the high 4 bits of the WORD, a value that indicates the type of base relocation to be applied. For more information, see Base Relocation Types.
0 12b Type Stored in the remaining 12 bits of the WORD, an offset from the starting address that was specified in the Page RVA field for the block. This offset specifies where the base relocation is to be applied.
...
".
O código de exemplo está em BinUtils .
Você pode encontrar o código de teste em binutils/ld/testsuite/ld-cygwin
.