<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style id="owaParaStyle" type="text/css">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
P {margin-top:0;margin-bottom:0;}</style>
</head>
<body ocsi="0" fpstyle="1">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">I'm resending this since many of the folks that would be interested in ELF direct object relocations were out last week.<br>
<br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF477717"><font color="#000000" face="Tahoma" size="2"><b>From:</b> Carter, Jack<br>
<b>Sent:</b> Thursday, June 07, 2012 12:43 PM<br>
<b>To:</b> List<br>
<b>Subject:</b> How to implement new ELF 64 bit relocation (N64)<br>
</font><br>
</div>
<div></div>
<div>
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">The ELF relocation record format is different for N64 which many Mips 64 ABIs use  than for O64 which many if not all other target ABIs use.<br>
<br>
The question I have is whether to treat N64 as a valid generic variant or should it be treated as target specific?
<br>
<br>
My contention is that it should be treated as an alternative generic format handled recognized and handled in the ELF class objects above the target specific level.<br>
<br>
<font color="black" face="Tahoma" size="2"><span dir="ltr" style="font-size:10pt">Most architectures have the following 64 bit relocation record format:<br>
<br>
<div style="margin-left:40px">typedef struct<br>
{<br>
<div style="margin-left:40px">Elf64_Addr    r_offset; /* Address of reference */<br>
Elf64_Xword  r_info; /* Symbol index and type of relocation */</div>
} Elf64_Rel;<br>
<div style="margin-left:40px"><br>
</div>
typedef struct <br>
{ <br>
<div style="margin-left:40px">Elf64_Addr      r_offset; <br>
Elf64_Xword    r_info; <br>
Elf64_Sxword  r_addend; <br>
</div>
} Elf64_Rela; <br>
</div>
<br>
Whereas N64 has the following format:<br>
<br>
<div style="margin-left:40px">typedef struct<br>
{<br>
<div style="margin-left:40px">Elf64_Addr    r_offset; /* Address of reference */<br>
Elf64_Word  r_sym;     /* Symbol index */</div>
<div style="margin-left:40px">Elf64_Byte  r_ssym;    /* Special symbol */ <br>
</div>
<div style="margin-left:40px">Elf64_Byte  r_type3;   /* Relocation type */ <br>
</div>
<div style="margin-left:40px">Elf64_Byte  r_type2;   /* Relocation type */ <br>
</div>
<div style="margin-left:40px">Elf64_Byte  r_type;     /* Relocation type */ <br>
</div>
} Elf64_Rel;<br>
<div style="margin-left:40px"><br>
</div>
typedef struct <br>
{ <br>
<div style="margin-left:40px">Elf64_Addr    r_offset; /* Address of reference */<br>
Elf64_Word  r_sym;     /* Symbol index */</div>
<div style="margin-left:40px">Elf64_Byte  r_ssym;    /* Special symbol */ <br>
Elf64_Byte  r_type3;   /* Relocation type */ <br>
Elf64_Byte  r_type2;   /* Relocation type */ <br>
</div>
<div style="margin-left:40px">Elf64_Byte  r_type;     /* Relocation type */ <br>
Elf64_Sxword  r_addend; <br>
</div>
} Elf64_Rela; <br>
</div>
<br>
The structure is the same size, but the r_info data element is now 5 separate elements. Besides the content aspects, endian byte reordering will be different for the area with each element being endianized separately.<br>
<br>
</span></font>In my mind there are 3 ways to approach this:<br>
<ol>
<li>Treat this as target specific :
<ol>
<li>ELFObjectWriter::RecordRelocation would need to be derived for N64 implementations<br>
</li></ol>
</li><li>Treat this as generic and continue to pass r_type as an integer masking and unmasking the byte sized N64 values for N64 mode. I've implemented this and it causes no affect on other current targets.<br>
</li><li>Treat as generic and changing r_type as a union. This is technically cleaner than (2) but would need to change the r_type type declaration and assignment for each target.</li></ol>
<p>My preference is to treat it as a generic format variation an first implement #2 and then the more intrusive #3.</p>
<p><br>
</p>
<p>I have attached a sample patch series, not for submittal yet, but as an example of my local implementation.</p>
<p><br>
</p>
<p>Thanks,</p>
<p><br>
</p>
<p>Jack<br>
</p>
</div>
</div>
</div>
</div>
</body>
</html>