Summary: | c++filt and libelftc do not demangle names correctly | ||||||
---|---|---|---|---|---|---|---|
Product: | Base System | Reporter: | Ian Lepore <ian> | ||||
Component: | bin | Assignee: | freebsd-toolchain (Nobody) <toolchain> | ||||
Status: | Open --- | ||||||
Severity: | Affects Many People | CC: | cem, emaste | ||||
Priority: | --- | ||||||
Version: | 12.2-STABLE | ||||||
Hardware: | Any | ||||||
OS: | Any | ||||||
See Also: | https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=222563 | ||||||
Bug Depends on: | |||||||
Bug Blocks: | 231027 | ||||||
Attachments: |
|
GNU c++filt demangles the 2nd as `typeinfo name for main::Bar` Related test case _ZZ4mainE3Bar, which GNU demangles as main::Bar and elftoolchain's fails with an assertion: % c++filt _ZZ4mainE3Bar Assertion failed: (ddata->output.size > 0), function cpp_demangle_read_sname, file /usr/home/emaste/src/freebsd-wip/contrib/elftoolchain/libelftc/libelftc_dem_gnu3.c, line 2139. The assertion failure can also be triggered attempting to demangle (invalid) symbol _ZZ1 With an up-to-date (as of today) ELF Tool Chain build on x86: % ./c++filt _ZTS3Foo _ZTSZ4mainE3Bar _ZZ4mainE3Bar typeinfo name for Foo _ZTSZ4mainE3Bar Assertion failed: (ddata->output.size > 0), function cpp_demangle_read_sname, file libelftc_dem_gnu3.c, line 2137. zsh: abort (core dumped) ./c++filt _ZTS3Foo _ZTSZ4mainE3Bar _ZZ4mainE3Bar Work is in progress to migrate to some LLVM binutils replacements; WITH_LLVM_CXXFILT is enabled by default in main and 13 $ c++filt _ZTS3Foo _ZTSZ4mainE3Bar _ZZ4mainE3Bar typeinfo name for Foo typeinfo name for main::Bar main::Bar |
Created attachment 186669 [details] Small c++ program to demonstrate the problem If you compile the attached tester.cc source (just "make tester.o") then use nm(1) on the .o file, the nm output includes two mangled symbol names: 00000000 V _ZTS3Foo 00000000 r _ZTSZ4mainE3Bar Running them through c++filt gives: # c++filt _ZTS3Foo _ZTSZ4mainE3Bar typeinfo name for Foo _ZTSZ4mainE3Bar (The program also produces wrong output when it runs, but that will be handled in a separate PR, becuase our current libcxxrt uses different demangling code than libelftc).