[pushed] c++: Make references to __cxa_pure_virtual weak.

Christophe Lyon christophe.lyon@linaro.org
Tue May 12 13:59:00 GMT 2020


On Tue, 12 May 2020 at 10:28, Andreas Schwab <schwab@linux-m68k.org> wrote:
>
> On Mai 11 2020, Jason Merrill via Gcc-patches wrote:
>
> > If a program has no other dependencies on libstdc++, we shouldn't require it
> > just for __cxa_pure_virtual, which is only there to give a prettier
> > diagnostic before crashing the program; resolving the reference to NULL will
> > also crash, just without the diagnostic.
>
> That doesn't work on ia64:
>
> pure-virtual1.o:(.data.rel.ro._ZTV1A[_ZTV1A]+0x10): undefined reference to `__cxa_pure_virtual'
> collect2: error: ld returned 1 exit status
> $ nm -u pure-virtual1.o
>                  U __cxa_pure_virtual
>

This doesn't work on aarch64-elf either: I'm using newlib/libgloss'
-specs=aem-ve.specs, which has:
*lib:
cpu-init/rdimon-aem-el3.o%s --start-group %(libc) %(libgloss) --end-group

Since the testcase uses -nodefaultlibs, this also removes libgloss
from the link, leading to:
/aarch64-none-elf/lib/rdimon-crt0.o: in function `_mainCRTStartup':
/newlib/libgloss/aarch64/crt0.S:113: undefined reference to `__heap_limit'
/newlib/libgloss/aarch64/crt0.S:114: undefined reference to `__heap_limit'
/newlib/libgloss/aarch64/crt0.S:165: undefined reference to
`initialise_monitor_handles'
[...]

Christophe


> Andreas.
>
> --
> Andreas Schwab, schwab@linux-m68k.org
> GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
> "And now for something completely different."


More information about the Gcc-patches mailing list