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

    <tr>
        <th>Summary</th>
        <td>
            [flang] Unexpected relocation R_AARCH64_MOVW_UABS_G0_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
        </td>
    </tr>

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

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

    <tr>
      <th>Reporter</th>
      <td>
          sscalpone
      </td>
    </tr>
</table>

<pre>
    Messages when linking a fujitsu tests with some fairly large arrays.  Note also that the linker gives some advice (to use -fPIC) that is rejected by flang (as expected).

```
% flang -mcmodel=large -fno-automatic -fno-pic 1033/1033_0141.f90
/opt/binutils/latest/bin/ld: /tmp/1033_0141-772b19.o: relocation R_AARCH64_MOVW_UABS_G0_NC against `a local symbol' can not be used when making a shared object; recompile with -fPIC
/opt/binutils/latest/bin/ld: BFD (GNU Binutils) 2.43 assertion fail elfnn-aarch64.c:5074
/opt/binutils/latest/bin/ld: BFD (GNU Binutils) 2.43 assertion fail elfnn-aarch64.c:5074
/tmp/1033_0141-772b19.o: in function `s_':
FIRModule:(.text+0x110): relocation truncated to fit: R_AARCH64_LD64_GOT_LO12_NC against symbol `_QQclXfd320d1fece8bb221c1c7d495e881010' defined in .rodata._QQclXfd320d1fece8bb221c1c7d495e881010[_QQclXfd320d1fece8bb221c1c7d495e881010] section in /tmp/1033_0141-772b19.o
/opt/binutils/latest/bin/ld: BFD (GNU Binutils) 2.43 assertion fail elfnn-aarch64.c:5074
/opt/binutils/latest/bin/ld: BFD (GNU Binutils) 2.43 assertion fail elfnn-aarch64.c:5074
FIRModule:(.text+0x390): relocation truncated to fit: R_AARCH64_LD64_GOT_LO12_NC against symbol `_QQclXfd320d1fece8bb221c1c7d495e881010' defined in .rodata._QQclXfd320d1fece8bb221c1c7d495e881010[_QQclXfd320d1fece8bb221c1c7d495e881010] section in /tmp/1033_0141-772b19.o
/opt/binutils/latest/bin/ld: BFD (GNU Binutils) 2.43 assertion fail elfnn-aarch64.c:5074
/opt/binutils/latest/bin/ld: BFD (GNU Binutils) 2.43 assertion fail elfnn-aarch64.c:5074
/tmp/1033_0141-772b19.o: in function `t_':
FIRModule:(.text+0x4c8): relocation truncated to fit: R_AARCH64_LD64_GOT_LO12_NC against symbol `_QQclXfd320d1fece8bb221c1c7d495e881010' defined in .rodata._QQclXfd320d1fece8bb221c1c7d495e881010[_QQclXfd320d1fece8bb221c1c7d495e881010] section in /tmp/1033_0141-772b19.o
/opt/binutils/latest/bin/ld: BFD (GNU Binutils) 2.43 assertion fail elfnn-aarch64.c:5074
/opt/binutils/latest/bin/ld: BFD (GNU Binutils) 2.43 assertion fail elfnn-aarch64.c:5074
FIRModule:(.text+0x4dc): relocation truncated to fit: R_AARCH64_LD64_GOT_LO12_NC against symbol `_QQclX6572726F72' defined in .rodata._QQclX6572726F72[_QQclX6572726F72] section in /tmp/1033_0141-772b19.o
/opt/binutils/latest/bin/ld: BFD (GNU Binutils) 2.43 assertion fail elfnn-aarch64.c:5074
/opt/binutils/latest/bin/ld: BFD (GNU Binutils) 2.43 assertion fail elfnn-aarch64.c:5074
FIRModule:(.text+0x510): relocation truncated to fit: R_AARCH64_LD64_GOT_LO12_NC against symbol `_QQclXfd320d1fece8bb221c1c7d495e881010' defined in .rodata._QQclXfd320d1fece8bb221c1c7d495e881010[_QQclXfd320d1fece8bb221c1c7d495e881010] section in /tmp/1033_0141-772b19.o
/opt/binutils/latest/bin/ld: BFD (GNU Binutils) 2.43 assertion fail elfnn-aarch64.c:5074
/opt/binutils/latest/bin/ld: BFD (GNU Binutils) 2.43 assertion fail elfnn-aarch64.c:5074
FIRModule:(.text+0x524): relocation truncated to fit: R_AARCH64_LD64_GOT_LO12_NC against symbol `_QQclX70617373' defined in .rodata._QQclX70617373[_QQclX70617373] section in /tmp/1033_0141-772b19.o
flang-21: error: linker command failed with exit code 1 (use -v to see invocation)
```
```
% flang -mcmodel=large -fno-automatic -fPIC 1033/1033_0141.f90
flang-21: error: invalid argument '-mcmodel=large' only allowed with '-fno-pic'
```
</pre>
<img width="1" height="1" alt="" src="http://email.email.llvm.org/o/eJzsV91u4zYTfRr6ZmCBon5oXfjCjuF8ATbJbr6m7Z1BUSObW4o0SMqJ376g5GyCoAmSAosWTQADMqnhcOacQwpHeK-2BnFOiiUpVhPRh511c--l0HtrcFLb5ji_RO_FFj3c7dCAVuYPZbYgoO2_q-B7COiDhzsVduBth9AK5fQRtHBbBOGcOPoE4MoGBKG9hbATAcIOh1ToYKsO6MelojkoiUDYLFjoPcK0_XpxRlg1LlIeHH5HGbCB-gitFmYbg4UHvN8P84RVCaGL-Cvp6UcXhBWn6GknO9ugJtlqLHDaGjsVfbCdCEqOw72SkNIsI2wdHxua5mnSVmOmtd0Hwta1Mn1Q2hO21iJCMM7FYUOyBRC2Dt3-aYYp56xOq8TG1w61lSIoa-Bms1jcnP2vzDeX17_-trldLP-_OaebqzMQW6GMD0BKKiDGa_DHrraaMA5SGDA2QI0RqWZkpxMncvxOOGzA1hEuki3BobTdXmkcmRqBfUc_y_UqQn1-dQvLH6EVsCTPQHiPbuilFUoD6taYqRBO7so8kSRbFJTn_8BmrxGgDLS9kUMiUlK_IYyTLApnfXFzaZteYxyyWRLwPhC2pPdpSgmrnrEXXG-kiIoMFloV4utHRr-synxzfv3L5st1yp5SOvIYd958-yb1722TMdqkLUqc1TVjqUwlb_KqwNkspXFjDg22ymATS0-cbUQQyRsXF8u3Bq7A4wiKMq9q-L8snRcVkFWfCvgQCnjf5RHecHnkcvYpnY8gnZcV0MifpoCy4Iyzcs3Zq1w_CXtg9enUJ3-v8Vd8fv4_ugJY_tMUwGmZ8oxnrzL9I-iB0ceJdzA3OKEpS2Ol6Jx18c_JjEnbdcI0A0LRVESvgPcqgLQNQhqxHXzZIXbrEUGZwwmJCM0z2_U3LdjXi7OX_Ndf1q7MQWjVgHDbvkMTgDD-fJeIqzX6CEJre_fQWgw8Ob74CX9S8qSZZ02VVWKC85QXlOYpZcVkN2f1rC0oq1OOTFblrOBNmxWyoLSqOebVRM0ZZQUt05KyjLIiKTlWWNCCSVHyjHOSU-yE0onWhy6xbjtR3vc4T_OczWYTLWrUfvDkjA39EhYv54mbxwXTut96klOtfPCPKYIKejDy44piBbfmwRT_O9zmpHd6vgth74dztSZsvVVh19eJtF08wPrw8JjunR1SsfUATTzuJ3QOc_ZnAAAA__-gmx83">