<table border="1" cellspacing="0" cellpadding="8">
    <tr>
        <th>Issue</th>
        <td>
            <a href=https://github.com/llvm/llvm-project/issues/55386>55386</a>
        </td>
    </tr>

    <tr>
        <th>Summary</th>
        <td>
            IMAGE_REL_AMD64_ADDR32NB relocation fatal error
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Assignees</th>
      <td>
      </td>
    </tr>

    <tr>
      <th>Reporter</th>
      <td>
          pierre-mercs
      </td>
    </tr>
</table>

<pre>
    After updating our code from LLVM3.5 to LLVM13, we encounter an unpredictable and frequent fatal error from "lib\ExecutionEngine\RuntimeDyld\Targets\RuntimeDyldCOFFX86_64.h:117", apparently in .pdata sections.

Our program lets the user enter code in a custom language. We then begin execution, lazily compiling that code with MCJIT as we find out what is actually needed.
We used to do it with a single LLVM module, but LLVM won't let us do that anymore, we need to close the module and open a new one everytime a function is compiled. We adapted our code to LLVM13+ with inspiration from the kaleidoscope tutorial.
When performing relocations, .pdata sections addresses are sometimes less than the module's ImageBase, leading to this fatal_error.

Comments hint at the need to use an ordered section layout, is there one readily available ? 
Is there an obvious point we are missing ?
Is it a known LLVM limitation or bug ?
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxdU0tv2zgQ_jXyhaighyU7Bx0cO16kSFogKLZ7M8biyOaWIlU-4np__c5Q8SZdwLAlmjPzveZo5bXbDAGdiJOEoMxJ2OhEbyWKwdlRPD39-VznjQg2PZZ1Vm3FBQWa3kbDhWBENJNDqfoAR410IKkWf0Y0QQwQQAt0zrq5YVZVWh2zZvvwC_sYlDUP5qQM0skLNVQj7q5a0ts3cCcM_vfz7df9_q91e2iX-TmrN2W5on4MCaYJHA3UV6GMyJkMCI89D_B5VuyyYjN_fyV-k7MnB6PQNECEM4roiQkmPok79QDRRx8IsQZzinDCXHxHvmzEEQmxwBsBnq_hH0WzeztOSrOM4Qxh7nVR4Syet58fvwnwrN2gSCEbg7jwHeUF9CGCpnKDKFG-wf2eYEmWXlqhwtyIWFF7kpntEKOVUSMDOFK_dHRhQKvA3KieSxMUMNfROnyzjwdx415bn0i9dUrm2QmZvsGLsIasfkV3ZQPobIgmScqoZ64El3UBCVNA-Z6eD4G5n5Er4yflIJWnKPDYH6BRSet7GipCDNYp0DcBWOsJ3WDdyJI61LZP9Z5p_M9kgiAdeo_05FB4OyKD9iSEZ5Mpp-88SSEvHkdy9R58EkUjyOQb60XsUnAPKbi_xWdrx5GC4sVZUbxJWG56k5P84n2wTiItxA0aheNKdvMUleJG8FhYxyPJdXgFpdPqZPVezGMebxe53fFVWbJysjyS3GN-o_IcBC75r4IyAuKHsRczR0GrUYVZcFq_Y0y3F7Kr5V19B4uggsbu8Xnzx8Ph5eHpsHnetcvDZrd7qasv9x_k_rjFi-h0dw5h8rR_WbWnz4ncjcec8kAvWr_efj7Rmv1NEtArgY1Iru2bpl63i3MHpRxwfVe00EDZrGDVDCiXZd2XxbFtl-sFCYLad1lznzW7heqqoqqKpizLpmqKIh9WRX_X1tUS22JYrmW2LHAkGXMenFt3WrguYSDWnv7Uygf__ieQeCdy7dYfYjhb102KOOKnEV3vFwlzlwD_C3f2wno">