[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE
From: |
hjl.tools at gmail dot com |
Subject: |
[Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE |
Date: |
Tue, 10 Oct 2017 23:36:19 +0000 |
https://sourceware.org/bugzilla/show_bug.cgi?id=22269
--- Comment #10 from H.J. Lu <hjl.tools at gmail dot com> ---
(In reply to Alan Modra from comment #9)
> > Since call is PC relative, this doesn't branch to address 0.
>
> I don't see why this matters. A symbol that resolves to zero without
> dynamic relocs in a PIE or shared lib results in an address of zero. If
> that zero is in a PC-relative instruction then you get zero relative to the
> shared library or PIE base. Typical code for dealing with weakly defined
> functions like
> if (foo)
> foo ();
> will give you a load of zero (absolute) on the condition, but a relative
> zero for the call.
If there is a program bug:
foo ();
without if (foo) check, PC relative branch to base may not crash and may
lead to undesired behavior.
> > This doesn't work with
> >
> > -pie --no-dynamic-linker -z dynamic-undefined-weak
>
> Define "doesn't work". I would have said that combination of options ought
> to result in a dynamic reloc for "func" on the original testcase. Which is
> what powerpc will do. It may not work in the runtime environment for static
> PIE, but that's a different issue. By passing -z dynamic-undefined-weak you
> asked for dynamic relocs!
-z dynamic-undefined-weak applies to there is a DT_NEEDED entry which
may provide definition for undefined weak reference at run-time. For static
PIE, weak undefined should always be resolved to 0.
--
You are receiving this mail because:
You are on the CC list for the bug.
- [Bug ld/22269] New: Undefined weak symbols isn't resolved to 0 in static PIE, hjl.tools at gmail dot com, 2017/10/06
- [Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE, hjl.tools at gmail dot com, 2017/10/06
- [Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE, hjl.tools at gmail dot com, 2017/10/06
- [Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE, hjl.tools at gmail dot com, 2017/10/06
- [Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE, amodra at gmail dot com, 2017/10/09
- [Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE, hjl.tools at gmail dot com, 2017/10/09
- [Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE, amodra at gmail dot com, 2017/10/10
- [Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE, hjl.tools at gmail dot com, 2017/10/10
- [Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE, hjl.tools at gmail dot com, 2017/10/10
- [Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE, amodra at gmail dot com, 2017/10/10
- [Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE,
hjl.tools at gmail dot com <=
- [Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE, amodra at gmail dot com, 2017/10/10
- [Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE, cvs-commit at gcc dot gnu.org, 2017/10/11
- [Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE, hjl.tools at gmail dot com, 2017/10/11
- [Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE, cvs-commit at gcc dot gnu.org, 2017/10/12
- [Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE, cvs-commit at gcc dot gnu.org, 2017/10/14
- [Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE, cvs-commit at gcc dot gnu.org, 2017/10/14
- [Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE, cvs-commit at gcc dot gnu.org, 2017/10/14
- [Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE, cvs-commit at gcc dot gnu.org, 2017/10/14
- [Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE, cvs-commit at gcc dot gnu.org, 2017/10/14
- [Bug ld/22269] Undefined weak symbols isn't resolved to 0 in static PIE, cvs-commit at gcc dot gnu.org, 2017/10/14