[PATCH RFC 00/11] Add Memory Sanitizer support

2023-02-06 Thread Ilya Leoshkevich via Elfutils-devel
Hi, This series adds minimalistic support for Memory Sanitizer (MSan) [1]. MSan is compiler instrumentation for detecting accesses to uninitialized memory. The motivation behind this is to be able to link elfutils into projects instrumented with MSan, since it essentially requires all the code ru

[PATCH RFC 02/11] libasm: Fix xdefault_pattern initialization

2023-02-06 Thread Ilya Leoshkevich via Elfutils-devel
clang complains: asm_newscn.c:48:22: error: field 'pattern' with variable sized type 'struct FillPattern' not at the end of a struct or class is a GNU extension [-Werror,-Wgnu-variable-sized-type-not-at-end] struct FillPattern pattern; ^ Fix by using a union i

[PATCH RFC 05/11] readelf: Fix set but not used variable

2023-02-06 Thread Ilya Leoshkevich via Elfutils-devel
clang complains: readelf.c:10250:10: error: variable 'nculist' set but not used [-Werror,-Wunused-but-set-variable] size_t nculist = 0; ^ Fix by deleting it. Signed-off-by: Ilya Leoshkevich --- src/readelf.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/reade

[PATCH RFC 07/11] addr2line: Do not test demangling in run-addr2line-i-test.sh

2023-02-06 Thread Ilya Leoshkevich via Elfutils-devel
There is run-addr2line-i-demangle-test.sh for that. Signed-off-by: Ilya Leoshkevich --- tests/run-addr2line-i-test.sh | 14 +++--- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/run-addr2line-i-test.sh b/tests/run-addr2line-i-test.sh index 4f63e487..e7b89083 100755 -

[PATCH RFC 06/11] Initialize reglocs for VMCOREINFO

2023-02-06 Thread Ilya Leoshkevich via Elfutils-devel
MSan complains: Uninitialized value was created by an allocation of 'reglocs' in the stack frame #0 0x562d35c686f0 in handle_core_note elfutils/src/readelf.c:12674:3 #const Ebl_Register_Location *reglocs; ==1006199==WARNING: MemorySanitizer: use-of-uninitialized-value

[PATCH RFC 01/11] libdwfl: Fix debuginfod_client redefinition

2023-02-06 Thread Ilya Leoshkevich via Elfutils-devel
clang complains: In file included from debuginfod-client.c:38: ./../debuginfod/debuginfod.h:47:34: error: redefinition of typedef 'debuginfod_client' is a C11 feature [-Werror,-Wtypedef-redefinition] typedef struct debuginfod_client debuginfod_client;

[PATCH RFC 10/11] configure: Add --disable-demangle

2023-02-06 Thread Ilya Leoshkevich via Elfutils-devel
__cxa_demangle is normally implemented in the C++ runtime library, instrumenting which for MSan is a hassle. Add a knob for disabling it. Signed-off-by: Ilya Leoshkevich --- configure.ac | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index

[PATCH RFC 03/11] printversion: Fix unused variable

2023-02-06 Thread Ilya Leoshkevich via Elfutils-devel
clang complains: debuginfod.cxx:354:1: error: unused variable 'apba__' [-Werror,-Wunused-const-variable] ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT; ^ ../lib/printversion.h:47:21: note: expanded from macro 'ARGP_PROGRAM_BUG_ADDRESS_DEF' const char *const apba__ __asm

[PATCH RFC 11/11] configure: Add --enable-sanitize-memory

2023-02-06 Thread Ilya Leoshkevich via Elfutils-devel
Add support for clang Memory Sanitizer [1], which detects the usage of uninitialized values. While elfutils itself is already checked with valgrind, checking code that depends on elfutils requires elfutils to be built with MSan. MSan is not linked into shared libraries, and is linked into executab

[PATCH RFC 04/11] readelf: Fix set but not used parameter

2023-02-06 Thread Ilya Leoshkevich via Elfutils-devel
clang complains: readelf.c:12205:72: error: parameter 'desc' set but not used [-Werror,-Wunused-but-set-parameter] handle_bit_registers (const Ebl_Register_Location *regloc, const void *desc, ^ Apparently handle_b

[PATCH RFC 08/11] x86_64_return_value_location: Support lvalue and rvalue references

2023-02-06 Thread Ilya Leoshkevich via Elfutils-devel
On the low level, they are the same as pointers. Signed-off-by: Ilya Leoshkevich --- backends/x86_64_retval.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backends/x86_64_retval.c b/backends/x86_64_retval.c index f9114cb1..e668eacc 100644 --- a/backends/x86_64_retval.c +++ b/backends/x8

[PATCH RFC 09/11] configure: Use -fno-addrsig if possible

2023-02-06 Thread Ilya Leoshkevich via Elfutils-devel
By default, clang produces .llvm_addrsig sections [1]. The GNU toolchain does not know how to handle them yet [2], so just ask clang not to generate them for the time being. [1] https://llvm.org/docs/Extensions.html#sht-llvm-addrsig-section-address-significance-table [2] https://gcc.gnu.org/bugzi

Re: [PATCH RFC 01/11] libdwfl: Fix debuginfod_client redefinition

2023-02-07 Thread Ilya Leoshkevich via Elfutils-devel
On Tue, 2023-02-07 at 20:22 +0100, Mark Wielaard wrote: > Hi Ilyam > > On Mon, Feb 06, 2023 at 11:25:03PM +0100, Ilya Leoshkevich via > Elfutils-devel wrote: > > clang complains: > > > >     In file included from debuginfod-client.c:38: > >     ./../

Re: [PATCH RFC 00/11] Add Memory Sanitizer support

2023-02-07 Thread Ilya Leoshkevich via Elfutils-devel
On Tue, 2023-02-07 at 20:05 +0100, Mark Wielaard wrote: > Hi Ilya, > > On Mon, Feb 06, 2023 at 11:25:02PM +0100, Ilya Leoshkevich via > Elfutils-devel wrote: > > This series adds minimalistic support for Memory Sanitizer (MSan) > > [1]. > > MSan is compiler instrume

Re: [PATCH RFC 02/11] libasm: Fix xdefault_pattern initialization

2023-02-07 Thread Ilya Leoshkevich via Elfutils-devel
On Tue, 2023-02-07 at 20:41 +0100, Mark Wielaard wrote: > Hi Ilya, > > On Mon, Feb 06, 2023 at 11:25:04PM +0100, Ilya Leoshkevich via > Elfutils-devel wrote: > > clang complains: > > > >     asm_newscn.c:48:22: error: field 'pattern' with variable sized

Re: [PATCH RFC 03/11] printversion: Fix unused variable

2023-02-08 Thread Ilya Leoshkevich via Elfutils-devel
On Tue, 2023-02-07 at 21:44 +0100, Mark Wielaard wrote: > Hi Ilya (CC Frank), > > On Mon, Feb 06, 2023 at 11:25:05PM +0100, Ilya Leoshkevich via > Elfutils-devel wrote: > > clang complains: > > > >     debuginfod.cxx:354:1: error: unused variable 'apba__

[PATCH v2 2/7] printversion: Fix unused variable

2023-02-08 Thread Ilya Leoshkevich via Elfutils-devel
clang complains: debuginfod.cxx:354:1: error: unused variable 'apba__' [-Werror,-Wunused-const-variable] ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT; ^ ../lib/printversion.h:47:21: note: expanded from macro 'ARGP_PROGRAM_BUG_ADDRESS_DEF' const char *const apba__ __asm

[PATCH v2 1/7] libasm: Fix xdefault_pattern initialization

2023-02-08 Thread Ilya Leoshkevich via Elfutils-devel
clang complains: asm_newscn.c:48:22: error: field 'pattern' with variable sized type 'struct FillPattern' not at the end of a struct or class is a GNU extension [-Werror,-Wgnu-variable-sized-type-not-at-end] struct FillPattern pattern; ^ Fix by using a union i

[PATCH v2 3/7] readelf: Fix set but not used parameter

2023-02-08 Thread Ilya Leoshkevich via Elfutils-devel
clang complains: readelf.c:12205:72: error: parameter 'desc' set but not used [-Werror,-Wunused-but-set-parameter] handle_bit_registers (const Ebl_Register_Location *regloc, const void *desc, ^ Mark Wielaard says:

[PATCH v2 0/7] Add Memory Sanitizer support

2023-02-08 Thread Ilya Leoshkevich via Elfutils-devel
Hi, I've made the updates suggested so far and rebased on top of the latest master. Please take a look. v1: https://sourceware.org/pipermail/elfutils-devel/2023q1/005831.html v1 -> v2: * Drop the unnecessary and the integrated patches. * Add a comment to the xdefault_pattern patch. * Add extern t

[PATCH v2 5/7] configure: Use -fno-addrsig if possible

2023-02-08 Thread Ilya Leoshkevich via Elfutils-devel
By default, clang produces .llvm_addrsig sections [1]. The GNU toolchain does not know how to handle them yet [2], so just ask clang not to generate them for the time being. [1] https://llvm.org/docs/Extensions.html#sht-llvm-addrsig-section-address-significance-table [2] https://gcc.gnu.org/bugzi

[PATCH v2 4/7] x86_64_return_value_location: Support lvalue and rvalue references

2023-02-08 Thread Ilya Leoshkevich via Elfutils-devel
On the low level, they are the same as pointers. Signed-off-by: Ilya Leoshkevich --- backends/x86_64_retval.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/backends/x86_64_retval.c b/backends/x86_64_retval.c index f9114cb1..e668eacc 100644 --- a/backends/x86_64_retval.c +++ b/backends/x8

[PATCH v2 7/7] configure: Add --enable-sanitize-memory

2023-02-08 Thread Ilya Leoshkevich via Elfutils-devel
Add support for clang Memory Sanitizer [1], which detects the usage of uninitialized values. While elfutils itself is already checked with valgrind, checking code that depends on elfutils requires elfutils to be built with MSan. MSan is not linked into shared libraries, and is linked into executab

[PATCH v2 6/7] configure: Add --disable-demangler

2023-02-08 Thread Ilya Leoshkevich via Elfutils-devel
__cxa_demangle is normally implemented in the C++ runtime library, instrumenting which for MSan is a hassle. Add a knob for disbling it. Signed-off-by: Ilya Leoshkevich --- configure.ac | 8 +++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 7

Re: [PATCH RFC 03/11] printversion: Fix unused variable

2023-02-09 Thread Ilya Leoshkevich via Elfutils-devel
On Thu, 2023-02-09 at 15:04 +0100, Mark Wielaard wrote: > Hi Ilya, > > On Wed, 2023-02-08 at 13:22 +0100, Ilya Leoshkevich wrote: > > If I build: > > > > const char *const apba__ __asm ("argp_program_bug_address") \ > > __attribute__ ((used)) = "foobarbaz"; > > > > with C and C++, the difference

Re: [PATCH v2 4/7] x86_64_return_value_location: Support lvalue and rvalue references

2023-02-09 Thread Ilya Leoshkevich via Elfutils-devel
On Thu, 2023-02-09 at 14:45 +0100, Mark Wielaard wrote: > Hi Ilya, > > On Wed, 2023-02-08 at 20:52 +0100, Ilya Leoshkevich wrote: > > On the low level, they are the same as pointers. > > Yes, I can see how that would work for return types. > Do you happen to have a testcase for this? You can tri

[PATCH v3 0/4] Add Memory Sanitizer support

2023-02-13 Thread Ilya Leoshkevich via Elfutils-devel
Hi, I've made a few more updates, as described in the changelog below. Please take a look. v2: https://sourceware.org/pipermail/elfutils-devel/2023q1/005868.html v2 -> v3: * Drop the integrated patches. * Fix all backends with respect to returning references and rvalue references; add a test. *

[PATCH v3 2/4] printversion: Fix unused variable

2023-02-13 Thread Ilya Leoshkevich via Elfutils-devel
clang complains: debuginfod.cxx:354:1: error: unused variable 'apba__' [-Werror,-Wunused-const-variable] ARGP_PROGRAM_BUG_ADDRESS_DEF = PACKAGE_BUGREPORT; ^ ../lib/printversion.h:47:21: note: expanded from macro 'ARGP_PROGRAM_BUG_ADDRESS_DEF' const char *const apba__ __asm

[PATCH v3 4/4] configure: Add --enable-sanitize-memory

2023-02-13 Thread Ilya Leoshkevich via Elfutils-devel
Add support for clang Memory Sanitizer [1], which detects the usage of uninitialized values. While elfutils itself is already checked with valgrind, checking code that depends on elfutils requires elfutils to be built with MSan. MSan is not linked into shared libraries, and is linked into executab

[PATCH v3 1/4] tests: Ignore dwfl-report-offline-memory

2023-02-13 Thread Ilya Leoshkevich via Elfutils-devel
It's showing up in git status when configuring in the source directory. Signed-off-by: Ilya Leoshkevich --- tests/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/.gitignore b/tests/.gitignore index 99d04819..536a41ec 100644 --- a/tests/.gitignore +++ b/tests/.gitignore @@ -4

[PATCH v3 3/4] backends: Support returning lvalue and rvalue references

2023-02-13 Thread Ilya Leoshkevich via Elfutils-devel
On the low level, they are the same as pointers. The change needs to be done for all backends, so define a function and a macro to avoid repetition. Also add a native test, which has to be implemented in C++. Add the configure check for it. Signed-off-by: Ilya Leoshkevich --- backends/aarch64_re