Skip to content
Commit 495a031c authored by Rui Ueyama's avatar Rui Ueyama
Browse files

[PECOFF] Fix AMD64_REL_[1-5] and AMD64_SECTION relocations

I hope this is the last fix for x64 relocations as I've wasted
a few days on this.

This caused a mysterious issue that some C++ programs crash on
startup. It was because a null pointer is passed as argv to main.
__tmainCRTStartup calls main, but before that it calls all
initialization routines between .text$xc_a and .text$xc_z.
pre_cpp_init is one of such routines, and it is the one who
initializes a heap pointer for argv for later use. That routine
was not called for some reason.

It turned out that __tmainCRTStartup was skipping a block of
code because of the relocation bug. A condition in the function
depends on a memory load, and that memory load was referring
a wrong location. As a result a jump instruction took the
wrong branch, skipping pre_cpp_init and so on.

This patch fixes the issue. Also added more tests to fix them
once and for all.

llvm-svn: 216772
parent 163ef040
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment