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

            Bug ID: 32071
           Summary: undefined weak hidden function symbols resolves to
                    garbage
           Product: binutils
           Version: 2.43
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: gold
          Assignee: ccoutant at gmail dot com
          Reporter: ishitatsuyuki at gmail dot com
                CC: chris at smowton dot net, ian at airs dot com
  Target Milestone: ---

When there is no definition for a weak undef STT_FUNC symbol, the function's
address should resolve to absolute zero, not some random address.

In Bug 15435 gold was changed to accept weak undefs with STV_HIDDEN, however
when no definition is present it seems to resolve to some garbage address [1],
instead of zero. This is easily reproducible with the sample from the same bug.

---
extern void undefined () __attribute__((visibility("hidden")))
  __attribute__((weak));

int main ()
{
  if (&undefined != 0) return 1;
  return 0;
}
---

$ gcc main.c -fuse-ld=bfd && ./a.out; echo $?
0

$ gcc main.c -fuse-ld=gold && ./a.out; echo $?
1

$ gcc main.c -fuse-ld=lld && ./a.out; echo $?
0

$ gcc main.c -fuse-ld=mold && ./a.out; echo $?
0

[1]:
https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/29986#note_2516917

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

Reply via email to