<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;}</style>
</head>
<body ocsi="0" fpstyle="1">
<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 style="font-size:10pt;" dir="ltr">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>
</body>
</html>