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

    <tr>
        <th>Summary</th>
        <td>
            [RISCV][LLD] Regression w/ -fno-pic between 14.x and 15.x
        </td>
    </tr>

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

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

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

<pre>
    Compile the following with -fno-pic:
```
#include <stdio.h>

int main (int argc, char* argv[])
{
 printf("result");
}
```

Here is the last working link and disassemble (14.x)
https://test.godbolt.org/z/7Pq73EvMv

The same for 15.x (fails to link):
https://test.godbolt.org/z/KaMMxMoaP

Link result for gcc 13.2.0:
https://test.godbolt.org/z/GzYv1edWx

The assembly for both:
15.x: https://test.godbolt.org/z/f8ahM4q11 
14.x https://test.godbolt.org/z/6454KjMWM

To my eye, there is no obvious differences in the assembly.  I think this is a linker (or possibly driver) change.

Doing some further experiments locally, I see no assembly difference (beyond compiled version info) between an old clang I have sitting around which successfully links this example, and a new one which doesn't. Interestingly, if I use the new assembly file as an input to the old clang (i.e. indirectly invoking the older linker), that works just fine. 

Now, where things get weird is the LD behavior.  If I compile with gcc and link, everything works.  If I compile with clang and link with LD, I get relocation errors.  (Including on the old clang which succeeds linking with LLD.)  If I take the .s from clang, remove the .addrsig directive, and invoke the gcc driver, that works.  

Anyone have a clue on what's going on here?

</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJyUVV-P2jgQ_zTmZbQRcYCFBx52l3KHCqeqd7rqHk08Sdw6NvU4AfrpT-NkWVr1oZVWLCGemd-fmbEiMrVDXIv5s5hvJqqLjQ_rU0DVIk2OXl_XL749GYsQG4TKW-vPxtVwNrGBh8r5h5MpRfEkphsxfRKL6fg3PMrCuNJ2GkEULxS18Vkjinfj2_RpXIRWGQdCLvm7CnUp5AuUjQpCPvF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