<div dir="ltr"><div style="color:black;font-size:10pt;font-family:arial,helvetica,sans-serif">CCing Nick Kledzik as <span style="font-size:10pt">I posed this question on IRC and Tim Northover suggested you as a good resource for this.</span></div><div style="color:black;font-size:10pt;font-family:arial,helvetica,sans-serif"><span style="font-size:10pt"><br></span></div><div style="color:black;font-size:10pt;font-family:arial,helvetica,sans-serif">I came across an error due to a scattered relocation offset being larger than 2**24 and I was hoping to find more information on scattered relocations. These are MachO specific, and Ive not been able to find any documentation on them outside of source code. </div><div style="color:black;font-size:10pt;font-family:arial,helvetica,sans-serif"><br></div><div style="color:black;font-size:10pt;font-family:arial,helvetica,sans-serif">I have a couple of immediate questions, but any info would be appreciated.</div><div style="color:black;font-size:10pt;font-family:arial,helvetica,sans-serif"><br></div><div style="color:black;font-size:10pt;font-family:arial,helvetica,sans-serif">* Should a check be added to ARMMachObjectWriter::<span style="font-size:13.3333px">RecordARMScatteredRelocation and </span><span style="font-size:10pt">RecordARMScatteredHalfRelocation to ensure that FixupOffset is within bounds?</span></div><div style="color:black;font-size:10pt;font-family:arial,helvetica,sans-serif"><span style="font-size:10pt"><br></span></div><div style="color:black;font-size:10pt;font-family:arial,helvetica,sans-serif"><span style="font-size:10pt">I see a check in the x86 back end that does precisely this and was curious why a similar check was not in place for ARM:</span></div><div style="color:black;font-size:10pt;font-family:arial,helvetica,sans-serif"><span style="font-size:10pt"><br></span></div><div style="color:rgb(0,0,0);font-family:helvetica,arial,sans-serif;font-size:13.3333px"><div><font face="Arial, Helvetica, sans-serif">  // Relocations are written out in reverse order, so the PAIR comes first.</font></div><div><font face="Arial, Helvetica, sans-serif">  if (Type == MachO::GENERIC_RELOC_SECTDIFF ||</font></div><div><font face="Arial, Helvetica, sans-serif">      Type == MachO::GENERIC_RELOC_LOCAL_SECTDIFF) {</font></div><div><font face="Arial, Helvetica, sans-serif">    // If the offset is too large to fit in a scattered relocation,</font></div><div><font face="Arial, Helvetica, sans-serif">    // we're hosed. It's an unfortunate limitation of the MachO format.</font></div><div><font face="Arial, Helvetica, sans-serif">    if (FixupOffset > 0xffffff) {</font></div><div><font face="Arial, Helvetica, sans-serif">      char Buffer[32];</font></div><div><font face="Arial, Helvetica, sans-serif">      format("0x%x", FixupOffset).print(Buffer, sizeof(Buffer));</font></div><div><font face="Arial, Helvetica, sans-serif">      Asm.getContext().reportError(Fixup.getLoc(),</font></div><div><font face="Arial, Helvetica, sans-serif">                         Twine("Section too large, can't encode "</font></div><div><font face="Arial, Helvetica, sans-serif">                                "r_address (") + Buffer +</font></div><div><font face="Arial, Helvetica, sans-serif">                         ") into 24 bits of scattered "</font></div><div><font face="Arial, Helvetica, sans-serif">                         "relocation entry.");</font></div><div><font face="Arial, Helvetica, sans-serif">      return false;</font></div><div><font face="Arial, Helvetica, sans-serif">    }</font></div></div><div style="color:rgb(0,0,0);font-family:helvetica,arial,sans-serif;font-size:13.3333px"><br></div><div style="color:rgb(0,0,0);font-family:helvetica,arial,sans-serif;font-size:13.3333px">* Once we get here there seems to be nothing that can be done. Are there ways of avoiding generation of scattered relocations? Ive had some success in working around the problem by using llc's -relocation-model flag with 'static' and 'dynamic-no-pic' though I believe that is simply due to a small size reduction in the binary pulling the offset back into range of a 24bit value. Im also not sure that iOS will accept apps built with a static relocation model.</div><div style="color:rgb(0,0,0);font-family:helvetica,arial,sans-serif;font-size:13.3333px"><br></div><div style="color:rgb(0,0,0);font-family:helvetica,arial,sans-serif;font-size:13.3333px">Thanks for any additional info</div><div style="color:rgb(0,0,0);font-family:helvetica,arial,sans-serif;font-size:13.3333px"><br></div><div style="color:rgb(0,0,0);font-family:helvetica,arial,sans-serif;font-size:13.3333px">Rob</div></div>