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

    <tr>
        <th>Summary</th>
        <td>
            [AArch64] Enhanced Large Code Model and Default PIE ON: Bug Fix and PIC Compatibility
        </td>
    </tr>

    <tr>
      <th>Labels</th>
      <td>
            new issue
      </td>
    </tr>

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

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

<pre>
    In the commit (https://github.com/llvm/llvm-project/commit/f2be7bed1be336aff40e87a7947b9aff676e237a), support for global values was added to the large code model to address the bug mentioned in (https://bugs.llvm.org/show_bug.cgi?id=35958).

However, after the commit (https://github.com/llvm/llvm-project/commit/ca68038d12a23fa7ebb2b1ccbda93c321635e6bf) that turned on the default PIE option, the code cannot be compiled correctly without PIC.

For example, when trying to compile the following code with the command `clang -mcmodel=large test.c`:

```c
#define BIG (1024*1024*1024)

int foo1[BIG];
int foo2[BIG];

int main(void)
{
  return foo1[0] + foo2[0];
}
```
The following error occurs:

```cmd
/usr/bin/aarch64-linux-gnu-ld: /tmp/test-c9e810.o: relocation R_AARCH64_MOVW_UABS_G0_NC against `foo1' can not be used when making a shared object; recompile with -fPIC
clang-15: error: linker command failed with exit code 1 (use -v to see invocation)
```
This error is due to the absence of Position Independent Code, which is required when creating shared objects.
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJysVUmP2zgX_DX0hbBBUfvBBy9RYuBL0sg3y9Hg8iQxoUgPSdnd_35A2u5uJ5jDAAMYksVnPlbVK5eY92owAGtUblG5X7A5jNatL4KQpqINKdn3BbfyZX0wOIyAhZ0mFTCizRjCyaN8g2iHaDeoMM58JeyEaKf1-X5bnpz9DiIg2l23Itr1lEPNQWYc8rxifV8QaGpWt0XNW9b3VV0BzWuGaIvoDvv5dLIu4N46PGjLmcZnpmfw-MI8ZlKCxMEmdJq5I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