bug-binutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Bug ld/22589] New: aarch64: adrp relocation gets filled with non-zero a


From: jwerner at chromium dot org
Subject: [Bug ld/22589] New: aarch64: adrp relocation gets filled with non-zero address for undefined weak symbol
Date: Mon, 11 Dec 2017 23:47:38 +0000

https://sourceware.org/bugzilla/show_bug.cgi?id=22589

            Bug ID: 22589
           Summary: aarch64: adrp relocation gets filled with non-zero
                    address for undefined weak symbol
           Product: binutils
           Version: 2.30 (HEAD)
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: ld
          Assignee: unassigned at sourceware dot org
          Reporter: jwerner at chromium dot org
  Target Milestone: ---

Consider the following minimal testcase:

weaklink.s:
  .weak myfunction

  _start:
    adrp x0, myfunction
    add  x0, x0, :lo12:myfunction

'binutils-gdb/gas/as-new weaklink.s -o weaklink.o' generates an unbound
R_AARCH64_ADR_PREL_PG_HI21 relocation for the first instruction as expected:

0000000000000000 <_start> (File Offset: 0x40):
   0:   90000000        adrp    x0, 0 <myfunction> (File Offset: 0x40)
                        0: R_AARCH64_ADR_PREL_PG_HI21   myfunction
   4:   91000000        add     x0, x0, #0x0
                        4: R_AARCH64_ADD_ABS_LO12_NC    myfunction

But 'binutils-gdb/ld/ld-new weaklink.o -o weaklink' somehow decides that
relocation should be bound to 0x40000 even though the myfunction symbol isn't
defined anywhere:

0000000000400078 <_start> (File Offset: 0x78):
  400078:       90000000        adrp    x0, 400000 <_start-0x78> (File Offset:
0x0)
  40007c:       91000000        add     x0, x0, #0x0

This breaks any code trying to test x0 for zero to see if the weak symbol is
defined. A work-around is to use ldr x0, =myfunction which gives the correct
result. Tested with the current binutils-gdb HEAD (c4e648430f3c5c13).

-- 
You are receiving this mail because:
You are on the CC list for the bug.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]