https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91713

            Bug ID: 91713
           Summary: GP linker relaxation is not performed with -nostdlib
           Product: gcc
           Version: 8.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: c
          Assignee: unassigned at gcc dot gnu.org
          Reporter: bmeng.cn at gmail dot com
  Target Milestone: ---

See the following test case
$ cat test.c
int a = 1;

int main()
{
    return a;
}

Building the test case with "-nostdlib" seems to disable the GP linker
relaxation:
$ riscv64-unknown-linux-gnu-gcc test.c -o test -nostdlib
$ riscv64-unknown-linux-gnu-objdump -d test | grep gp
<return nothing>

But if we compile test.c without "-nostdlib":
$ riscv64-unknown-linux-gnu-gcc test.c -o test
$ riscv64-unknown-linux-gnu-objdump -d test | grep gp
   103bc:       00002197                auipc   gp,0x2
   103c0:       46418193                addi    gp,gp,1124 # 12820
<__global_pointer$>
   1041c:       8141c783                lbu     a5,-2028(gp) # 12034 <_edata>
   1042a:       80f18a23                sb      a5,-2028(gp) # 12034 <_edata>
   10440:       8101a783                lw      a5,-2032(gp) # 12030 <a>

Reply via email to