This is an automated email from the git hooks/post-receive script. guillem pushed a commit to branch main in repository dpkg.
View the commit online: https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=3e2046ecd9ecc4e6b8116ff2fb06d6e6e7ed9bfe commit 3e2046ecd9ecc4e6b8116ff2fb06d6e6e7ed9bfe Author: Guillem Jover <[email protected]> AuthorDate: Sun Jul 28 16:14:43 2024 +0200 Dpkg::Shlibs::Cppfilt: Do not normalize angle brackets for operators We should not normalize angle brackets for these operators, otherwise we turn them into invalid syntax. Closes: #1076067 --- scripts/Dpkg/Shlibs/Cppfilt.pm | 2 + scripts/Makefile.am | 10 ++++ scripts/t/Dpkg_Shlibs/anglebrackets.cpp | 23 ++++++++++ scripts/t/Dpkg_Shlibs/anglebrackets.symbols | 7 +++ scripts/t/Dpkg_Shlibs/objdump.anglebrackets | 71 +++++++++++++++++++++++++++++ scripts/t/Dpkg_Shlibs_Cppfilt.t | 18 +++++++- 6 files changed, 130 insertions(+), 1 deletion(-) diff --git a/scripts/Dpkg/Shlibs/Cppfilt.pm b/scripts/Dpkg/Shlibs/Cppfilt.pm index 010fe6634..e2e1a3a7a 100644 --- a/scripts/Dpkg/Shlibs/Cppfilt.pm +++ b/scripts/Dpkg/Shlibs/Cppfilt.pm @@ -101,6 +101,8 @@ sub cppfilt_demangle { # as allowed by C++11, contrary to GNU binutils. if ($symbol eq $demangled) { $demangled = undef; + } elsif ($demangled =~ m{operator>>}) { + # Special case operator>> and operator>>=. } else { $demangled =~ s{(?<=>)(?=>)}{ }g; } diff --git a/scripts/Makefile.am b/scripts/Makefile.am index 12cf18a26..9cfdc1020 100644 --- a/scripts/Makefile.am +++ b/scripts/Makefile.am @@ -323,6 +323,8 @@ test_data = \ t/Dpkg_OpenPGP/sign-file-inline.sig \ t/Dpkg_OpenPGP/sign-file.asc \ t/Dpkg_OpenPGP/sign-file.sig \ + t/Dpkg_Shlibs/anglebrackets.cpp \ + t/Dpkg_Shlibs/anglebrackets.symbols \ t/Dpkg_Shlibs/basictags.c \ t/Dpkg_Shlibs/basictags.symbols \ t/Dpkg_Shlibs/ld.so.conf \ @@ -330,6 +332,7 @@ test_data = \ t/Dpkg_Shlibs/ld.so.conf.d/normal.conf \ t/Dpkg_Shlibs/ld.so.conf.d/recursive.conf \ t/Dpkg_Shlibs/ld.so.conf_2 \ + t/Dpkg_Shlibs/objdump.anglebrackets \ t/Dpkg_Shlibs/objdump.basictags-amd64 \ t/Dpkg_Shlibs/objdump.basictags-i386 \ t/Dpkg_Shlibs/objdump.basictags-mips \ @@ -431,6 +434,7 @@ EXTRA_DIST += \ # EOL test_data_objects = \ + t/Dpkg_Shlibs/libobjdump.anglebrackets.so \ t/Dpkg_Shlibs/libobjdump.basictags-amd64.so \ t/Dpkg_Shlibs/libobjdump.basictags-i386.so \ t/Dpkg_Shlibs/libobjdump.basictags-mips.so \ @@ -444,6 +448,10 @@ CLEANFILES += \ $(test_data_objects) \ # EOL +$(srcdir)/t/Dpkg_Shlibs/libobjdump.anglebrackets.so: $(srcdir)/t/Dpkg_Shlibs/anglebrackets.cpp + $(CXX) $(CXXFLAGS) -shared -fPIC -Wl,-soname -Wl,libanglebrackets.so.1 \ + $< -o $@ + $(srcdir)/t/Dpkg_Shlibs/libobjdump.basictags-amd64.so: $(srcdir)/t/Dpkg_Shlibs/basictags.c $(CC) $(CFLAGS) -shared -fPIC -Wl,-soname -Wl,libbasictags.so.1 $< \ -DAMD64 -o $@ @@ -477,6 +485,8 @@ $(srcdir)/t/Dpkg_Shlibs/libobjdump.spacesyms.so: $(srcdir)/t/Dpkg_Shlibs/spacesy OBJDUMP = objdump -w -f -p -T -R refresh-test-data: $(test_data_objects) + $(OBJDUMP) $(srcdir)/t/Dpkg_Shlibs/libobjdump.anglebrackets.so \ + >$(srcdir)/t/Dpkg_Shlibs/objdump.anglebrackets $(OBJDUMP) $(srcdir)/t/Dpkg_Shlibs/libobjdump.basictags-amd64.so \ >$(srcdir)/t/Dpkg_Shlibs/objdump.basictags-amd64 $(OBJDUMP) $(srcdir)/t/Dpkg_Shlibs/libobjdump.basictags-i386.so \ diff --git a/scripts/t/Dpkg_Shlibs/anglebrackets.cpp b/scripts/t/Dpkg_Shlibs/anglebrackets.cpp new file mode 100644 index 000000000..0db112ea8 --- /dev/null +++ b/scripts/t/Dpkg_Shlibs/anglebrackets.cpp @@ -0,0 +1,23 @@ +#define EXPORT(x) x {} + +class AngleBrackets { +public: + AngleBrackets(); + ~AngleBrackets(); + + void operator>>(int a); + void operator>>=(int a); + + template<typename T> + void operator>>(T a); + + template<typename T> + void operator>>=(T a); +}; + +EXPORT(AngleBrackets::AngleBrackets()) +EXPORT(AngleBrackets::~AngleBrackets()) +EXPORT(void AngleBrackets::operator>>(int a)) +EXPORT(void AngleBrackets::operator>>=(int a)) +template<> void AngleBrackets::operator>><float>(float a) {} +template<> void AngleBrackets::operator>>=<float>(float a) {} diff --git a/scripts/t/Dpkg_Shlibs/anglebrackets.symbols b/scripts/t/Dpkg_Shlibs/anglebrackets.symbols new file mode 100644 index 000000000..a98846d24 --- /dev/null +++ b/scripts/t/Dpkg_Shlibs/anglebrackets.symbols @@ -0,0 +1,7 @@ +libanglebrackets.so.1 libanglebrackets1 #MINVER# + (c++)AngleBrackets::AngleBrackets() 1 + (c++)AngleBrackets::~AngleBrackets() 1 + (c++)AngleBrackets::operator>>=(int) 1 + (c++)"void AngleBrackets::operator>>=<float>(float)" 1 + (c++)AngleBrackets::operator>>(int) 1 + (c++)"void AngleBrackets::operator>><float>(float)" 1 diff --git a/scripts/t/Dpkg_Shlibs/objdump.anglebrackets b/scripts/t/Dpkg_Shlibs/objdump.anglebrackets new file mode 100644 index 000000000..68a1e1a9d --- /dev/null +++ b/scripts/t/Dpkg_Shlibs/objdump.anglebrackets @@ -0,0 +1,71 @@ + +./t/Dpkg_Shlibs/libobjdump.anglebrackets.so: file format elf32-i386 +architecture: i386, flags 0x00000150: +HAS_SYMS, DYNAMIC, D_PAGED +start address 0x00000000 + +Program Header: + LOAD off 0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**12 + filesz 0x000003f4 memsz 0x000003f4 flags r-- + LOAD off 0x00001000 vaddr 0x00001000 paddr 0x00001000 align 2**12 + filesz 0x000001a8 memsz 0x000001a8 flags r-x + LOAD off 0x00002000 vaddr 0x00002000 paddr 0x00002000 align 2**12 + filesz 0x00000118 memsz 0x00000118 flags r-- + LOAD off 0x00002f2c vaddr 0x00003f2c paddr 0x00003f2c align 2**12 + filesz 0x000000d8 memsz 0x000000dc flags rw- + DYNAMIC off 0x00002f34 vaddr 0x00003f34 paddr 0x00003f34 align 2**2 + filesz 0x000000b0 memsz 0x000000b0 flags rw- + NOTE off 0x00000154 vaddr 0x00000154 paddr 0x00000154 align 2**2 + filesz 0x00000024 memsz 0x00000024 flags r-- +EH_FRAME off 0x00002000 vaddr 0x00002000 paddr 0x00002000 align 2**2 + filesz 0x0000004c memsz 0x0000004c flags r-- + STACK off 0x00000000 vaddr 0x00000000 paddr 0x00000000 align 2**4 + filesz 0x00000000 memsz 0x00000000 flags rw- + RELRO off 0x00002f2c vaddr 0x00003f2c paddr 0x00003f2c align 2**0 + filesz 0x000000d4 memsz 0x000000d4 flags r-- + +Dynamic Section: + SONAME libanglebrackets.so.1 + INIT 0x00001000 + FINI 0x00001194 + INIT_ARRAY 0x00003f2c + INIT_ARRAYSZ 0x00000004 + FINI_ARRAY 0x00003f30 + FINI_ARRAYSZ 0x00000004 + GNU_HASH 0x00000178 + STRTAB 0x0000028c + SYMTAB 0x000001bc + STRSZ 0x0000012d + SYMENT 0x00000010 + PLTGOT 0x00003ff4 + REL 0x000003bc + RELSZ 0x00000038 + RELENT 0x00000008 + RELCOUNT 0x00000003 + +DYNAMIC SYMBOL TABLE: +00000000 w D *UND* 00000000 __cxa_finalize +00000000 w D *UND* 00000000 _ITM_registerTMCloneTable +00000000 w D *UND* 00000000 _ITM_deregisterTMCloneTable +00000000 w D *UND* 00000000 __gmon_start__ +00001170 g DF .text 00000001 _ZN13AngleBracketsrSEi +00001190 g DF .text 00000001 _ZN13AngleBracketsrSIfEEvT_ +00001180 g DF .text 00000001 _ZN13AngleBracketsrsIfEEvT_ +00001160 g DF .text 00000001 _ZN13AngleBracketsrsEi +00001140 g DF .text 00000001 _ZN13AngleBracketsC1Ev +00001140 g DF .text 00000001 _ZN13AngleBracketsC2Ev +00001150 g DF .text 00000001 _ZN13AngleBracketsD1Ev +00001150 g DF .text 00000001 _ZN13AngleBracketsD2Ev + + +DYNAMIC RELOCATION RECORDS +OFFSET TYPE VALUE +00003f2c R_386_RELATIVE *ABS* +00003f30 R_386_RELATIVE *ABS* +00004000 R_386_RELATIVE *ABS* +00003fe4 R_386_GLOB_DAT __cxa_finalize +00003fe8 R_386_GLOB_DAT _ITM_registerTMCloneTable +00003fec R_386_GLOB_DAT _ITM_deregisterTMCloneTable +00003ff0 R_386_GLOB_DAT __gmon_start__ + + diff --git a/scripts/t/Dpkg_Shlibs_Cppfilt.t b/scripts/t/Dpkg_Shlibs_Cppfilt.t index cfbe3f7c0..eaf0b5613 100644 --- a/scripts/t/Dpkg_Shlibs_Cppfilt.t +++ b/scripts/t/Dpkg_Shlibs_Cppfilt.t @@ -24,7 +24,7 @@ use Config; test_needs_command('c++filt'); if (defined $Config{bin_ELF} && $Config{bin_ELF} eq 'define') { - plan tests => 124; + plan tests => 154; } else { plan skip_all => 'only ELF is currently supported'; } @@ -41,6 +41,12 @@ is(cppfilt_demangle_cpp('_ZNSt10istrstreamC1EPKcl@Base'), is(cppfilt_demangle_cpp('foobar _ZNSt10istrstreamC1EPKcl@Base'), 'foobar std::istrstream::istrstream(char const*, long)@Base', 'demangle symbol with garbage around it'); +is(cppfilt_demangle_cpp('_ZN13AngleBracketsrSEi'), + 'AngleBrackets::operator>>=(int)', + 'demangle symbol exempt from normalized angle brackets'); +is(cppfilt_demangle_cpp('_ZN13AngleBracketsrSIfEEvT_'), + 'void AngleBrackets::operator>>=<float>(float)', + 'demangle template symbol exempt from normalized angle brackets'); is(cppfilt_demangle_cpp('FoobarInvalidSymbol'), undef, 'non-demanglable string'); @@ -65,6 +71,11 @@ my @mangledtext = split(/\n+/s, <<'END'); 00000000000bff30 g DF .text 0000000000000019 _ZNSt18condition_variable10notify_oneEv@GLIBCXX_3.4.11 00000000000666a0 g DF .text 000000000000003f _ZNKSt3tr14hashIRKSbIwSt11char_traitsIwESaIwEEEclES6_@GLIBCXX_3.4.10 00000000002f6160 w DO .data.rel.ro 0000000000000050 _ZTTSt18basic_stringstreamIcSt11char_traitsIcESaIcEE@GLIBCXX_3.4 + +0000000000001170 g DF .text 0000000000000001 _ZN13AngleBracketsrSEi +0000000000001190 g DF .text 0000000000000001 _ZN13AngleBracketsrSIfEEvT_ +0000000000001180 g DF .text 0000000000000001 _ZN13AngleBracketsrsIfEEvT_ +0000000000001160 g DF .text 0000000000000001 _ZN13AngleBracketsrsEi END my @demangledtext = split(/\n+/s, <<'END'); @@ -86,6 +97,11 @@ my @demangledtext = split(/\n+/s, <<'END'); 00000000000bff30 g DF .text 0000000000000019 std::condition_variable::notify_one()@GLIBCXX_3.4.11 00000000000666a0 g DF .text 000000000000003f std::tr1::hash<std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&>::operator()(std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&) const@GLIBCXX_3.4.10 00000000002f6160 w DO .data.rel.ro 0000000000000050 VTT for std::basic_stringstream<char, std::char_traits<char>, std::allocator<char> >@GLIBCXX_3.4 + +0000000000001170 g DF .text 0000000000000001 AngleBrackets::operator>>=(int) +0000000000001190 g DF .text 0000000000000001 void AngleBrackets::operator>>=<float>(float) +0000000000001180 g DF .text 0000000000000001 void AngleBrackets::operator>><float>(float) +0000000000001160 g DF .text 0000000000000001 AngleBrackets::operator>>(int) END for my $try (1 .. 7) { -- Dpkg.Org's dpkg

