(adding back our friends on cc)
On 1 August 2016 at 12:36, Shi, Steven <email@example.com> wrote:
CoffAddFixup() must be used for absolute symbol references only. TheseOn 1 August 2016 at 12:16, Shi, Steven <firstname.lastname@example.org> wrote:[Steven]: My understanding is the n address (6000c8) is not a GOTPCREL relocation in .text section, but the 4000b2 and 4000b2 are GOTPCREL relocation in .text section. My CoffAddFixup() will only call twice for 4000b2 and 4000b2, but not for n address (6000c8).n -OK, another example:
instructions contain relative symbol references, which are
recalculated in WriteSections64().
The only absolute symbol reference is the GOT entry for 'n', and your
code (in WriteRelocations64()) calculates the address of the GOT entry
(which is always in .text BTW) and adds a fixup for it, i.e.,
mCoffSectionsOffset[RelShdr->sh_info] + GoTPcRelPtrOffset),
This code adds a fixup to the PE/COFF .reloc section for the GOT entry
containing the address of 'n', and the instructions perform a IP
relative load of the contents of the GOT entry to retrieve the address
By adding two fixups, the PE/COFF loader will apply the load offset
twice, resulting in an incorrect value.