mold
mold copied to clipboard
.rodata invalid
Getting the below error when running valgrind against a mold linked binary. In addition function name and line numbers for stack traces are missing within the valgrind messages. Running valgrind on the same binary but linked with gcc/clang linker results in no error and valid stack traces.
--26387-- WARNING: Serious error when reading debug info
--26387-- When reading debug info from /snip:
--26387-- Can't make sense of .rodata section mapping
Does this happen all the time or just for a specific program?
I just spot checked ~10 different binaries linked with mold and only one of them didn't have this error. Caveat this with all these binaries are build as part of the same build.
I have one binary with a similar warning that's presumably the same underlying issue:
$ objdump --headers liborcus-parser-0.17.so.0
...
27 __patchable_function_entries 00000008 0000000000139d80 0000000000139d80 00139d80 2**3
CONTENTS, ALLOC, LOAD, DATA
28 .bss 00000411 0000000000139d88 0000000000139d88 00000000 2**3
ALLOC
29 .bss 00000008 000000000013a1a0 000000000013a1a0 00000000 2**3
ALLOC
30 .gdb_index 001bdb97 0000000000000000 0000000000000000 0023a668 2**2
CONTENTS, READONLY, DEBUGGING
The Valgrind warning just means that it doesn't expect one section being present twice. It's just one binary out of ~100 in one build, I don't know what makes it different from the others.
I wonder how you end up with two .bss
sections. I built the same so using mold, but it contained only one .bss
. Can you link the same .so file with -Wl,-Map,map
and open the resulting map
file to see what's inside these .bss
sections?
FYI, here's my .so.
$ readelf -WS ./dev-libs/liborcus-0.16.1/work/liborcus-0.16.1/src/parser/.libs/liborcus-parser-0.16.so.0.0.0
There are 33 section headers, starting at offset 0x61ca8:
Section Headers:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000 000000 00 0 0 0
[ 1] .hash HASH 0000000000000238 000238 001a28 04 A 2 0 4
[ 2] .dynsym DYNSYM 0000000000001c60 001c60 004e60 18 A 3 1 8
[ 3] .dynstr STRTAB 0000000000006ac0 006ac0 00968c 00 A 0 0 1
[ 4] .gnu.version VERSYM 000000000001014c 01014c 000688 02 A 2 0 2
[ 5] .gnu.version_r VERNEED 00000000000107d8 0107d8 000160 00 A 3 4 8
[ 6] .rela.dyn RELA 0000000000010938 010938 003cd8 18 A 2 0 8
[ 7] .rela.plt RELA 0000000000014610 014610 001d88 18 A 2 25 8
[ 8] .plt PROGBITS 0000000000017000 017000 0013c0 00 AX 0 0 16
[ 9] .plt.got PROGBITS 00000000000183c0 0183c0 000038 00 AX 0 0 8
[10] .fini PROGBITS 00000000000183f8 0183f8 000009 00 AX 0 0 4
[11] .init PROGBITS 0000000000018404 018404 000017 00 AX 0 0 4
[12] .text PROGBITS 0000000000018420 018420 0214e3 00 AX 0 0 16
[13] .eh_frame PROGBITS 000000000003a000 03a000 006c50 00 A 0 0 8
[14] .eh_frame_hdr PROGBITS 0000000000040c50 040c50 0013cc 00 A 0 0 4
[15] .gcc_except_table PROGBITS 000000000004201c 04201c 001674 00 A 0 0 4
[16] .rodata PROGBITS 00000000000436a0 0436a0 000882 00 A 0 0 32
[17] .rodata PROGBITS 0000000000043f28 043f28 001310 00 A 0 0 8
[18] .rodata.cst PROGBITS 0000000000045240 045240 000050 00 A 0 0 16
[19] .rodata.str PROGBITS 0000000000045290 045290 002958 00 A 0 0 8
[20] .got PROGBITS 0000000000048000 048000 000248 00 WA 0 0 8
[21] .dynamic DYNAMIC 0000000000048248 048248 000230 10 WA 3 0 8
[22] .data.rel.ro PROGBITS 0000000000048480 048480 0007f0 00 WA 0 0 32
[23] .fini_array FINI_ARRAY 0000000000048c70 048c70 000008 00 WA 0 0 8
[24] .init_array INIT_ARRAY 0000000000048c78 048c78 000048 00 WA 0 0 8
[25] .got.plt PROGBITS 0000000000049000 049000 0009f0 00 WA 0 0 8
[26] .data PROGBITS 0000000000049a00 049a00 001fd0 00 WA 0 0 32
[27] .tm_clone_table PROGBITS 000000000004b9d0 04b9d0 000000 00 WA 0 0 8
[28] .bss NOBITS 000000000004b9e0 000000 000261 00 WA 0 0 32
[29] .strtab STRTAB 0000000000000000 04b9d0 00eef3 00 0 0 1
[30] .shstrtab STRTAB 0000000000000000 05a8c3 00012b 00 0 0 1
[31] .symtab SYMTAB 0000000000000000 05a9f0 007230 18 29 273 8
[32] .comment PROGBITS 0000000000000000 061c20 000081 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
D (mbind), l (large), p (processor specific)
@andrewkcorcoran
Can you run readelf -WS <your-executable>
and paste its output here?
Relevant parts from -Wl,-Map,map file:
0x139d88 1041 8 .bss
0x139d88 0 1 /usr/lib64/crti.o:(.bss)
0x139d88 1 1 /usr/lib64/gcc/x86_64-suse-linux/11/crtbeginS.o:(.bss)
0x139d88 0 0 completed.0
0x139d90 544 8 .libs/base64.o:(.bss._ZZN11__gnu_debug16_Error_formatter5_S_atEPKcjS2_E11__formatter)
0x139d90 0 0 __gnu_debug::_Error_formatter::_S_at(char const*, unsigned int, char const*)::__formatter
0x139fb0 8 8 .libs/base64.o:(.bss._ZGVZN11__gnu_debug16_Error_formatter5_S_atEPKcjS2_E11__formatter)
0x139fb0 0 0 guard variable for __gnu_debug::_Error_formatter::_S_at(char const*, unsigned int, char const*)::__formatter
0x139fb8 120 8 .libs/css_types.o:(.bss)
0x139fb8 0 0 orcus::css::to_pseudo_element(std::basic_string_view<char, std::char_traits<char> >)::elem_map
0x139fd8 0 0 guard variable for orcus::css::to_pseudo_element(std::basic_string_view<char, std::char_traits<char> >)::elem_map
0x139fe0 0 0 orcus::css::to_pseudo_class(std::basic_string_view<char, std::char_traits<char> >)::class_map
0x13a000 0 0 guard variable for orcus::css::to_pseudo_class(std::basic_string_view<char, std::char_traits<char> >)::class_map
0x13a008 0 0 orcus::css::to_property_function(std::basic_string_view<char, std::char_traits<char> >)::propfunc_map
0x13a028 0 0 guard variable for orcus::css::to_property_function(std::basic_string_view<char, std::char_traits<char> >)::propfunc_map
0x13a030 1 1 .libs/parser_global.o:(.bss)
0x13a030 0 0 std::__ioinit
0x13a031 1 1 .libs/pstring.o:(.bss)
0x13a031 0 0 std::__ioinit
0x13a038 192 8 .libs/sax_token_parser.o:(.bss)
0x13a038 0 0 orcus::(anonymous namespace)::decl_attr::entries
0x13a070 0 0 orcus::(anonymous namespace)::encoding::entries
0x13a0a8 0 0 orcus::(anonymous namespace)::decl_attr::get()::mt
0x13a0c8 0 0 guard variable for orcus::(anonymous namespace)::decl_attr::get()::mt
0x13a0d0 0 0 orcus::(anonymous namespace)::encoding::get()::mt
0x13a0f0 0 0 guard variable for orcus::(anonymous namespace)::encoding::get()::mt
0x13a0f8 1 1 .libs/sax_token_parser_thread.o:(.bss)
0x13a0f8 0 0 std::__ioinit
0x13a0f9 1 1 .libs/stream.o:(.bss)
0x13a0f9 0 0 std::__ioinit
0x13a100 8 8 .libs/stream.o:(.bss._ZGVN5boost12interprocess13mapped_region16page_size_holderILi0EE8PageSizeE)
0x13a100 0 0 guard variable for boost::interprocess::mapped_region::page_size_holder<0>::PageSize
0x13a108 1 1 .libs/string_pool.o:(.bss)
0x13a108 0 0 std::__ioinit
0x13a110 96 8 .libs/types.o:(.bss)
0x13a110 0 0 orcus::(anonymous namespace)::dump_format::entries
0x13a148 0 0 orcus::(anonymous namespace)::dump_format::get()::mt
0x13a168 0 0 guard variable for orcus::(anonymous namespace)::dump_format::get()::mt
0x13a170 40 8 .libs/yaml_parser_base.o:(.bss)
0x13a170 0 0 orcus::yaml::parser_base::parse_keyword(char const*, unsigned long)::map
0x13a190 0 0 guard variable for orcus::yaml::parser_base::parse_keyword(char const*, unsigned long)::map
0x13a198 1 1 .libs/zip_archive.o:(.bss)
0x13a198 0 0 std::__ioinit
0x13a199 0 1 /usr/lib64/libc_nonshared.a(fstat.oS):(.bss)
0x13a199 0 1 /usr/lib64/gcc/x86_64-suse-linux/11/crtendS.o:(.bss)
0x13a199 0 1 /usr/lib64/crtn.o:(.bss)
0x13a1a0 8 8 .bss
0x13a1a0 8 8 .libs/stream.o:(.bss._ZN5boost12interprocess13mapped_region16page_size_holderILi0EE8PageSizeE)
0x13a1a0 0 0 boost::interprocess::mapped_region::page_size_holder<0>::PageSize
Link command:
clang++ -std=c++17 -fPIC -DPIC -shared -nostdlib /usr/lib64/gcc/x86_64-suse-linux/11/../../../../lib64/crti.o /usr/lib64/gcc/x86_64-suse-linux/11/crtbeginS.o .libs/base64.o .libs/cell_buffer.o .libs/css_parser_base.o .libs/css_types.o .libs/csv_parser_base.o .libs/exception.o .libs/json_global.o .libs/json_parser_base.o .libs/json_parser_thread.o .libs/parser_base.o .libs/parser_global.o .libs/pstring.o .libs/sax_parser_base.o .libs/sax_token_parser.o .libs/sax_token_parser_thread.o .libs/stream.o .libs/string_pool.o .libs/tokens.o .libs/types.o .libs/utf8.o .libs/xml_namespace.o .libs/xml_writer.o .libs/yaml_parser_base.o .libs/zip_archive.o .libs/zip_archive_stream.o -lboost_system -lz -lboost_iostreams -lboost_filesystem -L/usr/lib64/gcc/x86_64-suse-linux/11 -L/usr/lib64/gcc/x86_64-suse-linux/11/../../../../lib64 -L/lib/../lib64 -L/usr/lib/../lib64 -L/usr/lib64/gcc/x86_64-suse-linux/11/../../../../x86_64-suse-linux/lib -L/home/seli/wrk/clang/install.143.pgo/bin/../lib -L/home/seli/wrk/clang/install.143.pgo/bin/../lib64 -L/lib -L/usr/lib -lstdc++ -lm -lpthread -lc -lgcc_s -lgcc /usr/lib64/gcc/x86_64-suse-linux/11/crtendS.o /usr/lib64/gcc/x86_64-suse-linux/11/../../../../lib64/crtn.o -O0 -ggdb2 -gsplit-dwarf -ggnu-pubnames -pthread -g -O0 -fuse-ld=/home/seli/tmp/mold/mold -Wl,--gdb-index -Wl,-z -Wl,origin -Wl,-rpath -Wl,\$ORIGIN -pthread -Wl,-soname -Wl,liborcus-parser-0.17.so.0 -o .libs/liborcus-parser-0.17.so.0.0.0 -Wl,-Map,/tmp/map
The .libs/stream.o file, in case it's useful: stream.zip
@llunak Thanks! It looks like in your case a .bss section has SHF_GNU_RETAIN attribute, and that caused mold to create another .bss. I'll fix this issue.
@andrewkcorcoran
Can you run
readelf -WS <your-executable>
and paste its output here?
There are 45 section headers, starting at offset 0x329d000:
Section Headers:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000 000000 00 0 0 0
[ 1] .interp PROGBITS 00000000002002e0 0002e0 00001c 00 A 0 0 1
[ 2] .note.gnu.build-id NOTE 00000000002002fc 0002fc 000024 00 A 0 0 4
[ 3] .note.ABI-tag NOTE 0000000000200320 000320 000020 00 A 0 0 4
[ 4] .gnu.hash GNU_HASH 0000000000200340 000340 030b90 00 A 5 0 8
[ 5] .dynsym DYNSYM 0000000000230ed0 030ed0 0b05e0 18 A 6 1 8
[ 6] .dynstr STRTAB 00000000002e14b0 0e14b0 280e19 00 A 0 0 1
[ 7] .gnu.version VERSYM 00000000005622ca 3622ca 00eb28 02 A 5 0 2
[ 8] .gnu.version_r VERNEED 0000000000570df8 370df8 000220 00 A 6 8 8
[ 9] .rela.dyn RELA 0000000000571018 371018 000a20 18 A 5 0 8
[10] .rela.plt RELA 0000000000571a38 371a38 001d58 18 A 5 30 8
[11] .plt PROGBITS 0000000000574000 374000 0013a0 00 AX 0 0 16
[12] .plt.got PROGBITS 00000000005753a0 3753a0 000010 00 AX 0 0 8
[13] .fini PROGBITS 00000000005753b0 3753b0 000009 00 AX 0 0 4
[14] .init PROGBITS 00000000005753bc 3753bc 00001a 00 AX 0 0 4
[15] .text PROGBITS 00000000005753e0 3753e0 a4f5d0 00 AX 0 0 16
[16] .eh_frame PROGBITS 0000000000fc5000 dc5000 0b31fc 00 A 0 0 8
[17] .eh_frame_hdr PROGBITS 00000000010781fc e781fc 029524 00 A 0 0 4
[18] .gcc_except_table PROGBITS 00000000010a1720 ea1720 022f05 00 A 0 0 4
[19] .rodata PROGBITS 00000000010c4640 ec4640 5761d3 00 A 0 0 32
[20] .rodata PROGBITS 000000000163a818 143a818 001e38 00 A 0 0 8
[21] .rodata.cst PROGBITS 000000000163c650 143c650 001190 00 A 0 0 16
[22] .rodata.str PROGBITS 000000000163d7e0 143d7e0 04c9e0 00 A 0 0 8
[23] .tbss NOBITS 000000000168b000 148a1c0 0000b0 00 WAT 0 0 8
[24] .got PROGBITS 000000000168b000 148b000 000200 00 WA 0 0 8
[25] .dynamic DYNAMIC 000000000168b200 148b200 0002a0 10 WA 6 0 8
[26] .data.rel.ro PROGBITS 000000000168b4a0 148b4a0 0009a8 00 WA 0 0 32
[27] .fini_array FINI_ARRAY 000000000168be48 148be48 000148 00 WA 0 0 8
[28] .init_array INIT_ARRAY 000000000168bf90 148bf90 000230 00 WA 0 0 8
[29] .preinit_array PREINIT_ARRAY 000000000168c1c0 148c1c0 000008 00 WA 0 0 8
[30] .got.plt PROGBITS 000000000168d000 148d000 0009e0 00 WA 0 0 8
[31] .data PROGBITS 000000000168d9e0 148d9e0 5d6560 00 WA 0 0 32
[32] .tm_clone_table PROGBITS 0000000001c63f40 1a63f40 000000 00 WA 0 0 8
[33] .copyrel NOBITS 0000000001c63f40 1a63f40 001288 00 WA 0 0 64
[34] .bss NOBITS 0000000001c65200 1a63f40 928d20 00 WA 0 0 64
[35] .strtab STRTAB 0000000000000000 1a64000 34393b 00 0 0 1
[36] .shstrtab STRTAB 0000000000000000 1da8000 0001c0 00 0 0 1
[37] .symtab SYMTAB 0000000000000000 1da9000 15e160 18 35 27318 8
[38] .comment PROGBITS 0000000000000000 1f08000 000104 00 0 0 1
[39] .debug_abbrev PROGBITS 0000000000000000 1f09000 01bc3c 00 0 0 1
[40] .debug_info PROGBITS 0000000000000000 1f25000 79b573 00 0 0 1
[41] .debug_line PROGBITS 0000000000000000 26c1000 5e40a4 00 0 0 1
[42] .debug_loc PROGBITS 0000000000000000 2ca6000 008db0 00 0 0 1
[43] .debug_ranges PROGBITS 0000000000000000 2caf000 0b0740 00 0 0 1
[44] .debug_str PROGBITS 0000000000000000 2d60000 53c5c7 00 0 0 1
Key to Flags:
W (write), A (alloc), X (execute), M (merge), S (strings), I (info),
L (link order), O (extra OS processing required), G (group), T (TLS),
C (compressed), x (unknown), o (OS specific), E (exclude),
l (large), p (processor specific)
@andrewkcorcoran Thanks! It looks like your executable contains two .rodata
. I'm interested in what is inside the second, smaller .rodata
. Can you link the executable with -Wl,-Map,map
and open the resulting map file to see what's inside the second .rodata
section?
@andrewkcorcoran Ping?
Details below. Just a thought but could the issue be related to RHEL devtoolset and the extra work it does to statically link the latest standard library calls to allow the generated binary to run on installs without the latest standard libray?
0x109b3c0 4413987 64 .rodata
0x109b3c0 8 8 /opt/rh/devtoolset-11/root/usr/lib/gcc/x86_64-redhat-linux/11/crtbegin.o:(.rodata)
0x109b3c0 0 0 __dso_handle
0x109b3c8 528 4 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(asan_errors.cpp.o):(.rodata)
0x109b5d8 188 4 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(asan_interceptors.cpp.o):(.rodata)
0x109b694 660 4 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(asan_report.cpp.o):(.rodata)
0x109b928 92 4 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(asan_report.cpp.o):(.rodata._ZN6__asan19ScopedInErrorReportD2Ev)
0x109b984 184 4 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(asan_rtl.cpp.o):(.rodata)
0x109ba40 97 16 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(asan_suppressions.cpp.o):(.rodata)
0x109ba40 0 0 __asan::kODRViolation
0x109ba50 0 0 __asan::kInterceptorViaLibrary
0x109ba70 0 0 __asan::kInterceptorViaFunction
0x109ba90 0 0 __asan::kInterceptorName
0x109baa4 4 4 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(sanitizer_errno.cpp.o):(.rodata)
0x109baa4 0 0 __sanitizer::errno_EOWNERDEAD
0x109baa8 39 4 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(sanitizer_linux.cpp.o):(.rodata)
0x109bac8 0 0 __sanitizer::ThreadLister::IsAlive(int)::kPrefix
0x109bad0 56 8 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(sanitizer_platform_limits_posix.cpp.o):(.rodata)
0x109bad0 0 0 __sanitizer::si_SEGV_ACCERR
0x109bad4 0 0 __sanitizer::si_SEGV_MAPERR
0x109bad8 0 0 __sanitizer::IOCTL_NOT_PRESENT
0x109bae0 0 0 __sanitizer::__sanitizer_bufsiz
0x109bae8 0 0 __sanitizer::sa_siginfo
0x109baf0 0 0 __sanitizer::sig_err
0x109baf8 0 0 __sanitizer::sig_dfl
0x109bb00 0 0 __sanitizer::sig_ign
0x109bb08 44 8 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(sanitizer_posix.cpp.o):(.rodata)
0x109bb28 0 0 CSWTCH.83
0x109bb34 132 4 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(sanitizer_printf.cpp.o):(.rodata)
0x109bbb8 4 4 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(sanitizer_thread_registry.cpp.o):(.rodata)
0x109bbb8 0 0 __sanitizer::ThreadRegistry::kUnknownTid
0x109bbbc 2 1 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(sanitizer_type_traits.cpp.o):(.rodata)
0x109bbbc 0 0 __sanitizer::false_type::value
0x109bbbd 0 0 __sanitizer::true_type::value
0x109bbbe 7 1 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(sanitizer_linux_libcdep.cpp.o):(.rodata)
0x109bbbe 0 0 __sanitizer::GetLibcVersion(int*, int*, int*)::kGLibC
0x109bbd0 28 16 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(sanitizer_stoptheworld_linux_libcdep.cpp.o):(.rodata)
0x109bbd0 0 0 __sanitizer::kSyncSignals
0x109bbf0 8 8 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(sanitizer_coverage_libcdep_new.cpp.o):(.rodata)
0x109bbf0 0 0 __sancov::(anonymous namespace)::Magic
0x109bc00 385 16 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(sanitizer_stacktrace_printer.cpp.o):(.rodata)
0x109bd70 0 0 __sanitizer::kDefaultFormat
0x109bd84 120 4 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(sanitizer_symbolizer_libcdep.cpp.o):(.rodata)
0x109be00 9 8 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(sanitizer_symbolizer_posix_libcdep.cpp.o):(.rodata)
0x109be00 0 0 __sanitizer::Addr2LineProcess::output_terminator_
0x109be20 79 32 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(sanitizer_symbolizer_report.cpp.o):(.rodata)
0x109be20 0 0 _ZZN11__sanitizer21ScopedErrorReportLockC4EvE3msg
0x109be50 0 0 __sanitizer::ReportStackOverflowImpl(__sanitizer::SignalContext const&, unsigned int, void (*)(__sanitizer::SignalContext const&, void const*, __sanitizer::BufferedStackTrace*), void const*)::kDescription
0x109be60 0 0 __sanitizer::StartReportDeadlySignal()::kDeadlySignal
0x109be70 26 16 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(lsan_common.cpp.o):(.rodata)
0x109be70 0 0 __lsan::kStdSuppressions
0x109be85 0 0 __lsan::kSuppressionLeak
0x109be8a 3 1 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(lsan_common_linux.cpp.o):(.rodata)
0x109be8a 0 0 __lsan::kLinkerName
0x109be90 323 8 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(ubsan_diag.cpp.o):(.rodata)
0x109bfc8 0 0 kVptrCheck
0x109bfd4 20 4 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan-x86_64.a(ubsan_handlers.cpp.o):(.rodata)
0x109bfe8 28 4 /opt/rh/llvm-toolset-12.0/root/usr/lib64/clang/12.0.1/lib/linux/libclang_rt.asan_cxx-x86_64.a(ubsan_handlers_cxx.cpp.o):(.rodata)
I'm running into the same issue with mold
and valgrind
. I've attached my map files for the same output linked with and without mold, and the readelf
output again against the binary generated with and without mold
. The binary in question is EventContention
.
The code is open source (it's a simple C++ meson project w/ no dependencies) and I'm happy to help you set up a working build environment if any assistance is needed. The binary in question (EventContention
) is one of the tests.
map_mold.txt map_no_mold.txt readelf_mold.txt readelf_no_mold.txt
@mqudsi
After cloning your project, how can I build your project with valgrind and mold?
The valgrind harness is in the atomic_wait_all
branch, yet to be merged into master
:
$ git checkout atomic_wait_all
$ rm -rf build/
$ env LDFLAGS="-B/opt/mold/ -Wl,-Map,map" meson --buildtype=debug build/
$ ninja -C build
$ ./valgrind.sh build/EventContention
==34749== Memcheck, a memory error detector
==34749== Copyright (C) 2002-2022, and GNU GPL'd, by Julian Seward et al.
==34749== Using Valgrind-3.19.0 and LibVEX; rerun with -h for copyright info
==34749== Command: build/EventContention
==34749==
--34749-- WARNING: Serious error when reading debug info
--34749-- When reading debug info from /home/mqudsi/pevents/build/EventContention:
--34749-- Can't make sense of .rodata section mapping
==34749==
==34749== HEAP SUMMARY:
==34749== in use at exit: 0 bytes in 0 blocks
==34749== total heap usage: 41 allocs, 41 frees, 78,568 bytes allocated
==34749==
==34749== All heap blocks were freed -- no leaks are possible
==34749==
==34749== For lists of detected and suppressed errors, rerun with: -s
==34749== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
Thanks!
I couldn't reproduce the issue for some reason. Here is the output of readelf, which indeed contains only one .rodata
.
readelf -SW build/EventContention
There are 43 section headers, starting at offset 0x41620:
Section Headers:
[Nr] Name Type Address Off Size ES Flg Lk Inf Al
[ 0] NULL 0000000000000000 000000 000000 00 0 0 0
[ 1] .interp PROGBITS 00000000000002e0 0002e0 00001c 00 A 0 0 1
[ 2] .note.gnu.build-id NOTE 00000000000002fc 0002fc 000024 00 A 0 0 4
[ 3] .note.ABI-tag NOTE 0000000000000320 000320 000020 00 A 0 0 4
[ 4] .note.gnu.property NOTE 0000000000000340 000340 000020 00 A 0 0 8
[ 5] .gnu.hash GNU_HASH 0000000000000360 000360 000020 00 A 6 0 8
[ 6] .dynsym DYNSYM 0000000000000380 000380 000390 18 A 7 1 8
[ 7] .dynstr STRTAB 0000000000000710 000710 0003d9 00 A 0 0 1
[ 8] .gnu.version VERSYM 0000000000000aea 000aea 00004c 02 A 6 0 2
[ 9] .gnu.version_r VERNEED 0000000000000b38 000b38 0000d0 00 A 7 3 8
[10] .rela.dyn RELA 0000000000000c08 000c08 000180 18 A 6 0 8
[11] .rela.plt RELA 0000000000000d88 000d88 0002d0 18 A 6 23 8
[12] .plt PROGBITS 0000000000002000 002000 000200 00 AX 0 0 16
[13] .plt.got PROGBITS 0000000000002200 002200 000010 00 AX 0 0 16
[14] .fini PROGBITS 0000000000002210 002210 00000d 00 AX 0 0 4
[15] .init PROGBITS 0000000000002220 002220 00001b 00 AX 0 0 4
[16] .text PROGBITS 0000000000002240 002240 007875 00 AX 0 0 16
[17] .eh_frame PROGBITS 000000000000a000 00a000 002260 00 A 0 0 8
[18] .eh_frame_hdr PROGBITS 000000000000c260 00c260 00085c 00 A 0 0 4
[19] .gcc_except_table PROGBITS 000000000000cabc 00cabc 00010c 00 A 0 0 4
[20] .rodata PROGBITS 000000000000cbe0 00cbe0 000408 00 A 0 0 32
[21] .rodata.cst PROGBITS 000000000000cfe8 00cfe8 000004 00 A 0 0 4
[22] .got PROGBITS 000000000000d000 00d000 000030 00 WA 0 0 8
[23] .got.plt PROGBITS 000000000000d030 00d030 000108 00 WA 0 0 8
[24] .dynamic DYNAMIC 000000000000d138 00d138 000250 10 WA 7 0 8
[25] .data.rel.ro PROGBITS 000000000000d388 00d388 000040 00 WA 0 0 8
[26] .fini_array FINI_ARRAY 000000000000d3c8 00d3c8 000008 00 WA 0 0 8
[27] .init_array INIT_ARRAY 000000000000d3d0 00d3d0 000010 00 WA 0 0 8
[28] .data PROGBITS 000000000000e000 00e000 000018 00 WA 0 0 8
[29] .tm_clone_table PROGBITS 000000000000e018 00e018 000000 00 WA 0 0 8
[30] .copyrel NOBITS 000000000000e040 000000 000028 00 WA 0 0 64
[31] .bss NOBITS 000000000000e068 000000 000002 00 WA 0 0 1
[32] .strtab STRTAB 0000000000000000 00e018 00677b 00 0 0 1
[33] .shstrtab STRTAB 0000000000000000 014793 0001c8 00 0 0 1
[34] .symtab SYMTAB 0000000000000000 014960 002e50 18 32 457 8
[35] .comment PROGBITS 0000000000000000 0177b0 000075 00 0 0 1
[36] .debug_abbrev PROGBITS 0000000000000000 017825 001ae2 00 0 0 1
[37] .debug_aranges PROGBITS 0000000000000000 019307 000f20 00 0 0 1
[38] .debug_info PROGBITS 0000000000000000 01a227 011a99 00 0 0 1
[39] .debug_line PROGBITS 0000000000000000 02bcc0 003711 00 0 0 1
[40] .debug_line_str PROGBITS 0000000000000000 02f3d1 000558 00 0 0 1
[41] .debug_rnglists PROGBITS 0000000000000000 02f929 0009bd 00 0 0 1
[42] .debug_str PROGBITS 0000000000000000 0302e6 011337 00 0 0 1
What is your compiler version? Are you using the latest version of mold?
Your map file doesn't give me a hint as to where the second .rodata
came from. Do you mind if I ask you to apply the following patch to mold and try again with -Map,map
?
diff --git a/elf/output-chunks.cc b/elf/output-chunks.cc
index cf2fe3d59..eb46c4aa1 100644
--- a/elf/output-chunks.cc
+++ b/elf/output-chunks.cc
@@ -773,11 +773,11 @@ static std::string_view get_output_name(Context<E> &ctx, std::string_view name)
return stem;
}
}
static std::string_view prefixes[] = {
- ".text.", ".data.rel.ro.", ".data.", ".rodata.", ".bss.rel.ro.", ".bss.",
+ ".text.", ".data.rel.ro.", ".data.", ".bss.rel.ro.", ".bss.",
".init_array.", ".fini_array.", ".tbss.", ".tdata.", ".gcc_except_table.",
".ctors.", ".dtors.",
};
for (std::string_view prefix : prefixes) {
I was not originally using the latest version of mold (it was a point 1.0 release from Feb 2022), but I upgraded to the latest code from master
and tested but the issue still reproduced.
I tested everything with the patch you provided, ran into some issues with the wrong version of the map file being uploaded (every individual link step in the meson build process clobbers the same map file (I originally thought it was appended to), so I was looking at and sharing the wrong one randomly until I started explicitly building, touching tests/EventContention.cpp
, then building again to make sure the map file was the right one), and several other issues before realizing that the sometimes the issue would not reproduce!
I chased up the wrong tree thinking it was my ccache installation (even though (s)ccache doesn't cache the linker output) then thinking was a race issue, but I think it's actually that the issue doesn't reproduce with the patch you supplied applied.
This is the correct map file (generated without the patch), previously it was one for a different test file: map_mold.txt
I don't think there's a point in sharing the map file with the patch you supplied since the issue does not reproduce with it applied, but just in case it's actually useful: map_patched_mold.txt
I am building with gcc 11.1.0 from the ubuntu toolchain ppa on Ubuntu 18.04.
Do the sections in our object files differ? I can share those with you to see if you can reproduce the problem linking from those?
This is the only EventContention
object file, linked against libpevents.a
to generate build/EventContention
:
mqudsi@studiog3 ~/pevents> readelf -WS build/EventContention.p/tests_EventContention.cpp.o | grep rodata
[ 8] .rodata.str1.1 PROGBITS 0000000000000000 0000f0 00003b 01 AMS 0 0 1
[ 9] .rodata.str1.8 PROGBITS 0000000000000000 000130 00009b 01 AMS 0 0 8
[12] .rodata._ZNSt6vectorISt6threadSaIS0_EE17_M_realloc_insertIJS0_EEEvN9__gnu_cxx17__normal_iteratorIPS0_S2_EEDpOT_.str1.1 PROGBITS 0000000000000000 000212 00001a 01 AMS 0 0 1
[24] .rodata PROGBITS 0000000000000000 000660 000043 00 A 0 0 32
This is the only object file that is used to generate libpevents.a
:
mqudsi@studiog3 ~/pevents> readelf -WS build/libpevents.a.p/src_pevents.cpp.o | grep rodata
[10] .rodata.str1.8 PROGBITS 0000000000000000 0020d8 00023d 01 AMS 0 0 8
[11] .rodata.str1.1 PROGBITS 0000000000000000 002315 000046 01 AMS 0 0 1
We didn't create .rodata
for .rodata.str1.1
, but I didn't know that there's a case that .rodata.<arbitrary string>.str1.1
existed. So it was accidentally converted to another .rodata
section.
I fixed the issue in the above commit. Please rebuild mold and try again. Thanks!
That worked perfectly. Thanks for the speedy fix and for the explanation!