<font size=2 face="sans-serif">In my case I wouldn't exceed the 2GB module
address range...</font>
<br><font size=2 face="sans-serif">As I understood - but I'm still a cub
with the LLVM and everything - the "OFFSET" thingy should calculate
the offset from the instruction to the address of the symbol. But LLVM
creates a jump to that symbol.</font>
<br>
<br>
<br>
<br><font size=1 color=#5f5f5f face="sans-serif">From:      
 </font><font size=1 face="sans-serif">Reid Kleckner <rnk@google.com></font>
<br><font size=1 color=#5f5f5f face="sans-serif">To:      
 </font><font size=1 face="sans-serif">bjoern.gaier@horiba.com,
Lang Hames <lhames@gmail.com></font>
<br><font size=1 color=#5f5f5f face="sans-serif">Cc:      
 </font><font size=1 face="sans-serif">llvm-dev <llvm-dev@lists.llvm.org></font>
<br><font size=1 color=#5f5f5f face="sans-serif">Date:      
 </font><font size=1 face="sans-serif">22.03.2018 18:43</font>
<br><font size=1 color=#5f5f5f face="sans-serif">Subject:    
   </font><font size=1 face="sans-serif">Re: [llvm-dev]
Broken relocation for generating offsets?</font>
<br>
<hr noshade>
<br>
<br>
<br><font size=3>I wouldn't be surprised if JITing COFF files on Windows
doesn't work so well, since the object file format assumes most symbols
are dllimport or within the local 2GB module address range.</font>
<br>
<br><font size=3>I'm not familiar with the current JIT state of the art,
though.</font>
<br><font size=3><br>
</font>
<br><font size=3>On Thu, Mar 22, 2018 at 1:45 AM via llvm-dev <</font><a href="mailto:llvm-dev@lists.llvm.org"><font size=3 color=blue><u>llvm-dev@lists.llvm.org</u></font></a><font size=3>>
wrote:</font>
<br><font size=2 face="sans-serif">Hello,</font><font size=3> </font><font size=2 face="sans-serif"><br>
<br>
I append another clue I found out: The problem is definitely not caused
by "__ImageBase" the problem comes with the "OFFSET".
I generated another object file which crashed. The commonality:</font><font size=3>
</font>
<table width=100% style="border-collapse:collapse;">
<tr valign=top height=8>
<td width=100% style="border-style:solid solid solid solid;border-color:#000000;border-width:1px 1px 1px 1px;padding:1px 1px;"><font size=2 face="sans-serif">mov
        edx, DWORD PTR ?normalPlanschbecken@@3HA ;
normalPlanschbecken</font><font size=3> </font><font size=2 face="sans-serif"><br>
lea         rcx, <b><u>OFFSET FLAT</u></b>:??_C@_0CC@LCMJAIPO@Reading?5?$CCnormalPlanschbecken?$CC?5?$CFi@</font><font size=3>
</font><font size=2 face="sans-serif"><br>
jmp         printf</font></table>
<br><font size=3><br>
<br>
<br>
</font><font size=1 color=#5f5f5f face="sans-serif"><br>
<br>
From:        </font><font size=1 face="sans-serif">via
llvm-dev <</font><a href="mailto:llvm-dev@lists.llvm.org" target=_blank><font size=1 color=blue face="sans-serif"><u>llvm-dev@lists.llvm.org</u></font></a><font size=1 face="sans-serif">></font><font size=3>
</font><font size=1 color=#5f5f5f face="sans-serif"><br>
To:        </font><a href="mailto:llvm-dev@lists.llvm.org" target=_blank><font size=1 color=blue face="sans-serif"><u>llvm-dev@lists.llvm.org</u></font></a><font size=3>
</font><font size=1 color=#5f5f5f face="sans-serif"><br>
Date:        </font><font size=1 face="sans-serif">06.03.2018
10:45</font><font size=3> </font><font size=1 color=#5f5f5f face="sans-serif"><br>
Subject:        </font><font size=1 face="sans-serif">[llvm-dev]
Broken relocation for generating offsets?</font><font size=3> </font><font size=1 color=#5f5f5f face="sans-serif"><br>
Sent by:        </font><font size=1 face="sans-serif">"llvm-dev"
<</font><a href="mailto:llvm-dev-bounces@lists.llvm.org" target=_blank><font size=1 color=blue face="sans-serif"><u>llvm-dev-bounces@lists.llvm.org</u></font></a><font size=1 face="sans-serif">></font><font size=3>
<br>
</font>
<hr noshade><font size=3><br>
</font><font size=2 face="sans-serif"><br>
<br>
Hello LLVM-Mailing-List,</font><font size=3> </font><font size=2 face="sans-serif"><br>
<br>
I discovered a strange behavior when dealing with object files generated
by the compiler of Visual Studio 2015.</font><font size=3> </font><font size=2 face="sans-serif"><br>
<br>
When jitting bc files I also add object files to look up functions. These
object files are coming from visual studio. When using a switch case instruction
that compiler often generates code based of __ImageBase. I show you a short
snippet of the assembly output.</font><font size=3> </font>
<table width=100% style="border-collapse:collapse;">
<tr valign=top height=8>
<td width=100% style="border-style:solid solid solid solid;border-color:#000000;border-width:1px 1px 1px 1px;padding:1px 1px;"><font size=2 face="sans-serif">mov
        eax, DWORD PTR ?myInt@@3HA ; myInt</font><font size=3>
</font><font size=2 face="sans-serif"><br>
lea         rdi,<b><u> OFFSET FLAT</u></b>:__ImageBase</font><font size=3>
</font><font size=2 face="sans-serif"><br>
xor         ebx, ebx</font></table>
<br><font size=3><br>
</font><font size=2 face="sans-serif"><br>
<br>
<br>
Then these offset is used to jump to some labels like "$LL4@execute:".</font><font size=3>
</font><font size=2 face="sans-serif"><br>
<br>
When the object file gets added to the jitting process this offset generation
seems to be broken. Executing the code coming from the object file will
lead to a crash. The crash address will always be exactly the address I
used to overload __ImageBase with. So it seems that the address relocation
is wrong with generating offsets?</font><font size=3> </font><font size=2 face="sans-serif"><br>
<br>
Kind regards</font><font size=3> </font><font size=2 face="sans-serif"><br>
Björn</font><font size=3> </font><font size=2 face="sans-serif"><br>
<br>
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr.
DE 114 165 789<br>
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko
Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.</font><tt><font size=2><br>
_______________________________________________<br>
LLVM Developers mailing list</font></tt><tt><font size=2 color=blue><u><br>
</u></font></tt><a href="mailto:llvm-dev@lists.llvm.org" target=_blank><tt><font size=2 color=blue><u>llvm-dev@lists.llvm.org</u></font></tt></a><font size=3 color=blue><u><br>
</u></font><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target=_blank><tt><font size=2 color=blue><u>http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</u></font></tt></a><font size=3><br>
</font><font size=2 face="sans-serif"><br>
<br>
<br>
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr.
DE 114 165 789<br>
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko
Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.</font><font size=3><br>
<br>
</font><font size=2 face="sans-serif"><br>
<br>
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr.
DE 114 165 789<br>
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko
Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.<br>
</font><font size=3><br>
_______________________________________________<br>
LLVM Developers mailing list</font><font size=3 color=blue><u><br>
</u></font><a href="mailto:llvm-dev@lists.llvm.org" target=_blank><font size=3 color=blue><u>llvm-dev@lists.llvm.org</u></font></a><font size=3 color=blue><u><br>
</u></font><a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" target=_blank><font size=3 color=blue><u>http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</u></font></a>
<br>
<br><font size=2 face="sans-serif"><br>
Als GmbH eingetragen im Handelsregister Bad Homburg v.d.H. HRB 9816, USt.ID-Nr.
DE 114 165 789<br>
Geschäftsführer: Dr. Hiroshi Nakamura, Dr. Robert Plank, Markus Bode, Heiko
Lampert, Hiroshi Kawamura, Takashi Nagano, Takeshi Fukushima.<br>
<br>
</font>