<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"> P {margin-top:0;margin-bottom:0;} </style>
</head>
<body dir="ltr">
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
Hi all,</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
I have reached the relocation phase of my backend implementation and I'm having some trouble. The LLVM code I'm trying to compile is this:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>%struct.Date = type { i32, i32, i32 }<br>
</span>
<div>@date = global %struct.Date { i32 2012, i32 10, i32 120000 }, align 4<br>
</div>
<div>; Function Attrs: nounwind<br>
</div>
<div>define i32 @foo() #0 {<br>
</div>
  %1 = load i32, i32* getelementptr inbounds (%struct.Date, %struct.Date* @date, i32 0, i32 2), align 4<br>
<div>  ret i32 %1<br>
</div>
<span>}</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>which yields the following assembly lines<br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>...</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><span>MOVI $r0, date</span></span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><span></span><span></span><span>LD $r4, $r0, 8 // load the content of [$r0 + 8] into return register $r4<br>
</span><span>JAL</span><br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>...<br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span><br>
</span></div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span></span>When I look at the text section (llvm-objdump -s output), I see this</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
0000 00c2</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
This is the correct MOVI opcode but the instead of the 0s, I should see the address of 'date'</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
The ouput of llvm-objdump -r -t  is this:</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<br>
</div>
<div style="font-family: Calibri, Helvetica, sans-serif; font-size: 12pt; color: rgb(0, 0, 0);">
<span>RELOCATION RECORDS FOR [.rel.text]:<br>
</span>
<div>00000000 R_XXX_MOVI date                             (Note: correct relocation type)<br>
</div>
<div><br>
</div>
<div>RELOCATION RECORDS FOR [.rel.eh_frame]:<br>
</div>
<div>0000001c R_XXX_NONE .text<br>
</div>
<div><br>
</div>
<div>SYMBOL TABLE:<br>
</div>
<div>00000000 l    df *ABS*   00000000 array.ll<br>
</div>
<div>00000000 l    d  .text   00000000 .text<br>
</div>
<div>00000000 g     F .text   0000000e foo<br>
</div>
<div>00000000 g     O .data   0000000c date</div>
<div><br>
</div>
<div><br>
</div>
<div>Why am I missing? Why didn't fill the instruction with the address of 'date'?</div>
<div><br>
</div>
<div>Thanks.<br>
</div>
<span></span><br>
</div>
</body>
</html>