NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
toolchain/53810: C++ exception does not work on m68k when libstdc++ is dynamicaly linked
>Number: 53810
>Category: toolchain
>Synopsis: C++ exception does not work on m68k when libstdc++ is dynamicaly linked
>Confidential: no
>Severity: critical
>Priority: high
>Responsible: toolchain-manager
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Tue Dec 25 12:20:00 +0000 2018
>Originator: Rin Okuyama
>Release: 8.99.29
>Organization:
Department of Physics, Meiji University
>Environment:
NetBSD a1200 8.99.29 NetBSD 8.99.29 (A1200) #0: Tue Dec 25 18:50:38 JST 2018 rin@latipes:/var/build/src/sys/arch/amiga/compile/A1200 amiga
>Description:
Throwing C++ exceptions fails on m68k:
---
% cat exception.cpp
#include <stdio.h>
class Usage{};
int main(int argc, char *argv[]) {
try {
if (argc != 2)
throw Usage();
printf("%s\n", argv[1]);
return 0;
}
catch (const Usage&) {
printf("usage: %s str\n", argv[0]);
return 1;
}
}
% g++ exception.cpp
% ./a.out
terminate called after throwing an instance of 'Usage'
zsh: abort (core dumped) ./a.out
---
This code works fine if libstdc++ is statically linked:
---
% g++ -static exception.cpp
% ./a.out
usage: ./a.out str
---
This does not mean that it does not work with dynamically-linked
binaries; It also works when only libstdc++ is statically linked:
---
% ld -dynamic-linker /usr/libexec/ld.elf_so /usr/lib/crt0.o /usr/lib/crti.o /usr/lib/crtbegin.o exception.o /usr/lib/libstdc++.a -lm -lgcc -lc -lgcc /usr/lib/crtend.o /usr/lib/crtn.o
% ldd a.out
a.out:
-lm.0 => /usr/lib/libm.so.0
-lc.12 => /usr/lib/libc.so.12
% ./a.out
usage: ./a.out str
---
It should be a root cause for the following PRs:
toolchain/53684: atf-run fails on m68k
toolchain/53685: gdb fails on m68k
Actually, both gdb and atf-run work normally when they are statically
linked.
Note that this problem does not occur with GCC 5.5 from gcc.old in
NetBSD-current as of 20180801.
>How-To-Repeat:
Described above.
>Fix:
Not known yet.
Home |
Main Index |
Thread Index |
Old Index